SPB Git forge

spb/admin-ka

Public
41commits 1branches 0releases
172.9 MBsize
maindefault branch
20 days agolast push
JavaScript 65.5% Python 17.8% CSS 13% HTML 3.7%

Social: ecran du noeud embarque (noVNC) + reels pro + fix scroll

- Pont VNC WebSocket /vncws (backend <-> Partage ecran 5900) + endpoint /api/social/vncpw
- Panneau + noVNC vendorise (public/vendor/novnc) dans onglet Social: voir/cliquer l ecran du noeud pour finir un Reel
- Reels ameliores: 9:16 plein ecran, rendu 2x (net), CRF 18 preset slow
- Musique pro: progression Am-F-C-G (pad) + kick 4-temps + shaker + reverbe/compresseur/limiteur
- Fix: #view-social scrollable
- Reels a la demande (reelEvery=0); publication assistee via ecran embarque

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Simon-Pierre Boucher committed 1 mo ago (Aug 23, 2026) parent 1c6b539

61 changed files +18,876 −18

added package-lock.json +43 −0
@@ -0,0 +1,43 @@
1 +{
2 + "name": "admin-ka",
3 + "version": "1.0.0",
4 + "lockfileVersion": 3,
5 + "requires": true,
6 + "packages": {
7 + "": {
8 + "name": "admin-ka",
9 + "version": "1.0.0",
10 + "dependencies": {
11 + "@novnc/novnc": "^1.6.0",
12 + "ws": "^8.18.0"
13 + }
14 + },
15 + "node_modules/@novnc/novnc": {
16 + "version": "1.6.0",
17 + "resolved": "https://registry.npmjs.org/@novnc/novnc/-/novnc-1.6.0.tgz",
18 + "integrity": "sha512-CJrmdSe9Yt2ZbLsJpVFoVkEu0KICEvnr3njW25Nz0jodaiFJtg8AYLGZogRYy0/N5HUWkGUsCmegKXYBSqwygw==",
19 + "license": "MPL-2.0"
20 + },
21 + "node_modules/ws": {
22 + "version": "8.21.3",
23 + "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
24 + "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
25 + "license": "MIT",
26 + "engines": {
27 + "node": ">=10.0.0"
28 + },
29 + "peerDependencies": {
30 + "bufferutil": "^4.0.1",
31 + "utf-8-validate": ">=5.0.2"
32 + },
33 + "peerDependenciesMeta": {
34 + "bufferutil": {
35 + "optional": true
36 + },
37 + "utf-8-validate": {
38 + "optional": true
39 + }
40 + }
41 + }
42 + }
43 +}
modified package.json +1 −0
@@ -9,6 +9,7 @@
9 9 "set-password": "node server/set-password.js"
10 10 },
11 11 "dependencies": {
12 + "@novnc/novnc": "^1.6.0",
12 13 "ws": "^8.18.0"
13 14 }
14 15 }
modified public/app.js +28 −0
@@ -67,6 +67,34 @@
67 67 }
68 68 document.querySelectorAll('.nav-btn').forEach((b) => { b.onclick = () => switchView(b.dataset.view); });
69 69
70 + // ---------- Écran du nœud (noVNC embarqué) ----------
71 + let _rfb = null;
72 + (function bindVNC(){
73 + const connect = document.getElementById('vncConnect');
74 + const disc = document.getElementById('vncDisconnect');
75 + const statusEl = document.getElementById('vncStatus');
76 + const panel = document.getElementById('vncPanel');
77 + if (!connect) return;
78 + connect.onclick = async () => {
79 + if (_rfb) { statusEl.textContent = 'déjà connecté'; return; }
80 + statusEl.textContent = 'connexion…';
81 + try {
82 + const pw = await (await fetch('/api/social/vncpw')).json();
83 + const { default: RFB } = await import('/vendor/novnc/rfb.js');
84 + const url = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/vncws';
85 + panel.style.display = 'block';
86 + _rfb = new RFB(panel, url, { credentials: { password: pw.password } });
87 + _rfb.scaleViewport = true;
88 + _rfb.resizeSession = false;
89 + _rfb.background = '#0d0d0d';
90 + _rfb.addEventListener('connect', () => { statusEl.textContent = '✅ connecté — tu peux cliquer dans l\'écran'; });
91 + _rfb.addEventListener('disconnect', (e) => { statusEl.textContent = 'déconnecté'; _rfb = null; panel.style.display='none'; });
92 + _rfb.addEventListener('credentialsrequired', () => { _rfb.sendCredentials({ password: pw.password }); });
93 + } catch (e) { statusEl.textContent = 'échec : ' + e.message; }
94 + };
95 + disc.onclick = () => { if (_rfb) { try { _rfb.disconnect(); } catch {} _rfb = null; } panel.style.display='none'; statusEl.textContent='déconnecté'; };
96 + })();
97 +
70 98 // ---------- Social ----------
71 99 let socDraft = null;
72 100 async function loadSocial() {
modified public/index.html +11 −0
@@ -150,6 +150,17 @@
150 150 <section id="view-social" class="view hidden">
151 151 <div class="view-head"><h2>Social</h2></div>
152 152
153 + <div class="soc-card">
154 + <h3>Écran du nœud (M3U96a) — pour finir un Reel</h3>
155 + <p class="soc-sub">Quand un Reel est prêt à publier, l'éditeur Facebook demande un clic « Suivant » manuel. Connecte-toi ici pour voir et cliquer directement dans l'app.</p>
156 + <div class="soc-actions">
157 + <button id="vncConnect" class="btn-cta small">🖥️ Connecter l'écran</button>
158 + <button id="vncDisconnect" class="btn-ghost small">Déconnecter</button>
159 + <span id="vncStatus" class="soc-sub"></span>
160 + </div>
161 + <div id="vncPanel" style="display:none;margin-top:12px;border:2px solid var(--ink,#1a1a1a);border-radius:12px;overflow:hidden;background:#0d0d0d;min-height:200px"></div>
162 + </div>
163 +
153 164 <div class="soc-card">
154 165 <label class="soc-switch">
155 166 <input type="checkbox" id="socAutoToggle">
modified public/style.css +4 −1
@@ -139,7 +139,7 @@ button { font-family: inherit; color: inherit; }
139 139
140 140 /* vues */
141 141 .view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
142 −#view-sessions, #view-prompts, #view-eco, #view-settings { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(86px + env(safe-area-inset-bottom)); }
142 +#view-sessions, #view-prompts, #view-eco, #view-social, #view-settings { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(86px + env(safe-area-inset-bottom)); }
143 143 .view-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; }
144 144 .view-head h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
145 145
@@ -660,3 +660,6 @@ details.thinking-box summary { color: var(--muted); font-size: 12.5px; cursor: p
660 660 .soc-log{display:flex;flex-direction:column;gap:6px;max-height:340px;overflow-y:auto;}
661 661 .soc-logrow{font-size:13px;padding:6px 8px;border-radius:8px;background:rgba(0,0,0,.04);}
662 662 .soc-logt{color:var(--muted,#6b7280);font-variant-numeric:tabular-nums;margin-right:6px;}
663 +
664 +#vncPanel canvas{max-width:100%;height:auto;display:block;margin:0 auto}
665 +#vncPanel{max-height:70vh}
added public/vendor/novnc/base64.js +100 −0
@@ -0,0 +1,100 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports["default"] = void 0;
8 +var Log = _interopRequireWildcard(require("./util/logging.js"));
9 +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); }
10 +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; }
11 +/* This Source Code Form is subject to the terms of the Mozilla Public
12 + * License, v. 2.0. If a copy of the MPL was not distributed with this
13 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
14 +// From: http://hg.mozilla.org/mozilla-central/raw-file/ec10630b1a54/js/src/devtools/jint/sunspider/string-base64.js
15 +var _default = exports["default"] = {
16 + /* Convert data (an array of integers) to a Base64 string. */
17 + toBase64Table: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split(''),
18 + base64Pad: '=',
19 + encode: function encode(data) {
20 + "use strict";
21 +
22 + var result = '';
23 + var length = data.length;
24 + var lengthpad = length % 3;
25 + // Convert every three bytes to 4 ascii characters.
26 +
27 + for (var i = 0; i < length - 2; i += 3) {
28 + result += this.toBase64Table[data[i] >> 2];
29 + result += this.toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)];
30 + result += this.toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)];
31 + result += this.toBase64Table[data[i + 2] & 0x3f];
32 + }
33 +
34 + // Convert the remaining 1 or 2 bytes, pad out to 4 characters.
35 + var j = length - lengthpad;
36 + if (lengthpad === 2) {
37 + result += this.toBase64Table[data[j] >> 2];
38 + result += this.toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)];
39 + result += this.toBase64Table[(data[j + 1] & 0x0f) << 2];
40 + result += this.toBase64Table[64];
41 + } else if (lengthpad === 1) {
42 + result += this.toBase64Table[data[j] >> 2];
43 + result += this.toBase64Table[(data[j] & 0x03) << 4];
44 + result += this.toBase64Table[64];
45 + result += this.toBase64Table[64];
46 + }
47 + return result;
48 + },
49 + /* Convert Base64 data to a string */
50 + /* eslint-disable comma-spacing */
51 + toBinaryTable: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1],
52 + /* eslint-enable comma-spacing */decode: function decode(data) {
53 + var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
54 + var dataLength = data.indexOf('=') - offset;
55 + if (dataLength < 0) {
56 + dataLength = data.length - offset;
57 + }
58 +
59 + /* Every four characters is 3 resulting numbers */
60 + var resultLength = (dataLength >> 2) * 3 + Math.floor(dataLength % 4 / 1.5);
61 + var result = new Array(resultLength);
62 +
63 + // Convert one by one.
64 +
65 + var leftbits = 0; // number of bits decoded, but yet to be appended
66 + var leftdata = 0; // bits decoded, but yet to be appended
67 + for (var idx = 0, i = offset; i < data.length; i++) {
68 + var c = this.toBinaryTable[data.charCodeAt(i) & 0x7f];
69 + var padding = data.charAt(i) === this.base64Pad;
70 + // Skip illegal characters and whitespace
71 + if (c === -1) {
72 + Log.Error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
73 + continue;
74 + }
75 +
76 + // Collect data into leftdata, update bitcount
77 + leftdata = leftdata << 6 | c;
78 + leftbits += 6;
79 +
80 + // If we have 8 or more bits, append 8 bits to the result
81 + if (leftbits >= 8) {
82 + leftbits -= 8;
83 + // Append if not padding.
84 + if (!padding) {
85 + result[idx++] = leftdata >> leftbits & 0xff;
86 + }
87 + leftdata &= (1 << leftbits) - 1;
88 + }
89 + }
90 +
91 + // If there are any bits left, the base64 string was corrupted
92 + if (leftbits) {
93 + var err = new Error('Corrupted base64 string');
94 + err.name = 'Base64-Error';
95 + throw err;
96 + }
97 + return result;
98 + }
99 +};
100 +/* End of Base64 namespace */
\ No newline at end of file
added public/vendor/novnc/crypto/aes.js +481 −0
@@ -0,0 +1,481 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.AESECBCipher = exports.AESEAXCipher = void 0;
7 +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); }
8 +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; }
9 +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); }
10 +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); }); }; }
11 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12 +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); } }
13 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +var AESECBCipher = exports.AESECBCipher = /*#__PURE__*/function () {
17 + function AESECBCipher() {
18 + _classCallCheck(this, AESECBCipher);
19 + this._key = null;
20 + }
21 + return _createClass(AESECBCipher, [{
22 + key: "algorithm",
23 + get: function get() {
24 + return {
25 + name: "AES-ECB"
26 + };
27 + }
28 + }, {
29 + key: "_importKey",
30 + value: function () {
31 + var _importKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, extractable, keyUsages) {
32 + return _regeneratorRuntime().wrap(function _callee$(_context) {
33 + while (1) switch (_context.prev = _context.next) {
34 + case 0:
35 + _context.next = 2;
36 + return window.crypto.subtle.importKey("raw", key, {
37 + name: "AES-CBC"
38 + }, extractable, keyUsages);
39 + case 2:
40 + this._key = _context.sent;
41 + case 3:
42 + case "end":
43 + return _context.stop();
44 + }
45 + }, _callee, this);
46 + }));
47 + function _importKey(_x, _x2, _x3) {
48 + return _importKey2.apply(this, arguments);
49 + }
50 + return _importKey;
51 + }()
52 + }, {
53 + key: "encrypt",
54 + value: function () {
55 + var _encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_algorithm, plaintext) {
56 + var x, n, i, y;
57 + return _regeneratorRuntime().wrap(function _callee2$(_context2) {
58 + while (1) switch (_context2.prev = _context2.next) {
59 + case 0:
60 + x = new Uint8Array(plaintext);
61 + if (!(x.length % 16 !== 0 || this._key === null)) {
62 + _context2.next = 3;
63 + break;
64 + }
65 + return _context2.abrupt("return", null);
66 + case 3:
67 + n = x.length / 16;
68 + i = 0;
69 + case 5:
70 + if (!(i < n)) {
71 + _context2.next = 15;
72 + break;
73 + }
74 + _context2.t0 = Uint8Array;
75 + _context2.next = 9;
76 + return window.crypto.subtle.encrypt({
77 + name: "AES-CBC",
78 + iv: new Uint8Array(16)
79 + }, this._key, x.slice(i * 16, i * 16 + 16));
80 + case 9:
81 + _context2.t1 = _context2.sent;
82 + y = new _context2.t0(_context2.t1).slice(0, 16);
83 + x.set(y, i * 16);
84 + case 12:
85 + i++;
86 + _context2.next = 5;
87 + break;
88 + case 15:
89 + return _context2.abrupt("return", x);
90 + case 16:
91 + case "end":
92 + return _context2.stop();
93 + }
94 + }, _callee2, this);
95 + }));
96 + function encrypt(_x4, _x5) {
97 + return _encrypt.apply(this, arguments);
98 + }
99 + return encrypt;
100 + }()
101 + }], [{
102 + key: "importKey",
103 + value: function () {
104 + var _importKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, _algorithm, extractable, keyUsages) {
105 + var cipher;
106 + return _regeneratorRuntime().wrap(function _callee3$(_context3) {
107 + while (1) switch (_context3.prev = _context3.next) {
108 + case 0:
109 + cipher = new AESECBCipher();
110 + _context3.next = 3;
111 + return cipher._importKey(key, extractable, keyUsages);
112 + case 3:
113 + return _context3.abrupt("return", cipher);
114 + case 4:
115 + case "end":
116 + return _context3.stop();
117 + }
118 + }, _callee3);
119 + }));
120 + function importKey(_x6, _x7, _x8, _x9) {
121 + return _importKey3.apply(this, arguments);
122 + }
123 + return importKey;
124 + }()
125 + }]);
126 +}();
127 +var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
128 + function AESEAXCipher() {
129 + _classCallCheck(this, AESEAXCipher);
130 + this._rawKey = null;
131 + this._ctrKey = null;
132 + this._cbcKey = null;
133 + this._zeroBlock = new Uint8Array(16);
134 + this._prefixBlock0 = this._zeroBlock;
135 + this._prefixBlock1 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
136 + this._prefixBlock2 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]);
137 + }
138 + return _createClass(AESEAXCipher, [{
139 + key: "algorithm",
140 + get: function get() {
141 + return {
142 + name: "AES-EAX"
143 + };
144 + }
145 + }, {
146 + key: "_encryptBlock",
147 + value: function () {
148 + var _encryptBlock2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(block) {
149 + var encrypted;
150 + return _regeneratorRuntime().wrap(function _callee4$(_context4) {
151 + while (1) switch (_context4.prev = _context4.next) {
152 + case 0:
153 + _context4.next = 2;
154 + return window.crypto.subtle.encrypt({
155 + name: "AES-CBC",
156 + iv: this._zeroBlock
157 + }, this._cbcKey, block);
158 + case 2:
159 + encrypted = _context4.sent;
160 + return _context4.abrupt("return", new Uint8Array(encrypted).slice(0, 16));
161 + case 4:
162 + case "end":
163 + return _context4.stop();
164 + }
165 + }, _callee4, this);
166 + }));
167 + function _encryptBlock(_x10) {
168 + return _encryptBlock2.apply(this, arguments);
169 + }
170 + return _encryptBlock;
171 + }()
172 + }, {
173 + key: "_initCMAC",
174 + value: function () {
175 + var _initCMAC2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
176 + var k1, k2, v, i, lut;
177 + return _regeneratorRuntime().wrap(function _callee5$(_context5) {
178 + while (1) switch (_context5.prev = _context5.next) {
179 + case 0:
180 + _context5.next = 2;
181 + return this._encryptBlock(this._zeroBlock);
182 + case 2:
183 + k1 = _context5.sent;
184 + k2 = new Uint8Array(16);
185 + v = k1[0] >>> 6;
186 + for (i = 0; i < 15; i++) {
187 + k2[i] = k1[i + 1] >> 6 | k1[i] << 2;
188 + k1[i] = k1[i + 1] >> 7 | k1[i] << 1;
189 + }
190 + lut = [0x0, 0x87, 0x0e, 0x89];
191 + k2[14] ^= v >>> 1;
192 + k2[15] = k1[15] << 2 ^ lut[v];
193 + k1[15] = k1[15] << 1 ^ lut[v >> 1];
194 + this._k1 = k1;
195 + this._k2 = k2;
196 + case 12:
197 + case "end":
198 + return _context5.stop();
199 + }
200 + }, _callee5, this);
201 + }));
202 + function _initCMAC() {
203 + return _initCMAC2.apply(this, arguments);
204 + }
205 + return _initCMAC;
206 + }()
207 + }, {
208 + key: "_encryptCTR",
209 + value: function () {
210 + var _encryptCTR2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data, counter) {
211 + var encrypted;
212 + return _regeneratorRuntime().wrap(function _callee6$(_context6) {
213 + while (1) switch (_context6.prev = _context6.next) {
214 + case 0:
215 + _context6.next = 2;
216 + return window.crypto.subtle.encrypt({
217 + name: "AES-CTR",
218 + counter: counter,
219 + length: 128
220 + }, this._ctrKey, data);
221 + case 2:
222 + encrypted = _context6.sent;
223 + return _context6.abrupt("return", new Uint8Array(encrypted));
224 + case 4:
225 + case "end":
226 + return _context6.stop();
227 + }
228 + }, _callee6, this);
229 + }));
230 + function _encryptCTR(_x11, _x12) {
231 + return _encryptCTR2.apply(this, arguments);
232 + }
233 + return _encryptCTR;
234 + }()
235 + }, {
236 + key: "_decryptCTR",
237 + value: function () {
238 + var _decryptCTR2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(data, counter) {
239 + var decrypted;
240 + return _regeneratorRuntime().wrap(function _callee7$(_context7) {
241 + while (1) switch (_context7.prev = _context7.next) {
242 + case 0:
243 + _context7.next = 2;
244 + return window.crypto.subtle.decrypt({
245 + name: "AES-CTR",
246 + counter: counter,
247 + length: 128
248 + }, this._ctrKey, data);
249 + case 2:
250 + decrypted = _context7.sent;
251 + return _context7.abrupt("return", new Uint8Array(decrypted));
252 + case 4:
253 + case "end":
254 + return _context7.stop();
255 + }
256 + }, _callee7, this);
257 + }));
258 + function _decryptCTR(_x13, _x14) {
259 + return _decryptCTR2.apply(this, arguments);
260 + }
261 + return _decryptCTR;
262 + }()
263 + }, {
264 + key: "_computeCMAC",
265 + value: function () {
266 + var _computeCMAC2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(data, prefixBlock) {
267 + var n, m, r, cbcData, i, _i, cbcEncrypted, mac;
268 + return _regeneratorRuntime().wrap(function _callee8$(_context8) {
269 + while (1) switch (_context8.prev = _context8.next) {
270 + case 0:
271 + if (!(prefixBlock.length !== 16)) {
272 + _context8.next = 2;
273 + break;
274 + }
275 + return _context8.abrupt("return", null);
276 + case 2:
277 + n = Math.floor(data.length / 16);
278 + m = Math.ceil(data.length / 16);
279 + r = data.length - n * 16;
280 + cbcData = new Uint8Array((m + 1) * 16);
281 + cbcData.set(prefixBlock);
282 + cbcData.set(data, 16);
283 + if (r === 0) {
284 + for (i = 0; i < 16; i++) {
285 + cbcData[n * 16 + i] ^= this._k1[i];
286 + }
287 + } else {
288 + cbcData[(n + 1) * 16 + r] = 0x80;
289 + for (_i = 0; _i < 16; _i++) {
290 + cbcData[(n + 1) * 16 + _i] ^= this._k2[_i];
291 + }
292 + }
293 + _context8.next = 11;
294 + return window.crypto.subtle.encrypt({
295 + name: "AES-CBC",
296 + iv: this._zeroBlock
297 + }, this._cbcKey, cbcData);
298 + case 11:
299 + cbcEncrypted = _context8.sent;
300 + cbcEncrypted = new Uint8Array(cbcEncrypted);
301 + mac = cbcEncrypted.slice(cbcEncrypted.length - 32, cbcEncrypted.length - 16);
302 + return _context8.abrupt("return", mac);
303 + case 15:
304 + case "end":
305 + return _context8.stop();
306 + }
307 + }, _callee8, this);
308 + }));
309 + function _computeCMAC(_x15, _x16) {
310 + return _computeCMAC2.apply(this, arguments);
311 + }
312 + return _computeCMAC;
313 + }()
314 + }, {
315 + key: "_importKey",
316 + value: function () {
317 + var _importKey4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key) {
318 + return _regeneratorRuntime().wrap(function _callee9$(_context9) {
319 + while (1) switch (_context9.prev = _context9.next) {
320 + case 0:
321 + this._rawKey = key;
322 + _context9.next = 3;
323 + return window.crypto.subtle.importKey("raw", key, {
324 + name: "AES-CTR"
325 + }, false, ["encrypt", "decrypt"]);
326 + case 3:
327 + this._ctrKey = _context9.sent;
328 + _context9.next = 6;
329 + return window.crypto.subtle.importKey("raw", key, {
330 + name: "AES-CBC"
331 + }, false, ["encrypt"]);
332 + case 6:
333 + this._cbcKey = _context9.sent;
334 + _context9.next = 9;
335 + return this._initCMAC();
336 + case 9:
337 + case "end":
338 + return _context9.stop();
339 + }
340 + }, _callee9, this);
341 + }));
342 + function _importKey(_x17) {
343 + return _importKey4.apply(this, arguments);
344 + }
345 + return _importKey;
346 + }()
347 + }, {
348 + key: "encrypt",
349 + value: function () {
350 + var _encrypt2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(algorithm, message) {
351 + var ad, nonce, nCMAC, encrypted, adCMAC, mac, i, res;
352 + return _regeneratorRuntime().wrap(function _callee10$(_context10) {
353 + while (1) switch (_context10.prev = _context10.next) {
354 + case 0:
355 + ad = algorithm.additionalData;
356 + nonce = algorithm.iv;
357 + _context10.next = 4;
358 + return this._computeCMAC(nonce, this._prefixBlock0);
359 + case 4:
360 + nCMAC = _context10.sent;
361 + _context10.next = 7;
362 + return this._encryptCTR(message, nCMAC);
363 + case 7:
364 + encrypted = _context10.sent;
365 + _context10.next = 10;
366 + return this._computeCMAC(ad, this._prefixBlock1);
367 + case 10:
368 + adCMAC = _context10.sent;
369 + _context10.next = 13;
370 + return this._computeCMAC(encrypted, this._prefixBlock2);
371 + case 13:
372 + mac = _context10.sent;
373 + for (i = 0; i < 16; i++) {
374 + mac[i] ^= nCMAC[i] ^ adCMAC[i];
375 + }
376 + res = new Uint8Array(16 + encrypted.length);
377 + res.set(encrypted);
378 + res.set(mac, encrypted.length);
379 + return _context10.abrupt("return", res);
380 + case 19:
381 + case "end":
382 + return _context10.stop();
383 + }
384 + }, _callee10, this);
385 + }));
386 + function encrypt(_x18, _x19) {
387 + return _encrypt2.apply(this, arguments);
388 + }
389 + return encrypt;
390 + }()
391 + }, {
392 + key: "decrypt",
393 + value: function () {
394 + var _decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(algorithm, data) {
395 + var encrypted, ad, nonce, mac, nCMAC, adCMAC, computedMac, i, _i2, res;
396 + return _regeneratorRuntime().wrap(function _callee11$(_context11) {
397 + while (1) switch (_context11.prev = _context11.next) {
398 + case 0:
399 + encrypted = data.slice(0, data.length - 16);
400 + ad = algorithm.additionalData;
401 + nonce = algorithm.iv;
402 + mac = data.slice(data.length - 16);
403 + _context11.next = 6;
404 + return this._computeCMAC(nonce, this._prefixBlock0);
405 + case 6:
406 + nCMAC = _context11.sent;
407 + _context11.next = 9;
408 + return this._computeCMAC(ad, this._prefixBlock1);
409 + case 9:
410 + adCMAC = _context11.sent;
411 + _context11.next = 12;
412 + return this._computeCMAC(encrypted, this._prefixBlock2);
413 + case 12:
414 + computedMac = _context11.sent;
415 + for (i = 0; i < 16; i++) {
416 + computedMac[i] ^= nCMAC[i] ^ adCMAC[i];
417 + }
418 + if (!(computedMac.length !== mac.length)) {
419 + _context11.next = 16;
420 + break;
421 + }
422 + return _context11.abrupt("return", null);
423 + case 16:
424 + _i2 = 0;
425 + case 17:
426 + if (!(_i2 < mac.length)) {
427 + _context11.next = 23;
428 + break;
429 + }
430 + if (!(computedMac[_i2] !== mac[_i2])) {
431 + _context11.next = 20;
432 + break;
433 + }
434 + return _context11.abrupt("return", null);
435 + case 20:
436 + _i2++;
437 + _context11.next = 17;
438 + break;
439 + case 23:
440 + _context11.next = 25;
441 + return this._decryptCTR(encrypted, nCMAC);
442 + case 25:
443 + res = _context11.sent;
444 + return _context11.abrupt("return", res);
445 + case 27:
446 + case "end":
447 + return _context11.stop();
448 + }
449 + }, _callee11, this);
450 + }));
451 + function decrypt(_x20, _x21) {
452 + return _decrypt.apply(this, arguments);
453 + }
454 + return decrypt;
455 + }()
456 + }], [{
457 + key: "importKey",
458 + value: function () {
459 + var _importKey5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key, _algorithm, _extractable, _keyUsages) {
460 + var cipher;
461 + return _regeneratorRuntime().wrap(function _callee12$(_context12) {
462 + while (1) switch (_context12.prev = _context12.next) {
463 + case 0:
464 + cipher = new AESEAXCipher();
465 + _context12.next = 3;
466 + return cipher._importKey(key);
467 + case 3:
468 + return _context12.abrupt("return", cipher);
469 + case 4:
470 + case "end":
471 + return _context12.stop();
472 + }
473 + }, _callee12);
474 + }));
475 + function importKey(_x22, _x23, _x24, _x25) {
476 + return _importKey5.apply(this, arguments);
477 + }
478 + return importKey;
479 + }()
480 + }]);
481 +}();
\ No newline at end of file
added public/vendor/novnc/crypto/bigint.js +41 −0
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.bigIntToU8Array = bigIntToU8Array;
7 +exports.modPow = modPow;
8 +exports.u8ArrayToBigInt = u8ArrayToBigInt;
9 +function modPow(b, e, m) {
10 + var r = 1n;
11 + b = b % m;
12 + while (e > 0n) {
13 + if ((e & 1n) === 1n) {
14 + r = r * b % m;
15 + }
16 + e = e >> 1n;
17 + b = b * b % m;
18 + }
19 + return r;
20 +}
21 +function bigIntToU8Array(bigint) {
22 + var padLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
23 + var hex = bigint.toString(16);
24 + if (padLength === 0) {
25 + padLength = Math.ceil(hex.length / 2);
26 + }
27 + hex = hex.padStart(padLength * 2, '0');
28 + var length = hex.length / 2;
29 + var arr = new Uint8Array(length);
30 + for (var i = 0; i < length; i++) {
31 + arr[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
32 + }
33 + return arr;
34 +}
35 +function u8ArrayToBigInt(arr) {
36 + var hex = '0x';
37 + for (var i = 0; i < arr.length; i++) {
38 + hex += arr[i].toString(16).padStart(2, '0');
39 + }
40 + return BigInt(hex);
41 +}
\ No newline at end of file
added public/vendor/novnc/crypto/crypto.js +109 −0
@@ -0,0 +1,109 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _aes = require("./aes.js");
8 +var _des = require("./des.js");
9 +var _rsa = require("./rsa.js");
10 +var _dh = require("./dh.js");
11 +var _md = require("./md5.js");
12 +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); }
13 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14 +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); } }
15 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +// A single interface for the cryptographic algorithms not supported by SubtleCrypto.
19 +// Both synchronous and asynchronous implmentations are allowed.
20 +var LegacyCrypto = /*#__PURE__*/function () {
21 + function LegacyCrypto() {
22 + _classCallCheck(this, LegacyCrypto);
23 + this._algorithms = {
24 + "AES-ECB": _aes.AESECBCipher,
25 + "AES-EAX": _aes.AESEAXCipher,
26 + "DES-ECB": _des.DESECBCipher,
27 + "DES-CBC": _des.DESCBCCipher,
28 + "RSA-PKCS1-v1_5": _rsa.RSACipher,
29 + "DH": _dh.DHCipher,
30 + "MD5": _md.MD5
31 + };
32 + }
33 + return _createClass(LegacyCrypto, [{
34 + key: "encrypt",
35 + value: function encrypt(algorithm, key, data) {
36 + if (key.algorithm.name !== algorithm.name) {
37 + throw new Error("algorithm does not match");
38 + }
39 + if (typeof key.encrypt !== "function") {
40 + throw new Error("key does not support encryption");
41 + }
42 + return key.encrypt(algorithm, data);
43 + }
44 + }, {
45 + key: "decrypt",
46 + value: function decrypt(algorithm, key, data) {
47 + if (key.algorithm.name !== algorithm.name) {
48 + throw new Error("algorithm does not match");
49 + }
50 + if (typeof key.decrypt !== "function") {
51 + throw new Error("key does not support encryption");
52 + }
53 + return key.decrypt(algorithm, data);
54 + }
55 + }, {
56 + key: "importKey",
57 + value: function importKey(format, keyData, algorithm, extractable, keyUsages) {
58 + if (format !== "raw") {
59 + throw new Error("key format is not supported");
60 + }
61 + var alg = this._algorithms[algorithm.name];
62 + if (typeof alg === "undefined" || typeof alg.importKey !== "function") {
63 + throw new Error("algorithm is not supported");
64 + }
65 + return alg.importKey(keyData, algorithm, extractable, keyUsages);
66 + }
67 + }, {
68 + key: "generateKey",
69 + value: function generateKey(algorithm, extractable, keyUsages) {
70 + var alg = this._algorithms[algorithm.name];
71 + if (typeof alg === "undefined" || typeof alg.generateKey !== "function") {
72 + throw new Error("algorithm is not supported");
73 + }
74 + return alg.generateKey(algorithm, extractable, keyUsages);
75 + }
76 + }, {
77 + key: "exportKey",
78 + value: function exportKey(format, key) {
79 + if (format !== "raw") {
80 + throw new Error("key format is not supported");
81 + }
82 + if (typeof key.exportKey !== "function") {
83 + throw new Error("key does not support exportKey");
84 + }
85 + return key.exportKey();
86 + }
87 + }, {
88 + key: "digest",
89 + value: function digest(algorithm, data) {
90 + var alg = this._algorithms[algorithm];
91 + if (typeof alg !== "function") {
92 + throw new Error("algorithm is not supported");
93 + }
94 + return alg(data);
95 + }
96 + }, {
97 + key: "deriveBits",
98 + value: function deriveBits(algorithm, key, length) {
99 + if (key.algorithm.name !== algorithm.name) {
100 + throw new Error("algorithm does not match");
101 + }
102 + if (typeof key.deriveBits !== "function") {
103 + throw new Error("key does not support deriveBits");
104 + }
105 + return key.deriveBits(algorithm, length);
106 + }
107 + }]);
108 +}();
109 +var _default = exports["default"] = new LegacyCrypto();
\ No newline at end of file
added public/vendor/novnc/crypto/des.js +374 −0
@@ -0,0 +1,374 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.DESECBCipher = exports.DESCBCCipher = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * Ported from Flashlight VNC ActionScript implementation:
15 + * http://www.wizhelp.com/flashlight-vnc/
16 + *
17 + * Full attribution follows:
18 + *
19 + * -------------------------------------------------------------------------
20 + *
21 + * This DES class has been extracted from package Acme.Crypto for use in VNC.
22 + * The unnecessary odd parity code has been removed.
23 + *
24 + * These changes are:
25 + * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
26 + *
27 + * This software is distributed in the hope that it will be useful,
28 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 + *
31 +
32 + * DesCipher - the DES encryption method
33 + *
34 + * The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
35 + *
36 + * Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
37 + *
38 + * Permission to use, copy, modify, and distribute this software
39 + * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
40 + * without fee is hereby granted, provided that this copyright notice is kept
41 + * intact.
42 + *
43 + * WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
44 + * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
45 + * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
46 + * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
47 + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
48 + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
49 + *
50 + * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
51 + * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
52 + * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
53 + * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
54 + * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
55 + * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
56 + * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
57 + * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
58 + * HIGH RISK ACTIVITIES.
59 + *
60 + *
61 + * The rest is:
62 + *
63 + * Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
64 + *
65 + * Redistribution and use in source and binary forms, with or without
66 + * modification, are permitted provided that the following conditions
67 + * are met:
68 + * 1. Redistributions of source code must retain the above copyright
69 + * notice, this list of conditions and the following disclaimer.
70 + * 2. Redistributions in binary form must reproduce the above copyright
71 + * notice, this list of conditions and the following disclaimer in the
72 + * documentation and/or other materials provided with the distribution.
73 + *
74 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
75 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
76 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
77 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
78 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
79 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
80 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
81 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
82 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
83 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
84 + * SUCH DAMAGE.
85 + *
86 + * Visit the ACME Labs Java page for up-to-date versions of this and other
87 + * fine Java utilities: http://www.acme.com/java/
88 + */
89 +
90 +/* eslint-disable comma-spacing */
91 +
92 +// Tables, permutations, S-boxes, etc.
93 +var PC2 = [13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31],
94 + totrot = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
95 +var z = 0x0;
96 +var a, b, c, d, e, f;
97 +a = 1 << 16;
98 +b = 1 << 24;
99 +c = a | b;
100 +d = 1 << 2;
101 +e = 1 << 10;
102 +f = d | e;
103 +var SP1 = [c | e, z | z, a | z, c | f, c | d, a | f, z | d, a | z, z | e, c | e, c | f, z | e, b | f, c | d, b | z, z | d, z | f, b | e, b | e, a | e, a | e, c | z, c | z, b | f, a | d, b | d, b | d, a | d, z | z, z | f, a | f, b | z, a | z, c | f, z | d, c | z, c | e, b | z, b | z, z | e, c | d, a | z, a | e, b | d, z | e, z | d, b | f, a | f, c | f, a | d, c | z, b | f, b | d, z | f, a | f, c | e, z | f, b | e, b | e, z | z, a | d, a | e, z | z, c | d];
104 +a = 1 << 20;
105 +b = 1 << 31;
106 +c = a | b;
107 +d = 1 << 5;
108 +e = 1 << 15;
109 +f = d | e;
110 +var SP2 = [c | f, b | e, z | e, a | f, a | z, z | d, c | d, b | f, b | d, c | f, c | e, b | z, b | e, a | z, z | d, c | d, a | e, a | d, b | f, z | z, b | z, z | e, a | f, c | z, a | d, b | d, z | z, a | e, z | f, c | e, c | z, z | f, z | z, a | f, c | d, a | z, b | f, c | z, c | e, z | e, c | z, b | e, z | d, c | f, a | f, z | d, z | e, b | z, z | f, c | e, a | z, b | d, a | d, b | f, b | d, a | d, a | e, z | z, b | e, z | f, b | z, c | d, c | f, a | e];
111 +a = 1 << 17;
112 +b = 1 << 27;
113 +c = a | b;
114 +d = 1 << 3;
115 +e = 1 << 9;
116 +f = d | e;
117 +var SP3 = [z | f, c | e, z | z, c | d, b | e, z | z, a | f, b | e, a | d, b | d, b | d, a | z, c | f, a | d, c | z, z | f, b | z, z | d, c | e, z | e, a | e, c | z, c | d, a | f, b | f, a | e, a | z, b | f, z | d, c | f, z | e, b | z, c | e, b | z, a | d, z | f, a | z, c | e, b | e, z | z, z | e, a | d, c | f, b | e, b | d, z | e, z | z, c | d, b | f, a | z, b | z, c | f, z | d, a | f, a | e, b | d, c | z, b | f, z | f, c | z, a | f, z | d, c | d, a | e];
118 +a = 1 << 13;
119 +b = 1 << 23;
120 +c = a | b;
121 +d = 1 << 0;
122 +e = 1 << 7;
123 +f = d | e;
124 +var SP4 = [c | d, a | f, a | f, z | e, c | e, b | f, b | d, a | d, z | z, c | z, c | z, c | f, z | f, z | z, b | e, b | d, z | d, a | z, b | z, c | d, z | e, b | z, a | d, a | e, b | f, z | d, a | e, b | e, a | z, c | e, c | f, z | f, b | e, b | d, c | z, c | f, z | f, z | z, z | z, c | z, a | e, b | e, b | f, z | d, c | d, a | f, a | f, z | e, c | f, z | f, z | d, a | z, b | d, a | d, c | e, b | f, a | d, a | e, b | z, c | d, z | e, b | z, a | z, c | e];
125 +a = 1 << 25;
126 +b = 1 << 30;
127 +c = a | b;
128 +d = 1 << 8;
129 +e = 1 << 19;
130 +f = d | e;
131 +var SP5 = [z | d, a | f, a | e, c | d, z | e, z | d, b | z, a | e, b | f, z | e, a | d, b | f, c | d, c | e, z | f, b | z, a | z, b | e, b | e, z | z, b | d, c | f, c | f, a | d, c | e, b | d, z | z, c | z, a | f, a | z, c | z, z | f, z | e, c | d, z | d, a | z, b | z, a | e, c | d, b | f, a | d, b | z, c | e, a | f, b | f, z | d, a | z, c | e, c | f, z | f, c | z, c | f, a | e, z | z, b | e, c | z, z | f, a | d, b | d, z | e, z | z, b | e, a | f, b | d];
132 +a = 1 << 22;
133 +b = 1 << 29;
134 +c = a | b;
135 +d = 1 << 4;
136 +e = 1 << 14;
137 +f = d | e;
138 +var SP6 = [b | d, c | z, z | e, c | f, c | z, z | d, c | f, a | z, b | e, a | f, a | z, b | d, a | d, b | e, b | z, z | f, z | z, a | d, b | f, z | e, a | e, b | f, z | d, c | d, c | d, z | z, a | f, c | e, z | f, a | e, c | e, b | z, b | e, z | d, c | d, a | e, c | f, a | z, z | f, b | d, a | z, b | e, b | z, z | f, b | d, c | f, a | e, c | z, a | f, c | e, z | z, c | d, z | d, z | e, c | z, a | f, z | e, a | d, b | f, z | z, c | e, b | z, a | d, b | f];
139 +a = 1 << 21;
140 +b = 1 << 26;
141 +c = a | b;
142 +d = 1 << 1;
143 +e = 1 << 11;
144 +f = d | e;
145 +var SP7 = [a | z, c | d, b | f, z | z, z | e, b | f, a | f, c | e, c | f, a | z, z | z, b | d, z | d, b | z, c | d, z | f, b | e, a | f, a | d, b | e, b | d, c | z, c | e, a | d, c | z, z | e, z | f, c | f, a | e, z | d, b | z, a | e, b | z, a | e, a | z, b | f, b | f, c | d, c | d, z | d, a | d, b | z, b | e, a | z, c | e, z | f, a | f, c | e, z | f, b | d, c | f, c | z, a | e, z | z, z | d, c | f, z | z, a | f, c | z, z | e, b | d, b | e, z | e, a | d];
146 +a = 1 << 18;
147 +b = 1 << 28;
148 +c = a | b;
149 +d = 1 << 6;
150 +e = 1 << 12;
151 +f = d | e;
152 +var SP8 = [b | f, z | e, a | z, c | f, b | z, b | f, z | d, b | z, a | d, c | z, c | f, a | e, c | e, a | f, z | e, z | d, c | z, b | d, b | e, z | f, a | e, a | d, c | d, c | e, z | f, z | z, z | z, c | d, b | d, b | e, a | f, a | z, a | f, a | z, c | e, z | e, z | d, c | d, z | e, a | f, b | e, z | d, b | d, c | z, c | d, b | z, a | z, b | f, z | z, c | f, a | d, b | d, c | z, b | e, b | f, z | z, c | f, a | e, a | e, z | f, z | f, a | d, b | z, c | e];
153 +
154 +/* eslint-enable comma-spacing */
155 +var DES = /*#__PURE__*/function () {
156 + function DES(password) {
157 + _classCallCheck(this, DES);
158 + this.keys = [];
159 +
160 + // Set the key.
161 + var pc1m = [],
162 + pcr = [],
163 + kn = [];
164 + for (var j = 0, l = 56; j < 56; ++j, l -= 8) {
165 + l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1
166 + var m = l & 0x7;
167 + pc1m[j] = (password[l >>> 3] & 1 << m) !== 0 ? 1 : 0;
168 + }
169 + for (var i = 0; i < 16; ++i) {
170 + var _m = i << 1;
171 + var n = _m + 1;
172 + kn[_m] = kn[n] = 0;
173 + for (var o = 28; o < 59; o += 28) {
174 + for (var _j = o - 28; _j < o; ++_j) {
175 + var _l = _j + totrot[i];
176 + pcr[_j] = _l < o ? pc1m[_l] : pc1m[_l - 28];
177 + }
178 + }
179 + for (var _j2 = 0; _j2 < 24; ++_j2) {
180 + if (pcr[PC2[_j2]] !== 0) {
181 + kn[_m] |= 1 << 23 - _j2;
182 + }
183 + if (pcr[PC2[_j2 + 24]] !== 0) {
184 + kn[n] |= 1 << 23 - _j2;
185 + }
186 + }
187 + }
188 +
189 + // cookey
190 + for (var _i = 0, rawi = 0, KnLi = 0; _i < 16; ++_i) {
191 + var raw0 = kn[rawi++];
192 + var raw1 = kn[rawi++];
193 + this.keys[KnLi] = (raw0 & 0x00fc0000) << 6;
194 + this.keys[KnLi] |= (raw0 & 0x00000fc0) << 10;
195 + this.keys[KnLi] |= (raw1 & 0x00fc0000) >>> 10;
196 + this.keys[KnLi] |= (raw1 & 0x00000fc0) >>> 6;
197 + ++KnLi;
198 + this.keys[KnLi] = (raw0 & 0x0003f000) << 12;
199 + this.keys[KnLi] |= (raw0 & 0x0000003f) << 16;
200 + this.keys[KnLi] |= (raw1 & 0x0003f000) >>> 4;
201 + this.keys[KnLi] |= raw1 & 0x0000003f;
202 + ++KnLi;
203 + }
204 + }
205 +
206 + // Encrypt 8 bytes of text
207 + return _createClass(DES, [{
208 + key: "enc8",
209 + value: function enc8(text) {
210 + var b = text.slice();
211 + var i = 0,
212 + l,
213 + r,
214 + x; // left, right, accumulator
215 +
216 + // Squash 8 bytes to 2 ints
217 + l = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
218 + r = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
219 + x = (l >>> 4 ^ r) & 0x0f0f0f0f;
220 + r ^= x;
221 + l ^= x << 4;
222 + x = (l >>> 16 ^ r) & 0x0000ffff;
223 + r ^= x;
224 + l ^= x << 16;
225 + x = (r >>> 2 ^ l) & 0x33333333;
226 + l ^= x;
227 + r ^= x << 2;
228 + x = (r >>> 8 ^ l) & 0x00ff00ff;
229 + l ^= x;
230 + r ^= x << 8;
231 + r = r << 1 | r >>> 31 & 1;
232 + x = (l ^ r) & 0xaaaaaaaa;
233 + l ^= x;
234 + r ^= x;
235 + l = l << 1 | l >>> 31 & 1;
236 + for (var _i2 = 0, keysi = 0; _i2 < 8; ++_i2) {
237 + x = r << 28 | r >>> 4;
238 + x ^= this.keys[keysi++];
239 + var fval = SP7[x & 0x3f];
240 + fval |= SP5[x >>> 8 & 0x3f];
241 + fval |= SP3[x >>> 16 & 0x3f];
242 + fval |= SP1[x >>> 24 & 0x3f];
243 + x = r ^ this.keys[keysi++];
244 + fval |= SP8[x & 0x3f];
245 + fval |= SP6[x >>> 8 & 0x3f];
246 + fval |= SP4[x >>> 16 & 0x3f];
247 + fval |= SP2[x >>> 24 & 0x3f];
248 + l ^= fval;
249 + x = l << 28 | l >>> 4;
250 + x ^= this.keys[keysi++];
251 + fval = SP7[x & 0x3f];
252 + fval |= SP5[x >>> 8 & 0x3f];
253 + fval |= SP3[x >>> 16 & 0x3f];
254 + fval |= SP1[x >>> 24 & 0x3f];
255 + x = l ^ this.keys[keysi++];
256 + fval |= SP8[x & 0x0000003f];
257 + fval |= SP6[x >>> 8 & 0x3f];
258 + fval |= SP4[x >>> 16 & 0x3f];
259 + fval |= SP2[x >>> 24 & 0x3f];
260 + r ^= fval;
261 + }
262 + r = r << 31 | r >>> 1;
263 + x = (l ^ r) & 0xaaaaaaaa;
264 + l ^= x;
265 + r ^= x;
266 + l = l << 31 | l >>> 1;
267 + x = (l >>> 8 ^ r) & 0x00ff00ff;
268 + r ^= x;
269 + l ^= x << 8;
270 + x = (l >>> 2 ^ r) & 0x33333333;
271 + r ^= x;
272 + l ^= x << 2;
273 + x = (r >>> 16 ^ l) & 0x0000ffff;
274 + l ^= x;
275 + r ^= x << 16;
276 + x = (r >>> 4 ^ l) & 0x0f0f0f0f;
277 + l ^= x;
278 + r ^= x << 4;
279 +
280 + // Spread ints to bytes
281 + x = [r, l];
282 + for (i = 0; i < 8; i++) {
283 + b[i] = (x[i >>> 2] >>> 8 * (3 - i % 4)) % 256;
284 + if (b[i] < 0) {
285 + b[i] += 256;
286 + } // unsigned
287 + }
288 + return b;
289 + }
290 + }]);
291 +}();
292 +var DESECBCipher = exports.DESECBCipher = /*#__PURE__*/function () {
293 + function DESECBCipher() {
294 + _classCallCheck(this, DESECBCipher);
295 + this._cipher = null;
296 + }
297 + return _createClass(DESECBCipher, [{
298 + key: "algorithm",
299 + get: function get() {
300 + return {
301 + name: "DES-ECB"
302 + };
303 + }
304 + }, {
305 + key: "_importKey",
306 + value: function _importKey(key, _extractable, _keyUsages) {
307 + this._cipher = new DES(key);
308 + }
309 + }, {
310 + key: "encrypt",
311 + value: function encrypt(_algorithm, plaintext) {
312 + var x = new Uint8Array(plaintext);
313 + if (x.length % 8 !== 0 || this._cipher === null) {
314 + return null;
315 + }
316 + var n = x.length / 8;
317 + for (var i = 0; i < n; i++) {
318 + x.set(this._cipher.enc8(x.slice(i * 8, i * 8 + 8)), i * 8);
319 + }
320 + return x;
321 + }
322 + }], [{
323 + key: "importKey",
324 + value: function importKey(key, _algorithm, _extractable, _keyUsages) {
325 + var cipher = new DESECBCipher();
326 + cipher._importKey(key);
327 + return cipher;
328 + }
329 + }]);
330 +}();
331 +var DESCBCCipher = exports.DESCBCCipher = /*#__PURE__*/function () {
332 + function DESCBCCipher() {
333 + _classCallCheck(this, DESCBCCipher);
334 + this._cipher = null;
335 + }
336 + return _createClass(DESCBCCipher, [{
337 + key: "algorithm",
338 + get: function get() {
339 + return {
340 + name: "DES-CBC"
341 + };
342 + }
343 + }, {
344 + key: "_importKey",
345 + value: function _importKey(key) {
346 + this._cipher = new DES(key);
347 + }
348 + }, {
349 + key: "encrypt",
350 + value: function encrypt(algorithm, plaintext) {
351 + var x = new Uint8Array(plaintext);
352 + var y = new Uint8Array(algorithm.iv);
353 + if (x.length % 8 !== 0 || this._cipher === null) {
354 + return null;
355 + }
356 + var n = x.length / 8;
357 + for (var i = 0; i < n; i++) {
358 + for (var j = 0; j < 8; j++) {
359 + y[j] ^= plaintext[i * 8 + j];
360 + }
361 + y = this._cipher.enc8(y);
362 + x.set(y, i * 8);
363 + }
364 + return x;
365 + }
366 + }], [{
367 + key: "importKey",
368 + value: function importKey(key, _algorithm, _extractable, _keyUsages) {
369 + var cipher = new DESCBCCipher();
370 + cipher._importKey(key);
371 + return cipher;
372 + }
373 + }]);
374 +}();
\ No newline at end of file
added public/vendor/novnc/crypto/dh.js +81 −0
@@ -0,0 +1,81 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.DHCipher = void 0;
7 +var _bigint = require("./bigint.js");
8 +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); }
9 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10 +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); } }
11 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13 +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); }
14 +var DHPublicKey = /*#__PURE__*/function () {
15 + function DHPublicKey(key) {
16 + _classCallCheck(this, DHPublicKey);
17 + this._key = key;
18 + }
19 + return _createClass(DHPublicKey, [{
20 + key: "algorithm",
21 + get: function get() {
22 + return {
23 + name: "DH"
24 + };
25 + }
26 + }, {
27 + key: "exportKey",
28 + value: function exportKey() {
29 + return this._key;
30 + }
31 + }]);
32 +}();
33 +var DHCipher = exports.DHCipher = /*#__PURE__*/function () {
34 + function DHCipher() {
35 + _classCallCheck(this, DHCipher);
36 + this._g = null;
37 + this._p = null;
38 + this._gBigInt = null;
39 + this._pBigInt = null;
40 + this._privateKey = null;
41 + }
42 + return _createClass(DHCipher, [{
43 + key: "algorithm",
44 + get: function get() {
45 + return {
46 + name: "DH"
47 + };
48 + }
49 + }, {
50 + key: "_generateKey",
51 + value: function _generateKey(algorithm) {
52 + var g = algorithm.g;
53 + var p = algorithm.p;
54 + this._keyBytes = p.length;
55 + this._gBigInt = (0, _bigint.u8ArrayToBigInt)(g);
56 + this._pBigInt = (0, _bigint.u8ArrayToBigInt)(p);
57 + this._privateKey = window.crypto.getRandomValues(new Uint8Array(this._keyBytes));
58 + this._privateKeyBigInt = (0, _bigint.u8ArrayToBigInt)(this._privateKey);
59 + this._publicKey = (0, _bigint.bigIntToU8Array)((0, _bigint.modPow)(this._gBigInt, this._privateKeyBigInt, this._pBigInt), this._keyBytes);
60 + }
61 + }, {
62 + key: "deriveBits",
63 + value: function deriveBits(algorithm, length) {
64 + var bytes = Math.ceil(length / 8);
65 + var pkey = new Uint8Array(algorithm["public"]);
66 + var len = bytes > this._keyBytes ? bytes : this._keyBytes;
67 + var secret = (0, _bigint.modPow)((0, _bigint.u8ArrayToBigInt)(pkey), this._privateKeyBigInt, this._pBigInt);
68 + return (0, _bigint.bigIntToU8Array)(secret, len).slice(0, len);
69 + }
70 + }], [{
71 + key: "generateKey",
72 + value: function generateKey(algorithm, _extractable) {
73 + var cipher = new DHCipher();
74 + cipher._generateKey(algorithm);
75 + return {
76 + privateKey: cipher,
77 + publicKey: new DHPublicKey(cipher._publicKey)
78 + };
79 + }
80 + }]);
81 +}();
\ No newline at end of file
added public/vendor/novnc/crypto/md5.js +97 −0
@@ -0,0 +1,97 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.MD5 = MD5;
7 +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); }
8 +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; }
9 +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); }
10 +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); }); }; }
11 +/*
12 + * noVNC: HTML5 VNC client
13 + * Copyright (C) 2021 The noVNC authors
14 + * Licensed under MPL 2.0 (see LICENSE.txt)
15 + *
16 + * See README.md for usage and integration instructions.
17 + */
18 +/*
19 + * Performs MD5 hashing on an array of bytes, returns an array of bytes
20 + */
21 +function MD5(_x) {
22 + return _MD.apply(this, arguments);
23 +}
24 +function _MD() {
25 + _MD = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(d) {
26 + var s, i;
27 + return _regeneratorRuntime().wrap(function _callee$(_context) {
28 + while (1) switch (_context.prev = _context.next) {
29 + case 0:
30 + s = "";
31 + for (i = 0; i < d.length; i++) {
32 + s += String.fromCharCode(d[i]);
33 + }
34 + return _context.abrupt("return", M(V(Y(X(s), 8 * s.length))));
35 + case 3:
36 + case "end":
37 + return _context.stop();
38 + }
39 + }, _callee);
40 + }));
41 + return _MD.apply(this, arguments);
42 +}
43 +function M(d) {
44 + var f = new Uint8Array(d.length);
45 + for (var i = 0; i < d.length; i++) {
46 + f[i] = d.charCodeAt(i);
47 + }
48 + return f;
49 +}
50 +function X(d) {
51 + var r = Array(d.length >> 2);
52 + for (var m = 0; m < r.length; m++) r[m] = 0;
53 + for (var _m = 0; _m < 8 * d.length; _m += 8) r[_m >> 5] |= (255 & d.charCodeAt(_m / 8)) << _m % 32;
54 + return r;
55 +}
56 +function V(d) {
57 + var r = "";
58 + for (var m = 0; m < 32 * d.length; m += 8) r += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
59 + return r;
60 +}
61 +function Y(d, g) {
62 + d[g >> 5] |= 128 << g % 32, d[14 + (g + 64 >>> 9 << 4)] = g;
63 + var m = 1732584193,
64 + f = -271733879,
65 + r = -1732584194,
66 + i = 271733878;
67 + for (var n = 0; n < d.length; n += 16) {
68 + var h = m,
69 + t = f,
70 + _g = r,
71 + e = i;
72 + f = ii(f = ii(f = ii(f = ii(f = hh(f = hh(f = hh(f = hh(f = gg(f = gg(f = gg(f = gg(f = ff(f = ff(f = ff(f = ff(f, r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 0], 7, -680876936), f, r, d[n + 1], 12, -389564586), m, f, d[n + 2], 17, 606105819), i, m, d[n + 3], 22, -1044525330), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 4], 7, -176418897), f, r, d[n + 5], 12, 1200080426), m, f, d[n + 6], 17, -1473231341), i, m, d[n + 7], 22, -45705983), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 8], 7, 1770035416), f, r, d[n + 9], 12, -1958414417), m, f, d[n + 10], 17, -42063), i, m, d[n + 11], 22, -1990404162), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 12], 7, 1804603682), f, r, d[n + 13], 12, -40341101), m, f, d[n + 14], 17, -1502002290), i, m, d[n + 15], 22, 1236535329), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 1], 5, -165796510), f, r, d[n + 6], 9, -1069501632), m, f, d[n + 11], 14, 643717713), i, m, d[n + 0], 20, -373897302), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 5], 5, -701558691), f, r, d[n + 10], 9, 38016083), m, f, d[n + 15], 14, -660478335), i, m, d[n + 4], 20, -405537848), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 9], 5, 568446438), f, r, d[n + 14], 9, -1019803690), m, f, d[n + 3], 14, -187363961), i, m, d[n + 8], 20, 1163531501), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 13], 5, -1444681467), f, r, d[n + 2], 9, -51403784), m, f, d[n + 7], 14, 1735328473), i, m, d[n + 12], 20, -1926607734), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 5], 4, -378558), f, r, d[n + 8], 11, -2022574463), m, f, d[n + 11], 16, 1839030562), i, m, d[n + 14], 23, -35309556), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 1], 4, -1530992060), f, r, d[n + 4], 11, 1272893353), m, f, d[n + 7], 16, -155497632), i, m, d[n + 10], 23, -1094730640), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 13], 4, 681279174), f, r, d[n + 0], 11, -358537222), m, f, d[n + 3], 16, -722521979), i, m, d[n + 6], 23, 76029189), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 9], 4, -640364487), f, r, d[n + 12], 11, -421815835), m, f, d[n + 15], 16, 530742520), i, m, d[n + 2], 23, -995338651), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 0], 6, -198630844), f, r, d[n + 7], 10, 1126891415), m, f, d[n + 14], 15, -1416354905), i, m, d[n + 5], 21, -57434055), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 12], 6, 1700485571), f, r, d[n + 3], 10, -1894986606), m, f, d[n + 10], 15, -1051523), i, m, d[n + 1], 21, -2054922799), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 8], 6, 1873313359), f, r, d[n + 15], 10, -30611744), m, f, d[n + 6], 15, -1560198380), i, m, d[n + 13], 21, 1309151649), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 4], 6, -145523070), f, r, d[n + 11], 10, -1120210379), m, f, d[n + 2], 15, 718787259), i, m, d[n + 9], 21, -343485551), m = add(m, h), f = add(f, t), r = add(r, _g), i = add(i, e);
73 + }
74 + return Array(m, f, r, i);
75 +}
76 +function cmn(d, g, m, f, r, i) {
77 + return add(rol(add(add(g, d), add(f, i)), r), m);
78 +}
79 +function ff(d, g, m, f, r, i, n) {
80 + return cmn(g & m | ~g & f, d, g, r, i, n);
81 +}
82 +function gg(d, g, m, f, r, i, n) {
83 + return cmn(g & f | m & ~f, d, g, r, i, n);
84 +}
85 +function hh(d, g, m, f, r, i, n) {
86 + return cmn(g ^ m ^ f, d, g, r, i, n);
87 +}
88 +function ii(d, g, m, f, r, i, n) {
89 + return cmn(m ^ (g | ~f), d, g, r, i, n);
90 +}
91 +function add(d, g) {
92 + var m = (65535 & d) + (65535 & g);
93 + return (d >> 16) + (g >> 16) + (m >> 16) << 16 | 65535 & m;
94 +}
95 +function rol(d, g) {
96 + return d << g | d >>> 32 - g;
97 +}
\ No newline at end of file
added public/vendor/novnc/crypto/rsa.js +312 −0
@@ -0,0 +1,312 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.RSACipher = void 0;
7 +var _base = _interopRequireDefault(require("../base64.js"));
8 +var _bigint = require("./bigint.js");
9 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 _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; }
12 +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); }
13 +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); }); }; }
14 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
15 +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); } }
16 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
20 + function RSACipher() {
21 + _classCallCheck(this, RSACipher);
22 + this._keyLength = 0;
23 + this._keyBytes = 0;
24 + this._n = null;
25 + this._e = null;
26 + this._d = null;
27 + this._nBigInt = null;
28 + this._eBigInt = null;
29 + this._dBigInt = null;
30 + this._extractable = false;
31 + }
32 + return _createClass(RSACipher, [{
33 + key: "algorithm",
34 + get: function get() {
35 + return {
36 + name: "RSA-PKCS1-v1_5"
37 + };
38 + }
39 + }, {
40 + key: "_base64urlDecode",
41 + value: function _base64urlDecode(data) {
42 + data = data.replace(/-/g, "+").replace(/_/g, "/");
43 + data = data.padEnd(Math.ceil(data.length / 4) * 4, "=");
44 + return _base["default"].decode(data);
45 + }
46 + }, {
47 + key: "_padArray",
48 + value: function _padArray(arr, length) {
49 + var res = new Uint8Array(length);
50 + res.set(arr, length - arr.length);
51 + return res;
52 + }
53 + }, {
54 + key: "_generateKey",
55 + value: function () {
56 + var _generateKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(algorithm, extractable) {
57 + var key, privateKey;
58 + return _regeneratorRuntime().wrap(function _callee$(_context) {
59 + while (1) switch (_context.prev = _context.next) {
60 + case 0:
61 + this._keyLength = algorithm.modulusLength;
62 + this._keyBytes = Math.ceil(this._keyLength / 8);
63 + _context.next = 4;
64 + return window.crypto.subtle.generateKey({
65 + name: "RSA-OAEP",
66 + modulusLength: algorithm.modulusLength,
67 + publicExponent: algorithm.publicExponent,
68 + hash: {
69 + name: "SHA-256"
70 + }
71 + }, true, ["encrypt", "decrypt"]);
72 + case 4:
73 + key = _context.sent;
74 + _context.next = 7;
75 + return window.crypto.subtle.exportKey("jwk", key.privateKey);
76 + case 7:
77 + privateKey = _context.sent;
78 + this._n = this._padArray(this._base64urlDecode(privateKey.n), this._keyBytes);
79 + this._nBigInt = (0, _bigint.u8ArrayToBigInt)(this._n);
80 + this._e = this._padArray(this._base64urlDecode(privateKey.e), this._keyBytes);
81 + this._eBigInt = (0, _bigint.u8ArrayToBigInt)(this._e);
82 + this._d = this._padArray(this._base64urlDecode(privateKey.d), this._keyBytes);
83 + this._dBigInt = (0, _bigint.u8ArrayToBigInt)(this._d);
84 + this._extractable = extractable;
85 + case 15:
86 + case "end":
87 + return _context.stop();
88 + }
89 + }, _callee, this);
90 + }));
91 + function _generateKey(_x, _x2) {
92 + return _generateKey2.apply(this, arguments);
93 + }
94 + return _generateKey;
95 + }()
96 + }, {
97 + key: "_importKey",
98 + value: function () {
99 + var _importKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, extractable) {
100 + var n, e;
101 + return _regeneratorRuntime().wrap(function _callee2$(_context2) {
102 + while (1) switch (_context2.prev = _context2.next) {
103 + case 0:
104 + n = key.n;
105 + e = key.e;
106 + if (!(n.length !== e.length)) {
107 + _context2.next = 4;
108 + break;
109 + }
110 + throw new Error("the sizes of modulus and public exponent do not match");
111 + case 4:
112 + this._keyBytes = n.length;
113 + this._keyLength = this._keyBytes * 8;
114 + this._n = new Uint8Array(this._keyBytes);
115 + this._e = new Uint8Array(this._keyBytes);
116 + this._n.set(n);
117 + this._e.set(e);
118 + this._nBigInt = (0, _bigint.u8ArrayToBigInt)(this._n);
119 + this._eBigInt = (0, _bigint.u8ArrayToBigInt)(this._e);
120 + this._extractable = extractable;
121 + case 13:
122 + case "end":
123 + return _context2.stop();
124 + }
125 + }, _callee2, this);
126 + }));
127 + function _importKey(_x3, _x4) {
128 + return _importKey2.apply(this, arguments);
129 + }
130 + return _importKey;
131 + }()
132 + }, {
133 + key: "encrypt",
134 + value: function () {
135 + var _encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_algorithm, message) {
136 + var ps, i, em, emBigInt, c;
137 + return _regeneratorRuntime().wrap(function _callee3$(_context3) {
138 + while (1) switch (_context3.prev = _context3.next) {
139 + case 0:
140 + if (!(message.length > this._keyBytes - 11)) {
141 + _context3.next = 2;
142 + break;
143 + }
144 + return _context3.abrupt("return", null);
145 + case 2:
146 + ps = new Uint8Array(this._keyBytes - message.length - 3);
147 + window.crypto.getRandomValues(ps);
148 + for (i = 0; i < ps.length; i++) {
149 + ps[i] = Math.floor(ps[i] * 254 / 255 + 1);
150 + }
151 + em = new Uint8Array(this._keyBytes);
152 + em[1] = 0x02;
153 + em.set(ps, 2);
154 + em.set(message, ps.length + 3);
155 + emBigInt = (0, _bigint.u8ArrayToBigInt)(em);
156 + c = (0, _bigint.modPow)(emBigInt, this._eBigInt, this._nBigInt);
157 + return _context3.abrupt("return", (0, _bigint.bigIntToU8Array)(c, this._keyBytes));
158 + case 12:
159 + case "end":
160 + return _context3.stop();
161 + }
162 + }, _callee3, this);
163 + }));
164 + function encrypt(_x5, _x6) {
165 + return _encrypt.apply(this, arguments);
166 + }
167 + return encrypt;
168 + }()
169 + }, {
170 + key: "decrypt",
171 + value: function () {
172 + var _decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_algorithm, message) {
173 + var msgBigInt, emBigInt, em, i;
174 + return _regeneratorRuntime().wrap(function _callee4$(_context4) {
175 + while (1) switch (_context4.prev = _context4.next) {
176 + case 0:
177 + if (!(message.length !== this._keyBytes)) {
178 + _context4.next = 2;
179 + break;
180 + }
181 + return _context4.abrupt("return", null);
182 + case 2:
183 + msgBigInt = (0, _bigint.u8ArrayToBigInt)(message);
184 + emBigInt = (0, _bigint.modPow)(msgBigInt, this._dBigInt, this._nBigInt);
185 + em = (0, _bigint.bigIntToU8Array)(emBigInt, this._keyBytes);
186 + if (!(em[0] !== 0x00 || em[1] !== 0x02)) {
187 + _context4.next = 7;
188 + break;
189 + }
190 + return _context4.abrupt("return", null);
191 + case 7:
192 + i = 2;
193 + case 8:
194 + if (!(i < em.length)) {
195 + _context4.next = 14;
196 + break;
197 + }
198 + if (!(em[i] === 0x00)) {
199 + _context4.next = 11;
200 + break;
201 + }
202 + return _context4.abrupt("break", 14);
203 + case 11:
204 + i++;
205 + _context4.next = 8;
206 + break;
207 + case 14:
208 + if (!(i === em.length)) {
209 + _context4.next = 16;
210 + break;
211 + }
212 + return _context4.abrupt("return", null);
213 + case 16:
214 + return _context4.abrupt("return", em.slice(i + 1, em.length));
215 + case 17:
216 + case "end":
217 + return _context4.stop();
218 + }
219 + }, _callee4, this);
220 + }));
221 + function decrypt(_x7, _x8) {
222 + return _decrypt.apply(this, arguments);
223 + }
224 + return decrypt;
225 + }()
226 + }, {
227 + key: "exportKey",
228 + value: function () {
229 + var _exportKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
230 + return _regeneratorRuntime().wrap(function _callee5$(_context5) {
231 + while (1) switch (_context5.prev = _context5.next) {
232 + case 0:
233 + if (this._extractable) {
234 + _context5.next = 2;
235 + break;
236 + }
237 + throw new Error("key is not extractable");
238 + case 2:
239 + return _context5.abrupt("return", {
240 + n: this._n,
241 + e: this._e,
242 + d: this._d
243 + });
244 + case 3:
245 + case "end":
246 + return _context5.stop();
247 + }
248 + }, _callee5, this);
249 + }));
250 + function exportKey() {
251 + return _exportKey.apply(this, arguments);
252 + }
253 + return exportKey;
254 + }()
255 + }], [{
256 + key: "generateKey",
257 + value: function () {
258 + var _generateKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(algorithm, extractable, _keyUsages) {
259 + var cipher;
260 + return _regeneratorRuntime().wrap(function _callee6$(_context6) {
261 + while (1) switch (_context6.prev = _context6.next) {
262 + case 0:
263 + cipher = new RSACipher();
264 + _context6.next = 3;
265 + return cipher._generateKey(algorithm, extractable);
266 + case 3:
267 + return _context6.abrupt("return", {
268 + privateKey: cipher
269 + });
270 + case 4:
271 + case "end":
272 + return _context6.stop();
273 + }
274 + }, _callee6);
275 + }));
276 + function generateKey(_x9, _x10, _x11) {
277 + return _generateKey3.apply(this, arguments);
278 + }
279 + return generateKey;
280 + }()
281 + }, {
282 + key: "importKey",
283 + value: function () {
284 + var _importKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, _algorithm, extractable, keyUsages) {
285 + var cipher;
286 + return _regeneratorRuntime().wrap(function _callee7$(_context7) {
287 + while (1) switch (_context7.prev = _context7.next) {
288 + case 0:
289 + if (!(keyUsages.length !== 1 || keyUsages[0] !== "encrypt")) {
290 + _context7.next = 2;
291 + break;
292 + }
293 + throw new Error("only support importing RSA public key");
294 + case 2:
295 + cipher = new RSACipher();
296 + _context7.next = 5;
297 + return cipher._importKey(key, extractable);
298 + case 5:
299 + return _context7.abrupt("return", cipher);
300 + case 6:
301 + case "end":
302 + return _context7.stop();
303 + }
304 + }, _callee7);
305 + }));
306 + function importKey(_x12, _x13, _x14, _x15) {
307 + return _importKey3.apply(this, arguments);
308 + }
309 + return importKey;
310 + }()
311 + }]);
312 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/copyrect.js +40 −0
@@ -0,0 +1,40 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2019 The noVNC authors
16 + * Licensed under MPL 2.0 (see LICENSE.txt)
17 + *
18 + * See README.md for usage and integration instructions.
19 + *
20 + */
21 +var CopyRectDecoder = exports["default"] = /*#__PURE__*/function () {
22 + function CopyRectDecoder() {
23 + _classCallCheck(this, CopyRectDecoder);
24 + }
25 + return _createClass(CopyRectDecoder, [{
26 + key: "decodeRect",
27 + value: function decodeRect(x, y, width, height, sock, display, depth) {
28 + if (sock.rQwait("COPYRECT", 4)) {
29 + return false;
30 + }
31 + var deltaX = sock.rQshift16();
32 + var deltaY = sock.rQshift16();
33 + if (width === 0 || height === 0) {
34 + return true;
35 + }
36 + display.copyImage(deltaX, deltaY, x, y, width, height);
37 + return true;
38 + }
39 + }]);
40 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/h264.js +349 −0
@@ -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 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/hextile.js +195 −0
@@ -0,0 +1,195 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = 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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12 +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); } }
13 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 + * noVNC: HTML5 VNC client
17 + * Copyright (C) 2019 The noVNC authors
18 + * Licensed under MPL 2.0 (see LICENSE.txt)
19 + *
20 + * See README.md for usage and integration instructions.
21 + *
22 + */
23 +var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
24 + function HextileDecoder() {
25 + _classCallCheck(this, HextileDecoder);
26 + this._tiles = 0;
27 + this._lastsubencoding = 0;
28 + this._tileBuffer = new Uint8Array(16 * 16 * 4);
29 + }
30 + return _createClass(HextileDecoder, [{
31 + key: "decodeRect",
32 + value: function decodeRect(x, y, width, height, sock, display, depth) {
33 + if (this._tiles === 0) {
34 + this._tilesX = Math.ceil(width / 16);
35 + this._tilesY = Math.ceil(height / 16);
36 + this._totalTiles = this._tilesX * this._tilesY;
37 + this._tiles = this._totalTiles;
38 + }
39 + while (this._tiles > 0) {
40 + var bytes = 1;
41 + if (sock.rQwait("HEXTILE", bytes)) {
42 + return false;
43 + }
44 + var subencoding = sock.rQpeek8();
45 + if (subencoding > 30) {
46 + // Raw
47 + throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
48 + }
49 + var currTile = this._totalTiles - this._tiles;
50 + var tileX = currTile % this._tilesX;
51 + var tileY = Math.floor(currTile / this._tilesX);
52 + var tx = x + tileX * 16;
53 + var ty = y + tileY * 16;
54 + var tw = Math.min(16, x + width - tx);
55 + var th = Math.min(16, y + height - ty);
56 +
57 + // Figure out how much we are expecting
58 + if (subencoding & 0x01) {
59 + // Raw
60 + bytes += tw * th * 4;
61 + } else {
62 + if (subencoding & 0x02) {
63 + // Background
64 + bytes += 4;
65 + }
66 + if (subencoding & 0x04) {
67 + // Foreground
68 + bytes += 4;
69 + }
70 + if (subencoding & 0x08) {
71 + // AnySubrects
72 + bytes++; // Since we aren't shifting it off
73 +
74 + if (sock.rQwait("HEXTILE", bytes)) {
75 + return false;
76 + }
77 + var subrects = sock.rQpeekBytes(bytes).at(-1);
78 + if (subencoding & 0x10) {
79 + // SubrectsColoured
80 + bytes += subrects * (4 + 2);
81 + } else {
82 + bytes += subrects * 2;
83 + }
84 + }
85 + }
86 + if (sock.rQwait("HEXTILE", bytes)) {
87 + return false;
88 + }
89 +
90 + // We know the encoding and have a whole tile
91 + sock.rQshift8();
92 + if (subencoding === 0) {
93 + if (this._lastsubencoding & 0x01) {
94 + // Weird: ignore blanks are RAW
95 + Log.Debug(" Ignoring blank after RAW");
96 + } else {
97 + display.fillRect(tx, ty, tw, th, this._background);
98 + }
99 + } else if (subencoding & 0x01) {
100 + // Raw
101 + var pixels = tw * th;
102 + var data = sock.rQshiftBytes(pixels * 4, false);
103 + // Max sure the image is fully opaque
104 + for (var i = 0; i < pixels; i++) {
105 + data[i * 4 + 3] = 255;
106 + }
107 + display.blitImage(tx, ty, tw, th, data, 0);
108 + } else {
109 + if (subencoding & 0x02) {
110 + // Background
111 + this._background = new Uint8Array(sock.rQshiftBytes(4));
112 + }
113 + if (subencoding & 0x04) {
114 + // Foreground
115 + this._foreground = new Uint8Array(sock.rQshiftBytes(4));
116 + }
117 + this._startTile(tx, ty, tw, th, this._background);
118 + if (subencoding & 0x08) {
119 + // AnySubrects
120 + var _subrects = sock.rQshift8();
121 + for (var s = 0; s < _subrects; s++) {
122 + var color = void 0;
123 + if (subencoding & 0x10) {
124 + // SubrectsColoured
125 + color = sock.rQshiftBytes(4);
126 + } else {
127 + color = this._foreground;
128 + }
129 + var xy = sock.rQshift8();
130 + var sx = xy >> 4;
131 + var sy = xy & 0x0f;
132 + var wh = sock.rQshift8();
133 + var sw = (wh >> 4) + 1;
134 + var sh = (wh & 0x0f) + 1;
135 + this._subTile(sx, sy, sw, sh, color);
136 + }
137 + }
138 + this._finishTile(display);
139 + }
140 + this._lastsubencoding = subencoding;
141 + this._tiles--;
142 + }
143 + return true;
144 + }
145 +
146 + // start updating a tile
147 + }, {
148 + key: "_startTile",
149 + value: function _startTile(x, y, width, height, color) {
150 + this._tileX = x;
151 + this._tileY = y;
152 + this._tileW = width;
153 + this._tileH = height;
154 + var red = color[0];
155 + var green = color[1];
156 + var blue = color[2];
157 + var data = this._tileBuffer;
158 + for (var i = 0; i < width * height * 4; i += 4) {
159 + data[i] = red;
160 + data[i + 1] = green;
161 + data[i + 2] = blue;
162 + data[i + 3] = 255;
163 + }
164 + }
165 +
166 + // update sub-rectangle of the current tile
167 + }, {
168 + key: "_subTile",
169 + value: function _subTile(x, y, w, h, color) {
170 + var red = color[0];
171 + var green = color[1];
172 + var blue = color[2];
173 + var xend = x + w;
174 + var yend = y + h;
175 + var data = this._tileBuffer;
176 + var width = this._tileW;
177 + for (var j = y; j < yend; j++) {
178 + for (var i = x; i < xend; i++) {
179 + var p = (i + j * width) * 4;
180 + data[p] = red;
181 + data[p + 1] = green;
182 + data[p + 2] = blue;
183 + data[p + 3] = 255;
184 + }
185 + }
186 + }
187 +
188 + // draw the current tile to the screen
189 + }, {
190 + key: "_finishTile",
191 + value: function _finishTile(display) {
192 + display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
193 + }
194 + }]);
195 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/jpeg.js +175 −0
@@ -0,0 +1,175 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
9 +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10 +function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
11 +function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
12 +function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16 +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); } }
17 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
21 + * noVNC: HTML5 VNC client
22 + * Copyright (C) 2019 The noVNC authors
23 + * Licensed under MPL 2.0 (see LICENSE.txt)
24 + *
25 + * See README.md for usage and integration instructions.
26 + *
27 + */
28 +var JPEGDecoder = exports["default"] = /*#__PURE__*/function () {
29 + function JPEGDecoder() {
30 + _classCallCheck(this, JPEGDecoder);
31 + // RealVNC will reuse the quantization tables
32 + // and Huffman tables, so we need to cache them.
33 + this._cachedQuantTables = [];
34 + this._cachedHuffmanTables = [];
35 + this._segments = [];
36 + }
37 + return _createClass(JPEGDecoder, [{
38 + key: "decodeRect",
39 + value: function decodeRect(x, y, width, height, sock, display, depth) {
40 + // A rect of JPEG encodings is simply a JPEG file
41 + while (true) {
42 + var segment = this._readSegment(sock);
43 + if (segment === null) {
44 + return false;
45 + }
46 + this._segments.push(segment);
47 + // End of image?
48 + if (segment[1] === 0xD9) {
49 + break;
50 + }
51 + }
52 + var huffmanTables = [];
53 + var quantTables = [];
54 + var _iterator = _createForOfIteratorHelper(this._segments),
55 + _step;
56 + try {
57 + for (_iterator.s(); !(_step = _iterator.n()).done;) {
58 + var _segment = _step.value;
59 + var type = _segment[1];
60 + if (type === 0xC4) {
61 + // Huffman tables
62 + huffmanTables.push(_segment);
63 + } else if (type === 0xDB) {
64 + // Quantization tables
65 + quantTables.push(_segment);
66 + }
67 + }
68 + } catch (err) {
69 + _iterator.e(err);
70 + } finally {
71 + _iterator.f();
72 + }
73 + var sofIndex = this._segments.findIndex(function (x) {
74 + return x[1] == 0xC0 || x[1] == 0xC2;
75 + });
76 + if (sofIndex == -1) {
77 + throw new Error("Illegal JPEG image without SOF");
78 + }
79 + if (quantTables.length === 0) {
80 + var _this$_segments;
81 + (_this$_segments = this._segments).splice.apply(_this$_segments, [sofIndex + 1, 0].concat(_toConsumableArray(this._cachedQuantTables)));
82 + }
83 + if (huffmanTables.length === 0) {
84 + var _this$_segments2;
85 + (_this$_segments2 = this._segments).splice.apply(_this$_segments2, [sofIndex + 1, 0].concat(_toConsumableArray(this._cachedHuffmanTables)));
86 + }
87 + var length = 0;
88 + var _iterator2 = _createForOfIteratorHelper(this._segments),
89 + _step2;
90 + try {
91 + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
92 + var _segment2 = _step2.value;
93 + length += _segment2.length;
94 + }
95 + } catch (err) {
96 + _iterator2.e(err);
97 + } finally {
98 + _iterator2.f();
99 + }
100 + var data = new Uint8Array(length);
101 + length = 0;
102 + var _iterator3 = _createForOfIteratorHelper(this._segments),
103 + _step3;
104 + try {
105 + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
106 + var _segment3 = _step3.value;
107 + data.set(_segment3, length);
108 + length += _segment3.length;
109 + }
110 + } catch (err) {
111 + _iterator3.e(err);
112 + } finally {
113 + _iterator3.f();
114 + }
115 + display.imageRect(x, y, width, height, "image/jpeg", data);
116 + if (huffmanTables.length !== 0) {
117 + this._cachedHuffmanTables = huffmanTables;
118 + }
119 + if (quantTables.length !== 0) {
120 + this._cachedQuantTables = quantTables;
121 + }
122 + this._segments = [];
123 + return true;
124 + }
125 + }, {
126 + key: "_readSegment",
127 + value: function _readSegment(sock) {
128 + if (sock.rQwait("JPEG", 2)) {
129 + return null;
130 + }
131 + var marker = sock.rQshift8();
132 + if (marker != 0xFF) {
133 + throw new Error("Illegal JPEG marker received (byte: " + marker + ")");
134 + }
135 + var type = sock.rQshift8();
136 + if (type >= 0xD0 && type <= 0xD9 || type == 0x01) {
137 + // No length after marker
138 + return new Uint8Array([marker, type]);
139 + }
140 + if (sock.rQwait("JPEG", 2, 2)) {
141 + return null;
142 + }
143 + var length = sock.rQshift16();
144 + if (length < 2) {
145 + throw new Error("Illegal JPEG length received (length: " + length + ")");
146 + }
147 + if (sock.rQwait("JPEG", length - 2, 4)) {
148 + return null;
149 + }
150 + var extra = 0;
151 + if (type === 0xDA) {
152 + // start of scan
153 + extra += 2;
154 + while (true) {
155 + if (sock.rQwait("JPEG", length - 2 + extra, 4)) {
156 + return null;
157 + }
158 + var data = sock.rQpeekBytes(length - 2 + extra, false);
159 + if (data.at(-2) === 0xFF && data.at(-1) !== 0x00 && !(data.at(-1) >= 0xD0 && data.at(-1) <= 0xD7)) {
160 + extra -= 2;
161 + break;
162 + }
163 + extra++;
164 + }
165 + }
166 + var segment = new Uint8Array(2 + length + extra);
167 + segment[0] = marker;
168 + segment[1] = type;
169 + segment[2] = length >> 8;
170 + segment[3] = length;
171 + segment.set(sock.rQshiftBytes(length - 2 + extra, false), 4);
172 + return segment;
173 + }
174 + }]);
175 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/raw.js +66 −0
@@ -0,0 +1,66 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2019 The noVNC authors
16 + * Licensed under MPL 2.0 (see LICENSE.txt)
17 + *
18 + * See README.md for usage and integration instructions.
19 + *
20 + */
21 +var RawDecoder = exports["default"] = /*#__PURE__*/function () {
22 + function RawDecoder() {
23 + _classCallCheck(this, RawDecoder);
24 + this._lines = 0;
25 + }
26 + return _createClass(RawDecoder, [{
27 + key: "decodeRect",
28 + value: function decodeRect(x, y, width, height, sock, display, depth) {
29 + if (width === 0 || height === 0) {
30 + return true;
31 + }
32 + if (this._lines === 0) {
33 + this._lines = height;
34 + }
35 + var pixelSize = depth == 8 ? 1 : 4;
36 + var bytesPerLine = width * pixelSize;
37 + while (this._lines > 0) {
38 + if (sock.rQwait("RAW", bytesPerLine)) {
39 + return false;
40 + }
41 + var curY = y + (height - this._lines);
42 + var data = sock.rQshiftBytes(bytesPerLine, false);
43 +
44 + // Convert data if needed
45 + if (depth == 8) {
46 + var newdata = new Uint8Array(width * 4);
47 + for (var i = 0; i < width; i++) {
48 + newdata[i * 4 + 0] = (data[i] >> 0 & 0x3) * 255 / 3;
49 + newdata[i * 4 + 1] = (data[i] >> 2 & 0x3) * 255 / 3;
50 + newdata[i * 4 + 2] = (data[i] >> 4 & 0x3) * 255 / 3;
51 + newdata[i * 4 + 3] = 255;
52 + }
53 + data = newdata;
54 + }
55 +
56 + // Max sure the image is fully opaque
57 + for (var _i = 0; _i < width; _i++) {
58 + data[_i * 4 + 3] = 255;
59 + }
60 + display.blitImage(x, curY, width, 1, data, 0);
61 + this._lines--;
62 + }
63 + return true;
64 + }
65 + }]);
66 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/rre.js +52 −0
@@ -0,0 +1,52 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2019 The noVNC authors
16 + * Licensed under MPL 2.0 (see LICENSE.txt)
17 + *
18 + * See README.md for usage and integration instructions.
19 + *
20 + */
21 +var RREDecoder = exports["default"] = /*#__PURE__*/function () {
22 + function RREDecoder() {
23 + _classCallCheck(this, RREDecoder);
24 + this._subrects = 0;
25 + }
26 + return _createClass(RREDecoder, [{
27 + key: "decodeRect",
28 + value: function decodeRect(x, y, width, height, sock, display, depth) {
29 + if (this._subrects === 0) {
30 + if (sock.rQwait("RRE", 4 + 4)) {
31 + return false;
32 + }
33 + this._subrects = sock.rQshift32();
34 + var color = sock.rQshiftBytes(4); // Background
35 + display.fillRect(x, y, width, height, color);
36 + }
37 + while (this._subrects > 0) {
38 + if (sock.rQwait("RRE", 4 + 8)) {
39 + return false;
40 + }
41 + var _color = sock.rQshiftBytes(4);
42 + var sx = sock.rQshift16();
43 + var sy = sock.rQshift16();
44 + var swidth = sock.rQshift16();
45 + var sheight = sock.rQshift16();
46 + display.fillRect(x + sx, y + sy, swidth, sheight, _color);
47 + this._subrects--;
48 + }
49 + return true;
50 + }
51 + }]);
52 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/tight.js +363 −0
@@ -0,0 +1,363 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var Log = _interopRequireWildcard(require("../util/logging.js"));
8 +var _inflator = _interopRequireDefault(require("../inflator.js"));
9 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10 +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); }
11 +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; }
12 +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); }
13 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14 +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); } }
15 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 + * noVNC: HTML5 VNC client
19 + * Copyright (C) 2019 The noVNC authors
20 + * (c) 2012 Michael Tinglof, Joe Balaz, Les Piech (Mercuri.ca)
21 + * Licensed under MPL 2.0 (see LICENSE.txt)
22 + *
23 + * See README.md for usage and integration instructions.
24 + *
25 + */
26 +var TightDecoder = exports["default"] = /*#__PURE__*/function () {
27 + function TightDecoder() {
28 + _classCallCheck(this, TightDecoder);
29 + this._ctl = null;
30 + this._filter = null;
31 + this._numColors = 0;
32 + this._palette = new Uint8Array(1024); // 256 * 4 (max palette size * max bytes-per-pixel)
33 + this._len = 0;
34 + this._zlibs = [];
35 + for (var i = 0; i < 4; i++) {
36 + this._zlibs[i] = new _inflator["default"]();
37 + }
38 + }
39 + return _createClass(TightDecoder, [{
40 + key: "decodeRect",
41 + value: function decodeRect(x, y, width, height, sock, display, depth) {
42 + if (this._ctl === null) {
43 + if (sock.rQwait("TIGHT compression-control", 1)) {
44 + return false;
45 + }
46 + this._ctl = sock.rQshift8();
47 +
48 + // Reset streams if the server requests it
49 + for (var i = 0; i < 4; i++) {
50 + if (this._ctl >> i & 1) {
51 + this._zlibs[i].reset();
52 + Log.Info("Reset zlib stream " + i);
53 + }
54 + }
55 +
56 + // Figure out filter
57 + this._ctl = this._ctl >> 4;
58 + }
59 + var ret;
60 + if (this._ctl === 0x08) {
61 + ret = this._fillRect(x, y, width, height, sock, display, depth);
62 + } else if (this._ctl === 0x09) {
63 + ret = this._jpegRect(x, y, width, height, sock, display, depth);
64 + } else if (this._ctl === 0x0A) {
65 + ret = this._pngRect(x, y, width, height, sock, display, depth);
66 + } else if ((this._ctl & 0x08) == 0) {
67 + ret = this._basicRect(this._ctl, x, y, width, height, sock, display, depth);
68 + } else {
69 + throw new Error("Illegal tight compression received (ctl: " + this._ctl + ")");
70 + }
71 + if (ret) {
72 + this._ctl = null;
73 + }
74 + return ret;
75 + }
76 + }, {
77 + key: "_fillRect",
78 + value: function _fillRect(x, y, width, height, sock, display, depth) {
79 + if (sock.rQwait("TIGHT", 3)) {
80 + return false;
81 + }
82 + var pixel = sock.rQshiftBytes(3);
83 + display.fillRect(x, y, width, height, pixel, false);
84 + return true;
85 + }
86 + }, {
87 + key: "_jpegRect",
88 + value: function _jpegRect(x, y, width, height, sock, display, depth) {
89 + var data = this._readData(sock);
90 + if (data === null) {
91 + return false;
92 + }
93 + display.imageRect(x, y, width, height, "image/jpeg", data);
94 + return true;
95 + }
96 + }, {
97 + key: "_pngRect",
98 + value: function _pngRect(x, y, width, height, sock, display, depth) {
99 + throw new Error("PNG received in standard Tight rect");
100 + }
101 + }, {
102 + key: "_basicRect",
103 + value: function _basicRect(ctl, x, y, width, height, sock, display, depth) {
104 + if (this._filter === null) {
105 + if (ctl & 0x4) {
106 + if (sock.rQwait("TIGHT", 1)) {
107 + return false;
108 + }
109 + this._filter = sock.rQshift8();
110 + } else {
111 + // Implicit CopyFilter
112 + this._filter = 0;
113 + }
114 + }
115 + var streamId = ctl & 0x3;
116 + var ret;
117 + switch (this._filter) {
118 + case 0:
119 + // CopyFilter
120 + ret = this._copyFilter(streamId, x, y, width, height, sock, display, depth);
121 + break;
122 + case 1:
123 + // PaletteFilter
124 + ret = this._paletteFilter(streamId, x, y, width, height, sock, display, depth);
125 + break;
126 + case 2:
127 + // GradientFilter
128 + ret = this._gradientFilter(streamId, x, y, width, height, sock, display, depth);
129 + break;
130 + default:
131 + throw new Error("Illegal tight filter received (ctl: " + this._filter + ")");
132 + }
133 + if (ret) {
134 + this._filter = null;
135 + }
136 + return ret;
137 + }
138 + }, {
139 + key: "_copyFilter",
140 + value: function _copyFilter(streamId, x, y, width, height, sock, display, depth) {
141 + var uncompressedSize = width * height * 3;
142 + var data;
143 + if (uncompressedSize === 0) {
144 + return true;
145 + }
146 + if (uncompressedSize < 12) {
147 + if (sock.rQwait("TIGHT", uncompressedSize)) {
148 + return false;
149 + }
150 + data = sock.rQshiftBytes(uncompressedSize);
151 + } else {
152 + data = this._readData(sock);
153 + if (data === null) {
154 + return false;
155 + }
156 + this._zlibs[streamId].setInput(data);
157 + data = this._zlibs[streamId].inflate(uncompressedSize);
158 + this._zlibs[streamId].setInput(null);
159 + }
160 + var rgbx = new Uint8Array(width * height * 4);
161 + for (var i = 0, j = 0; i < width * height * 4; i += 4, j += 3) {
162 + rgbx[i] = data[j];
163 + rgbx[i + 1] = data[j + 1];
164 + rgbx[i + 2] = data[j + 2];
165 + rgbx[i + 3] = 255; // Alpha
166 + }
167 + display.blitImage(x, y, width, height, rgbx, 0, false);
168 + return true;
169 + }
170 + }, {
171 + key: "_paletteFilter",
172 + value: function _paletteFilter(streamId, x, y, width, height, sock, display, depth) {
173 + if (this._numColors === 0) {
174 + if (sock.rQwait("TIGHT palette", 1)) {
175 + return false;
176 + }
177 + var numColors = sock.rQpeek8() + 1;
178 + var paletteSize = numColors * 3;
179 + if (sock.rQwait("TIGHT palette", 1 + paletteSize)) {
180 + return false;
181 + }
182 + this._numColors = numColors;
183 + sock.rQskipBytes(1);
184 + sock.rQshiftTo(this._palette, paletteSize);
185 + }
186 + var bpp = this._numColors <= 2 ? 1 : 8;
187 + var rowSize = Math.floor((width * bpp + 7) / 8);
188 + var uncompressedSize = rowSize * height;
189 + var data;
190 + if (uncompressedSize === 0) {
191 + return true;
192 + }
193 + if (uncompressedSize < 12) {
194 + if (sock.rQwait("TIGHT", uncompressedSize)) {
195 + return false;
196 + }
197 + data = sock.rQshiftBytes(uncompressedSize);
198 + } else {
199 + data = this._readData(sock);
200 + if (data === null) {
201 + return false;
202 + }
203 + this._zlibs[streamId].setInput(data);
204 + data = this._zlibs[streamId].inflate(uncompressedSize);
205 + this._zlibs[streamId].setInput(null);
206 + }
207 +
208 + // Convert indexed (palette based) image data to RGB
209 + if (this._numColors == 2) {
210 + this._monoRect(x, y, width, height, data, this._palette, display);
211 + } else {
212 + this._paletteRect(x, y, width, height, data, this._palette, display);
213 + }
214 + this._numColors = 0;
215 + return true;
216 + }
217 + }, {
218 + key: "_monoRect",
219 + value: function _monoRect(x, y, width, height, data, palette, display) {
220 + // Convert indexed (palette based) image data to RGB
221 + // TODO: reduce number of calculations inside loop
222 + var dest = this._getScratchBuffer(width * height * 4);
223 + var w = Math.floor((width + 7) / 8);
224 + var w1 = Math.floor(width / 8);
225 + for (var _y = 0; _y < height; _y++) {
226 + var dp = void 0,
227 + sp = void 0,
228 + _x = void 0;
229 + for (_x = 0; _x < w1; _x++) {
230 + for (var b = 7; b >= 0; b--) {
231 + dp = (_y * width + _x * 8 + 7 - b) * 4;
232 + sp = (data[_y * w + _x] >> b & 1) * 3;
233 + dest[dp] = palette[sp];
234 + dest[dp + 1] = palette[sp + 1];
235 + dest[dp + 2] = palette[sp + 2];
236 + dest[dp + 3] = 255;
237 + }
238 + }
239 + for (var _b = 7; _b >= 8 - width % 8; _b--) {
240 + dp = (_y * width + _x * 8 + 7 - _b) * 4;
241 + sp = (data[_y * w + _x] >> _b & 1) * 3;
242 + dest[dp] = palette[sp];
243 + dest[dp + 1] = palette[sp + 1];
244 + dest[dp + 2] = palette[sp + 2];
245 + dest[dp + 3] = 255;
246 + }
247 + }
248 + display.blitImage(x, y, width, height, dest, 0, false);
249 + }
250 + }, {
251 + key: "_paletteRect",
252 + value: function _paletteRect(x, y, width, height, data, palette, display) {
253 + // Convert indexed (palette based) image data to RGB
254 + var dest = this._getScratchBuffer(width * height * 4);
255 + var total = width * height * 4;
256 + for (var i = 0, j = 0; i < total; i += 4, j++) {
257 + var sp = data[j] * 3;
258 + dest[i] = palette[sp];
259 + dest[i + 1] = palette[sp + 1];
260 + dest[i + 2] = palette[sp + 2];
261 + dest[i + 3] = 255;
262 + }
263 + display.blitImage(x, y, width, height, dest, 0, false);
264 + }
265 + }, {
266 + key: "_gradientFilter",
267 + value: function _gradientFilter(streamId, x, y, width, height, sock, display, depth) {
268 + // assume the TPIXEL is 3 bytes long
269 + var uncompressedSize = width * height * 3;
270 + var data;
271 + if (uncompressedSize === 0) {
272 + return true;
273 + }
274 + if (uncompressedSize < 12) {
275 + if (sock.rQwait("TIGHT", uncompressedSize)) {
276 + return false;
277 + }
278 + data = sock.rQshiftBytes(uncompressedSize);
279 + } else {
280 + data = this._readData(sock);
281 + if (data === null) {
282 + return false;
283 + }
284 + this._zlibs[streamId].setInput(data);
285 + data = this._zlibs[streamId].inflate(uncompressedSize);
286 + this._zlibs[streamId].setInput(null);
287 + }
288 + var rgbx = new Uint8Array(4 * width * height);
289 + var rgbxIndex = 0,
290 + dataIndex = 0;
291 + var left = new Uint8Array(3);
292 + for (var _x2 = 0; _x2 < width; _x2++) {
293 + for (var c = 0; c < 3; c++) {
294 + var prediction = left[c];
295 + var value = data[dataIndex++] + prediction;
296 + rgbx[rgbxIndex++] = value;
297 + left[c] = value;
298 + }
299 + rgbx[rgbxIndex++] = 255;
300 + }
301 + var upperIndex = 0;
302 + var upper = new Uint8Array(3),
303 + upperleft = new Uint8Array(3);
304 + for (var _y2 = 1; _y2 < height; _y2++) {
305 + left.fill(0);
306 + upperleft.fill(0);
307 + for (var _x3 = 0; _x3 < width; _x3++) {
308 + for (var _c = 0; _c < 3; _c++) {
309 + upper[_c] = rgbx[upperIndex++];
310 + var _prediction = left[_c] + upper[_c] - upperleft[_c];
311 + if (_prediction < 0) {
312 + _prediction = 0;
313 + } else if (_prediction > 255) {
314 + _prediction = 255;
315 + }
316 + var _value = data[dataIndex++] + _prediction;
317 + rgbx[rgbxIndex++] = _value;
318 + upperleft[_c] = upper[_c];
319 + left[_c] = _value;
320 + }
321 + rgbx[rgbxIndex++] = 255;
322 + upperIndex++;
323 + }
324 + }
325 + display.blitImage(x, y, width, height, rgbx, 0, false);
326 + return true;
327 + }
328 + }, {
329 + key: "_readData",
330 + value: function _readData(sock) {
331 + if (this._len === 0) {
332 + if (sock.rQwait("TIGHT", 3)) {
333 + return null;
334 + }
335 + var _byte;
336 + _byte = sock.rQshift8();
337 + this._len = _byte & 0x7f;
338 + if (_byte & 0x80) {
339 + _byte = sock.rQshift8();
340 + this._len |= (_byte & 0x7f) << 7;
341 + if (_byte & 0x80) {
342 + _byte = sock.rQshift8();
343 + this._len |= _byte << 14;
344 + }
345 + }
346 + }
347 + if (sock.rQwait("TIGHT", this._len)) {
348 + return null;
349 + }
350 + var data = sock.rQshiftBytes(this._len, false);
351 + this._len = 0;
352 + return data;
353 + }
354 + }, {
355 + key: "_getScratchBuffer",
356 + value: function _getScratchBuffer(size) {
357 + if (!this._scratchBuffer || this._scratchBuffer.length < size) {
358 + this._scratchBuffer = new Uint8Array(size);
359 + }
360 + return this._scratchBuffer;
361 + }
362 + }]);
363 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/tightpng.js +51 −0
@@ -0,0 +1,51 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports["default"] = void 0;
8 +var _tight = _interopRequireDefault(require("./tight.js"));
9 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
16 +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
17 +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18 +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19 +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
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 +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
22 + * noVNC: HTML5 VNC client
23 + * Copyright (C) 2019 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 TightPNGDecoder = exports["default"] = /*#__PURE__*/function (_TightDecoder) {
30 + function TightPNGDecoder() {
31 + _classCallCheck(this, TightPNGDecoder);
32 + return _callSuper(this, TightPNGDecoder, arguments);
33 + }
34 + _inherits(TightPNGDecoder, _TightDecoder);
35 + return _createClass(TightPNGDecoder, [{
36 + key: "_pngRect",
37 + value: function _pngRect(x, y, width, height, sock, display, depth) {
38 + var data = this._readData(sock);
39 + if (data === null) {
40 + return false;
41 + }
42 + display.imageRect(x, y, width, height, "image/png", data);
43 + return true;
44 + }
45 + }, {
46 + key: "_basicRect",
47 + value: function _basicRect(ctl, x, y, width, height, sock, display, depth) {
48 + throw new Error("BasicCompression received in TightPNG rect");
49 + }
50 + }]);
51 +}(_tight["default"]);
\ No newline at end of file
added public/vendor/novnc/decoders/zlib.js +57 −0
@@ -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 +}();
\ No newline at end of file
added public/vendor/novnc/decoders/zrle.js +192 −0
@@ -0,0 +1,192 @@
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) 2021 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 ZRLE_TILE_WIDTH = 64;
23 +var ZRLE_TILE_HEIGHT = 64;
24 +var ZRLEDecoder = exports["default"] = /*#__PURE__*/function () {
25 + function ZRLEDecoder() {
26 + _classCallCheck(this, ZRLEDecoder);
27 + this._length = 0;
28 + this._inflator = new _inflator["default"]();
29 + this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
30 + this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
31 + }
32 + return _createClass(ZRLEDecoder, [{
33 + key: "decodeRect",
34 + value: function decodeRect(x, y, width, height, sock, display, depth) {
35 + if (this._length === 0) {
36 + if (sock.rQwait("ZLib data length", 4)) {
37 + return false;
38 + }
39 + this._length = sock.rQshift32();
40 + }
41 + if (sock.rQwait("Zlib data", this._length)) {
42 + return false;
43 + }
44 + var data = sock.rQshiftBytes(this._length, false);
45 + this._inflator.setInput(data);
46 + for (var ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
47 + var th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
48 + for (var tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
49 + var tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
50 + var tileSize = tw * th;
51 + var subencoding = this._inflator.inflate(1)[0];
52 + if (subencoding === 0) {
53 + // raw data
54 + var _data = this._readPixels(tileSize);
55 + display.blitImage(tx, ty, tw, th, _data, 0, false);
56 + } else if (subencoding === 1) {
57 + // solid
58 + var background = this._readPixels(1);
59 + display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
60 + } else if (subencoding >= 2 && subencoding <= 16) {
61 + var _data2 = this._decodePaletteTile(subencoding, tileSize, tw, th);
62 + display.blitImage(tx, ty, tw, th, _data2, 0, false);
63 + } else if (subencoding === 128) {
64 + var _data3 = this._decodeRLETile(tileSize);
65 + display.blitImage(tx, ty, tw, th, _data3, 0, false);
66 + } else if (subencoding >= 130 && subencoding <= 255) {
67 + var _data4 = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
68 + display.blitImage(tx, ty, tw, th, _data4, 0, false);
69 + } else {
70 + throw new Error('Unknown subencoding: ' + subencoding);
71 + }
72 + }
73 + }
74 + this._length = 0;
75 + return true;
76 + }
77 + }, {
78 + key: "_getBitsPerPixelInPalette",
79 + value: function _getBitsPerPixelInPalette(paletteSize) {
80 + if (paletteSize <= 2) {
81 + return 1;
82 + } else if (paletteSize <= 4) {
83 + return 2;
84 + } else if (paletteSize <= 16) {
85 + return 4;
86 + }
87 + }
88 + }, {
89 + key: "_readPixels",
90 + value: function _readPixels(pixels) {
91 + var data = this._pixelBuffer;
92 + var buffer = this._inflator.inflate(3 * pixels);
93 + for (var i = 0, j = 0; i < pixels * 4; i += 4, j += 3) {
94 + data[i] = buffer[j];
95 + data[i + 1] = buffer[j + 1];
96 + data[i + 2] = buffer[j + 2];
97 + data[i + 3] = 255; // Add the Alpha
98 + }
99 + return data;
100 + }
101 + }, {
102 + key: "_decodePaletteTile",
103 + value: function _decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
104 + var data = this._tileBuffer;
105 + var palette = this._readPixels(paletteSize);
106 + var bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
107 + var mask = (1 << bitsPerPixel) - 1;
108 + var offset = 0;
109 + var encoded = this._inflator.inflate(1)[0];
110 + for (var y = 0; y < tileh; y++) {
111 + var shift = 8 - bitsPerPixel;
112 + for (var x = 0; x < tilew; x++) {
113 + if (shift < 0) {
114 + shift = 8 - bitsPerPixel;
115 + encoded = this._inflator.inflate(1)[0];
116 + }
117 + var indexInPalette = encoded >> shift & mask;
118 + data[offset] = palette[indexInPalette * 4];
119 + data[offset + 1] = palette[indexInPalette * 4 + 1];
120 + data[offset + 2] = palette[indexInPalette * 4 + 2];
121 + data[offset + 3] = palette[indexInPalette * 4 + 3];
122 + offset += 4;
123 + shift -= bitsPerPixel;
124 + }
125 + if (shift < 8 - bitsPerPixel && y < tileh - 1) {
126 + encoded = this._inflator.inflate(1)[0];
127 + }
128 + }
129 + return data;
130 + }
131 + }, {
132 + key: "_decodeRLETile",
133 + value: function _decodeRLETile(tileSize) {
134 + var data = this._tileBuffer;
135 + var i = 0;
136 + while (i < tileSize) {
137 + var pixel = this._readPixels(1);
138 + var length = this._readRLELength();
139 + for (var j = 0; j < length; j++) {
140 + data[i * 4] = pixel[0];
141 + data[i * 4 + 1] = pixel[1];
142 + data[i * 4 + 2] = pixel[2];
143 + data[i * 4 + 3] = pixel[3];
144 + i++;
145 + }
146 + }
147 + return data;
148 + }
149 + }, {
150 + key: "_decodeRLEPaletteTile",
151 + value: function _decodeRLEPaletteTile(paletteSize, tileSize) {
152 + var data = this._tileBuffer;
153 +
154 + // palette
155 + var palette = this._readPixels(paletteSize);
156 + var offset = 0;
157 + while (offset < tileSize) {
158 + var indexInPalette = this._inflator.inflate(1)[0];
159 + var length = 1;
160 + if (indexInPalette >= 128) {
161 + indexInPalette -= 128;
162 + length = this._readRLELength();
163 + }
164 + if (indexInPalette > paletteSize) {
165 + throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
166 + }
167 + if (offset + length > tileSize) {
168 + throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
169 + }
170 + for (var j = 0; j < length; j++) {
171 + data[offset * 4] = palette[indexInPalette * 4];
172 + data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
173 + data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
174 + data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
175 + offset++;
176 + }
177 + }
178 + return data;
179 + }
180 + }, {
181 + key: "_readRLELength",
182 + value: function _readRLELength() {
183 + var length = 0;
184 + var current = 0;
185 + do {
186 + current = this._inflator.inflate(1)[0];
187 + length += current;
188 + } while (current === 255);
189 + return length + 1;
190 + }
191 + }]);
192 +}();
\ No newline at end of file
added public/vendor/novnc/deflator.js +88 −0
@@ -0,0 +1,88 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _deflate2 = require("../lib/vendor/pako/lib/zlib/deflate.js");
8 +var _zstream = _interopRequireDefault(require("../lib/vendor/pako/lib/zlib/zstream.js"));
9 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12 +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); } }
13 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 + * noVNC: HTML5 VNC client
17 + * Copyright (C) 2020 The noVNC authors
18 + * Licensed under MPL 2.0 (see LICENSE.txt)
19 + *
20 + * See README.md for usage and integration instructions.
21 + */
22 +var Deflator = exports["default"] = /*#__PURE__*/function () {
23 + function Deflator() {
24 + _classCallCheck(this, Deflator);
25 + this.strm = new _zstream["default"]();
26 + this.chunkSize = 1024 * 10 * 10;
27 + this.outputBuffer = new Uint8Array(this.chunkSize);
28 + (0, _deflate2.deflateInit)(this.strm, _deflate2.Z_DEFAULT_COMPRESSION);
29 + }
30 + return _createClass(Deflator, [{
31 + key: "deflate",
32 + value: function deflate(inData) {
33 + /* eslint-disable camelcase */
34 + this.strm.input = inData;
35 + this.strm.avail_in = this.strm.input.length;
36 + this.strm.next_in = 0;
37 + this.strm.output = this.outputBuffer;
38 + this.strm.avail_out = this.chunkSize;
39 + this.strm.next_out = 0;
40 + /* eslint-enable camelcase */
41 +
42 + var lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
43 + var outData = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
44 + if (lastRet < 0) {
45 + throw new Error("zlib deflate failed");
46 + }
47 + if (this.strm.avail_in > 0) {
48 + // Read chunks until done
49 +
50 + var chunks = [outData];
51 + var totalLen = outData.length;
52 + do {
53 + /* eslint-disable camelcase */
54 + this.strm.output = new Uint8Array(this.chunkSize);
55 + this.strm.next_out = 0;
56 + this.strm.avail_out = this.chunkSize;
57 + /* eslint-enable camelcase */
58 +
59 + lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
60 + if (lastRet < 0) {
61 + throw new Error("zlib deflate failed");
62 + }
63 + var chunk = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
64 + totalLen += chunk.length;
65 + chunks.push(chunk);
66 + } while (this.strm.avail_in > 0);
67 +
68 + // Combine chunks into a single data
69 +
70 + var newData = new Uint8Array(totalLen);
71 + var offset = 0;
72 + for (var i = 0; i < chunks.length; i++) {
73 + newData.set(chunks[i], offset);
74 + offset += chunks[i].length;
75 + }
76 + outData = newData;
77 + }
78 +
79 + /* eslint-disable camelcase */
80 + this.strm.input = null;
81 + this.strm.avail_in = 0;
82 + this.strm.next_in = 0;
83 + /* eslint-enable camelcase */
84 +
85 + return outData;
86 + }
87 + }]);
88 +}();
\ No newline at end of file
added public/vendor/novnc/display.js +588 −0
@@ -0,0 +1,588 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var Log = _interopRequireWildcard(require("./util/logging.js"));
8 +var _base = _interopRequireDefault(require("./base64.js"));
9 +var _int = require("./util/int.js");
10 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11 +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); }
12 +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; }
13 +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); }
14 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
15 +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); } }
16 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 + * noVNC: HTML5 VNC client
20 + * Copyright (C) 2019 The noVNC authors
21 + * Licensed under MPL 2.0 (see LICENSE.txt)
22 + *
23 + * See README.md for usage and integration instructions.
24 + */
25 +var Display = exports["default"] = /*#__PURE__*/function () {
26 + function Display(target) {
27 + _classCallCheck(this, Display);
28 + this._drawCtx = null;
29 + this._renderQ = []; // queue drawing actions for in-oder rendering
30 + this._flushPromise = null;
31 +
32 + // the full frame buffer (logical canvas) size
33 + this._fbWidth = 0;
34 + this._fbHeight = 0;
35 + this._prevDrawStyle = "";
36 + Log.Debug(">> Display.constructor");
37 +
38 + // The visible canvas
39 + this._target = target;
40 + if (!this._target) {
41 + throw new Error("Target must be set");
42 + }
43 + if (typeof this._target === 'string') {
44 + throw new Error('target must be a DOM element');
45 + }
46 + if (!this._target.getContext) {
47 + throw new Error("no getContext method");
48 + }
49 + this._targetCtx = this._target.getContext('2d');
50 +
51 + // the visible canvas viewport (i.e. what actually gets seen)
52 + this._viewportLoc = {
53 + 'x': 0,
54 + 'y': 0,
55 + 'w': this._target.width,
56 + 'h': this._target.height
57 + };
58 +
59 + // The hidden canvas, where we do the actual rendering
60 + this._backbuffer = document.createElement('canvas');
61 + this._drawCtx = this._backbuffer.getContext('2d');
62 + this._damageBounds = {
63 + left: 0,
64 + top: 0,
65 + right: this._backbuffer.width,
66 + bottom: this._backbuffer.height
67 + };
68 + Log.Debug("User Agent: " + navigator.userAgent);
69 + Log.Debug("<< Display.constructor");
70 +
71 + // ===== PROPERTIES =====
72 +
73 + this._scale = 1.0;
74 + this._clipViewport = false;
75 + }
76 +
77 + // ===== PROPERTIES =====
78 + return _createClass(Display, [{
79 + key: "scale",
80 + get: function get() {
81 + return this._scale;
82 + },
83 + set: function set(scale) {
84 + this._rescale(scale);
85 + }
86 + }, {
87 + key: "clipViewport",
88 + get: function get() {
89 + return this._clipViewport;
90 + },
91 + set: function set(viewport) {
92 + this._clipViewport = viewport;
93 + // May need to readjust the viewport dimensions
94 + var vp = this._viewportLoc;
95 + this.viewportChangeSize(vp.w, vp.h);
96 + this.viewportChangePos(0, 0);
97 + }
98 + }, {
99 + key: "width",
100 + get: function get() {
101 + return this._fbWidth;
102 + }
103 + }, {
104 + key: "height",
105 + get: function get() {
106 + return this._fbHeight;
107 + }
108 +
109 + // ===== PUBLIC METHODS =====
110 + }, {
111 + key: "viewportChangePos",
112 + value: function viewportChangePos(deltaX, deltaY) {
113 + var vp = this._viewportLoc;
114 + deltaX = Math.floor(deltaX);
115 + deltaY = Math.floor(deltaY);
116 + if (!this._clipViewport) {
117 + deltaX = -vp.w; // clamped later of out of bounds
118 + deltaY = -vp.h;
119 + }
120 + var vx2 = vp.x + vp.w - 1;
121 + var vy2 = vp.y + vp.h - 1;
122 +
123 + // Position change
124 +
125 + if (deltaX < 0 && vp.x + deltaX < 0) {
126 + deltaX = -vp.x;
127 + }
128 + if (vx2 + deltaX >= this._fbWidth) {
129 + deltaX -= vx2 + deltaX - this._fbWidth + 1;
130 + }
131 + if (vp.y + deltaY < 0) {
132 + deltaY = -vp.y;
133 + }
134 + if (vy2 + deltaY >= this._fbHeight) {
135 + deltaY -= vy2 + deltaY - this._fbHeight + 1;
136 + }
137 + if (deltaX === 0 && deltaY === 0) {
138 + return;
139 + }
140 + Log.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY);
141 + vp.x += deltaX;
142 + vp.y += deltaY;
143 + this._damage(vp.x, vp.y, vp.w, vp.h);
144 + this.flip();
145 + }
146 + }, {
147 + key: "viewportChangeSize",
148 + value: function viewportChangeSize(width, height) {
149 + if (!this._clipViewport || typeof width === "undefined" || typeof height === "undefined") {
150 + Log.Debug("Setting viewport to full display region");
151 + width = this._fbWidth;
152 + height = this._fbHeight;
153 + }
154 + width = Math.floor(width);
155 + height = Math.floor(height);
156 + if (width > this._fbWidth) {
157 + width = this._fbWidth;
158 + }
159 + if (height > this._fbHeight) {
160 + height = this._fbHeight;
161 + }
162 + var vp = this._viewportLoc;
163 + if (vp.w !== width || vp.h !== height) {
164 + vp.w = width;
165 + vp.h = height;
166 + var canvas = this._target;
167 + canvas.width = width;
168 + canvas.height = height;
169 +
170 + // The position might need to be updated if we've grown
171 + this.viewportChangePos(0, 0);
172 + this._damage(vp.x, vp.y, vp.w, vp.h);
173 + this.flip();
174 +
175 + // Update the visible size of the target canvas
176 + this._rescale(this._scale);
177 + }
178 + }
179 + }, {
180 + key: "absX",
181 + value: function absX(x) {
182 + if (this._scale === 0) {
183 + return 0;
184 + }
185 + return (0, _int.toSigned32bit)(x / this._scale + this._viewportLoc.x);
186 + }
187 + }, {
188 + key: "absY",
189 + value: function absY(y) {
190 + if (this._scale === 0) {
191 + return 0;
192 + }
193 + return (0, _int.toSigned32bit)(y / this._scale + this._viewportLoc.y);
194 + }
195 + }, {
196 + key: "resize",
197 + value: function resize(width, height) {
198 + this._prevDrawStyle = "";
199 + this._fbWidth = width;
200 + this._fbHeight = height;
201 + var canvas = this._backbuffer;
202 + if (canvas.width !== width || canvas.height !== height) {
203 + // We have to save the canvas data since changing the size will clear it
204 + var saveImg = null;
205 + if (canvas.width > 0 && canvas.height > 0) {
206 + saveImg = this._drawCtx.getImageData(0, 0, canvas.width, canvas.height);
207 + }
208 + if (canvas.width !== width) {
209 + canvas.width = width;
210 + }
211 + if (canvas.height !== height) {
212 + canvas.height = height;
213 + }
214 + if (saveImg) {
215 + this._drawCtx.putImageData(saveImg, 0, 0);
216 + }
217 + }
218 +
219 + // Readjust the viewport as it may be incorrectly sized
220 + // and positioned
221 + var vp = this._viewportLoc;
222 + this.viewportChangeSize(vp.w, vp.h);
223 + this.viewportChangePos(0, 0);
224 + }
225 + }, {
226 + key: "getImageData",
227 + value: function getImageData() {
228 + return this._drawCtx.getImageData(0, 0, this.width, this.height);
229 + }
230 + }, {
231 + key: "toDataURL",
232 + value: function toDataURL(type, encoderOptions) {
233 + return this._backbuffer.toDataURL(type, encoderOptions);
234 + }
235 + }, {
236 + key: "toBlob",
237 + value: function toBlob(callback, type, quality) {
238 + return this._backbuffer.toBlob(callback, type, quality);
239 + }
240 +
241 + // Track what parts of the visible canvas that need updating
242 + }, {
243 + key: "_damage",
244 + value: function _damage(x, y, w, h) {
245 + if (x < this._damageBounds.left) {
246 + this._damageBounds.left = x;
247 + }
248 + if (y < this._damageBounds.top) {
249 + this._damageBounds.top = y;
250 + }
251 + if (x + w > this._damageBounds.right) {
252 + this._damageBounds.right = x + w;
253 + }
254 + if (y + h > this._damageBounds.bottom) {
255 + this._damageBounds.bottom = y + h;
256 + }
257 + }
258 +
259 + // Update the visible canvas with the contents of the
260 + // rendering canvas
261 + }, {
262 + key: "flip",
263 + value: function flip(fromQueue) {
264 + if (this._renderQ.length !== 0 && !fromQueue) {
265 + this._renderQPush({
266 + 'type': 'flip'
267 + });
268 + } else {
269 + var x = this._damageBounds.left;
270 + var y = this._damageBounds.top;
271 + var w = this._damageBounds.right - x;
272 + var h = this._damageBounds.bottom - y;
273 + var vx = x - this._viewportLoc.x;
274 + var vy = y - this._viewportLoc.y;
275 + if (vx < 0) {
276 + w += vx;
277 + x -= vx;
278 + vx = 0;
279 + }
280 + if (vy < 0) {
281 + h += vy;
282 + y -= vy;
283 + vy = 0;
284 + }
285 + if (vx + w > this._viewportLoc.w) {
286 + w = this._viewportLoc.w - vx;
287 + }
288 + if (vy + h > this._viewportLoc.h) {
289 + h = this._viewportLoc.h - vy;
290 + }
291 + if (w > 0 && h > 0) {
292 + // FIXME: We may need to disable image smoothing here
293 + // as well (see copyImage()), but we haven't
294 + // noticed any problem yet.
295 + this._targetCtx.drawImage(this._backbuffer, x, y, w, h, vx, vy, w, h);
296 + }
297 + this._damageBounds.left = this._damageBounds.top = 65535;
298 + this._damageBounds.right = this._damageBounds.bottom = 0;
299 + }
300 + }
301 + }, {
302 + key: "pending",
303 + value: function pending() {
304 + return this._renderQ.length > 0;
305 + }
306 + }, {
307 + key: "flush",
308 + value: function flush() {
309 + var _this = this;
310 + if (this._renderQ.length === 0) {
311 + return Promise.resolve();
312 + } else {
313 + if (this._flushPromise === null) {
314 + this._flushPromise = new Promise(function (resolve) {
315 + _this._flushResolve = resolve;
316 + });
317 + }
318 + return this._flushPromise;
319 + }
320 + }
321 + }, {
322 + key: "fillRect",
323 + value: function fillRect(x, y, width, height, color, fromQueue) {
324 + if (this._renderQ.length !== 0 && !fromQueue) {
325 + this._renderQPush({
326 + 'type': 'fill',
327 + 'x': x,
328 + 'y': y,
329 + 'width': width,
330 + 'height': height,
331 + 'color': color
332 + });
333 + } else {
334 + this._setFillColor(color);
335 + this._drawCtx.fillRect(x, y, width, height);
336 + this._damage(x, y, width, height);
337 + }
338 + }
339 + }, {
340 + key: "copyImage",
341 + value: function copyImage(oldX, oldY, newX, newY, w, h, fromQueue) {
342 + if (this._renderQ.length !== 0 && !fromQueue) {
343 + this._renderQPush({
344 + 'type': 'copy',
345 + 'oldX': oldX,
346 + 'oldY': oldY,
347 + 'x': newX,
348 + 'y': newY,
349 + 'width': w,
350 + 'height': h
351 + });
352 + } else {
353 + // Due to this bug among others [1] we need to disable the image-smoothing to
354 + // avoid getting a blur effect when copying data.
355 + //
356 + // 1. https://bugzilla.mozilla.org/show_bug.cgi?id=1194719
357 + //
358 + // We need to set these every time since all properties are reset
359 + // when the the size is changed
360 + this._drawCtx.mozImageSmoothingEnabled = false;
361 + this._drawCtx.webkitImageSmoothingEnabled = false;
362 + this._drawCtx.msImageSmoothingEnabled = false;
363 + this._drawCtx.imageSmoothingEnabled = false;
364 + this._drawCtx.drawImage(this._backbuffer, oldX, oldY, w, h, newX, newY, w, h);
365 + this._damage(newX, newY, w, h);
366 + }
367 + }
368 + }, {
369 + key: "imageRect",
370 + value: function imageRect(x, y, width, height, mime, arr) {
371 + /* The internal logic cannot handle empty images, so bail early */
372 + if (width === 0 || height === 0) {
373 + return;
374 + }
375 + var img = new Image();
376 + img.src = "data: " + mime + ";base64," + _base["default"].encode(arr);
377 + this._renderQPush({
378 + 'type': 'img',
379 + 'img': img,
380 + 'x': x,
381 + 'y': y,
382 + 'width': width,
383 + 'height': height
384 + });
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 + }
398 + }, {
399 + key: "blitImage",
400 + value: function blitImage(x, y, width, height, arr, offset, fromQueue) {
401 + if (this._renderQ.length !== 0 && !fromQueue) {
402 + // NB(directxman12): it's technically more performant here to use preallocated arrays,
403 + // but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
404 + // this probably isn't getting called *nearly* as much
405 + var newArr = new Uint8Array(width * height * 4);
406 + newArr.set(new Uint8Array(arr.buffer, 0, newArr.length));
407 + this._renderQPush({
408 + 'type': 'blit',
409 + 'data': newArr,
410 + 'x': x,
411 + 'y': y,
412 + 'width': width,
413 + 'height': height
414 + });
415 + } else {
416 + // NB(directxman12): arr must be an Type Array view
417 + var data = new Uint8ClampedArray(arr.buffer, arr.byteOffset + offset, width * height * 4);
418 + var img = new ImageData(data, width, height);
419 + this._drawCtx.putImageData(img, x, y);
420 + this._damage(x, y, width, height);
421 + }
422 + }
423 + }, {
424 + key: "drawImage",
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 + }
442 + }
443 + }, {
444 + key: "autoscale",
445 + value: function autoscale(containerWidth, containerHeight) {
446 + var scaleRatio;
447 + if (containerWidth === 0 || containerHeight === 0) {
448 + scaleRatio = 0;
449 + } else {
450 + var vp = this._viewportLoc;
451 + var targetAspectRatio = containerWidth / containerHeight;
452 + var fbAspectRatio = vp.w / vp.h;
453 + if (fbAspectRatio >= targetAspectRatio) {
454 + scaleRatio = containerWidth / vp.w;
455 + } else {
456 + scaleRatio = containerHeight / vp.h;
457 + }
458 + }
459 + this._rescale(scaleRatio);
460 + }
461 +
462 + // ===== PRIVATE METHODS =====
463 + }, {
464 + key: "_rescale",
465 + value: function _rescale(factor) {
466 + this._scale = factor;
467 + var vp = this._viewportLoc;
468 +
469 + // NB(directxman12): If you set the width directly, or set the
470 + // style width to a number, the canvas is cleared.
471 + // However, if you set the style width to a string
472 + // ('NNNpx'), the canvas is scaled without clearing.
473 + var width = factor * vp.w + 'px';
474 + var height = factor * vp.h + 'px';
475 + if (this._target.style.width !== width || this._target.style.height !== height) {
476 + this._target.style.width = width;
477 + this._target.style.height = height;
478 + }
479 + }
480 + }, {
481 + key: "_setFillColor",
482 + value: function _setFillColor(color) {
483 + var newStyle = 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')';
484 + if (newStyle !== this._prevDrawStyle) {
485 + this._drawCtx.fillStyle = newStyle;
486 + this._prevDrawStyle = newStyle;
487 + }
488 + }
489 + }, {
490 + key: "_renderQPush",
491 + value: function _renderQPush(action) {
492 + this._renderQ.push(action);
493 + if (this._renderQ.length === 1) {
494 + // If this can be rendered immediately it will be, otherwise
495 + // the scanner will wait for the relevant event
496 + this._scanRenderQ();
497 + }
498 + }
499 + }, {
500 + key: "_resumeRenderQ",
501 + value: function _resumeRenderQ() {
502 + // "this" is the object that is ready, not the
503 + // display object
504 + this.removeEventListener('load', this._noVNCDisplay._resumeRenderQ);
505 + this._noVNCDisplay._scanRenderQ();
506 + }
507 + }, {
508 + key: "_scanRenderQ",
509 + value: function _scanRenderQ() {
510 + var _this2 = this;
511 + var ready = true;
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;
542 + }
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;
580 + }
581 + if (this._renderQ.length === 0 && this._flushPromise !== null) {
582 + this._flushResolve();
583 + this._flushPromise = null;
584 + this._flushResolve = null;
585 + }
586 + }
587 + }]);
588 +}();
\ No newline at end of file
added public/vendor/novnc/encodings.js +70 −0
@@ -0,0 +1,70 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.encodingName = encodingName;
7 +exports.encodings = void 0;
8 +/*
9 + * noVNC: HTML5 VNC client
10 + * Copyright (C) 2019 The noVNC authors
11 + * Licensed under MPL 2.0 (see LICENSE.txt)
12 + *
13 + * See README.md for usage and integration instructions.
14 + */
15 +
16 +var encodings = exports.encodings = {
17 + encodingRaw: 0,
18 + encodingCopyRect: 1,
19 + encodingRRE: 2,
20 + encodingHextile: 5,
21 + encodingZlib: 6,
22 + encodingTight: 7,
23 + encodingZRLE: 16,
24 + encodingTightPNG: -260,
25 + encodingJPEG: 21,
26 + encodingH264: 50,
27 + pseudoEncodingQualityLevel9: -23,
28 + pseudoEncodingQualityLevel0: -32,
29 + pseudoEncodingDesktopSize: -223,
30 + pseudoEncodingLastRect: -224,
31 + pseudoEncodingCursor: -239,
32 + pseudoEncodingQEMUExtendedKeyEvent: -258,
33 + pseudoEncodingQEMULedEvent: -261,
34 + pseudoEncodingDesktopName: -307,
35 + pseudoEncodingExtendedDesktopSize: -308,
36 + pseudoEncodingXvp: -309,
37 + pseudoEncodingFence: -312,
38 + pseudoEncodingContinuousUpdates: -313,
39 + pseudoEncodingExtendedMouseButtons: -316,
40 + pseudoEncodingCompressLevel9: -247,
41 + pseudoEncodingCompressLevel0: -256,
42 + pseudoEncodingVMwareCursor: 0x574d5664,
43 + pseudoEncodingExtendedClipboard: 0xc0a1e5ce
44 +};
45 +function encodingName(num) {
46 + switch (num) {
47 + case encodings.encodingRaw:
48 + return "Raw";
49 + case encodings.encodingCopyRect:
50 + return "CopyRect";
51 + case encodings.encodingRRE:
52 + return "RRE";
53 + case encodings.encodingHextile:
54 + return "Hextile";
55 + case encodings.encodingZlib:
56 + return "Zlib";
57 + case encodings.encodingTight:
58 + return "Tight";
59 + case encodings.encodingZRLE:
60 + return "ZRLE";
61 + case encodings.encodingTightPNG:
62 + return "TightPNG";
63 + case encodings.encodingJPEG:
64 + return "JPEG";
65 + case encodings.encodingH264:
66 + return "H.264";
67 + default:
68 + return "[unknown encoding " + num + "]";
69 + }
70 +}
\ No newline at end of file
added public/vendor/novnc/inflator.js +77 −0
@@ -0,0 +1,77 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _inflate2 = require("../lib/vendor/pako/lib/zlib/inflate.js");
8 +var _zstream = _interopRequireDefault(require("../lib/vendor/pako/lib/zlib/zstream.js"));
9 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12 +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); } }
13 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 + * noVNC: HTML5 VNC client
17 + * Copyright (C) 2020 The noVNC authors
18 + * Licensed under MPL 2.0 (see LICENSE.txt)
19 + *
20 + * See README.md for usage and integration instructions.
21 + */
22 +var Inflate = exports["default"] = /*#__PURE__*/function () {
23 + function Inflate() {
24 + _classCallCheck(this, Inflate);
25 + this.strm = new _zstream["default"]();
26 + this.chunkSize = 1024 * 10 * 10;
27 + this.strm.output = new Uint8Array(this.chunkSize);
28 + (0, _inflate2.inflateInit)(this.strm);
29 + }
30 + return _createClass(Inflate, [{
31 + key: "setInput",
32 + value: function setInput(data) {
33 + if (!data) {
34 + //FIXME: flush remaining data.
35 + /* eslint-disable camelcase */
36 + this.strm.input = null;
37 + this.strm.avail_in = 0;
38 + this.strm.next_in = 0;
39 + } else {
40 + this.strm.input = data;
41 + this.strm.avail_in = this.strm.input.length;
42 + this.strm.next_in = 0;
43 + /* eslint-enable camelcase */
44 + }
45 + }
46 + }, {
47 + key: "inflate",
48 + value: function inflate(expected) {
49 + // resize our output buffer if it's too small
50 + // (we could just use multiple chunks, but that would cause an extra
51 + // allocation each time to flatten the chunks)
52 + if (expected > this.chunkSize) {
53 + this.chunkSize = expected;
54 + this.strm.output = new Uint8Array(this.chunkSize);
55 + }
56 +
57 + /* eslint-disable camelcase */
58 + this.strm.next_out = 0;
59 + this.strm.avail_out = expected;
60 + /* eslint-enable camelcase */
61 +
62 + var ret = (0, _inflate2.inflate)(this.strm, 0); // Flush argument not used.
63 + if (ret < 0) {
64 + throw new Error("zlib inflate failed");
65 + }
66 + if (this.strm.next_out != expected) {
67 + throw new Error("Incomplete zlib block");
68 + }
69 + return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
70 + }
71 + }, {
72 + key: "reset",
73 + value: function reset() {
74 + (0, _inflate2.inflateReset)(this.strm);
75 + }
76 + }]);
77 +}();
\ No newline at end of file
added public/vendor/novnc/input/domkeytable.js +313 −0
@@ -0,0 +1,313 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _keysym = _interopRequireDefault(require("./keysym.js"));
8 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9 +/*
10 + * noVNC: HTML5 VNC client
11 + * Copyright (C) 2018 The noVNC authors
12 + * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
13 + */
14 +
15 +/*
16 + * Mapping between HTML key values and VNC/X11 keysyms for "special"
17 + * keys that cannot be handled via their Unicode codepoint.
18 + *
19 + * See https://www.w3.org/TR/uievents-key/ for possible values.
20 + */
21 +
22 +var DOMKeyTable = {};
23 +function addStandard(key, standard) {
24 + if (standard === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
25 + if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
26 + DOMKeyTable[key] = [standard, standard, standard, standard];
27 +}
28 +function addLeftRight(key, left, right) {
29 + if (left === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
30 + if (right === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
31 + if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
32 + DOMKeyTable[key] = [left, left, right, left];
33 +}
34 +function addNumpad(key, standard, numpad) {
35 + if (standard === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
36 + if (numpad === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
37 + if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
38 + DOMKeyTable[key] = [standard, standard, standard, numpad];
39 +}
40 +
41 +// 3.2. Modifier Keys
42 +
43 +addLeftRight("Alt", _keysym["default"].XK_Alt_L, _keysym["default"].XK_Alt_R);
44 +addStandard("AltGraph", _keysym["default"].XK_ISO_Level3_Shift);
45 +addStandard("CapsLock", _keysym["default"].XK_Caps_Lock);
46 +addLeftRight("Control", _keysym["default"].XK_Control_L, _keysym["default"].XK_Control_R);
47 +// - Fn
48 +// - FnLock
49 +addLeftRight("Meta", _keysym["default"].XK_Super_L, _keysym["default"].XK_Super_R);
50 +addStandard("NumLock", _keysym["default"].XK_Num_Lock);
51 +addStandard("ScrollLock", _keysym["default"].XK_Scroll_Lock);
52 +addLeftRight("Shift", _keysym["default"].XK_Shift_L, _keysym["default"].XK_Shift_R);
53 +// - Symbol
54 +// - SymbolLock
55 +// - Hyper
56 +// - Super
57 +
58 +// 3.3. Whitespace Keys
59 +
60 +addNumpad("Enter", _keysym["default"].XK_Return, _keysym["default"].XK_KP_Enter);
61 +addStandard("Tab", _keysym["default"].XK_Tab);
62 +addNumpad(" ", _keysym["default"].XK_space, _keysym["default"].XK_KP_Space);
63 +
64 +// 3.4. Navigation Keys
65 +
66 +addNumpad("ArrowDown", _keysym["default"].XK_Down, _keysym["default"].XK_KP_Down);
67 +addNumpad("ArrowLeft", _keysym["default"].XK_Left, _keysym["default"].XK_KP_Left);
68 +addNumpad("ArrowRight", _keysym["default"].XK_Right, _keysym["default"].XK_KP_Right);
69 +addNumpad("ArrowUp", _keysym["default"].XK_Up, _keysym["default"].XK_KP_Up);
70 +addNumpad("End", _keysym["default"].XK_End, _keysym["default"].XK_KP_End);
71 +addNumpad("Home", _keysym["default"].XK_Home, _keysym["default"].XK_KP_Home);
72 +addNumpad("PageDown", _keysym["default"].XK_Next, _keysym["default"].XK_KP_Next);
73 +addNumpad("PageUp", _keysym["default"].XK_Prior, _keysym["default"].XK_KP_Prior);
74 +
75 +// 3.5. Editing Keys
76 +
77 +addStandard("Backspace", _keysym["default"].XK_BackSpace);
78 +// Browsers send "Clear" for the numpad 5 without NumLock because
79 +// Windows uses VK_Clear for that key. But Unix expects KP_Begin for
80 +// that scenario.
81 +addNumpad("Clear", _keysym["default"].XK_Clear, _keysym["default"].XK_KP_Begin);
82 +addStandard("Copy", _keysym["default"].XF86XK_Copy);
83 +// - CrSel
84 +addStandard("Cut", _keysym["default"].XF86XK_Cut);
85 +addNumpad("Delete", _keysym["default"].XK_Delete, _keysym["default"].XK_KP_Delete);
86 +// - EraseEof
87 +// - ExSel
88 +addNumpad("Insert", _keysym["default"].XK_Insert, _keysym["default"].XK_KP_Insert);
89 +addStandard("Paste", _keysym["default"].XF86XK_Paste);
90 +addStandard("Redo", _keysym["default"].XK_Redo);
91 +addStandard("Undo", _keysym["default"].XK_Undo);
92 +
93 +// 3.6. UI Keys
94 +
95 +// - Accept
96 +// - Again (could just be XK_Redo)
97 +// - Attn
98 +addStandard("Cancel", _keysym["default"].XK_Cancel);
99 +addStandard("ContextMenu", _keysym["default"].XK_Menu);
100 +addStandard("Escape", _keysym["default"].XK_Escape);
101 +addStandard("Execute", _keysym["default"].XK_Execute);
102 +addStandard("Find", _keysym["default"].XK_Find);
103 +addStandard("Help", _keysym["default"].XK_Help);
104 +addStandard("Pause", _keysym["default"].XK_Pause);
105 +// - Play
106 +// - Props
107 +addStandard("Select", _keysym["default"].XK_Select);
108 +addStandard("ZoomIn", _keysym["default"].XF86XK_ZoomIn);
109 +addStandard("ZoomOut", _keysym["default"].XF86XK_ZoomOut);
110 +
111 +// 3.7. Device Keys
112 +
113 +addStandard("BrightnessDown", _keysym["default"].XF86XK_MonBrightnessDown);
114 +addStandard("BrightnessUp", _keysym["default"].XF86XK_MonBrightnessUp);
115 +addStandard("Eject", _keysym["default"].XF86XK_Eject);
116 +addStandard("LogOff", _keysym["default"].XF86XK_LogOff);
117 +addStandard("Power", _keysym["default"].XF86XK_PowerOff);
118 +addStandard("PowerOff", _keysym["default"].XF86XK_PowerDown);
119 +addStandard("PrintScreen", _keysym["default"].XK_Print);
120 +addStandard("Hibernate", _keysym["default"].XF86XK_Hibernate);
121 +addStandard("Standby", _keysym["default"].XF86XK_Standby);
122 +addStandard("WakeUp", _keysym["default"].XF86XK_WakeUp);
123 +
124 +// 3.8. IME and Composition Keys
125 +
126 +addStandard("AllCandidates", _keysym["default"].XK_MultipleCandidate);
127 +addStandard("Alphanumeric", _keysym["default"].XK_Eisu_toggle);
128 +addStandard("CodeInput", _keysym["default"].XK_Codeinput);
129 +addStandard("Compose", _keysym["default"].XK_Multi_key);
130 +addStandard("Convert", _keysym["default"].XK_Henkan);
131 +// - Dead
132 +// - FinalMode
133 +addStandard("GroupFirst", _keysym["default"].XK_ISO_First_Group);
134 +addStandard("GroupLast", _keysym["default"].XK_ISO_Last_Group);
135 +addStandard("GroupNext", _keysym["default"].XK_ISO_Next_Group);
136 +addStandard("GroupPrevious", _keysym["default"].XK_ISO_Prev_Group);
137 +// - ModeChange (XK_Mode_switch is often used for AltGr)
138 +// - NextCandidate
139 +addStandard("NonConvert", _keysym["default"].XK_Muhenkan);
140 +addStandard("PreviousCandidate", _keysym["default"].XK_PreviousCandidate);
141 +// - Process
142 +addStandard("SingleCandidate", _keysym["default"].XK_SingleCandidate);
143 +addStandard("HangulMode", _keysym["default"].XK_Hangul);
144 +addStandard("HanjaMode", _keysym["default"].XK_Hangul_Hanja);
145 +addStandard("JunjaMode", _keysym["default"].XK_Hangul_Jeonja);
146 +addStandard("Eisu", _keysym["default"].XK_Eisu_toggle);
147 +addStandard("Hankaku", _keysym["default"].XK_Hankaku);
148 +addStandard("Hiragana", _keysym["default"].XK_Hiragana);
149 +addStandard("HiraganaKatakana", _keysym["default"].XK_Hiragana_Katakana);
150 +addStandard("KanaMode", _keysym["default"].XK_Kana_Shift); // could also be _Kana_Lock
151 +addStandard("KanjiMode", _keysym["default"].XK_Kanji);
152 +addStandard("Katakana", _keysym["default"].XK_Katakana);
153 +addStandard("Romaji", _keysym["default"].XK_Romaji);
154 +addStandard("Zenkaku", _keysym["default"].XK_Zenkaku);
155 +addStandard("ZenkakuHankaku", _keysym["default"].XK_Zenkaku_Hankaku);
156 +
157 +// 3.9. General-Purpose Function Keys
158 +
159 +addStandard("F1", _keysym["default"].XK_F1);
160 +addStandard("F2", _keysym["default"].XK_F2);
161 +addStandard("F3", _keysym["default"].XK_F3);
162 +addStandard("F4", _keysym["default"].XK_F4);
163 +addStandard("F5", _keysym["default"].XK_F5);
164 +addStandard("F6", _keysym["default"].XK_F6);
165 +addStandard("F7", _keysym["default"].XK_F7);
166 +addStandard("F8", _keysym["default"].XK_F8);
167 +addStandard("F9", _keysym["default"].XK_F9);
168 +addStandard("F10", _keysym["default"].XK_F10);
169 +addStandard("F11", _keysym["default"].XK_F11);
170 +addStandard("F12", _keysym["default"].XK_F12);
171 +addStandard("F13", _keysym["default"].XK_F13);
172 +addStandard("F14", _keysym["default"].XK_F14);
173 +addStandard("F15", _keysym["default"].XK_F15);
174 +addStandard("F16", _keysym["default"].XK_F16);
175 +addStandard("F17", _keysym["default"].XK_F17);
176 +addStandard("F18", _keysym["default"].XK_F18);
177 +addStandard("F19", _keysym["default"].XK_F19);
178 +addStandard("F20", _keysym["default"].XK_F20);
179 +addStandard("F21", _keysym["default"].XK_F21);
180 +addStandard("F22", _keysym["default"].XK_F22);
181 +addStandard("F23", _keysym["default"].XK_F23);
182 +addStandard("F24", _keysym["default"].XK_F24);
183 +addStandard("F25", _keysym["default"].XK_F25);
184 +addStandard("F26", _keysym["default"].XK_F26);
185 +addStandard("F27", _keysym["default"].XK_F27);
186 +addStandard("F28", _keysym["default"].XK_F28);
187 +addStandard("F29", _keysym["default"].XK_F29);
188 +addStandard("F30", _keysym["default"].XK_F30);
189 +addStandard("F31", _keysym["default"].XK_F31);
190 +addStandard("F32", _keysym["default"].XK_F32);
191 +addStandard("F33", _keysym["default"].XK_F33);
192 +addStandard("F34", _keysym["default"].XK_F34);
193 +addStandard("F35", _keysym["default"].XK_F35);
194 +// - Soft1...
195 +
196 +// 3.10. Multimedia Keys
197 +
198 +// - ChannelDown
199 +// - ChannelUp
200 +addStandard("Close", _keysym["default"].XF86XK_Close);
201 +addStandard("MailForward", _keysym["default"].XF86XK_MailForward);
202 +addStandard("MailReply", _keysym["default"].XF86XK_Reply);
203 +addStandard("MailSend", _keysym["default"].XF86XK_Send);
204 +// - MediaClose
205 +addStandard("MediaFastForward", _keysym["default"].XF86XK_AudioForward);
206 +addStandard("MediaPause", _keysym["default"].XF86XK_AudioPause);
207 +addStandard("MediaPlay", _keysym["default"].XF86XK_AudioPlay);
208 +// - MediaPlayPause
209 +addStandard("MediaRecord", _keysym["default"].XF86XK_AudioRecord);
210 +addStandard("MediaRewind", _keysym["default"].XF86XK_AudioRewind);
211 +addStandard("MediaStop", _keysym["default"].XF86XK_AudioStop);
212 +addStandard("MediaTrackNext", _keysym["default"].XF86XK_AudioNext);
213 +addStandard("MediaTrackPrevious", _keysym["default"].XF86XK_AudioPrev);
214 +addStandard("New", _keysym["default"].XF86XK_New);
215 +addStandard("Open", _keysym["default"].XF86XK_Open);
216 +addStandard("Print", _keysym["default"].XK_Print);
217 +addStandard("Save", _keysym["default"].XF86XK_Save);
218 +addStandard("SpellCheck", _keysym["default"].XF86XK_Spell);
219 +
220 +// 3.11. Multimedia Numpad Keys
221 +
222 +// - Key11
223 +// - Key12
224 +
225 +// 3.12. Audio Keys
226 +
227 +// - AudioBalanceLeft
228 +// - AudioBalanceRight
229 +// - AudioBassBoostDown
230 +// - AudioBassBoostToggle
231 +// - AudioBassBoostUp
232 +// - AudioFaderFront
233 +// - AudioFaderRear
234 +// - AudioSurroundModeNext
235 +// - AudioTrebleDown
236 +// - AudioTrebleUp
237 +addStandard("AudioVolumeDown", _keysym["default"].XF86XK_AudioLowerVolume);
238 +addStandard("AudioVolumeUp", _keysym["default"].XF86XK_AudioRaiseVolume);
239 +addStandard("AudioVolumeMute", _keysym["default"].XF86XK_AudioMute);
240 +// - MicrophoneToggle
241 +// - MicrophoneVolumeDown
242 +// - MicrophoneVolumeUp
243 +addStandard("MicrophoneVolumeMute", _keysym["default"].XF86XK_AudioMicMute);
244 +
245 +// 3.13. Speech Keys
246 +
247 +// - SpeechCorrectionList
248 +// - SpeechInputToggle
249 +
250 +// 3.14. Application Keys
251 +
252 +addStandard("LaunchApplication1", _keysym["default"].XF86XK_MyComputer);
253 +addStandard("LaunchApplication2", _keysym["default"].XF86XK_Calculator);
254 +addStandard("LaunchCalendar", _keysym["default"].XF86XK_Calendar);
255 +// - LaunchContacts
256 +addStandard("LaunchMail", _keysym["default"].XF86XK_Mail);
257 +addStandard("LaunchMediaPlayer", _keysym["default"].XF86XK_AudioMedia);
258 +addStandard("LaunchMusicPlayer", _keysym["default"].XF86XK_Music);
259 +addStandard("LaunchPhone", _keysym["default"].XF86XK_Phone);
260 +addStandard("LaunchScreenSaver", _keysym["default"].XF86XK_ScreenSaver);
261 +addStandard("LaunchSpreadsheet", _keysym["default"].XF86XK_Excel);
262 +addStandard("LaunchWebBrowser", _keysym["default"].XF86XK_WWW);
263 +addStandard("LaunchWebCam", _keysym["default"].XF86XK_WebCam);
264 +addStandard("LaunchWordProcessor", _keysym["default"].XF86XK_Word);
265 +
266 +// 3.15. Browser Keys
267 +
268 +addStandard("BrowserBack", _keysym["default"].XF86XK_Back);
269 +addStandard("BrowserFavorites", _keysym["default"].XF86XK_Favorites);
270 +addStandard("BrowserForward", _keysym["default"].XF86XK_Forward);
271 +addStandard("BrowserHome", _keysym["default"].XF86XK_HomePage);
272 +addStandard("BrowserRefresh", _keysym["default"].XF86XK_Refresh);
273 +addStandard("BrowserSearch", _keysym["default"].XF86XK_Search);
274 +addStandard("BrowserStop", _keysym["default"].XF86XK_Stop);
275 +
276 +// 3.16. Mobile Phone Keys
277 +
278 +// - A whole bunch...
279 +
280 +// 3.17. TV Keys
281 +
282 +// - A whole bunch...
283 +
284 +// 3.18. Media Controller Keys
285 +
286 +// - A whole bunch...
287 +addStandard("Dimmer", _keysym["default"].XF86XK_BrightnessAdjust);
288 +addStandard("MediaAudioTrack", _keysym["default"].XF86XK_AudioCycleTrack);
289 +addStandard("RandomToggle", _keysym["default"].XF86XK_AudioRandomPlay);
290 +addStandard("SplitScreenToggle", _keysym["default"].XF86XK_SplitScreen);
291 +addStandard("Subtitle", _keysym["default"].XF86XK_Subtitle);
292 +addStandard("VideoModeNext", _keysym["default"].XF86XK_Next_VMode);
293 +
294 +// Extra: Numpad
295 +
296 +addNumpad("=", _keysym["default"].XK_equal, _keysym["default"].XK_KP_Equal);
297 +addNumpad("+", _keysym["default"].XK_plus, _keysym["default"].XK_KP_Add);
298 +addNumpad("-", _keysym["default"].XK_minus, _keysym["default"].XK_KP_Subtract);
299 +addNumpad("*", _keysym["default"].XK_asterisk, _keysym["default"].XK_KP_Multiply);
300 +addNumpad("/", _keysym["default"].XK_slash, _keysym["default"].XK_KP_Divide);
301 +addNumpad(".", _keysym["default"].XK_period, _keysym["default"].XK_KP_Decimal);
302 +addNumpad(",", _keysym["default"].XK_comma, _keysym["default"].XK_KP_Separator);
303 +addNumpad("0", _keysym["default"].XK_0, _keysym["default"].XK_KP_0);
304 +addNumpad("1", _keysym["default"].XK_1, _keysym["default"].XK_KP_1);
305 +addNumpad("2", _keysym["default"].XK_2, _keysym["default"].XK_KP_2);
306 +addNumpad("3", _keysym["default"].XK_3, _keysym["default"].XK_KP_3);
307 +addNumpad("4", _keysym["default"].XK_4, _keysym["default"].XK_KP_4);
308 +addNumpad("5", _keysym["default"].XK_5, _keysym["default"].XK_KP_5);
309 +addNumpad("6", _keysym["default"].XK_6, _keysym["default"].XK_KP_6);
310 +addNumpad("7", _keysym["default"].XK_7, _keysym["default"].XK_KP_7);
311 +addNumpad("8", _keysym["default"].XK_8, _keysym["default"].XK_KP_8);
312 +addNumpad("9", _keysym["default"].XK_9, _keysym["default"].XK_KP_9);
313 +var _default = exports["default"] = DOMKeyTable;
\ No newline at end of file
added public/vendor/novnc/input/fixedkeys.js +127 −0
@@ -0,0 +1,127 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +/*
8 + * noVNC: HTML5 VNC client
9 + * Copyright (C) 2018 The noVNC authors
10 + * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
11 + */
12 +/*
13 + * Fallback mapping between HTML key codes (physical keys) and
14 + * HTML key values. This only works for keys that don't vary
15 + * between layouts. We also omit those who manage fine by mapping the
16 + * Unicode representation.
17 + *
18 + * See https://www.w3.org/TR/uievents-code/ for possible codes.
19 + * See https://www.w3.org/TR/uievents-key/ for possible values.
20 + */
21 +/* eslint-disable key-spacing */
22 +var _default = exports["default"] = {
23 + // 3.1.1.1. Writing System Keys
24 +
25 + 'Backspace': 'Backspace',
26 + // 3.1.1.2. Functional Keys
27 +
28 + 'AltLeft': 'Alt',
29 + 'AltRight': 'Alt',
30 + // This could also be 'AltGraph'
31 + 'CapsLock': 'CapsLock',
32 + 'ContextMenu': 'ContextMenu',
33 + 'ControlLeft': 'Control',
34 + 'ControlRight': 'Control',
35 + 'Enter': 'Enter',
36 + 'MetaLeft': 'Meta',
37 + 'MetaRight': 'Meta',
38 + 'ShiftLeft': 'Shift',
39 + 'ShiftRight': 'Shift',
40 + 'Tab': 'Tab',
41 + // FIXME: Japanese/Korean keys
42 +
43 + // 3.1.2. Control Pad Section
44 +
45 + 'Delete': 'Delete',
46 + 'End': 'End',
47 + 'Help': 'Help',
48 + 'Home': 'Home',
49 + 'Insert': 'Insert',
50 + 'PageDown': 'PageDown',
51 + 'PageUp': 'PageUp',
52 + // 3.1.3. Arrow Pad Section
53 +
54 + 'ArrowDown': 'ArrowDown',
55 + 'ArrowLeft': 'ArrowLeft',
56 + 'ArrowRight': 'ArrowRight',
57 + 'ArrowUp': 'ArrowUp',
58 + // 3.1.4. Numpad Section
59 +
60 + 'NumLock': 'NumLock',
61 + 'NumpadBackspace': 'Backspace',
62 + 'NumpadClear': 'Clear',
63 + // 3.1.5. Function Section
64 +
65 + 'Escape': 'Escape',
66 + 'F1': 'F1',
67 + 'F2': 'F2',
68 + 'F3': 'F3',
69 + 'F4': 'F4',
70 + 'F5': 'F5',
71 + 'F6': 'F6',
72 + 'F7': 'F7',
73 + 'F8': 'F8',
74 + 'F9': 'F9',
75 + 'F10': 'F10',
76 + 'F11': 'F11',
77 + 'F12': 'F12',
78 + 'F13': 'F13',
79 + 'F14': 'F14',
80 + 'F15': 'F15',
81 + 'F16': 'F16',
82 + 'F17': 'F17',
83 + 'F18': 'F18',
84 + 'F19': 'F19',
85 + 'F20': 'F20',
86 + 'F21': 'F21',
87 + 'F22': 'F22',
88 + 'F23': 'F23',
89 + 'F24': 'F24',
90 + 'F25': 'F25',
91 + 'F26': 'F26',
92 + 'F27': 'F27',
93 + 'F28': 'F28',
94 + 'F29': 'F29',
95 + 'F30': 'F30',
96 + 'F31': 'F31',
97 + 'F32': 'F32',
98 + 'F33': 'F33',
99 + 'F34': 'F34',
100 + 'F35': 'F35',
101 + 'PrintScreen': 'PrintScreen',
102 + 'ScrollLock': 'ScrollLock',
103 + 'Pause': 'Pause',
104 + // 3.1.6. Media Keys
105 +
106 + 'BrowserBack': 'BrowserBack',
107 + 'BrowserFavorites': 'BrowserFavorites',
108 + 'BrowserForward': 'BrowserForward',
109 + 'BrowserHome': 'BrowserHome',
110 + 'BrowserRefresh': 'BrowserRefresh',
111 + 'BrowserSearch': 'BrowserSearch',
112 + 'BrowserStop': 'BrowserStop',
113 + 'Eject': 'Eject',
114 + 'LaunchApp1': 'LaunchMyComputer',
115 + 'LaunchApp2': 'LaunchCalendar',
116 + 'LaunchMail': 'LaunchMail',
117 + 'MediaPlayPause': 'MediaPlay',
118 + 'MediaStop': 'MediaStop',
119 + 'MediaTrackNext': 'MediaTrackNext',
120 + 'MediaTrackPrevious': 'MediaTrackPrevious',
121 + 'Power': 'Power',
122 + 'Sleep': 'Sleep',
123 + 'AudioVolumeDown': 'AudioVolumeDown',
124 + 'AudioVolumeMute': 'AudioVolumeMute',
125 + 'AudioVolumeUp': 'AudioVolumeUp',
126 + 'WakeUp': 'WakeUp'
127 +};
\ No newline at end of file
added public/vendor/novnc/input/gesturehandler.js +573 −0
@@ -0,0 +1,573 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2020 The noVNC authors
16 + * Licensed under MPL 2.0 (see LICENSE.txt)
17 + *
18 + * See README.md for usage and integration instructions.
19 + *
20 + */
21 +
22 +var GH_NOGESTURE = 0;
23 +var GH_ONETAP = 1;
24 +var GH_TWOTAP = 2;
25 +var GH_THREETAP = 4;
26 +var GH_DRAG = 8;
27 +var GH_LONGPRESS = 16;
28 +var GH_TWODRAG = 32;
29 +var GH_PINCH = 64;
30 +var GH_INITSTATE = 127;
31 +var GH_MOVE_THRESHOLD = 50;
32 +var GH_ANGLE_THRESHOLD = 90; // Degrees
33 +
34 +// Timeout when waiting for gestures (ms)
35 +var GH_MULTITOUCH_TIMEOUT = 250;
36 +
37 +// Maximum time between press and release for a tap (ms)
38 +var GH_TAP_TIMEOUT = 1000;
39 +
40 +// Timeout when waiting for longpress (ms)
41 +var GH_LONGPRESS_TIMEOUT = 1000;
42 +
43 +// Timeout when waiting to decide between PINCH and TWODRAG (ms)
44 +var GH_TWOTOUCH_TIMEOUT = 50;
45 +var GestureHandler = exports["default"] = /*#__PURE__*/function () {
46 + function GestureHandler() {
47 + _classCallCheck(this, GestureHandler);
48 + this._target = null;
49 + this._state = GH_INITSTATE;
50 + this._tracked = [];
51 + this._ignored = [];
52 + this._waitingRelease = false;
53 + this._releaseStart = 0.0;
54 + this._longpressTimeoutId = null;
55 + this._twoTouchTimeoutId = null;
56 + this._boundEventHandler = this._eventHandler.bind(this);
57 + }
58 + return _createClass(GestureHandler, [{
59 + key: "attach",
60 + value: function attach(target) {
61 + this.detach();
62 + this._target = target;
63 + this._target.addEventListener('touchstart', this._boundEventHandler);
64 + this._target.addEventListener('touchmove', this._boundEventHandler);
65 + this._target.addEventListener('touchend', this._boundEventHandler);
66 + this._target.addEventListener('touchcancel', this._boundEventHandler);
67 + }
68 + }, {
69 + key: "detach",
70 + value: function detach() {
71 + if (!this._target) {
72 + return;
73 + }
74 + this._stopLongpressTimeout();
75 + this._stopTwoTouchTimeout();
76 + this._target.removeEventListener('touchstart', this._boundEventHandler);
77 + this._target.removeEventListener('touchmove', this._boundEventHandler);
78 + this._target.removeEventListener('touchend', this._boundEventHandler);
79 + this._target.removeEventListener('touchcancel', this._boundEventHandler);
80 + this._target = null;
81 + }
82 + }, {
83 + key: "_eventHandler",
84 + value: function _eventHandler(e) {
85 + var fn;
86 + e.stopPropagation();
87 + e.preventDefault();
88 + switch (e.type) {
89 + case 'touchstart':
90 + fn = this._touchStart;
91 + break;
92 + case 'touchmove':
93 + fn = this._touchMove;
94 + break;
95 + case 'touchend':
96 + case 'touchcancel':
97 + fn = this._touchEnd;
98 + break;
99 + }
100 + for (var i = 0; i < e.changedTouches.length; i++) {
101 + var touch = e.changedTouches[i];
102 + fn.call(this, touch.identifier, touch.clientX, touch.clientY);
103 + }
104 + }
105 + }, {
106 + key: "_touchStart",
107 + value: function _touchStart(id, x, y) {
108 + // Ignore any new touches if there is already an active gesture,
109 + // or we're in a cleanup state
110 + if (this._hasDetectedGesture() || this._state === GH_NOGESTURE) {
111 + this._ignored.push(id);
112 + return;
113 + }
114 +
115 + // Did it take too long between touches that we should no longer
116 + // consider this a single gesture?
117 + if (this._tracked.length > 0 && Date.now() - this._tracked[0].started > GH_MULTITOUCH_TIMEOUT) {
118 + this._state = GH_NOGESTURE;
119 + this._ignored.push(id);
120 + return;
121 + }
122 +
123 + // If we're waiting for fingers to release then we should no longer
124 + // recognize new touches
125 + if (this._waitingRelease) {
126 + this._state = GH_NOGESTURE;
127 + this._ignored.push(id);
128 + return;
129 + }
130 + this._tracked.push({
131 + id: id,
132 + started: Date.now(),
133 + active: true,
134 + firstX: x,
135 + firstY: y,
136 + lastX: x,
137 + lastY: y,
138 + angle: 0
139 + });
140 + switch (this._tracked.length) {
141 + case 1:
142 + this._startLongpressTimeout();
143 + break;
144 + case 2:
145 + this._state &= ~(GH_ONETAP | GH_DRAG | GH_LONGPRESS);
146 + this._stopLongpressTimeout();
147 + break;
148 + case 3:
149 + this._state &= ~(GH_TWOTAP | GH_TWODRAG | GH_PINCH);
150 + break;
151 + default:
152 + this._state = GH_NOGESTURE;
153 + }
154 + }
155 + }, {
156 + key: "_touchMove",
157 + value: function _touchMove(id, x, y) {
158 + var touch = this._tracked.find(function (t) {
159 + return t.id === id;
160 + });
161 +
162 + // If this is an update for a touch we're not tracking, ignore it
163 + if (touch === undefined) {
164 + return;
165 + }
166 +
167 + // Update the touches last position with the event coordinates
168 + touch.lastX = x;
169 + touch.lastY = y;
170 + var deltaX = x - touch.firstX;
171 + var deltaY = y - touch.firstY;
172 +
173 + // Update angle when the touch has moved
174 + if (touch.firstX !== touch.lastX || touch.firstY !== touch.lastY) {
175 + touch.angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI;
176 + }
177 + if (!this._hasDetectedGesture()) {
178 + // Ignore moves smaller than the minimum threshold
179 + if (Math.hypot(deltaX, deltaY) < GH_MOVE_THRESHOLD) {
180 + return;
181 + }
182 +
183 + // Can't be a tap or long press as we've seen movement
184 + this._state &= ~(GH_ONETAP | GH_TWOTAP | GH_THREETAP | GH_LONGPRESS);
185 + this._stopLongpressTimeout();
186 + if (this._tracked.length !== 1) {
187 + this._state &= ~GH_DRAG;
188 + }
189 + if (this._tracked.length !== 2) {
190 + this._state &= ~(GH_TWODRAG | GH_PINCH);
191 + }
192 +
193 + // We need to figure out which of our different two touch gestures
194 + // this might be
195 + if (this._tracked.length === 2) {
196 + // The other touch is the one where the id doesn't match
197 + var prevTouch = this._tracked.find(function (t) {
198 + return t.id !== id;
199 + });
200 +
201 + // How far the previous touch point has moved since start
202 + var prevDeltaMove = Math.hypot(prevTouch.firstX - prevTouch.lastX, prevTouch.firstY - prevTouch.lastY);
203 +
204 + // We know that the current touch moved far enough,
205 + // but unless both touches moved further than their
206 + // threshold we don't want to disqualify any gestures
207 + if (prevDeltaMove > GH_MOVE_THRESHOLD) {
208 + // The angle difference between the direction of the touch points
209 + var deltaAngle = Math.abs(touch.angle - prevTouch.angle);
210 + deltaAngle = Math.abs((deltaAngle + 180) % 360 - 180);
211 +
212 + // PINCH or TWODRAG can be eliminated depending on the angle
213 + if (deltaAngle > GH_ANGLE_THRESHOLD) {
214 + this._state &= ~GH_TWODRAG;
215 + } else {
216 + this._state &= ~GH_PINCH;
217 + }
218 + if (this._isTwoTouchTimeoutRunning()) {
219 + this._stopTwoTouchTimeout();
220 + }
221 + } else if (!this._isTwoTouchTimeoutRunning()) {
222 + // We can't determine the gesture right now, let's
223 + // wait and see if more events are on their way
224 + this._startTwoTouchTimeout();
225 + }
226 + }
227 + if (!this._hasDetectedGesture()) {
228 + return;
229 + }
230 + this._pushEvent('gesturestart');
231 + }
232 + this._pushEvent('gesturemove');
233 + }
234 + }, {
235 + key: "_touchEnd",
236 + value: function _touchEnd(id, x, y) {
237 + // Check if this is an ignored touch
238 + if (this._ignored.indexOf(id) !== -1) {
239 + // Remove this touch from ignored
240 + this._ignored.splice(this._ignored.indexOf(id), 1);
241 +
242 + // And reset the state if there are no more touches
243 + if (this._ignored.length === 0 && this._tracked.length === 0) {
244 + this._state = GH_INITSTATE;
245 + this._waitingRelease = false;
246 + }
247 + return;
248 + }
249 +
250 + // We got a touchend before the timer triggered,
251 + // this cannot result in a gesture anymore.
252 + if (!this._hasDetectedGesture() && this._isTwoTouchTimeoutRunning()) {
253 + this._stopTwoTouchTimeout();
254 + this._state = GH_NOGESTURE;
255 + }
256 +
257 + // Some gestures don't trigger until a touch is released
258 + if (!this._hasDetectedGesture()) {
259 + // Can't be a gesture that relies on movement
260 + this._state &= ~(GH_DRAG | GH_TWODRAG | GH_PINCH);
261 + // Or something that relies on more time
262 + this._state &= ~GH_LONGPRESS;
263 + this._stopLongpressTimeout();
264 + if (!this._waitingRelease) {
265 + this._releaseStart = Date.now();
266 + this._waitingRelease = true;
267 +
268 + // Can't be a tap that requires more touches than we current have
269 + switch (this._tracked.length) {
270 + case 1:
271 + this._state &= ~(GH_TWOTAP | GH_THREETAP);
272 + break;
273 + case 2:
274 + this._state &= ~(GH_ONETAP | GH_THREETAP);
275 + break;
276 + }
277 + }
278 + }
279 +
280 + // Waiting for all touches to release? (i.e. some tap)
281 + if (this._waitingRelease) {
282 + // Were all touches released at roughly the same time?
283 + if (Date.now() - this._releaseStart > GH_MULTITOUCH_TIMEOUT) {
284 + this._state = GH_NOGESTURE;
285 + }
286 +
287 + // Did too long time pass between press and release?
288 + if (this._tracked.some(function (t) {
289 + return Date.now() - t.started > GH_TAP_TIMEOUT;
290 + })) {
291 + this._state = GH_NOGESTURE;
292 + }
293 + var touch = this._tracked.find(function (t) {
294 + return t.id === id;
295 + });
296 + touch.active = false;
297 +
298 + // Are we still waiting for more releases?
299 + if (this._hasDetectedGesture()) {
300 + this._pushEvent('gesturestart');
301 + } else {
302 + // Have we reached a dead end?
303 + if (this._state !== GH_NOGESTURE) {
304 + return;
305 + }
306 + }
307 + }
308 + if (this._hasDetectedGesture()) {
309 + this._pushEvent('gestureend');
310 + }
311 +
312 + // Ignore any remaining touches until they are ended
313 + for (var i = 0; i < this._tracked.length; i++) {
314 + if (this._tracked[i].active) {
315 + this._ignored.push(this._tracked[i].id);
316 + }
317 + }
318 + this._tracked = [];
319 + this._state = GH_NOGESTURE;
320 +
321 + // Remove this touch from ignored if it's in there
322 + if (this._ignored.indexOf(id) !== -1) {
323 + this._ignored.splice(this._ignored.indexOf(id), 1);
324 + }
325 +
326 + // We reset the state if ignored is empty
327 + if (this._ignored.length === 0) {
328 + this._state = GH_INITSTATE;
329 + this._waitingRelease = false;
330 + }
331 + }
332 + }, {
333 + key: "_hasDetectedGesture",
334 + value: function _hasDetectedGesture() {
335 + if (this._state === GH_NOGESTURE) {
336 + return false;
337 + }
338 + // Check to see if the bitmask value is a power of 2
339 + // (i.e. only one bit set). If it is, we have a state.
340 + if (this._state & this._state - 1) {
341 + return false;
342 + }
343 +
344 + // For taps we also need to have all touches released
345 + // before we've fully detected the gesture
346 + if (this._state & (GH_ONETAP | GH_TWOTAP | GH_THREETAP)) {
347 + if (this._tracked.some(function (t) {
348 + return t.active;
349 + })) {
350 + return false;
351 + }
352 + }
353 + return true;
354 + }
355 + }, {
356 + key: "_startLongpressTimeout",
357 + value: function _startLongpressTimeout() {
358 + var _this = this;
359 + this._stopLongpressTimeout();
360 + this._longpressTimeoutId = setTimeout(function () {
361 + return _this._longpressTimeout();
362 + }, GH_LONGPRESS_TIMEOUT);
363 + }
364 + }, {
365 + key: "_stopLongpressTimeout",
366 + value: function _stopLongpressTimeout() {
367 + clearTimeout(this._longpressTimeoutId);
368 + this._longpressTimeoutId = null;
369 + }
370 + }, {
371 + key: "_longpressTimeout",
372 + value: function _longpressTimeout() {
373 + if (this._hasDetectedGesture()) {
374 + throw new Error("A longpress gesture failed, conflict with a different gesture");
375 + }
376 + this._state = GH_LONGPRESS;
377 + this._pushEvent('gesturestart');
378 + }
379 + }, {
380 + key: "_startTwoTouchTimeout",
381 + value: function _startTwoTouchTimeout() {
382 + var _this2 = this;
383 + this._stopTwoTouchTimeout();
384 + this._twoTouchTimeoutId = setTimeout(function () {
385 + return _this2._twoTouchTimeout();
386 + }, GH_TWOTOUCH_TIMEOUT);
387 + }
388 + }, {
389 + key: "_stopTwoTouchTimeout",
390 + value: function _stopTwoTouchTimeout() {
391 + clearTimeout(this._twoTouchTimeoutId);
392 + this._twoTouchTimeoutId = null;
393 + }
394 + }, {
395 + key: "_isTwoTouchTimeoutRunning",
396 + value: function _isTwoTouchTimeoutRunning() {
397 + return this._twoTouchTimeoutId !== null;
398 + }
399 + }, {
400 + key: "_twoTouchTimeout",
401 + value: function _twoTouchTimeout() {
402 + if (this._tracked.length === 0) {
403 + throw new Error("A pinch or two drag gesture failed, no tracked touches");
404 + }
405 +
406 + // How far each touch point has moved since start
407 + var avgM = this._getAverageMovement();
408 + var avgMoveH = Math.abs(avgM.x);
409 + var avgMoveV = Math.abs(avgM.y);
410 +
411 + // The difference in the distance between where
412 + // the touch points started and where they are now
413 + var avgD = this._getAverageDistance();
414 + var deltaTouchDistance = Math.abs(Math.hypot(avgD.first.x, avgD.first.y) - Math.hypot(avgD.last.x, avgD.last.y));
415 + if (avgMoveV < deltaTouchDistance && avgMoveH < deltaTouchDistance) {
416 + this._state = GH_PINCH;
417 + } else {
418 + this._state = GH_TWODRAG;
419 + }
420 + this._pushEvent('gesturestart');
421 + this._pushEvent('gesturemove');
422 + }
423 + }, {
424 + key: "_pushEvent",
425 + value: function _pushEvent(type) {
426 + var detail = {
427 + type: this._stateToGesture(this._state)
428 + };
429 +
430 + // For most gesture events the current (average) position is the
431 + // most useful
432 + var avg = this._getPosition();
433 + var pos = avg.last;
434 +
435 + // However we have a slight distance to detect gestures, so for the
436 + // first gesture event we want to use the first positions we saw
437 + if (type === 'gesturestart') {
438 + pos = avg.first;
439 + }
440 +
441 + // For these gestures, we always want the event coordinates
442 + // to be where the gesture began, not the current touch location.
443 + switch (this._state) {
444 + case GH_TWODRAG:
445 + case GH_PINCH:
446 + pos = avg.first;
447 + break;
448 + }
449 + detail['clientX'] = pos.x;
450 + detail['clientY'] = pos.y;
451 +
452 + // FIXME: other coordinates?
453 +
454 + // Some gestures also have a magnitude
455 + if (this._state === GH_PINCH) {
456 + var distance = this._getAverageDistance();
457 + if (type === 'gesturestart') {
458 + detail['magnitudeX'] = distance.first.x;
459 + detail['magnitudeY'] = distance.first.y;
460 + } else {
461 + detail['magnitudeX'] = distance.last.x;
462 + detail['magnitudeY'] = distance.last.y;
463 + }
464 + } else if (this._state === GH_TWODRAG) {
465 + if (type === 'gesturestart') {
466 + detail['magnitudeX'] = 0.0;
467 + detail['magnitudeY'] = 0.0;
468 + } else {
469 + var movement = this._getAverageMovement();
470 + detail['magnitudeX'] = movement.x;
471 + detail['magnitudeY'] = movement.y;
472 + }
473 + }
474 + var gev = new CustomEvent(type, {
475 + detail: detail
476 + });
477 + this._target.dispatchEvent(gev);
478 + }
479 + }, {
480 + key: "_stateToGesture",
481 + value: function _stateToGesture(state) {
482 + switch (state) {
483 + case GH_ONETAP:
484 + return 'onetap';
485 + case GH_TWOTAP:
486 + return 'twotap';
487 + case GH_THREETAP:
488 + return 'threetap';
489 + case GH_DRAG:
490 + return 'drag';
491 + case GH_LONGPRESS:
492 + return 'longpress';
493 + case GH_TWODRAG:
494 + return 'twodrag';
495 + case GH_PINCH:
496 + return 'pinch';
497 + }
498 + throw new Error("Unknown gesture state: " + state);
499 + }
500 + }, {
501 + key: "_getPosition",
502 + value: function _getPosition() {
503 + if (this._tracked.length === 0) {
504 + throw new Error("Failed to get gesture position, no tracked touches");
505 + }
506 + var size = this._tracked.length;
507 + var fx = 0,
508 + fy = 0,
509 + lx = 0,
510 + ly = 0;
511 + for (var i = 0; i < this._tracked.length; i++) {
512 + fx += this._tracked[i].firstX;
513 + fy += this._tracked[i].firstY;
514 + lx += this._tracked[i].lastX;
515 + ly += this._tracked[i].lastY;
516 + }
517 + return {
518 + first: {
519 + x: fx / size,
520 + y: fy / size
521 + },
522 + last: {
523 + x: lx / size,
524 + y: ly / size
525 + }
526 + };
527 + }
528 + }, {
529 + key: "_getAverageMovement",
530 + value: function _getAverageMovement() {
531 + if (this._tracked.length === 0) {
532 + throw new Error("Failed to get gesture movement, no tracked touches");
533 + }
534 + var totalH, totalV;
535 + totalH = totalV = 0;
536 + var size = this._tracked.length;
537 + for (var i = 0; i < this._tracked.length; i++) {
538 + totalH += this._tracked[i].lastX - this._tracked[i].firstX;
539 + totalV += this._tracked[i].lastY - this._tracked[i].firstY;
540 + }
541 + return {
542 + x: totalH / size,
543 + y: totalV / size
544 + };
545 + }
546 + }, {
547 + key: "_getAverageDistance",
548 + value: function _getAverageDistance() {
549 + if (this._tracked.length === 0) {
550 + throw new Error("Failed to get gesture distance, no tracked touches");
551 + }
552 +
553 + // Distance between the first and last tracked touches
554 +
555 + var first = this._tracked[0];
556 + var last = this._tracked[this._tracked.length - 1];
557 + var fdx = Math.abs(last.firstX - first.firstX);
558 + var fdy = Math.abs(last.firstY - first.firstY);
559 + var ldx = Math.abs(last.lastX - first.lastX);
560 + var ldy = Math.abs(last.lastY - first.lastY);
561 + return {
562 + first: {
563 + x: fdx,
564 + y: fdy
565 + },
566 + last: {
567 + x: ldx,
568 + y: ldy
569 + }
570 + };
571 + }
572 + }]);
573 +}();
\ No newline at end of file
added public/vendor/novnc/input/keyboard.js +293 −0
@@ -0,0 +1,293 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var Log = _interopRequireWildcard(require("../util/logging.js"));
8 +var _events = require("../util/events.js");
9 +var KeyboardUtil = _interopRequireWildcard(require("./util.js"));
10 +var _keysym = _interopRequireDefault(require("./keysym.js"));
11 +var browser = _interopRequireWildcard(require("../util/browser.js"));
12 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13 +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); }
14 +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; }
15 +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); }
16 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
17 +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); } }
18 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
19 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20 +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); } /*
21 + * noVNC: HTML5 VNC client
22 + * Copyright (C) 2019 The noVNC authors
23 + * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
24 + */
25 +//
26 +// Keyboard event handler
27 +//
28 +var Keyboard = exports["default"] = /*#__PURE__*/function () {
29 + function Keyboard(target) {
30 + _classCallCheck(this, Keyboard);
31 + this._target = target || null;
32 + this._keyDownList = {}; // List of depressed keys
33 + // (even if they are happy)
34 + this._altGrArmed = false; // Windows AltGr detection
35 +
36 + // keep these here so we can refer to them later
37 + this._eventHandlers = {
38 + 'keyup': this._handleKeyUp.bind(this),
39 + 'keydown': this._handleKeyDown.bind(this),
40 + 'blur': this._allKeysUp.bind(this)
41 + };
42 +
43 + // ===== EVENT HANDLERS =====
44 +
45 + this.onkeyevent = function () {}; // Handler for key press/release
46 + }
47 +
48 + // ===== PRIVATE METHODS =====
49 + return _createClass(Keyboard, [{
50 + key: "_sendKeyEvent",
51 + value: function _sendKeyEvent(keysym, code, down) {
52 + var numlock = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
53 + var capslock = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
54 + if (down) {
55 + this._keyDownList[code] = keysym;
56 + } else {
57 + // Do we really think this key is down?
58 + if (!(code in this._keyDownList)) {
59 + return;
60 + }
61 + delete this._keyDownList[code];
62 + }
63 + Log.Debug("onkeyevent " + (down ? "down" : "up") + ", keysym: " + keysym, ", code: " + code + ", numlock: " + numlock + ", capslock: " + capslock);
64 + this.onkeyevent(keysym, code, down, numlock, capslock);
65 + }
66 + }, {
67 + key: "_getKeyCode",
68 + value: function _getKeyCode(e) {
69 + var code = KeyboardUtil.getKeycode(e);
70 + if (code !== 'Unidentified') {
71 + return code;
72 + }
73 +
74 + // Unstable, but we don't have anything else to go on
75 + if (e.keyCode) {
76 + // 229 is used for composition events
77 + if (e.keyCode !== 229) {
78 + return 'Platform' + e.keyCode;
79 + }
80 + }
81 +
82 + // A precursor to the final DOM3 standard. Unfortunately it
83 + // is not layout independent, so it is as bad as using keyCode
84 + if (e.keyIdentifier) {
85 + // Non-character key?
86 + if (e.keyIdentifier.substr(0, 2) !== 'U+') {
87 + return e.keyIdentifier;
88 + }
89 + var codepoint = parseInt(e.keyIdentifier.substr(2), 16);
90 + var _char = String.fromCharCode(codepoint).toUpperCase();
91 + return 'Platform' + _char.charCodeAt();
92 + }
93 + return 'Unidentified';
94 + }
95 + }, {
96 + key: "_handleKeyDown",
97 + value: function _handleKeyDown(e) {
98 + var code = this._getKeyCode(e);
99 + var keysym = KeyboardUtil.getKeysym(e);
100 + var numlock = e.getModifierState('NumLock');
101 + var capslock = e.getModifierState('CapsLock');
102 +
103 + // getModifierState for NumLock is not supported on mac and ios and always returns false.
104 + // Set to null to indicate unknown/unsupported instead.
105 + if (browser.isMac() || browser.isIOS()) {
106 + numlock = null;
107 + }
108 +
109 + // Windows doesn't have a proper AltGr, but handles it using
110 + // fake Ctrl+Alt. However the remote end might not be Windows,
111 + // so we need to merge those in to a single AltGr event. We
112 + // detect this case by seeing the two key events directly after
113 + // each other with a very short time between them (<50ms).
114 + if (this._altGrArmed) {
115 + this._altGrArmed = false;
116 + clearTimeout(this._altGrTimeout);
117 + if (code === "AltRight" && e.timeStamp - this._altGrCtrlTime < 50) {
118 + // FIXME: We fail to detect this if either Ctrl key is
119 + // first manually pressed as Windows then no
120 + // longer sends the fake Ctrl down event. It
121 + // does however happily send real Ctrl events
122 + // even when AltGr is already down. Some
123 + // browsers detect this for us though and set the
124 + // key to "AltGraph".
125 + keysym = _keysym["default"].XK_ISO_Level3_Shift;
126 + } else {
127 + this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true, numlock, capslock);
128 + }
129 + }
130 +
131 + // We cannot handle keys we cannot track, but we also need
132 + // to deal with virtual keyboards which omit key info
133 + if (code === 'Unidentified') {
134 + if (keysym) {
135 + // If it's a virtual keyboard then it should be
136 + // sufficient to just send press and release right
137 + // after each other
138 + this._sendKeyEvent(keysym, code, true, numlock, capslock);
139 + this._sendKeyEvent(keysym, code, false, numlock, capslock);
140 + }
141 + (0, _events.stopEvent)(e);
142 + return;
143 + }
144 +
145 + // Alt behaves more like AltGraph on macOS, so shuffle the
146 + // keys around a bit to make things more sane for the remote
147 + // server. This method is used by RealVNC and TigerVNC (and
148 + // possibly others).
149 + if (browser.isMac() || browser.isIOS()) {
150 + switch (keysym) {
151 + case _keysym["default"].XK_Super_L:
152 + keysym = _keysym["default"].XK_Alt_L;
153 + break;
154 + case _keysym["default"].XK_Super_R:
155 + keysym = _keysym["default"].XK_Super_L;
156 + break;
157 + case _keysym["default"].XK_Alt_L:
158 + keysym = _keysym["default"].XK_Mode_switch;
159 + break;
160 + case _keysym["default"].XK_Alt_R:
161 + keysym = _keysym["default"].XK_ISO_Level3_Shift;
162 + break;
163 + }
164 + }
165 +
166 + // Is this key already pressed? If so, then we must use the
167 + // same keysym or we'll confuse the server
168 + if (code in this._keyDownList) {
169 + keysym = this._keyDownList[code];
170 + }
171 +
172 + // macOS doesn't send proper key releases if a key is pressed
173 + // while meta is held down
174 + if ((browser.isMac() || browser.isIOS()) && e.metaKey && code !== 'MetaLeft' && code !== 'MetaRight') {
175 + this._sendKeyEvent(keysym, code, true, numlock, capslock);
176 + this._sendKeyEvent(keysym, code, false, numlock, capslock);
177 + (0, _events.stopEvent)(e);
178 + return;
179 + }
180 +
181 + // macOS doesn't send proper key events for modifiers, only
182 + // state change events. That gets extra confusing for CapsLock
183 + // which toggles on each press, but not on release. So pretend
184 + // it was a quick press and release of the button.
185 + if ((browser.isMac() || browser.isIOS()) && code === 'CapsLock') {
186 + this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', true, numlock, capslock);
187 + this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', false, numlock, capslock);
188 + (0, _events.stopEvent)(e);
189 + return;
190 + }
191 +
192 + // Windows doesn't send proper key releases for a bunch of
193 + // Japanese IM keys so we have to fake the release right away
194 + var jpBadKeys = [_keysym["default"].XK_Zenkaku_Hankaku, _keysym["default"].XK_Eisu_toggle, _keysym["default"].XK_Katakana, _keysym["default"].XK_Hiragana, _keysym["default"].XK_Romaji];
195 + if (browser.isWindows() && jpBadKeys.includes(keysym)) {
196 + this._sendKeyEvent(keysym, code, true, numlock, capslock);
197 + this._sendKeyEvent(keysym, code, false, numlock, capslock);
198 + (0, _events.stopEvent)(e);
199 + return;
200 + }
201 + (0, _events.stopEvent)(e);
202 +
203 + // Possible start of AltGr sequence? (see above)
204 + if (code === "ControlLeft" && browser.isWindows() && !("ControlLeft" in this._keyDownList)) {
205 + this._altGrArmed = true;
206 + this._altGrTimeout = setTimeout(this._interruptAltGrSequence.bind(this), 100);
207 + this._altGrCtrlTime = e.timeStamp;
208 + return;
209 + }
210 + this._sendKeyEvent(keysym, code, true, numlock, capslock);
211 + }
212 + }, {
213 + key: "_handleKeyUp",
214 + value: function _handleKeyUp(e) {
215 + (0, _events.stopEvent)(e);
216 + var code = this._getKeyCode(e);
217 +
218 + // We can't get a release in the middle of an AltGr sequence, so
219 + // abort that detection
220 + this._interruptAltGrSequence();
221 +
222 + // See comment in _handleKeyDown()
223 + if ((browser.isMac() || browser.isIOS()) && code === 'CapsLock') {
224 + this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', true);
225 + this._sendKeyEvent(_keysym["default"].XK_Caps_Lock, 'CapsLock', false);
226 + return;
227 + }
228 + this._sendKeyEvent(this._keyDownList[code], code, false);
229 +
230 + // Windows has a rather nasty bug where it won't send key
231 + // release events for a Shift button if the other Shift is still
232 + // pressed
233 + if (browser.isWindows() && (code === 'ShiftLeft' || code === 'ShiftRight')) {
234 + if ('ShiftRight' in this._keyDownList) {
235 + this._sendKeyEvent(this._keyDownList['ShiftRight'], 'ShiftRight', false);
236 + }
237 + if ('ShiftLeft' in this._keyDownList) {
238 + this._sendKeyEvent(this._keyDownList['ShiftLeft'], 'ShiftLeft', false);
239 + }
240 + }
241 + }
242 + }, {
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 + }
250 + }
251 + }, {
252 + key: "_allKeysUp",
253 + value: function _allKeysUp() {
254 + Log.Debug(">> Keyboard.allKeysUp");
255 +
256 + // Prevent control key being processed after losing focus.
257 + this._interruptAltGrSequence();
258 + for (var code in this._keyDownList) {
259 + this._sendKeyEvent(this._keyDownList[code], code, false);
260 + }
261 + Log.Debug("<< Keyboard.allKeysUp");
262 + }
263 +
264 + // ===== PUBLIC METHODS =====
265 + }, {
266 + key: "grab",
267 + value: function grab() {
268 + //Log.Debug(">> Keyboard.grab");
269 +
270 + this._target.addEventListener('keydown', this._eventHandlers.keydown);
271 + this._target.addEventListener('keyup', this._eventHandlers.keyup);
272 +
273 + // Release (key up) if window loses focus
274 + window.addEventListener('blur', this._eventHandlers.blur);
275 +
276 + //Log.Debug("<< Keyboard.grab");
277 + }
278 + }, {
279 + key: "ungrab",
280 + value: function ungrab() {
281 + //Log.Debug(">> Keyboard.ungrab");
282 +
283 + this._target.removeEventListener('keydown', this._eventHandlers.keydown);
284 + this._target.removeEventListener('keyup', this._eventHandlers.keyup);
285 + window.removeEventListener('blur', this._eventHandlers.blur);
286 +
287 + // Release (key up) all keys that are in a down state
288 + this._allKeysUp();
289 +
290 + //Log.Debug(">> Keyboard.ungrab");
291 + }
292 + }]);
293 +}();
\ No newline at end of file
added public/vendor/novnc/input/keysym.js +878 −0
@@ -0,0 +1,878 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +/* eslint-disable key-spacing */
8 +var _default = exports["default"] = {
9 + XK_VoidSymbol: 0xffffff,
10 + /* Void symbol */
11 +
12 + XK_BackSpace: 0xff08,
13 + /* Back space, back char */
14 + XK_Tab: 0xff09,
15 + XK_Linefeed: 0xff0a,
16 + /* Linefeed, LF */
17 + XK_Clear: 0xff0b,
18 + XK_Return: 0xff0d,
19 + /* Return, enter */
20 + XK_Pause: 0xff13,
21 + /* Pause, hold */
22 + XK_Scroll_Lock: 0xff14,
23 + XK_Sys_Req: 0xff15,
24 + XK_Escape: 0xff1b,
25 + XK_Delete: 0xffff,
26 + /* Delete, rubout */
27 +
28 + /* International & multi-key character composition */
29 +
30 + XK_Multi_key: 0xff20,
31 + /* Multi-key character compose */
32 + XK_Codeinput: 0xff37,
33 + XK_SingleCandidate: 0xff3c,
34 + XK_MultipleCandidate: 0xff3d,
35 + XK_PreviousCandidate: 0xff3e,
36 + /* Japanese keyboard support */
37 +
38 + XK_Kanji: 0xff21,
39 + /* Kanji, Kanji convert */
40 + XK_Muhenkan: 0xff22,
41 + /* Cancel Conversion */
42 + XK_Henkan_Mode: 0xff23,
43 + /* Start/Stop Conversion */
44 + XK_Henkan: 0xff23,
45 + /* Alias for Henkan_Mode */
46 + XK_Romaji: 0xff24,
47 + /* to Romaji */
48 + XK_Hiragana: 0xff25,
49 + /* to Hiragana */
50 + XK_Katakana: 0xff26,
51 + /* to Katakana */
52 + XK_Hiragana_Katakana: 0xff27,
53 + /* Hiragana/Katakana toggle */
54 + XK_Zenkaku: 0xff28,
55 + /* to Zenkaku */
56 + XK_Hankaku: 0xff29,
57 + /* to Hankaku */
58 + XK_Zenkaku_Hankaku: 0xff2a,
59 + /* Zenkaku/Hankaku toggle */
60 + XK_Touroku: 0xff2b,
61 + /* Add to Dictionary */
62 + XK_Massyo: 0xff2c,
63 + /* Delete from Dictionary */
64 + XK_Kana_Lock: 0xff2d,
65 + /* Kana Lock */
66 + XK_Kana_Shift: 0xff2e,
67 + /* Kana Shift */
68 + XK_Eisu_Shift: 0xff2f,
69 + /* Alphanumeric Shift */
70 + XK_Eisu_toggle: 0xff30,
71 + /* Alphanumeric toggle */
72 + XK_Kanji_Bangou: 0xff37,
73 + /* Codeinput */
74 + XK_Zen_Koho: 0xff3d,
75 + /* Multiple/All Candidate(s) */
76 + XK_Mae_Koho: 0xff3e,
77 + /* Previous Candidate */
78 +
79 + /* Cursor control & motion */
80 +
81 + XK_Home: 0xff50,
82 + XK_Left: 0xff51,
83 + /* Move left, left arrow */
84 + XK_Up: 0xff52,
85 + /* Move up, up arrow */
86 + XK_Right: 0xff53,
87 + /* Move right, right arrow */
88 + XK_Down: 0xff54,
89 + /* Move down, down arrow */
90 + XK_Prior: 0xff55,
91 + /* Prior, previous */
92 + XK_Page_Up: 0xff55,
93 + XK_Next: 0xff56,
94 + /* Next */
95 + XK_Page_Down: 0xff56,
96 + XK_End: 0xff57,
97 + /* EOL */
98 + XK_Begin: 0xff58,
99 + /* BOL */
100 +
101 + /* Misc functions */
102 +
103 + XK_Select: 0xff60,
104 + /* Select, mark */
105 + XK_Print: 0xff61,
106 + XK_Execute: 0xff62,
107 + /* Execute, run, do */
108 + XK_Insert: 0xff63,
109 + /* Insert, insert here */
110 + XK_Undo: 0xff65,
111 + XK_Redo: 0xff66,
112 + /* Redo, again */
113 + XK_Menu: 0xff67,
114 + XK_Find: 0xff68,
115 + /* Find, search */
116 + XK_Cancel: 0xff69,
117 + /* Cancel, stop, abort, exit */
118 + XK_Help: 0xff6a,
119 + /* Help */
120 + XK_Break: 0xff6b,
121 + XK_Mode_switch: 0xff7e,
122 + /* Character set switch */
123 + XK_script_switch: 0xff7e,
124 + /* Alias for mode_switch */
125 + XK_Num_Lock: 0xff7f,
126 + /* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
127 +
128 + XK_KP_Space: 0xff80,
129 + /* Space */
130 + XK_KP_Tab: 0xff89,
131 + XK_KP_Enter: 0xff8d,
132 + /* Enter */
133 + XK_KP_F1: 0xff91,
134 + /* PF1, KP_A, ... */
135 + XK_KP_F2: 0xff92,
136 + XK_KP_F3: 0xff93,
137 + XK_KP_F4: 0xff94,
138 + XK_KP_Home: 0xff95,
139 + XK_KP_Left: 0xff96,
140 + XK_KP_Up: 0xff97,
141 + XK_KP_Right: 0xff98,
142 + XK_KP_Down: 0xff99,
143 + XK_KP_Prior: 0xff9a,
144 + XK_KP_Page_Up: 0xff9a,
145 + XK_KP_Next: 0xff9b,
146 + XK_KP_Page_Down: 0xff9b,
147 + XK_KP_End: 0xff9c,
148 + XK_KP_Begin: 0xff9d,
149 + XK_KP_Insert: 0xff9e,
150 + XK_KP_Delete: 0xff9f,
151 + XK_KP_Equal: 0xffbd,
152 + /* Equals */
153 + XK_KP_Multiply: 0xffaa,
154 + XK_KP_Add: 0xffab,
155 + XK_KP_Separator: 0xffac,
156 + /* Separator, often comma */
157 + XK_KP_Subtract: 0xffad,
158 + XK_KP_Decimal: 0xffae,
159 + XK_KP_Divide: 0xffaf,
160 + XK_KP_0: 0xffb0,
161 + XK_KP_1: 0xffb1,
162 + XK_KP_2: 0xffb2,
163 + XK_KP_3: 0xffb3,
164 + XK_KP_4: 0xffb4,
165 + XK_KP_5: 0xffb5,
166 + XK_KP_6: 0xffb6,
167 + XK_KP_7: 0xffb7,
168 + XK_KP_8: 0xffb8,
169 + XK_KP_9: 0xffb9,
170 + /*
171 + * Auxiliary functions; note the duplicate definitions for left and right
172 + * function keys; Sun keyboards and a few other manufacturers have such
173 + * function key groups on the left and/or right sides of the keyboard.
174 + * We've not found a keyboard with more than 35 function keys total.
175 + */
176 +
177 + XK_F1: 0xffbe,
178 + XK_F2: 0xffbf,
179 + XK_F3: 0xffc0,
180 + XK_F4: 0xffc1,
181 + XK_F5: 0xffc2,
182 + XK_F6: 0xffc3,
183 + XK_F7: 0xffc4,
184 + XK_F8: 0xffc5,
185 + XK_F9: 0xffc6,
186 + XK_F10: 0xffc7,
187 + XK_F11: 0xffc8,
188 + XK_L1: 0xffc8,
189 + XK_F12: 0xffc9,
190 + XK_L2: 0xffc9,
191 + XK_F13: 0xffca,
192 + XK_L3: 0xffca,
193 + XK_F14: 0xffcb,
194 + XK_L4: 0xffcb,
195 + XK_F15: 0xffcc,
196 + XK_L5: 0xffcc,
197 + XK_F16: 0xffcd,
198 + XK_L6: 0xffcd,
199 + XK_F17: 0xffce,
200 + XK_L7: 0xffce,
201 + XK_F18: 0xffcf,
202 + XK_L8: 0xffcf,
203 + XK_F19: 0xffd0,
204 + XK_L9: 0xffd0,
205 + XK_F20: 0xffd1,
206 + XK_L10: 0xffd1,
207 + XK_F21: 0xffd2,
208 + XK_R1: 0xffd2,
209 + XK_F22: 0xffd3,
210 + XK_R2: 0xffd3,
211 + XK_F23: 0xffd4,
212 + XK_R3: 0xffd4,
213 + XK_F24: 0xffd5,
214 + XK_R4: 0xffd5,
215 + XK_F25: 0xffd6,
216 + XK_R5: 0xffd6,
217 + XK_F26: 0xffd7,
218 + XK_R6: 0xffd7,
219 + XK_F27: 0xffd8,
220 + XK_R7: 0xffd8,
221 + XK_F28: 0xffd9,
222 + XK_R8: 0xffd9,
223 + XK_F29: 0xffda,
224 + XK_R9: 0xffda,
225 + XK_F30: 0xffdb,
226 + XK_R10: 0xffdb,
227 + XK_F31: 0xffdc,
228 + XK_R11: 0xffdc,
229 + XK_F32: 0xffdd,
230 + XK_R12: 0xffdd,
231 + XK_F33: 0xffde,
232 + XK_R13: 0xffde,
233 + XK_F34: 0xffdf,
234 + XK_R14: 0xffdf,
235 + XK_F35: 0xffe0,
236 + XK_R15: 0xffe0,
237 + /* Modifiers */
238 +
239 + XK_Shift_L: 0xffe1,
240 + /* Left shift */
241 + XK_Shift_R: 0xffe2,
242 + /* Right shift */
243 + XK_Control_L: 0xffe3,
244 + /* Left control */
245 + XK_Control_R: 0xffe4,
246 + /* Right control */
247 + XK_Caps_Lock: 0xffe5,
248 + /* Caps lock */
249 + XK_Shift_Lock: 0xffe6,
250 + /* Shift lock */
251 +
252 + XK_Meta_L: 0xffe7,
253 + /* Left meta */
254 + XK_Meta_R: 0xffe8,
255 + /* Right meta */
256 + XK_Alt_L: 0xffe9,
257 + /* Left alt */
258 + XK_Alt_R: 0xffea,
259 + /* Right alt */
260 + XK_Super_L: 0xffeb,
261 + /* Left super */
262 + XK_Super_R: 0xffec,
263 + /* Right super */
264 + XK_Hyper_L: 0xffed,
265 + /* Left hyper */
266 + XK_Hyper_R: 0xffee,
267 + /* Right hyper */
268 +
269 + /*
270 + * Keyboard (XKB) Extension function and modifier keys
271 + * (from Appendix C of "The X Keyboard Extension: Protocol Specification")
272 + * Byte 3 = 0xfe
273 + */
274 +
275 + XK_ISO_Level3_Shift: 0xfe03,
276 + /* AltGr */
277 + XK_ISO_Next_Group: 0xfe08,
278 + XK_ISO_Prev_Group: 0xfe0a,
279 + XK_ISO_First_Group: 0xfe0c,
280 + XK_ISO_Last_Group: 0xfe0e,
281 + /*
282 + * Latin 1
283 + * (ISO/IEC 8859-1: Unicode U+0020..U+00FF)
284 + * Byte 3: 0
285 + */
286 +
287 + XK_space: 0x0020,
288 + /* U+0020 SPACE */
289 + XK_exclam: 0x0021,
290 + /* U+0021 EXCLAMATION MARK */
291 + XK_quotedbl: 0x0022,
292 + /* U+0022 QUOTATION MARK */
293 + XK_numbersign: 0x0023,
294 + /* U+0023 NUMBER SIGN */
295 + XK_dollar: 0x0024,
296 + /* U+0024 DOLLAR SIGN */
297 + XK_percent: 0x0025,
298 + /* U+0025 PERCENT SIGN */
299 + XK_ampersand: 0x0026,
300 + /* U+0026 AMPERSAND */
301 + XK_apostrophe: 0x0027,
302 + /* U+0027 APOSTROPHE */
303 + XK_quoteright: 0x0027,
304 + /* deprecated */
305 + XK_parenleft: 0x0028,
306 + /* U+0028 LEFT PARENTHESIS */
307 + XK_parenright: 0x0029,
308 + /* U+0029 RIGHT PARENTHESIS */
309 + XK_asterisk: 0x002a,
310 + /* U+002A ASTERISK */
311 + XK_plus: 0x002b,
312 + /* U+002B PLUS SIGN */
313 + XK_comma: 0x002c,
314 + /* U+002C COMMA */
315 + XK_minus: 0x002d,
316 + /* U+002D HYPHEN-MINUS */
317 + XK_period: 0x002e,
318 + /* U+002E FULL STOP */
319 + XK_slash: 0x002f,
320 + /* U+002F SOLIDUS */
321 + XK_0: 0x0030,
322 + /* U+0030 DIGIT ZERO */
323 + XK_1: 0x0031,
324 + /* U+0031 DIGIT ONE */
325 + XK_2: 0x0032,
326 + /* U+0032 DIGIT TWO */
327 + XK_3: 0x0033,
328 + /* U+0033 DIGIT THREE */
329 + XK_4: 0x0034,
330 + /* U+0034 DIGIT FOUR */
331 + XK_5: 0x0035,
332 + /* U+0035 DIGIT FIVE */
333 + XK_6: 0x0036,
334 + /* U+0036 DIGIT SIX */
335 + XK_7: 0x0037,
336 + /* U+0037 DIGIT SEVEN */
337 + XK_8: 0x0038,
338 + /* U+0038 DIGIT EIGHT */
339 + XK_9: 0x0039,
340 + /* U+0039 DIGIT NINE */
341 + XK_colon: 0x003a,
342 + /* U+003A COLON */
343 + XK_semicolon: 0x003b,
344 + /* U+003B SEMICOLON */
345 + XK_less: 0x003c,
346 + /* U+003C LESS-THAN SIGN */
347 + XK_equal: 0x003d,
348 + /* U+003D EQUALS SIGN */
349 + XK_greater: 0x003e,
350 + /* U+003E GREATER-THAN SIGN */
351 + XK_question: 0x003f,
352 + /* U+003F QUESTION MARK */
353 + XK_at: 0x0040,
354 + /* U+0040 COMMERCIAL AT */
355 + XK_A: 0x0041,
356 + /* U+0041 LATIN CAPITAL LETTER A */
357 + XK_B: 0x0042,
358 + /* U+0042 LATIN CAPITAL LETTER B */
359 + XK_C: 0x0043,
360 + /* U+0043 LATIN CAPITAL LETTER C */
361 + XK_D: 0x0044,
362 + /* U+0044 LATIN CAPITAL LETTER D */
363 + XK_E: 0x0045,
364 + /* U+0045 LATIN CAPITAL LETTER E */
365 + XK_F: 0x0046,
366 + /* U+0046 LATIN CAPITAL LETTER F */
367 + XK_G: 0x0047,
368 + /* U+0047 LATIN CAPITAL LETTER G */
369 + XK_H: 0x0048,
370 + /* U+0048 LATIN CAPITAL LETTER H */
371 + XK_I: 0x0049,
372 + /* U+0049 LATIN CAPITAL LETTER I */
373 + XK_J: 0x004a,
374 + /* U+004A LATIN CAPITAL LETTER J */
375 + XK_K: 0x004b,
376 + /* U+004B LATIN CAPITAL LETTER K */
377 + XK_L: 0x004c,
378 + /* U+004C LATIN CAPITAL LETTER L */
379 + XK_M: 0x004d,
380 + /* U+004D LATIN CAPITAL LETTER M */
381 + XK_N: 0x004e,
382 + /* U+004E LATIN CAPITAL LETTER N */
383 + XK_O: 0x004f,
384 + /* U+004F LATIN CAPITAL LETTER O */
385 + XK_P: 0x0050,
386 + /* U+0050 LATIN CAPITAL LETTER P */
387 + XK_Q: 0x0051,
388 + /* U+0051 LATIN CAPITAL LETTER Q */
389 + XK_R: 0x0052,
390 + /* U+0052 LATIN CAPITAL LETTER R */
391 + XK_S: 0x0053,
392 + /* U+0053 LATIN CAPITAL LETTER S */
393 + XK_T: 0x0054,
394 + /* U+0054 LATIN CAPITAL LETTER T */
395 + XK_U: 0x0055,
396 + /* U+0055 LATIN CAPITAL LETTER U */
397 + XK_V: 0x0056,
398 + /* U+0056 LATIN CAPITAL LETTER V */
399 + XK_W: 0x0057,
400 + /* U+0057 LATIN CAPITAL LETTER W */
401 + XK_X: 0x0058,
402 + /* U+0058 LATIN CAPITAL LETTER X */
403 + XK_Y: 0x0059,
404 + /* U+0059 LATIN CAPITAL LETTER Y */
405 + XK_Z: 0x005a,
406 + /* U+005A LATIN CAPITAL LETTER Z */
407 + XK_bracketleft: 0x005b,
408 + /* U+005B LEFT SQUARE BRACKET */
409 + XK_backslash: 0x005c,
410 + /* U+005C REVERSE SOLIDUS */
411 + XK_bracketright: 0x005d,
412 + /* U+005D RIGHT SQUARE BRACKET */
413 + XK_asciicircum: 0x005e,
414 + /* U+005E CIRCUMFLEX ACCENT */
415 + XK_underscore: 0x005f,
416 + /* U+005F LOW LINE */
417 + XK_grave: 0x0060,
418 + /* U+0060 GRAVE ACCENT */
419 + XK_quoteleft: 0x0060,
420 + /* deprecated */
421 + XK_a: 0x0061,
422 + /* U+0061 LATIN SMALL LETTER A */
423 + XK_b: 0x0062,
424 + /* U+0062 LATIN SMALL LETTER B */
425 + XK_c: 0x0063,
426 + /* U+0063 LATIN SMALL LETTER C */
427 + XK_d: 0x0064,
428 + /* U+0064 LATIN SMALL LETTER D */
429 + XK_e: 0x0065,
430 + /* U+0065 LATIN SMALL LETTER E */
431 + XK_f: 0x0066,
432 + /* U+0066 LATIN SMALL LETTER F */
433 + XK_g: 0x0067,
434 + /* U+0067 LATIN SMALL LETTER G */
435 + XK_h: 0x0068,
436 + /* U+0068 LATIN SMALL LETTER H */
437 + XK_i: 0x0069,
438 + /* U+0069 LATIN SMALL LETTER I */
439 + XK_j: 0x006a,
440 + /* U+006A LATIN SMALL LETTER J */
441 + XK_k: 0x006b,
442 + /* U+006B LATIN SMALL LETTER K */
443 + XK_l: 0x006c,
444 + /* U+006C LATIN SMALL LETTER L */
445 + XK_m: 0x006d,
446 + /* U+006D LATIN SMALL LETTER M */
447 + XK_n: 0x006e,
448 + /* U+006E LATIN SMALL LETTER N */
449 + XK_o: 0x006f,
450 + /* U+006F LATIN SMALL LETTER O */
451 + XK_p: 0x0070,
452 + /* U+0070 LATIN SMALL LETTER P */
453 + XK_q: 0x0071,
454 + /* U+0071 LATIN SMALL LETTER Q */
455 + XK_r: 0x0072,
456 + /* U+0072 LATIN SMALL LETTER R */
457 + XK_s: 0x0073,
458 + /* U+0073 LATIN SMALL LETTER S */
459 + XK_t: 0x0074,
460 + /* U+0074 LATIN SMALL LETTER T */
461 + XK_u: 0x0075,
462 + /* U+0075 LATIN SMALL LETTER U */
463 + XK_v: 0x0076,
464 + /* U+0076 LATIN SMALL LETTER V */
465 + XK_w: 0x0077,
466 + /* U+0077 LATIN SMALL LETTER W */
467 + XK_x: 0x0078,
468 + /* U+0078 LATIN SMALL LETTER X */
469 + XK_y: 0x0079,
470 + /* U+0079 LATIN SMALL LETTER Y */
471 + XK_z: 0x007a,
472 + /* U+007A LATIN SMALL LETTER Z */
473 + XK_braceleft: 0x007b,
474 + /* U+007B LEFT CURLY BRACKET */
475 + XK_bar: 0x007c,
476 + /* U+007C VERTICAL LINE */
477 + XK_braceright: 0x007d,
478 + /* U+007D RIGHT CURLY BRACKET */
479 + XK_asciitilde: 0x007e,
480 + /* U+007E TILDE */
481 +
482 + XK_nobreakspace: 0x00a0,
483 + /* U+00A0 NO-BREAK SPACE */
484 + XK_exclamdown: 0x00a1,
485 + /* U+00A1 INVERTED EXCLAMATION MARK */
486 + XK_cent: 0x00a2,
487 + /* U+00A2 CENT SIGN */
488 + XK_sterling: 0x00a3,
489 + /* U+00A3 POUND SIGN */
490 + XK_currency: 0x00a4,
491 + /* U+00A4 CURRENCY SIGN */
492 + XK_yen: 0x00a5,
493 + /* U+00A5 YEN SIGN */
494 + XK_brokenbar: 0x00a6,
495 + /* U+00A6 BROKEN BAR */
496 + XK_section: 0x00a7,
497 + /* U+00A7 SECTION SIGN */
498 + XK_diaeresis: 0x00a8,
499 + /* U+00A8 DIAERESIS */
500 + XK_copyright: 0x00a9,
501 + /* U+00A9 COPYRIGHT SIGN */
502 + XK_ordfeminine: 0x00aa,
503 + /* U+00AA FEMININE ORDINAL INDICATOR */
504 + XK_guillemotleft: 0x00ab,
505 + /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
506 + XK_notsign: 0x00ac,
507 + /* U+00AC NOT SIGN */
508 + XK_hyphen: 0x00ad,
509 + /* U+00AD SOFT HYPHEN */
510 + XK_registered: 0x00ae,
511 + /* U+00AE REGISTERED SIGN */
512 + XK_macron: 0x00af,
513 + /* U+00AF MACRON */
514 + XK_degree: 0x00b0,
515 + /* U+00B0 DEGREE SIGN */
516 + XK_plusminus: 0x00b1,
517 + /* U+00B1 PLUS-MINUS SIGN */
518 + XK_twosuperior: 0x00b2,
519 + /* U+00B2 SUPERSCRIPT TWO */
520 + XK_threesuperior: 0x00b3,
521 + /* U+00B3 SUPERSCRIPT THREE */
522 + XK_acute: 0x00b4,
523 + /* U+00B4 ACUTE ACCENT */
524 + XK_mu: 0x00b5,
525 + /* U+00B5 MICRO SIGN */
526 + XK_paragraph: 0x00b6,
527 + /* U+00B6 PILCROW SIGN */
528 + XK_periodcentered: 0x00b7,
529 + /* U+00B7 MIDDLE DOT */
530 + XK_cedilla: 0x00b8,
531 + /* U+00B8 CEDILLA */
532 + XK_onesuperior: 0x00b9,
533 + /* U+00B9 SUPERSCRIPT ONE */
534 + XK_masculine: 0x00ba,
535 + /* U+00BA MASCULINE ORDINAL INDICATOR */
536 + XK_guillemotright: 0x00bb,
537 + /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
538 + XK_onequarter: 0x00bc,
539 + /* U+00BC VULGAR FRACTION ONE QUARTER */
540 + XK_onehalf: 0x00bd,
541 + /* U+00BD VULGAR FRACTION ONE HALF */
542 + XK_threequarters: 0x00be,
543 + /* U+00BE VULGAR FRACTION THREE QUARTERS */
544 + XK_questiondown: 0x00bf,
545 + /* U+00BF INVERTED QUESTION MARK */
546 + XK_Agrave: 0x00c0,
547 + /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */
548 + XK_Aacute: 0x00c1,
549 + /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */
550 + XK_Acircumflex: 0x00c2,
551 + /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
552 + XK_Atilde: 0x00c3,
553 + /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */
554 + XK_Adiaeresis: 0x00c4,
555 + /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */
556 + XK_Aring: 0x00c5,
557 + /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */
558 + XK_AE: 0x00c6,
559 + /* U+00C6 LATIN CAPITAL LETTER AE */
560 + XK_Ccedilla: 0x00c7,
561 + /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */
562 + XK_Egrave: 0x00c8,
563 + /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */
564 + XK_Eacute: 0x00c9,
565 + /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
566 + XK_Ecircumflex: 0x00ca,
567 + /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
568 + XK_Ediaeresis: 0x00cb,
569 + /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */
570 + XK_Igrave: 0x00cc,
571 + /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */
572 + XK_Iacute: 0x00cd,
573 + /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */
574 + XK_Icircumflex: 0x00ce,
575 + /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
576 + XK_Idiaeresis: 0x00cf,
577 + /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */
578 + XK_ETH: 0x00d0,
579 + /* U+00D0 LATIN CAPITAL LETTER ETH */
580 + XK_Eth: 0x00d0,
581 + /* deprecated */
582 + XK_Ntilde: 0x00d1,
583 + /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */
584 + XK_Ograve: 0x00d2,
585 + /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */
586 + XK_Oacute: 0x00d3,
587 + /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */
588 + XK_Ocircumflex: 0x00d4,
589 + /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
590 + XK_Otilde: 0x00d5,
591 + /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */
592 + XK_Odiaeresis: 0x00d6,
593 + /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */
594 + XK_multiply: 0x00d7,
595 + /* U+00D7 MULTIPLICATION SIGN */
596 + XK_Oslash: 0x00d8,
597 + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
598 + XK_Ooblique: 0x00d8,
599 + /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
600 + XK_Ugrave: 0x00d9,
601 + /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */
602 + XK_Uacute: 0x00da,
603 + /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */
604 + XK_Ucircumflex: 0x00db,
605 + /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
606 + XK_Udiaeresis: 0x00dc,
607 + /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */
608 + XK_Yacute: 0x00dd,
609 + /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */
610 + XK_THORN: 0x00de,
611 + /* U+00DE LATIN CAPITAL LETTER THORN */
612 + XK_Thorn: 0x00de,
613 + /* deprecated */
614 + XK_ssharp: 0x00df,
615 + /* U+00DF LATIN SMALL LETTER SHARP S */
616 + XK_agrave: 0x00e0,
617 + /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */
618 + XK_aacute: 0x00e1,
619 + /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */
620 + XK_acircumflex: 0x00e2,
621 + /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */
622 + XK_atilde: 0x00e3,
623 + /* U+00E3 LATIN SMALL LETTER A WITH TILDE */
624 + XK_adiaeresis: 0x00e4,
625 + /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */
626 + XK_aring: 0x00e5,
627 + /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */
628 + XK_ae: 0x00e6,
629 + /* U+00E6 LATIN SMALL LETTER AE */
630 + XK_ccedilla: 0x00e7,
631 + /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */
632 + XK_egrave: 0x00e8,
633 + /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */
634 + XK_eacute: 0x00e9,
635 + /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
636 + XK_ecircumflex: 0x00ea,
637 + /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */
638 + XK_ediaeresis: 0x00eb,
639 + /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */
640 + XK_igrave: 0x00ec,
641 + /* U+00EC LATIN SMALL LETTER I WITH GRAVE */
642 + XK_iacute: 0x00ed,
643 + /* U+00ED LATIN SMALL LETTER I WITH ACUTE */
644 + XK_icircumflex: 0x00ee,
645 + /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */
646 + XK_idiaeresis: 0x00ef,
647 + /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */
648 + XK_eth: 0x00f0,
649 + /* U+00F0 LATIN SMALL LETTER ETH */
650 + XK_ntilde: 0x00f1,
651 + /* U+00F1 LATIN SMALL LETTER N WITH TILDE */
652 + XK_ograve: 0x00f2,
653 + /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */
654 + XK_oacute: 0x00f3,
655 + /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */
656 + XK_ocircumflex: 0x00f4,
657 + /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */
658 + XK_otilde: 0x00f5,
659 + /* U+00F5 LATIN SMALL LETTER O WITH TILDE */
660 + XK_odiaeresis: 0x00f6,
661 + /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */
662 + XK_division: 0x00f7,
663 + /* U+00F7 DIVISION SIGN */
664 + XK_oslash: 0x00f8,
665 + /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
666 + XK_ooblique: 0x00f8,
667 + /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
668 + XK_ugrave: 0x00f9,
669 + /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */
670 + XK_uacute: 0x00fa,
671 + /* U+00FA LATIN SMALL LETTER U WITH ACUTE */
672 + XK_ucircumflex: 0x00fb,
673 + /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */
674 + XK_udiaeresis: 0x00fc,
675 + /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */
676 + XK_yacute: 0x00fd,
677 + /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */
678 + XK_thorn: 0x00fe,
679 + /* U+00FE LATIN SMALL LETTER THORN */
680 + XK_ydiaeresis: 0x00ff,
681 + /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
682 +
683 + /*
684 + * Korean
685 + * Byte 3 = 0x0e
686 + */
687 +
688 + XK_Hangul: 0xff31,
689 + /* Hangul start/stop(toggle) */
690 + XK_Hangul_Hanja: 0xff34,
691 + /* Start Hangul->Hanja Conversion */
692 + XK_Hangul_Jeonja: 0xff38,
693 + /* Jeonja mode */
694 +
695 + /*
696 + * XFree86 vendor specific keysyms.
697 + *
698 + * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
699 + */
700 +
701 + XF86XK_ModeLock: 0x1008FF01,
702 + XF86XK_MonBrightnessUp: 0x1008FF02,
703 + XF86XK_MonBrightnessDown: 0x1008FF03,
704 + XF86XK_KbdLightOnOff: 0x1008FF04,
705 + XF86XK_KbdBrightnessUp: 0x1008FF05,
706 + XF86XK_KbdBrightnessDown: 0x1008FF06,
707 + XF86XK_Standby: 0x1008FF10,
708 + XF86XK_AudioLowerVolume: 0x1008FF11,
709 + XF86XK_AudioMute: 0x1008FF12,
710 + XF86XK_AudioRaiseVolume: 0x1008FF13,
711 + XF86XK_AudioPlay: 0x1008FF14,
712 + XF86XK_AudioStop: 0x1008FF15,
713 + XF86XK_AudioPrev: 0x1008FF16,
714 + XF86XK_AudioNext: 0x1008FF17,
715 + XF86XK_HomePage: 0x1008FF18,
716 + XF86XK_Mail: 0x1008FF19,
717 + XF86XK_Start: 0x1008FF1A,
718 + XF86XK_Search: 0x1008FF1B,
719 + XF86XK_AudioRecord: 0x1008FF1C,
720 + XF86XK_Calculator: 0x1008FF1D,
721 + XF86XK_Memo: 0x1008FF1E,
722 + XF86XK_ToDoList: 0x1008FF1F,
723 + XF86XK_Calendar: 0x1008FF20,
724 + XF86XK_PowerDown: 0x1008FF21,
725 + XF86XK_ContrastAdjust: 0x1008FF22,
726 + XF86XK_RockerUp: 0x1008FF23,
727 + XF86XK_RockerDown: 0x1008FF24,
728 + XF86XK_RockerEnter: 0x1008FF25,
729 + XF86XK_Back: 0x1008FF26,
730 + XF86XK_Forward: 0x1008FF27,
731 + XF86XK_Stop: 0x1008FF28,
732 + XF86XK_Refresh: 0x1008FF29,
733 + XF86XK_PowerOff: 0x1008FF2A,
734 + XF86XK_WakeUp: 0x1008FF2B,
735 + XF86XK_Eject: 0x1008FF2C,
736 + XF86XK_ScreenSaver: 0x1008FF2D,
737 + XF86XK_WWW: 0x1008FF2E,
738 + XF86XK_Sleep: 0x1008FF2F,
739 + XF86XK_Favorites: 0x1008FF30,
740 + XF86XK_AudioPause: 0x1008FF31,
741 + XF86XK_AudioMedia: 0x1008FF32,
742 + XF86XK_MyComputer: 0x1008FF33,
743 + XF86XK_VendorHome: 0x1008FF34,
744 + XF86XK_LightBulb: 0x1008FF35,
745 + XF86XK_Shop: 0x1008FF36,
746 + XF86XK_History: 0x1008FF37,
747 + XF86XK_OpenURL: 0x1008FF38,
748 + XF86XK_AddFavorite: 0x1008FF39,
749 + XF86XK_HotLinks: 0x1008FF3A,
750 + XF86XK_BrightnessAdjust: 0x1008FF3B,
751 + XF86XK_Finance: 0x1008FF3C,
752 + XF86XK_Community: 0x1008FF3D,
753 + XF86XK_AudioRewind: 0x1008FF3E,
754 + XF86XK_BackForward: 0x1008FF3F,
755 + XF86XK_Launch0: 0x1008FF40,
756 + XF86XK_Launch1: 0x1008FF41,
757 + XF86XK_Launch2: 0x1008FF42,
758 + XF86XK_Launch3: 0x1008FF43,
759 + XF86XK_Launch4: 0x1008FF44,
760 + XF86XK_Launch5: 0x1008FF45,
761 + XF86XK_Launch6: 0x1008FF46,
762 + XF86XK_Launch7: 0x1008FF47,
763 + XF86XK_Launch8: 0x1008FF48,
764 + XF86XK_Launch9: 0x1008FF49,
765 + XF86XK_LaunchA: 0x1008FF4A,
766 + XF86XK_LaunchB: 0x1008FF4B,
767 + XF86XK_LaunchC: 0x1008FF4C,
768 + XF86XK_LaunchD: 0x1008FF4D,
769 + XF86XK_LaunchE: 0x1008FF4E,
770 + XF86XK_LaunchF: 0x1008FF4F,
771 + XF86XK_ApplicationLeft: 0x1008FF50,
772 + XF86XK_ApplicationRight: 0x1008FF51,
773 + XF86XK_Book: 0x1008FF52,
774 + XF86XK_CD: 0x1008FF53,
775 + XF86XK_Calculater: 0x1008FF54,
776 + XF86XK_Clear: 0x1008FF55,
777 + XF86XK_Close: 0x1008FF56,
778 + XF86XK_Copy: 0x1008FF57,
779 + XF86XK_Cut: 0x1008FF58,
780 + XF86XK_Display: 0x1008FF59,
781 + XF86XK_DOS: 0x1008FF5A,
782 + XF86XK_Documents: 0x1008FF5B,
783 + XF86XK_Excel: 0x1008FF5C,
784 + XF86XK_Explorer: 0x1008FF5D,
785 + XF86XK_Game: 0x1008FF5E,
786 + XF86XK_Go: 0x1008FF5F,
787 + XF86XK_iTouch: 0x1008FF60,
788 + XF86XK_LogOff: 0x1008FF61,
789 + XF86XK_Market: 0x1008FF62,
790 + XF86XK_Meeting: 0x1008FF63,
791 + XF86XK_MenuKB: 0x1008FF65,
792 + XF86XK_MenuPB: 0x1008FF66,
793 + XF86XK_MySites: 0x1008FF67,
794 + XF86XK_New: 0x1008FF68,
795 + XF86XK_News: 0x1008FF69,
796 + XF86XK_OfficeHome: 0x1008FF6A,
797 + XF86XK_Open: 0x1008FF6B,
798 + XF86XK_Option: 0x1008FF6C,
799 + XF86XK_Paste: 0x1008FF6D,
800 + XF86XK_Phone: 0x1008FF6E,
801 + XF86XK_Q: 0x1008FF70,
802 + XF86XK_Reply: 0x1008FF72,
803 + XF86XK_Reload: 0x1008FF73,
804 + XF86XK_RotateWindows: 0x1008FF74,
805 + XF86XK_RotationPB: 0x1008FF75,
806 + XF86XK_RotationKB: 0x1008FF76,
807 + XF86XK_Save: 0x1008FF77,
808 + XF86XK_ScrollUp: 0x1008FF78,
809 + XF86XK_ScrollDown: 0x1008FF79,
810 + XF86XK_ScrollClick: 0x1008FF7A,
811 + XF86XK_Send: 0x1008FF7B,
812 + XF86XK_Spell: 0x1008FF7C,
813 + XF86XK_SplitScreen: 0x1008FF7D,
814 + XF86XK_Support: 0x1008FF7E,
815 + XF86XK_TaskPane: 0x1008FF7F,
816 + XF86XK_Terminal: 0x1008FF80,
817 + XF86XK_Tools: 0x1008FF81,
818 + XF86XK_Travel: 0x1008FF82,
819 + XF86XK_UserPB: 0x1008FF84,
820 + XF86XK_User1KB: 0x1008FF85,
821 + XF86XK_User2KB: 0x1008FF86,
822 + XF86XK_Video: 0x1008FF87,
823 + XF86XK_WheelButton: 0x1008FF88,
824 + XF86XK_Word: 0x1008FF89,
825 + XF86XK_Xfer: 0x1008FF8A,
826 + XF86XK_ZoomIn: 0x1008FF8B,
827 + XF86XK_ZoomOut: 0x1008FF8C,
828 + XF86XK_Away: 0x1008FF8D,
829 + XF86XK_Messenger: 0x1008FF8E,
830 + XF86XK_WebCam: 0x1008FF8F,
831 + XF86XK_MailForward: 0x1008FF90,
832 + XF86XK_Pictures: 0x1008FF91,
833 + XF86XK_Music: 0x1008FF92,
834 + XF86XK_Battery: 0x1008FF93,
835 + XF86XK_Bluetooth: 0x1008FF94,
836 + XF86XK_WLAN: 0x1008FF95,
837 + XF86XK_UWB: 0x1008FF96,
838 + XF86XK_AudioForward: 0x1008FF97,
839 + XF86XK_AudioRepeat: 0x1008FF98,
840 + XF86XK_AudioRandomPlay: 0x1008FF99,
841 + XF86XK_Subtitle: 0x1008FF9A,
842 + XF86XK_AudioCycleTrack: 0x1008FF9B,
843 + XF86XK_CycleAngle: 0x1008FF9C,
844 + XF86XK_FrameBack: 0x1008FF9D,
845 + XF86XK_FrameForward: 0x1008FF9E,
846 + XF86XK_Time: 0x1008FF9F,
847 + XF86XK_Select: 0x1008FFA0,
848 + XF86XK_View: 0x1008FFA1,
849 + XF86XK_TopMenu: 0x1008FFA2,
850 + XF86XK_Red: 0x1008FFA3,
851 + XF86XK_Green: 0x1008FFA4,
852 + XF86XK_Yellow: 0x1008FFA5,
853 + XF86XK_Blue: 0x1008FFA6,
854 + XF86XK_Suspend: 0x1008FFA7,
855 + XF86XK_Hibernate: 0x1008FFA8,
856 + XF86XK_TouchpadToggle: 0x1008FFA9,
857 + XF86XK_TouchpadOn: 0x1008FFB0,
858 + XF86XK_TouchpadOff: 0x1008FFB1,
859 + XF86XK_AudioMicMute: 0x1008FFB2,
860 + XF86XK_Switch_VT_1: 0x1008FE01,
861 + XF86XK_Switch_VT_2: 0x1008FE02,
862 + XF86XK_Switch_VT_3: 0x1008FE03,
863 + XF86XK_Switch_VT_4: 0x1008FE04,
864 + XF86XK_Switch_VT_5: 0x1008FE05,
865 + XF86XK_Switch_VT_6: 0x1008FE06,
866 + XF86XK_Switch_VT_7: 0x1008FE07,
867 + XF86XK_Switch_VT_8: 0x1008FE08,
868 + XF86XK_Switch_VT_9: 0x1008FE09,
869 + XF86XK_Switch_VT_10: 0x1008FE0A,
870 + XF86XK_Switch_VT_11: 0x1008FE0B,
871 + XF86XK_Switch_VT_12: 0x1008FE0C,
872 + XF86XK_Ungrab: 0x1008FE20,
873 + XF86XK_ClearGrab: 0x1008FE21,
874 + XF86XK_Next_VMode: 0x1008FE22,
875 + XF86XK_Prev_VMode: 0x1008FE23,
876 + XF86XK_LogWindowTree: 0x1008FE24,
877 + XF86XK_LogGrabInfo: 0x1008FE25
878 +};
\ No newline at end of file
added public/vendor/novnc/input/keysymdef.js +1351 −0
@@ -0,0 +1,1351 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +/*
8 + * Mapping from Unicode codepoints to X11/RFB keysyms
9 + *
10 + * This file was automatically generated from keysymdef.h
11 + * DO NOT EDIT!
12 + */
13 +
14 +/* Functions at the bottom */
15 +
16 +var codepoints = {
17 + 0x0100: 0x03c0,
18 + // XK_Amacron
19 + 0x0101: 0x03e0,
20 + // XK_amacron
21 + 0x0102: 0x01c3,
22 + // XK_Abreve
23 + 0x0103: 0x01e3,
24 + // XK_abreve
25 + 0x0104: 0x01a1,
26 + // XK_Aogonek
27 + 0x0105: 0x01b1,
28 + // XK_aogonek
29 + 0x0106: 0x01c6,
30 + // XK_Cacute
31 + 0x0107: 0x01e6,
32 + // XK_cacute
33 + 0x0108: 0x02c6,
34 + // XK_Ccircumflex
35 + 0x0109: 0x02e6,
36 + // XK_ccircumflex
37 + 0x010a: 0x02c5,
38 + // XK_Cabovedot
39 + 0x010b: 0x02e5,
40 + // XK_cabovedot
41 + 0x010c: 0x01c8,
42 + // XK_Ccaron
43 + 0x010d: 0x01e8,
44 + // XK_ccaron
45 + 0x010e: 0x01cf,
46 + // XK_Dcaron
47 + 0x010f: 0x01ef,
48 + // XK_dcaron
49 + 0x0110: 0x01d0,
50 + // XK_Dstroke
51 + 0x0111: 0x01f0,
52 + // XK_dstroke
53 + 0x0112: 0x03aa,
54 + // XK_Emacron
55 + 0x0113: 0x03ba,
56 + // XK_emacron
57 + 0x0116: 0x03cc,
58 + // XK_Eabovedot
59 + 0x0117: 0x03ec,
60 + // XK_eabovedot
61 + 0x0118: 0x01ca,
62 + // XK_Eogonek
63 + 0x0119: 0x01ea,
64 + // XK_eogonek
65 + 0x011a: 0x01cc,
66 + // XK_Ecaron
67 + 0x011b: 0x01ec,
68 + // XK_ecaron
69 + 0x011c: 0x02d8,
70 + // XK_Gcircumflex
71 + 0x011d: 0x02f8,
72 + // XK_gcircumflex
73 + 0x011e: 0x02ab,
74 + // XK_Gbreve
75 + 0x011f: 0x02bb,
76 + // XK_gbreve
77 + 0x0120: 0x02d5,
78 + // XK_Gabovedot
79 + 0x0121: 0x02f5,
80 + // XK_gabovedot
81 + 0x0122: 0x03ab,
82 + // XK_Gcedilla
83 + 0x0123: 0x03bb,
84 + // XK_gcedilla
85 + 0x0124: 0x02a6,
86 + // XK_Hcircumflex
87 + 0x0125: 0x02b6,
88 + // XK_hcircumflex
89 + 0x0126: 0x02a1,
90 + // XK_Hstroke
91 + 0x0127: 0x02b1,
92 + // XK_hstroke
93 + 0x0128: 0x03a5,
94 + // XK_Itilde
95 + 0x0129: 0x03b5,
96 + // XK_itilde
97 + 0x012a: 0x03cf,
98 + // XK_Imacron
99 + 0x012b: 0x03ef,
100 + // XK_imacron
101 + 0x012e: 0x03c7,
102 + // XK_Iogonek
103 + 0x012f: 0x03e7,
104 + // XK_iogonek
105 + 0x0130: 0x02a9,
106 + // XK_Iabovedot
107 + 0x0131: 0x02b9,
108 + // XK_idotless
109 + 0x0134: 0x02ac,
110 + // XK_Jcircumflex
111 + 0x0135: 0x02bc,
112 + // XK_jcircumflex
113 + 0x0136: 0x03d3,
114 + // XK_Kcedilla
115 + 0x0137: 0x03f3,
116 + // XK_kcedilla
117 + 0x0138: 0x03a2,
118 + // XK_kra
119 + 0x0139: 0x01c5,
120 + // XK_Lacute
121 + 0x013a: 0x01e5,
122 + // XK_lacute
123 + 0x013b: 0x03a6,
124 + // XK_Lcedilla
125 + 0x013c: 0x03b6,
126 + // XK_lcedilla
127 + 0x013d: 0x01a5,
128 + // XK_Lcaron
129 + 0x013e: 0x01b5,
130 + // XK_lcaron
131 + 0x0141: 0x01a3,
132 + // XK_Lstroke
133 + 0x0142: 0x01b3,
134 + // XK_lstroke
135 + 0x0143: 0x01d1,
136 + // XK_Nacute
137 + 0x0144: 0x01f1,
138 + // XK_nacute
139 + 0x0145: 0x03d1,
140 + // XK_Ncedilla
141 + 0x0146: 0x03f1,
142 + // XK_ncedilla
143 + 0x0147: 0x01d2,
144 + // XK_Ncaron
145 + 0x0148: 0x01f2,
146 + // XK_ncaron
147 + 0x014a: 0x03bd,
148 + // XK_ENG
149 + 0x014b: 0x03bf,
150 + // XK_eng
151 + 0x014c: 0x03d2,
152 + // XK_Omacron
153 + 0x014d: 0x03f2,
154 + // XK_omacron
155 + 0x0150: 0x01d5,
156 + // XK_Odoubleacute
157 + 0x0151: 0x01f5,
158 + // XK_odoubleacute
159 + 0x0152: 0x13bc,
160 + // XK_OE
161 + 0x0153: 0x13bd,
162 + // XK_oe
163 + 0x0154: 0x01c0,
164 + // XK_Racute
165 + 0x0155: 0x01e0,
166 + // XK_racute
167 + 0x0156: 0x03a3,
168 + // XK_Rcedilla
169 + 0x0157: 0x03b3,
170 + // XK_rcedilla
171 + 0x0158: 0x01d8,
172 + // XK_Rcaron
173 + 0x0159: 0x01f8,
174 + // XK_rcaron
175 + 0x015a: 0x01a6,
176 + // XK_Sacute
177 + 0x015b: 0x01b6,
178 + // XK_sacute
179 + 0x015c: 0x02de,
180 + // XK_Scircumflex
181 + 0x015d: 0x02fe,
182 + // XK_scircumflex
183 + 0x015e: 0x01aa,
184 + // XK_Scedilla
185 + 0x015f: 0x01ba,
186 + // XK_scedilla
187 + 0x0160: 0x01a9,
188 + // XK_Scaron
189 + 0x0161: 0x01b9,
190 + // XK_scaron
191 + 0x0162: 0x01de,
192 + // XK_Tcedilla
193 + 0x0163: 0x01fe,
194 + // XK_tcedilla
195 + 0x0164: 0x01ab,
196 + // XK_Tcaron
197 + 0x0165: 0x01bb,
198 + // XK_tcaron
199 + 0x0166: 0x03ac,
200 + // XK_Tslash
201 + 0x0167: 0x03bc,
202 + // XK_tslash
203 + 0x0168: 0x03dd,
204 + // XK_Utilde
205 + 0x0169: 0x03fd,
206 + // XK_utilde
207 + 0x016a: 0x03de,
208 + // XK_Umacron
209 + 0x016b: 0x03fe,
210 + // XK_umacron
211 + 0x016c: 0x02dd,
212 + // XK_Ubreve
213 + 0x016d: 0x02fd,
214 + // XK_ubreve
215 + 0x016e: 0x01d9,
216 + // XK_Uring
217 + 0x016f: 0x01f9,
218 + // XK_uring
219 + 0x0170: 0x01db,
220 + // XK_Udoubleacute
221 + 0x0171: 0x01fb,
222 + // XK_udoubleacute
223 + 0x0172: 0x03d9,
224 + // XK_Uogonek
225 + 0x0173: 0x03f9,
226 + // XK_uogonek
227 + 0x0178: 0x13be,
228 + // XK_Ydiaeresis
229 + 0x0179: 0x01ac,
230 + // XK_Zacute
231 + 0x017a: 0x01bc,
232 + // XK_zacute
233 + 0x017b: 0x01af,
234 + // XK_Zabovedot
235 + 0x017c: 0x01bf,
236 + // XK_zabovedot
237 + 0x017d: 0x01ae,
238 + // XK_Zcaron
239 + 0x017e: 0x01be,
240 + // XK_zcaron
241 + 0x0192: 0x08f6,
242 + // XK_function
243 + 0x01d2: 0x10001d1,
244 + // XK_Ocaron
245 + 0x02c7: 0x01b7,
246 + // XK_caron
247 + 0x02d8: 0x01a2,
248 + // XK_breve
249 + 0x02d9: 0x01ff,
250 + // XK_abovedot
251 + 0x02db: 0x01b2,
252 + // XK_ogonek
253 + 0x02dd: 0x01bd,
254 + // XK_doubleacute
255 + 0x0385: 0x07ae,
256 + // XK_Greek_accentdieresis
257 + 0x0386: 0x07a1,
258 + // XK_Greek_ALPHAaccent
259 + 0x0388: 0x07a2,
260 + // XK_Greek_EPSILONaccent
261 + 0x0389: 0x07a3,
262 + // XK_Greek_ETAaccent
263 + 0x038a: 0x07a4,
264 + // XK_Greek_IOTAaccent
265 + 0x038c: 0x07a7,
266 + // XK_Greek_OMICRONaccent
267 + 0x038e: 0x07a8,
268 + // XK_Greek_UPSILONaccent
269 + 0x038f: 0x07ab,
270 + // XK_Greek_OMEGAaccent
271 + 0x0390: 0x07b6,
272 + // XK_Greek_iotaaccentdieresis
273 + 0x0391: 0x07c1,
274 + // XK_Greek_ALPHA
275 + 0x0392: 0x07c2,
276 + // XK_Greek_BETA
277 + 0x0393: 0x07c3,
278 + // XK_Greek_GAMMA
279 + 0x0394: 0x07c4,
280 + // XK_Greek_DELTA
281 + 0x0395: 0x07c5,
282 + // XK_Greek_EPSILON
283 + 0x0396: 0x07c6,
284 + // XK_Greek_ZETA
285 + 0x0397: 0x07c7,
286 + // XK_Greek_ETA
287 + 0x0398: 0x07c8,
288 + // XK_Greek_THETA
289 + 0x0399: 0x07c9,
290 + // XK_Greek_IOTA
291 + 0x039a: 0x07ca,
292 + // XK_Greek_KAPPA
293 + 0x039b: 0x07cb,
294 + // XK_Greek_LAMDA
295 + 0x039c: 0x07cc,
296 + // XK_Greek_MU
297 + 0x039d: 0x07cd,
298 + // XK_Greek_NU
299 + 0x039e: 0x07ce,
300 + // XK_Greek_XI
301 + 0x039f: 0x07cf,
302 + // XK_Greek_OMICRON
303 + 0x03a0: 0x07d0,
304 + // XK_Greek_PI
305 + 0x03a1: 0x07d1,
306 + // XK_Greek_RHO
307 + 0x03a3: 0x07d2,
308 + // XK_Greek_SIGMA
309 + 0x03a4: 0x07d4,
310 + // XK_Greek_TAU
311 + 0x03a5: 0x07d5,
312 + // XK_Greek_UPSILON
313 + 0x03a6: 0x07d6,
314 + // XK_Greek_PHI
315 + 0x03a7: 0x07d7,
316 + // XK_Greek_CHI
317 + 0x03a8: 0x07d8,
318 + // XK_Greek_PSI
319 + 0x03a9: 0x07d9,
320 + // XK_Greek_OMEGA
321 + 0x03aa: 0x07a5,
322 + // XK_Greek_IOTAdieresis
323 + 0x03ab: 0x07a9,
324 + // XK_Greek_UPSILONdieresis
325 + 0x03ac: 0x07b1,
326 + // XK_Greek_alphaaccent
327 + 0x03ad: 0x07b2,
328 + // XK_Greek_epsilonaccent
329 + 0x03ae: 0x07b3,
330 + // XK_Greek_etaaccent
331 + 0x03af: 0x07b4,
332 + // XK_Greek_iotaaccent
333 + 0x03b0: 0x07ba,
334 + // XK_Greek_upsilonaccentdieresis
335 + 0x03b1: 0x07e1,
336 + // XK_Greek_alpha
337 + 0x03b2: 0x07e2,
338 + // XK_Greek_beta
339 + 0x03b3: 0x07e3,
340 + // XK_Greek_gamma
341 + 0x03b4: 0x07e4,
342 + // XK_Greek_delta
343 + 0x03b5: 0x07e5,
344 + // XK_Greek_epsilon
345 + 0x03b6: 0x07e6,
346 + // XK_Greek_zeta
347 + 0x03b7: 0x07e7,
348 + // XK_Greek_eta
349 + 0x03b8: 0x07e8,
350 + // XK_Greek_theta
351 + 0x03b9: 0x07e9,
352 + // XK_Greek_iota
353 + 0x03ba: 0x07ea,
354 + // XK_Greek_kappa
355 + 0x03bb: 0x07eb,
356 + // XK_Greek_lamda
357 + 0x03bc: 0x07ec,
358 + // XK_Greek_mu
359 + 0x03bd: 0x07ed,
360 + // XK_Greek_nu
361 + 0x03be: 0x07ee,
362 + // XK_Greek_xi
363 + 0x03bf: 0x07ef,
364 + // XK_Greek_omicron
365 + 0x03c0: 0x07f0,
366 + // XK_Greek_pi
367 + 0x03c1: 0x07f1,
368 + // XK_Greek_rho
369 + 0x03c2: 0x07f3,
370 + // XK_Greek_finalsmallsigma
371 + 0x03c3: 0x07f2,
372 + // XK_Greek_sigma
373 + 0x03c4: 0x07f4,
374 + // XK_Greek_tau
375 + 0x03c5: 0x07f5,
376 + // XK_Greek_upsilon
377 + 0x03c6: 0x07f6,
378 + // XK_Greek_phi
379 + 0x03c7: 0x07f7,
380 + // XK_Greek_chi
381 + 0x03c8: 0x07f8,
382 + // XK_Greek_psi
383 + 0x03c9: 0x07f9,
384 + // XK_Greek_omega
385 + 0x03ca: 0x07b5,
386 + // XK_Greek_iotadieresis
387 + 0x03cb: 0x07b9,
388 + // XK_Greek_upsilondieresis
389 + 0x03cc: 0x07b7,
390 + // XK_Greek_omicronaccent
391 + 0x03cd: 0x07b8,
392 + // XK_Greek_upsilonaccent
393 + 0x03ce: 0x07bb,
394 + // XK_Greek_omegaaccent
395 + 0x0401: 0x06b3,
396 + // XK_Cyrillic_IO
397 + 0x0402: 0x06b1,
398 + // XK_Serbian_DJE
399 + 0x0403: 0x06b2,
400 + // XK_Macedonia_GJE
401 + 0x0404: 0x06b4,
402 + // XK_Ukrainian_IE
403 + 0x0405: 0x06b5,
404 + // XK_Macedonia_DSE
405 + 0x0406: 0x06b6,
406 + // XK_Ukrainian_I
407 + 0x0407: 0x06b7,
408 + // XK_Ukrainian_YI
409 + 0x0408: 0x06b8,
410 + // XK_Cyrillic_JE
411 + 0x0409: 0x06b9,
412 + // XK_Cyrillic_LJE
413 + 0x040a: 0x06ba,
414 + // XK_Cyrillic_NJE
415 + 0x040b: 0x06bb,
416 + // XK_Serbian_TSHE
417 + 0x040c: 0x06bc,
418 + // XK_Macedonia_KJE
419 + 0x040e: 0x06be,
420 + // XK_Byelorussian_SHORTU
421 + 0x040f: 0x06bf,
422 + // XK_Cyrillic_DZHE
423 + 0x0410: 0x06e1,
424 + // XK_Cyrillic_A
425 + 0x0411: 0x06e2,
426 + // XK_Cyrillic_BE
427 + 0x0412: 0x06f7,
428 + // XK_Cyrillic_VE
429 + 0x0413: 0x06e7,
430 + // XK_Cyrillic_GHE
431 + 0x0414: 0x06e4,
432 + // XK_Cyrillic_DE
433 + 0x0415: 0x06e5,
434 + // XK_Cyrillic_IE
435 + 0x0416: 0x06f6,
436 + // XK_Cyrillic_ZHE
437 + 0x0417: 0x06fa,
438 + // XK_Cyrillic_ZE
439 + 0x0418: 0x06e9,
440 + // XK_Cyrillic_I
441 + 0x0419: 0x06ea,
442 + // XK_Cyrillic_SHORTI
443 + 0x041a: 0x06eb,
444 + // XK_Cyrillic_KA
445 + 0x041b: 0x06ec,
446 + // XK_Cyrillic_EL
447 + 0x041c: 0x06ed,
448 + // XK_Cyrillic_EM
449 + 0x041d: 0x06ee,
450 + // XK_Cyrillic_EN
451 + 0x041e: 0x06ef,
452 + // XK_Cyrillic_O
453 + 0x041f: 0x06f0,
454 + // XK_Cyrillic_PE
455 + 0x0420: 0x06f2,
456 + // XK_Cyrillic_ER
457 + 0x0421: 0x06f3,
458 + // XK_Cyrillic_ES
459 + 0x0422: 0x06f4,
460 + // XK_Cyrillic_TE
461 + 0x0423: 0x06f5,
462 + // XK_Cyrillic_U
463 + 0x0424: 0x06e6,
464 + // XK_Cyrillic_EF
465 + 0x0425: 0x06e8,
466 + // XK_Cyrillic_HA
467 + 0x0426: 0x06e3,
468 + // XK_Cyrillic_TSE
469 + 0x0427: 0x06fe,
470 + // XK_Cyrillic_CHE
471 + 0x0428: 0x06fb,
472 + // XK_Cyrillic_SHA
473 + 0x0429: 0x06fd,
474 + // XK_Cyrillic_SHCHA
475 + 0x042a: 0x06ff,
476 + // XK_Cyrillic_HARDSIGN
477 + 0x042b: 0x06f9,
478 + // XK_Cyrillic_YERU
479 + 0x042c: 0x06f8,
480 + // XK_Cyrillic_SOFTSIGN
481 + 0x042d: 0x06fc,
482 + // XK_Cyrillic_E
483 + 0x042e: 0x06e0,
484 + // XK_Cyrillic_YU
485 + 0x042f: 0x06f1,
486 + // XK_Cyrillic_YA
487 + 0x0430: 0x06c1,
488 + // XK_Cyrillic_a
489 + 0x0431: 0x06c2,
490 + // XK_Cyrillic_be
491 + 0x0432: 0x06d7,
492 + // XK_Cyrillic_ve
493 + 0x0433: 0x06c7,
494 + // XK_Cyrillic_ghe
495 + 0x0434: 0x06c4,
496 + // XK_Cyrillic_de
497 + 0x0435: 0x06c5,
498 + // XK_Cyrillic_ie
499 + 0x0436: 0x06d6,
500 + // XK_Cyrillic_zhe
501 + 0x0437: 0x06da,
502 + // XK_Cyrillic_ze
503 + 0x0438: 0x06c9,
504 + // XK_Cyrillic_i
505 + 0x0439: 0x06ca,
506 + // XK_Cyrillic_shorti
507 + 0x043a: 0x06cb,
508 + // XK_Cyrillic_ka
509 + 0x043b: 0x06cc,
510 + // XK_Cyrillic_el
511 + 0x043c: 0x06cd,
512 + // XK_Cyrillic_em
513 + 0x043d: 0x06ce,
514 + // XK_Cyrillic_en
515 + 0x043e: 0x06cf,
516 + // XK_Cyrillic_o
517 + 0x043f: 0x06d0,
518 + // XK_Cyrillic_pe
519 + 0x0440: 0x06d2,
520 + // XK_Cyrillic_er
521 + 0x0441: 0x06d3,
522 + // XK_Cyrillic_es
523 + 0x0442: 0x06d4,
524 + // XK_Cyrillic_te
525 + 0x0443: 0x06d5,
526 + // XK_Cyrillic_u
527 + 0x0444: 0x06c6,
528 + // XK_Cyrillic_ef
529 + 0x0445: 0x06c8,
530 + // XK_Cyrillic_ha
531 + 0x0446: 0x06c3,
532 + // XK_Cyrillic_tse
533 + 0x0447: 0x06de,
534 + // XK_Cyrillic_che
535 + 0x0448: 0x06db,
536 + // XK_Cyrillic_sha
537 + 0x0449: 0x06dd,
538 + // XK_Cyrillic_shcha
539 + 0x044a: 0x06df,
540 + // XK_Cyrillic_hardsign
541 + 0x044b: 0x06d9,
542 + // XK_Cyrillic_yeru
543 + 0x044c: 0x06d8,
544 + // XK_Cyrillic_softsign
545 + 0x044d: 0x06dc,
546 + // XK_Cyrillic_e
547 + 0x044e: 0x06c0,
548 + // XK_Cyrillic_yu
549 + 0x044f: 0x06d1,
550 + // XK_Cyrillic_ya
551 + 0x0451: 0x06a3,
552 + // XK_Cyrillic_io
553 + 0x0452: 0x06a1,
554 + // XK_Serbian_dje
555 + 0x0453: 0x06a2,
556 + // XK_Macedonia_gje
557 + 0x0454: 0x06a4,
558 + // XK_Ukrainian_ie
559 + 0x0455: 0x06a5,
560 + // XK_Macedonia_dse
561 + 0x0456: 0x06a6,
562 + // XK_Ukrainian_i
563 + 0x0457: 0x06a7,
564 + // XK_Ukrainian_yi
565 + 0x0458: 0x06a8,
566 + // XK_Cyrillic_je
567 + 0x0459: 0x06a9,
568 + // XK_Cyrillic_lje
569 + 0x045a: 0x06aa,
570 + // XK_Cyrillic_nje
571 + 0x045b: 0x06ab,
572 + // XK_Serbian_tshe
573 + 0x045c: 0x06ac,
574 + // XK_Macedonia_kje
575 + 0x045e: 0x06ae,
576 + // XK_Byelorussian_shortu
577 + 0x045f: 0x06af,
578 + // XK_Cyrillic_dzhe
579 + 0x0490: 0x06bd,
580 + // XK_Ukrainian_GHE_WITH_UPTURN
581 + 0x0491: 0x06ad,
582 + // XK_Ukrainian_ghe_with_upturn
583 + 0x05d0: 0x0ce0,
584 + // XK_hebrew_aleph
585 + 0x05d1: 0x0ce1,
586 + // XK_hebrew_bet
587 + 0x05d2: 0x0ce2,
588 + // XK_hebrew_gimel
589 + 0x05d3: 0x0ce3,
590 + // XK_hebrew_dalet
591 + 0x05d4: 0x0ce4,
592 + // XK_hebrew_he
593 + 0x05d5: 0x0ce5,
594 + // XK_hebrew_waw
595 + 0x05d6: 0x0ce6,
596 + // XK_hebrew_zain
597 + 0x05d7: 0x0ce7,
598 + // XK_hebrew_chet
599 + 0x05d8: 0x0ce8,
600 + // XK_hebrew_tet
601 + 0x05d9: 0x0ce9,
602 + // XK_hebrew_yod
603 + 0x05da: 0x0cea,
604 + // XK_hebrew_finalkaph
605 + 0x05db: 0x0ceb,
606 + // XK_hebrew_kaph
607 + 0x05dc: 0x0cec,
608 + // XK_hebrew_lamed
609 + 0x05dd: 0x0ced,
610 + // XK_hebrew_finalmem
611 + 0x05de: 0x0cee,
612 + // XK_hebrew_mem
613 + 0x05df: 0x0cef,
614 + // XK_hebrew_finalnun
615 + 0x05e0: 0x0cf0,
616 + // XK_hebrew_nun
617 + 0x05e1: 0x0cf1,
618 + // XK_hebrew_samech
619 + 0x05e2: 0x0cf2,
620 + // XK_hebrew_ayin
621 + 0x05e3: 0x0cf3,
622 + // XK_hebrew_finalpe
623 + 0x05e4: 0x0cf4,
624 + // XK_hebrew_pe
625 + 0x05e5: 0x0cf5,
626 + // XK_hebrew_finalzade
627 + 0x05e6: 0x0cf6,
628 + // XK_hebrew_zade
629 + 0x05e7: 0x0cf7,
630 + // XK_hebrew_qoph
631 + 0x05e8: 0x0cf8,
632 + // XK_hebrew_resh
633 + 0x05e9: 0x0cf9,
634 + // XK_hebrew_shin
635 + 0x05ea: 0x0cfa,
636 + // XK_hebrew_taw
637 + 0x060c: 0x05ac,
638 + // XK_Arabic_comma
639 + 0x061b: 0x05bb,
640 + // XK_Arabic_semicolon
641 + 0x061f: 0x05bf,
642 + // XK_Arabic_question_mark
643 + 0x0621: 0x05c1,
644 + // XK_Arabic_hamza
645 + 0x0622: 0x05c2,
646 + // XK_Arabic_maddaonalef
647 + 0x0623: 0x05c3,
648 + // XK_Arabic_hamzaonalef
649 + 0x0624: 0x05c4,
650 + // XK_Arabic_hamzaonwaw
651 + 0x0625: 0x05c5,
652 + // XK_Arabic_hamzaunderalef
653 + 0x0626: 0x05c6,
654 + // XK_Arabic_hamzaonyeh
655 + 0x0627: 0x05c7,
656 + // XK_Arabic_alef
657 + 0x0628: 0x05c8,
658 + // XK_Arabic_beh
659 + 0x0629: 0x05c9,
660 + // XK_Arabic_tehmarbuta
661 + 0x062a: 0x05ca,
662 + // XK_Arabic_teh
663 + 0x062b: 0x05cb,
664 + // XK_Arabic_theh
665 + 0x062c: 0x05cc,
666 + // XK_Arabic_jeem
667 + 0x062d: 0x05cd,
668 + // XK_Arabic_hah
669 + 0x062e: 0x05ce,
670 + // XK_Arabic_khah
671 + 0x062f: 0x05cf,
672 + // XK_Arabic_dal
673 + 0x0630: 0x05d0,
674 + // XK_Arabic_thal
675 + 0x0631: 0x05d1,
676 + // XK_Arabic_ra
677 + 0x0632: 0x05d2,
678 + // XK_Arabic_zain
679 + 0x0633: 0x05d3,
680 + // XK_Arabic_seen
681 + 0x0634: 0x05d4,
682 + // XK_Arabic_sheen
683 + 0x0635: 0x05d5,
684 + // XK_Arabic_sad
685 + 0x0636: 0x05d6,
686 + // XK_Arabic_dad
687 + 0x0637: 0x05d7,
688 + // XK_Arabic_tah
689 + 0x0638: 0x05d8,
690 + // XK_Arabic_zah
691 + 0x0639: 0x05d9,
692 + // XK_Arabic_ain
693 + 0x063a: 0x05da,
694 + // XK_Arabic_ghain
695 + 0x0640: 0x05e0,
696 + // XK_Arabic_tatweel
697 + 0x0641: 0x05e1,
698 + // XK_Arabic_feh
699 + 0x0642: 0x05e2,
700 + // XK_Arabic_qaf
701 + 0x0643: 0x05e3,
702 + // XK_Arabic_kaf
703 + 0x0644: 0x05e4,
704 + // XK_Arabic_lam
705 + 0x0645: 0x05e5,
706 + // XK_Arabic_meem
707 + 0x0646: 0x05e6,
708 + // XK_Arabic_noon
709 + 0x0647: 0x05e7,
710 + // XK_Arabic_ha
711 + 0x0648: 0x05e8,
712 + // XK_Arabic_waw
713 + 0x0649: 0x05e9,
714 + // XK_Arabic_alefmaksura
715 + 0x064a: 0x05ea,
716 + // XK_Arabic_yeh
717 + 0x064b: 0x05eb,
718 + // XK_Arabic_fathatan
719 + 0x064c: 0x05ec,
720 + // XK_Arabic_dammatan
721 + 0x064d: 0x05ed,
722 + // XK_Arabic_kasratan
723 + 0x064e: 0x05ee,
724 + // XK_Arabic_fatha
725 + 0x064f: 0x05ef,
726 + // XK_Arabic_damma
727 + 0x0650: 0x05f0,
728 + // XK_Arabic_kasra
729 + 0x0651: 0x05f1,
730 + // XK_Arabic_shadda
731 + 0x0652: 0x05f2,
732 + // XK_Arabic_sukun
733 + 0x0e01: 0x0da1,
734 + // XK_Thai_kokai
735 + 0x0e02: 0x0da2,
736 + // XK_Thai_khokhai
737 + 0x0e03: 0x0da3,
738 + // XK_Thai_khokhuat
739 + 0x0e04: 0x0da4,
740 + // XK_Thai_khokhwai
741 + 0x0e05: 0x0da5,
742 + // XK_Thai_khokhon
743 + 0x0e06: 0x0da6,
744 + // XK_Thai_khorakhang
745 + 0x0e07: 0x0da7,
746 + // XK_Thai_ngongu
747 + 0x0e08: 0x0da8,
748 + // XK_Thai_chochan
749 + 0x0e09: 0x0da9,
750 + // XK_Thai_choching
751 + 0x0e0a: 0x0daa,
752 + // XK_Thai_chochang
753 + 0x0e0b: 0x0dab,
754 + // XK_Thai_soso
755 + 0x0e0c: 0x0dac,
756 + // XK_Thai_chochoe
757 + 0x0e0d: 0x0dad,
758 + // XK_Thai_yoying
759 + 0x0e0e: 0x0dae,
760 + // XK_Thai_dochada
761 + 0x0e0f: 0x0daf,
762 + // XK_Thai_topatak
763 + 0x0e10: 0x0db0,
764 + // XK_Thai_thothan
765 + 0x0e11: 0x0db1,
766 + // XK_Thai_thonangmontho
767 + 0x0e12: 0x0db2,
768 + // XK_Thai_thophuthao
769 + 0x0e13: 0x0db3,
770 + // XK_Thai_nonen
771 + 0x0e14: 0x0db4,
772 + // XK_Thai_dodek
773 + 0x0e15: 0x0db5,
774 + // XK_Thai_totao
775 + 0x0e16: 0x0db6,
776 + // XK_Thai_thothung
777 + 0x0e17: 0x0db7,
778 + // XK_Thai_thothahan
779 + 0x0e18: 0x0db8,
780 + // XK_Thai_thothong
781 + 0x0e19: 0x0db9,
782 + // XK_Thai_nonu
783 + 0x0e1a: 0x0dba,
784 + // XK_Thai_bobaimai
785 + 0x0e1b: 0x0dbb,
786 + // XK_Thai_popla
787 + 0x0e1c: 0x0dbc,
788 + // XK_Thai_phophung
789 + 0x0e1d: 0x0dbd,
790 + // XK_Thai_fofa
791 + 0x0e1e: 0x0dbe,
792 + // XK_Thai_phophan
793 + 0x0e1f: 0x0dbf,
794 + // XK_Thai_fofan
795 + 0x0e20: 0x0dc0,
796 + // XK_Thai_phosamphao
797 + 0x0e21: 0x0dc1,
798 + // XK_Thai_moma
799 + 0x0e22: 0x0dc2,
800 + // XK_Thai_yoyak
801 + 0x0e23: 0x0dc3,
802 + // XK_Thai_rorua
803 + 0x0e24: 0x0dc4,
804 + // XK_Thai_ru
805 + 0x0e25: 0x0dc5,
806 + // XK_Thai_loling
807 + 0x0e26: 0x0dc6,
808 + // XK_Thai_lu
809 + 0x0e27: 0x0dc7,
810 + // XK_Thai_wowaen
811 + 0x0e28: 0x0dc8,
812 + // XK_Thai_sosala
813 + 0x0e29: 0x0dc9,
814 + // XK_Thai_sorusi
815 + 0x0e2a: 0x0dca,
816 + // XK_Thai_sosua
817 + 0x0e2b: 0x0dcb,
818 + // XK_Thai_hohip
819 + 0x0e2c: 0x0dcc,
820 + // XK_Thai_lochula
821 + 0x0e2d: 0x0dcd,
822 + // XK_Thai_oang
823 + 0x0e2e: 0x0dce,
824 + // XK_Thai_honokhuk
825 + 0x0e2f: 0x0dcf,
826 + // XK_Thai_paiyannoi
827 + 0x0e30: 0x0dd0,
828 + // XK_Thai_saraa
829 + 0x0e31: 0x0dd1,
830 + // XK_Thai_maihanakat
831 + 0x0e32: 0x0dd2,
832 + // XK_Thai_saraaa
833 + 0x0e33: 0x0dd3,
834 + // XK_Thai_saraam
835 + 0x0e34: 0x0dd4,
836 + // XK_Thai_sarai
837 + 0x0e35: 0x0dd5,
838 + // XK_Thai_saraii
839 + 0x0e36: 0x0dd6,
840 + // XK_Thai_saraue
841 + 0x0e37: 0x0dd7,
842 + // XK_Thai_sarauee
843 + 0x0e38: 0x0dd8,
844 + // XK_Thai_sarau
845 + 0x0e39: 0x0dd9,
846 + // XK_Thai_sarauu
847 + 0x0e3a: 0x0dda,
848 + // XK_Thai_phinthu
849 + 0x0e3f: 0x0ddf,
850 + // XK_Thai_baht
851 + 0x0e40: 0x0de0,
852 + // XK_Thai_sarae
853 + 0x0e41: 0x0de1,
854 + // XK_Thai_saraae
855 + 0x0e42: 0x0de2,
856 + // XK_Thai_sarao
857 + 0x0e43: 0x0de3,
858 + // XK_Thai_saraaimaimuan
859 + 0x0e44: 0x0de4,
860 + // XK_Thai_saraaimaimalai
861 + 0x0e45: 0x0de5,
862 + // XK_Thai_lakkhangyao
863 + 0x0e46: 0x0de6,
864 + // XK_Thai_maiyamok
865 + 0x0e47: 0x0de7,
866 + // XK_Thai_maitaikhu
867 + 0x0e48: 0x0de8,
868 + // XK_Thai_maiek
869 + 0x0e49: 0x0de9,
870 + // XK_Thai_maitho
871 + 0x0e4a: 0x0dea,
872 + // XK_Thai_maitri
873 + 0x0e4b: 0x0deb,
874 + // XK_Thai_maichattawa
875 + 0x0e4c: 0x0dec,
876 + // XK_Thai_thanthakhat
877 + 0x0e4d: 0x0ded,
878 + // XK_Thai_nikhahit
879 + 0x0e50: 0x0df0,
880 + // XK_Thai_leksun
881 + 0x0e51: 0x0df1,
882 + // XK_Thai_leknung
883 + 0x0e52: 0x0df2,
884 + // XK_Thai_leksong
885 + 0x0e53: 0x0df3,
886 + // XK_Thai_leksam
887 + 0x0e54: 0x0df4,
888 + // XK_Thai_leksi
889 + 0x0e55: 0x0df5,
890 + // XK_Thai_lekha
891 + 0x0e56: 0x0df6,
892 + // XK_Thai_lekhok
893 + 0x0e57: 0x0df7,
894 + // XK_Thai_lekchet
895 + 0x0e58: 0x0df8,
896 + // XK_Thai_lekpaet
897 + 0x0e59: 0x0df9,
898 + // XK_Thai_lekkao
899 + 0x2002: 0x0aa2,
900 + // XK_enspace
901 + 0x2003: 0x0aa1,
902 + // XK_emspace
903 + 0x2004: 0x0aa3,
904 + // XK_em3space
905 + 0x2005: 0x0aa4,
906 + // XK_em4space
907 + 0x2007: 0x0aa5,
908 + // XK_digitspace
909 + 0x2008: 0x0aa6,
910 + // XK_punctspace
911 + 0x2009: 0x0aa7,
912 + // XK_thinspace
913 + 0x200a: 0x0aa8,
914 + // XK_hairspace
915 + 0x2012: 0x0abb,
916 + // XK_figdash
917 + 0x2013: 0x0aaa,
918 + // XK_endash
919 + 0x2014: 0x0aa9,
920 + // XK_emdash
921 + 0x2015: 0x07af,
922 + // XK_Greek_horizbar
923 + 0x2017: 0x0cdf,
924 + // XK_hebrew_doublelowline
925 + 0x2018: 0x0ad0,
926 + // XK_leftsinglequotemark
927 + 0x2019: 0x0ad1,
928 + // XK_rightsinglequotemark
929 + 0x201a: 0x0afd,
930 + // XK_singlelowquotemark
931 + 0x201c: 0x0ad2,
932 + // XK_leftdoublequotemark
933 + 0x201d: 0x0ad3,
934 + // XK_rightdoublequotemark
935 + 0x201e: 0x0afe,
936 + // XK_doublelowquotemark
937 + 0x2020: 0x0af1,
938 + // XK_dagger
939 + 0x2021: 0x0af2,
940 + // XK_doubledagger
941 + 0x2022: 0x0ae6,
942 + // XK_enfilledcircbullet
943 + 0x2025: 0x0aaf,
944 + // XK_doubbaselinedot
945 + 0x2026: 0x0aae,
946 + // XK_ellipsis
947 + 0x2030: 0x0ad5,
948 + // XK_permille
949 + 0x2032: 0x0ad6,
950 + // XK_minutes
951 + 0x2033: 0x0ad7,
952 + // XK_seconds
953 + 0x2038: 0x0afc,
954 + // XK_caret
955 + 0x203e: 0x047e,
956 + // XK_overline
957 + 0x20a9: 0x0eff,
958 + // XK_Korean_Won
959 + 0x20ac: 0x20ac,
960 + // XK_EuroSign
961 + 0x2105: 0x0ab8,
962 + // XK_careof
963 + 0x2116: 0x06b0,
964 + // XK_numerosign
965 + 0x2117: 0x0afb,
966 + // XK_phonographcopyright
967 + 0x211e: 0x0ad4,
968 + // XK_prescription
969 + 0x2122: 0x0ac9,
970 + // XK_trademark
971 + 0x2153: 0x0ab0,
972 + // XK_onethird
973 + 0x2154: 0x0ab1,
974 + // XK_twothirds
975 + 0x2155: 0x0ab2,
976 + // XK_onefifth
977 + 0x2156: 0x0ab3,
978 + // XK_twofifths
979 + 0x2157: 0x0ab4,
980 + // XK_threefifths
981 + 0x2158: 0x0ab5,
982 + // XK_fourfifths
983 + 0x2159: 0x0ab6,
984 + // XK_onesixth
985 + 0x215a: 0x0ab7,
986 + // XK_fivesixths
987 + 0x215b: 0x0ac3,
988 + // XK_oneeighth
989 + 0x215c: 0x0ac4,
990 + // XK_threeeighths
991 + 0x215d: 0x0ac5,
992 + // XK_fiveeighths
993 + 0x215e: 0x0ac6,
994 + // XK_seveneighths
995 + 0x2190: 0x08fb,
996 + // XK_leftarrow
997 + 0x2191: 0x08fc,
998 + // XK_uparrow
999 + 0x2192: 0x08fd,
1000 + // XK_rightarrow
1001 + 0x2193: 0x08fe,
1002 + // XK_downarrow
1003 + 0x21d2: 0x08ce,
1004 + // XK_implies
1005 + 0x21d4: 0x08cd,
1006 + // XK_ifonlyif
1007 + 0x2202: 0x08ef,
1008 + // XK_partialderivative
1009 + 0x2207: 0x08c5,
1010 + // XK_nabla
1011 + 0x2218: 0x0bca,
1012 + // XK_jot
1013 + 0x221a: 0x08d6,
1014 + // XK_radical
1015 + 0x221d: 0x08c1,
1016 + // XK_variation
1017 + 0x221e: 0x08c2,
1018 + // XK_infinity
1019 + 0x2227: 0x08de,
1020 + // XK_logicaland
1021 + 0x2228: 0x08df,
1022 + // XK_logicalor
1023 + 0x2229: 0x08dc,
1024 + // XK_intersection
1025 + 0x222a: 0x08dd,
1026 + // XK_union
1027 + 0x222b: 0x08bf,
1028 + // XK_integral
1029 + 0x2234: 0x08c0,
1030 + // XK_therefore
1031 + 0x223c: 0x08c8,
1032 + // XK_approximate
1033 + 0x2243: 0x08c9,
1034 + // XK_similarequal
1035 + 0x2245: 0x1002248,
1036 + // XK_approxeq
1037 + 0x2260: 0x08bd,
1038 + // XK_notequal
1039 + 0x2261: 0x08cf,
1040 + // XK_identical
1041 + 0x2264: 0x08bc,
1042 + // XK_lessthanequal
1043 + 0x2265: 0x08be,
1044 + // XK_greaterthanequal
1045 + 0x2282: 0x08da,
1046 + // XK_includedin
1047 + 0x2283: 0x08db,
1048 + // XK_includes
1049 + 0x22a2: 0x0bfc,
1050 + // XK_righttack
1051 + 0x22a3: 0x0bdc,
1052 + // XK_lefttack
1053 + 0x22a4: 0x0bc2,
1054 + // XK_downtack
1055 + 0x22a5: 0x0bce,
1056 + // XK_uptack
1057 + 0x2308: 0x0bd3,
1058 + // XK_upstile
1059 + 0x230a: 0x0bc4,
1060 + // XK_downstile
1061 + 0x2315: 0x0afa,
1062 + // XK_telephonerecorder
1063 + 0x2320: 0x08a4,
1064 + // XK_topintegral
1065 + 0x2321: 0x08a5,
1066 + // XK_botintegral
1067 + 0x2395: 0x0bcc,
1068 + // XK_quad
1069 + 0x239b: 0x08ab,
1070 + // XK_topleftparens
1071 + 0x239d: 0x08ac,
1072 + // XK_botleftparens
1073 + 0x239e: 0x08ad,
1074 + // XK_toprightparens
1075 + 0x23a0: 0x08ae,
1076 + // XK_botrightparens
1077 + 0x23a1: 0x08a7,
1078 + // XK_topleftsqbracket
1079 + 0x23a3: 0x08a8,
1080 + // XK_botleftsqbracket
1081 + 0x23a4: 0x08a9,
1082 + // XK_toprightsqbracket
1083 + 0x23a6: 0x08aa,
1084 + // XK_botrightsqbracket
1085 + 0x23a8: 0x08af,
1086 + // XK_leftmiddlecurlybrace
1087 + 0x23ac: 0x08b0,
1088 + // XK_rightmiddlecurlybrace
1089 + 0x23b7: 0x08a1,
1090 + // XK_leftradical
1091 + 0x23ba: 0x09ef,
1092 + // XK_horizlinescan1
1093 + 0x23bb: 0x09f0,
1094 + // XK_horizlinescan3
1095 + 0x23bc: 0x09f2,
1096 + // XK_horizlinescan7
1097 + 0x23bd: 0x09f3,
1098 + // XK_horizlinescan9
1099 + 0x2409: 0x09e2,
1100 + // XK_ht
1101 + 0x240a: 0x09e5,
1102 + // XK_lf
1103 + 0x240b: 0x09e9,
1104 + // XK_vt
1105 + 0x240c: 0x09e3,
1106 + // XK_ff
1107 + 0x240d: 0x09e4,
1108 + // XK_cr
1109 + 0x2423: 0x0aac,
1110 + // XK_signifblank
1111 + 0x2424: 0x09e8,
1112 + // XK_nl
1113 + 0x2500: 0x08a3,
1114 + // XK_horizconnector
1115 + 0x2502: 0x08a6,
1116 + // XK_vertconnector
1117 + 0x250c: 0x08a2,
1118 + // XK_topleftradical
1119 + 0x2510: 0x09eb,
1120 + // XK_uprightcorner
1121 + 0x2514: 0x09ed,
1122 + // XK_lowleftcorner
1123 + 0x2518: 0x09ea,
1124 + // XK_lowrightcorner
1125 + 0x251c: 0x09f4,
1126 + // XK_leftt
1127 + 0x2524: 0x09f5,
1128 + // XK_rightt
1129 + 0x252c: 0x09f7,
1130 + // XK_topt
1131 + 0x2534: 0x09f6,
1132 + // XK_bott
1133 + 0x253c: 0x09ee,
1134 + // XK_crossinglines
1135 + 0x2592: 0x09e1,
1136 + // XK_checkerboard
1137 + 0x25aa: 0x0ae7,
1138 + // XK_enfilledsqbullet
1139 + 0x25ab: 0x0ae1,
1140 + // XK_enopensquarebullet
1141 + 0x25ac: 0x0adb,
1142 + // XK_filledrectbullet
1143 + 0x25ad: 0x0ae2,
1144 + // XK_openrectbullet
1145 + 0x25ae: 0x0adf,
1146 + // XK_emfilledrect
1147 + 0x25af: 0x0acf,
1148 + // XK_emopenrectangle
1149 + 0x25b2: 0x0ae8,
1150 + // XK_filledtribulletup
1151 + 0x25b3: 0x0ae3,
1152 + // XK_opentribulletup
1153 + 0x25b6: 0x0add,
1154 + // XK_filledrighttribullet
1155 + 0x25b7: 0x0acd,
1156 + // XK_rightopentriangle
1157 + 0x25bc: 0x0ae9,
1158 + // XK_filledtribulletdown
1159 + 0x25bd: 0x0ae4,
1160 + // XK_opentribulletdown
1161 + 0x25c0: 0x0adc,
1162 + // XK_filledlefttribullet
1163 + 0x25c1: 0x0acc,
1164 + // XK_leftopentriangle
1165 + 0x25c6: 0x09e0,
1166 + // XK_soliddiamond
1167 + 0x25cb: 0x0ace,
1168 + // XK_emopencircle
1169 + 0x25cf: 0x0ade,
1170 + // XK_emfilledcircle
1171 + 0x25e6: 0x0ae0,
1172 + // XK_enopencircbullet
1173 + 0x2606: 0x0ae5,
1174 + // XK_openstar
1175 + 0x260e: 0x0af9,
1176 + // XK_telephone
1177 + 0x2613: 0x0aca,
1178 + // XK_signaturemark
1179 + 0x261c: 0x0aea,
1180 + // XK_leftpointer
1181 + 0x261e: 0x0aeb,
1182 + // XK_rightpointer
1183 + 0x2640: 0x0af8,
1184 + // XK_femalesymbol
1185 + 0x2642: 0x0af7,
1186 + // XK_malesymbol
1187 + 0x2663: 0x0aec,
1188 + // XK_club
1189 + 0x2665: 0x0aee,
1190 + // XK_heart
1191 + 0x2666: 0x0aed,
1192 + // XK_diamond
1193 + 0x266d: 0x0af6,
1194 + // XK_musicalflat
1195 + 0x266f: 0x0af5,
1196 + // XK_musicalsharp
1197 + 0x2713: 0x0af3,
1198 + // XK_checkmark
1199 + 0x2717: 0x0af4,
1200 + // XK_ballotcross
1201 + 0x271d: 0x0ad9,
1202 + // XK_latincross
1203 + 0x2720: 0x0af0,
1204 + // XK_maltesecross
1205 + 0x27e8: 0x0abc,
1206 + // XK_leftanglebracket
1207 + 0x27e9: 0x0abe,
1208 + // XK_rightanglebracket
1209 + 0x3001: 0x04a4,
1210 + // XK_kana_comma
1211 + 0x3002: 0x04a1,
1212 + // XK_kana_fullstop
1213 + 0x300c: 0x04a2,
1214 + // XK_kana_openingbracket
1215 + 0x300d: 0x04a3,
1216 + // XK_kana_closingbracket
1217 + 0x309b: 0x04de,
1218 + // XK_voicedsound
1219 + 0x309c: 0x04df,
1220 + // XK_semivoicedsound
1221 + 0x30a1: 0x04a7,
1222 + // XK_kana_a
1223 + 0x30a2: 0x04b1,
1224 + // XK_kana_A
1225 + 0x30a3: 0x04a8,
1226 + // XK_kana_i
1227 + 0x30a4: 0x04b2,
1228 + // XK_kana_I
1229 + 0x30a5: 0x04a9,
1230 + // XK_kana_u
1231 + 0x30a6: 0x04b3,
1232 + // XK_kana_U
1233 + 0x30a7: 0x04aa,
1234 + // XK_kana_e
1235 + 0x30a8: 0x04b4,
1236 + // XK_kana_E
1237 + 0x30a9: 0x04ab,
1238 + // XK_kana_o
1239 + 0x30aa: 0x04b5,
1240 + // XK_kana_O
1241 + 0x30ab: 0x04b6,
1242 + // XK_kana_KA
1243 + 0x30ad: 0x04b7,
1244 + // XK_kana_KI
1245 + 0x30af: 0x04b8,
1246 + // XK_kana_KU
1247 + 0x30b1: 0x04b9,
1248 + // XK_kana_KE
1249 + 0x30b3: 0x04ba,
1250 + // XK_kana_KO
1251 + 0x30b5: 0x04bb,
1252 + // XK_kana_SA
1253 + 0x30b7: 0x04bc,
1254 + // XK_kana_SHI
1255 + 0x30b9: 0x04bd,
1256 + // XK_kana_SU
1257 + 0x30bb: 0x04be,
1258 + // XK_kana_SE
1259 + 0x30bd: 0x04bf,
1260 + // XK_kana_SO
1261 + 0x30bf: 0x04c0,
1262 + // XK_kana_TA
1263 + 0x30c1: 0x04c1,
1264 + // XK_kana_CHI
1265 + 0x30c3: 0x04af,
1266 + // XK_kana_tsu
1267 + 0x30c4: 0x04c2,
1268 + // XK_kana_TSU
1269 + 0x30c6: 0x04c3,
1270 + // XK_kana_TE
1271 + 0x30c8: 0x04c4,
1272 + // XK_kana_TO
1273 + 0x30ca: 0x04c5,
1274 + // XK_kana_NA
1275 + 0x30cb: 0x04c6,
1276 + // XK_kana_NI
1277 + 0x30cc: 0x04c7,
1278 + // XK_kana_NU
1279 + 0x30cd: 0x04c8,
1280 + // XK_kana_NE
1281 + 0x30ce: 0x04c9,
1282 + // XK_kana_NO
1283 + 0x30cf: 0x04ca,
1284 + // XK_kana_HA
1285 + 0x30d2: 0x04cb,
1286 + // XK_kana_HI
1287 + 0x30d5: 0x04cc,
1288 + // XK_kana_FU
1289 + 0x30d8: 0x04cd,
1290 + // XK_kana_HE
1291 + 0x30db: 0x04ce,
1292 + // XK_kana_HO
1293 + 0x30de: 0x04cf,
1294 + // XK_kana_MA
1295 + 0x30df: 0x04d0,
1296 + // XK_kana_MI
1297 + 0x30e0: 0x04d1,
1298 + // XK_kana_MU
1299 + 0x30e1: 0x04d2,
1300 + // XK_kana_ME
1301 + 0x30e2: 0x04d3,
1302 + // XK_kana_MO
1303 + 0x30e3: 0x04ac,
1304 + // XK_kana_ya
1305 + 0x30e4: 0x04d4,
1306 + // XK_kana_YA
1307 + 0x30e5: 0x04ad,
1308 + // XK_kana_yu
1309 + 0x30e6: 0x04d5,
1310 + // XK_kana_YU
1311 + 0x30e7: 0x04ae,
1312 + // XK_kana_yo
1313 + 0x30e8: 0x04d6,
1314 + // XK_kana_YO
1315 + 0x30e9: 0x04d7,
1316 + // XK_kana_RA
1317 + 0x30ea: 0x04d8,
1318 + // XK_kana_RI
1319 + 0x30eb: 0x04d9,
1320 + // XK_kana_RU
1321 + 0x30ec: 0x04da,
1322 + // XK_kana_RE
1323 + 0x30ed: 0x04db,
1324 + // XK_kana_RO
1325 + 0x30ef: 0x04dc,
1326 + // XK_kana_WA
1327 + 0x30f2: 0x04a6,
1328 + // XK_kana_WO
1329 + 0x30f3: 0x04dd,
1330 + // XK_kana_N
1331 + 0x30fb: 0x04a5,
1332 + // XK_kana_conjunctive
1333 + 0x30fc: 0x04b0 // XK_prolongedsound
1334 +};
1335 +var _default = exports["default"] = {
1336 + lookup: function lookup(u) {
1337 + // Latin-1 is one-to-one mapping
1338 + if (u >= 0x20 && u <= 0xff) {
1339 + return u;
1340 + }
1341 +
1342 + // Lookup table (fairly random)
1343 + var keysym = codepoints[u];
1344 + if (keysym !== undefined) {
1345 + return keysym;
1346 + }
1347 +
1348 + // General mapping as final fallback
1349 + return 0x01000000 | u;
1350 + }
1351 +};
\ No newline at end of file
added public/vendor/novnc/input/util.js +217 −0
@@ -0,0 +1,217 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports.getKey = getKey;
8 +exports.getKeycode = getKeycode;
9 +exports.getKeysym = getKeysym;
10 +var _keysym = _interopRequireDefault(require("./keysym.js"));
11 +var _keysymdef = _interopRequireDefault(require("./keysymdef.js"));
12 +var _vkeys = _interopRequireDefault(require("./vkeys.js"));
13 +var _fixedkeys = _interopRequireDefault(require("./fixedkeys.js"));
14 +var _domkeytable = _interopRequireDefault(require("./domkeytable.js"));
15 +var browser = _interopRequireWildcard(require("../util/browser.js"));
16 +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); }
17 +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; }
18 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19 +// Get 'KeyboardEvent.code', handling legacy browsers
20 +function getKeycode(evt) {
21 + // Are we getting proper key identifiers?
22 + // (unfortunately Firefox and Chrome are crappy here and gives
23 + // us an empty string on some platforms, rather than leaving it
24 + // undefined)
25 + if (evt.code) {
26 + // Mozilla isn't fully in sync with the spec yet
27 + switch (evt.code) {
28 + case 'OSLeft':
29 + return 'MetaLeft';
30 + case 'OSRight':
31 + return 'MetaRight';
32 + }
33 + return evt.code;
34 + }
35 +
36 + // The de-facto standard is to use Windows Virtual-Key codes
37 + // in the 'keyCode' field for non-printable characters
38 + if (evt.keyCode in _vkeys["default"]) {
39 + var code = _vkeys["default"][evt.keyCode];
40 +
41 + // macOS has messed up this code for some reason
42 + if (browser.isMac() && code === 'ContextMenu') {
43 + code = 'MetaRight';
44 + }
45 +
46 + // The keyCode doesn't distinguish between left and right
47 + // for the standard modifiers
48 + if (evt.location === 2) {
49 + switch (code) {
50 + case 'ShiftLeft':
51 + return 'ShiftRight';
52 + case 'ControlLeft':
53 + return 'ControlRight';
54 + case 'AltLeft':
55 + return 'AltRight';
56 + }
57 + }
58 +
59 + // Nor a bunch of the numpad keys
60 + if (evt.location === 3) {
61 + switch (code) {
62 + case 'Delete':
63 + return 'NumpadDecimal';
64 + case 'Insert':
65 + return 'Numpad0';
66 + case 'End':
67 + return 'Numpad1';
68 + case 'ArrowDown':
69 + return 'Numpad2';
70 + case 'PageDown':
71 + return 'Numpad3';
72 + case 'ArrowLeft':
73 + return 'Numpad4';
74 + case 'ArrowRight':
75 + return 'Numpad6';
76 + case 'Home':
77 + return 'Numpad7';
78 + case 'ArrowUp':
79 + return 'Numpad8';
80 + case 'PageUp':
81 + return 'Numpad9';
82 + case 'Enter':
83 + return 'NumpadEnter';
84 + }
85 + }
86 + return code;
87 + }
88 + return 'Unidentified';
89 +}
90 +
91 +// Get 'KeyboardEvent.key', handling legacy browsers
92 +function getKey(evt) {
93 + // Are we getting a proper key value?
94 + if (evt.key !== undefined && evt.key !== 'Unidentified') {
95 + // Mozilla isn't fully in sync with the spec yet
96 + switch (evt.key) {
97 + case 'OS':
98 + return 'Meta';
99 + case 'LaunchMyComputer':
100 + return 'LaunchApplication1';
101 + case 'LaunchCalculator':
102 + return 'LaunchApplication2';
103 + }
104 +
105 + // iOS leaks some OS names
106 + switch (evt.key) {
107 + case 'UIKeyInputUpArrow':
108 + return 'ArrowUp';
109 + case 'UIKeyInputDownArrow':
110 + return 'ArrowDown';
111 + case 'UIKeyInputLeftArrow':
112 + return 'ArrowLeft';
113 + case 'UIKeyInputRightArrow':
114 + return 'ArrowRight';
115 + case 'UIKeyInputEscape':
116 + return 'Escape';
117 + }
118 +
119 + // Broken behaviour in Chrome
120 + if (evt.key === '\x00' && evt.code === 'NumpadDecimal') {
121 + return 'Delete';
122 + }
123 + return evt.key;
124 + }
125 +
126 + // Try to deduce it based on the physical key
127 + var code = getKeycode(evt);
128 + if (code in _fixedkeys["default"]) {
129 + return _fixedkeys["default"][code];
130 + }
131 +
132 + // If that failed, then see if we have a printable character
133 + if (evt.charCode) {
134 + return String.fromCharCode(evt.charCode);
135 + }
136 +
137 + // At this point we have nothing left to go on
138 + return 'Unidentified';
139 +}
140 +
141 +// Get the most reliable keysym value we can get from a key event
142 +function getKeysym(evt) {
143 + var key = getKey(evt);
144 + if (key === 'Unidentified') {
145 + return null;
146 + }
147 +
148 + // First look up special keys
149 + if (key in _domkeytable["default"]) {
150 + var location = evt.location;
151 +
152 + // Safari screws up location for the right cmd key
153 + if (key === 'Meta' && location === 0) {
154 + location = 2;
155 + }
156 +
157 + // And for Clear
158 + if (key === 'Clear' && location === 3) {
159 + var code = getKeycode(evt);
160 + if (code === 'NumLock') {
161 + location = 0;
162 + }
163 + }
164 + if (location === undefined || location > 3) {
165 + location = 0;
166 + }
167 +
168 + // The original Meta key now gets confused with the Windows key
169 + // https://bugs.chromium.org/p/chromium/issues/detail?id=1020141
170 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1232918
171 + if (key === 'Meta') {
172 + var _code = getKeycode(evt);
173 + if (_code === 'AltLeft') {
174 + return _keysym["default"].XK_Meta_L;
175 + } else if (_code === 'AltRight') {
176 + return _keysym["default"].XK_Meta_R;
177 + }
178 + }
179 +
180 + // macOS has Clear instead of NumLock, but the remote system is
181 + // probably not macOS, so lying here is probably best...
182 + if (key === 'Clear') {
183 + var _code2 = getKeycode(evt);
184 + if (_code2 === 'NumLock') {
185 + return _keysym["default"].XK_Num_Lock;
186 + }
187 + }
188 +
189 + // Windows sends alternating symbols for some keys when using a
190 + // Japanese layout. We have no way of synchronising with the IM
191 + // running on the remote system, so we send some combined keysym
192 + // instead and hope for the best.
193 + if (browser.isWindows()) {
194 + switch (key) {
195 + case 'Zenkaku':
196 + case 'Hankaku':
197 + return _keysym["default"].XK_Zenkaku_Hankaku;
198 + case 'Romaji':
199 + case 'KanaMode':
200 + return _keysym["default"].XK_Romaji;
201 + }
202 + }
203 + return _domkeytable["default"][key][location];
204 + }
205 +
206 + // Now we need to look at the Unicode symbol instead
207 +
208 + // Special key? (FIXME: Should have been caught earlier)
209 + if (key.length !== 1) {
210 + return null;
211 + }
212 + var codepoint = key.charCodeAt();
213 + if (codepoint) {
214 + return _keysymdef["default"].lookup(codepoint);
215 + }
216 + return null;
217 +}
\ No newline at end of file
added public/vendor/novnc/input/vkeys.js +121 −0
@@ -0,0 +1,121 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +/*
8 + * noVNC: HTML5 VNC client
9 + * Copyright (C) 2018 The noVNC authors
10 + * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
11 + */
12 +/*
13 + * Mapping between Microsoft® Windows® Virtual-Key codes and
14 + * HTML key codes.
15 + */
16 +var _default = exports["default"] = {
17 + 0x08: 'Backspace',
18 + 0x09: 'Tab',
19 + 0x0a: 'NumpadClear',
20 + 0x0d: 'Enter',
21 + 0x10: 'ShiftLeft',
22 + 0x11: 'ControlLeft',
23 + 0x12: 'AltLeft',
24 + 0x13: 'Pause',
25 + 0x14: 'CapsLock',
26 + 0x15: 'Lang1',
27 + 0x19: 'Lang2',
28 + 0x1b: 'Escape',
29 + 0x1c: 'Convert',
30 + 0x1d: 'NonConvert',
31 + 0x20: 'Space',
32 + 0x21: 'PageUp',
33 + 0x22: 'PageDown',
34 + 0x23: 'End',
35 + 0x24: 'Home',
36 + 0x25: 'ArrowLeft',
37 + 0x26: 'ArrowUp',
38 + 0x27: 'ArrowRight',
39 + 0x28: 'ArrowDown',
40 + 0x29: 'Select',
41 + 0x2c: 'PrintScreen',
42 + 0x2d: 'Insert',
43 + 0x2e: 'Delete',
44 + 0x2f: 'Help',
45 + 0x30: 'Digit0',
46 + 0x31: 'Digit1',
47 + 0x32: 'Digit2',
48 + 0x33: 'Digit3',
49 + 0x34: 'Digit4',
50 + 0x35: 'Digit5',
51 + 0x36: 'Digit6',
52 + 0x37: 'Digit7',
53 + 0x38: 'Digit8',
54 + 0x39: 'Digit9',
55 + 0x5b: 'MetaLeft',
56 + 0x5c: 'MetaRight',
57 + 0x5d: 'ContextMenu',
58 + 0x5f: 'Sleep',
59 + 0x60: 'Numpad0',
60 + 0x61: 'Numpad1',
61 + 0x62: 'Numpad2',
62 + 0x63: 'Numpad3',
63 + 0x64: 'Numpad4',
64 + 0x65: 'Numpad5',
65 + 0x66: 'Numpad6',
66 + 0x67: 'Numpad7',
67 + 0x68: 'Numpad8',
68 + 0x69: 'Numpad9',
69 + 0x6a: 'NumpadMultiply',
70 + 0x6b: 'NumpadAdd',
71 + 0x6c: 'NumpadDecimal',
72 + 0x6d: 'NumpadSubtract',
73 + 0x6e: 'NumpadDecimal',
74 + // Duplicate, because buggy on Windows
75 + 0x6f: 'NumpadDivide',
76 + 0x70: 'F1',
77 + 0x71: 'F2',
78 + 0x72: 'F3',
79 + 0x73: 'F4',
80 + 0x74: 'F5',
81 + 0x75: 'F6',
82 + 0x76: 'F7',
83 + 0x77: 'F8',
84 + 0x78: 'F9',
85 + 0x79: 'F10',
86 + 0x7a: 'F11',
87 + 0x7b: 'F12',
88 + 0x7c: 'F13',
89 + 0x7d: 'F14',
90 + 0x7e: 'F15',
91 + 0x7f: 'F16',
92 + 0x80: 'F17',
93 + 0x81: 'F18',
94 + 0x82: 'F19',
95 + 0x83: 'F20',
96 + 0x84: 'F21',
97 + 0x85: 'F22',
98 + 0x86: 'F23',
99 + 0x87: 'F24',
100 + 0x90: 'NumLock',
101 + 0x91: 'ScrollLock',
102 + 0xa6: 'BrowserBack',
103 + 0xa7: 'BrowserForward',
104 + 0xa8: 'BrowserRefresh',
105 + 0xa9: 'BrowserStop',
106 + 0xaa: 'BrowserSearch',
107 + 0xab: 'BrowserFavorites',
108 + 0xac: 'BrowserHome',
109 + 0xad: 'AudioVolumeMute',
110 + 0xae: 'AudioVolumeDown',
111 + 0xaf: 'AudioVolumeUp',
112 + 0xb0: 'MediaTrackNext',
113 + 0xb1: 'MediaTrackPrevious',
114 + 0xb2: 'MediaStop',
115 + 0xb3: 'MediaPlayPause',
116 + 0xb4: 'LaunchMail',
117 + 0xb5: 'MediaSelect',
118 + 0xb6: 'LaunchApp1',
119 + 0xb7: 'LaunchApp2',
120 + 0xe1: 'AltRight' // Only when it is AltGraph
121 +};
\ No newline at end of file
added public/vendor/novnc/input/xtscancodes.js +343 −0
@@ -0,0 +1,343 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +/*
8 + * This file is auto-generated from keymaps.csv
9 + * Database checksum sha256(76d68c10e97d37fe2ea459e210125ae41796253fb217e900bf2983ade13a7920)
10 + * To re-generate, run:
11 + * keymap-gen code-map --lang=js keymaps.csv html atset1
12 +*/
13 +var _default = exports["default"] = {
14 + "Again": 0xe005,
15 + /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */
16 + "AltLeft": 0x38,
17 + /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */
18 + "AltRight": 0xe038,
19 + /* html:AltRight (AltRight) -> linux:100 (KEY_RIGHTALT) -> atset1:57400 */
20 + "ArrowDown": 0xe050,
21 + /* html:ArrowDown (ArrowDown) -> linux:108 (KEY_DOWN) -> atset1:57424 */
22 + "ArrowLeft": 0xe04b,
23 + /* html:ArrowLeft (ArrowLeft) -> linux:105 (KEY_LEFT) -> atset1:57419 */
24 + "ArrowRight": 0xe04d,
25 + /* html:ArrowRight (ArrowRight) -> linux:106 (KEY_RIGHT) -> atset1:57421 */
26 + "ArrowUp": 0xe048,
27 + /* html:ArrowUp (ArrowUp) -> linux:103 (KEY_UP) -> atset1:57416 */
28 + "AudioVolumeDown": 0xe02e,
29 + /* html:AudioVolumeDown (AudioVolumeDown) -> linux:114 (KEY_VOLUMEDOWN) -> atset1:57390 */
30 + "AudioVolumeMute": 0xe020,
31 + /* html:AudioVolumeMute (AudioVolumeMute) -> linux:113 (KEY_MUTE) -> atset1:57376 */
32 + "AudioVolumeUp": 0xe030,
33 + /* html:AudioVolumeUp (AudioVolumeUp) -> linux:115 (KEY_VOLUMEUP) -> atset1:57392 */
34 + "Backquote": 0x29,
35 + /* html:Backquote (Backquote) -> linux:41 (KEY_GRAVE) -> atset1:41 */
36 + "Backslash": 0x2b,
37 + /* html:Backslash (Backslash) -> linux:43 (KEY_BACKSLASH) -> atset1:43 */
38 + "Backspace": 0xe,
39 + /* html:Backspace (Backspace) -> linux:14 (KEY_BACKSPACE) -> atset1:14 */
40 + "BracketLeft": 0x1a,
41 + /* html:BracketLeft (BracketLeft) -> linux:26 (KEY_LEFTBRACE) -> atset1:26 */
42 + "BracketRight": 0x1b,
43 + /* html:BracketRight (BracketRight) -> linux:27 (KEY_RIGHTBRACE) -> atset1:27 */
44 + "BrowserBack": 0xe06a,
45 + /* html:BrowserBack (BrowserBack) -> linux:158 (KEY_BACK) -> atset1:57450 */
46 + "BrowserFavorites": 0xe066,
47 + /* html:BrowserFavorites (BrowserFavorites) -> linux:156 (KEY_BOOKMARKS) -> atset1:57446 */
48 + "BrowserForward": 0xe069,
49 + /* html:BrowserForward (BrowserForward) -> linux:159 (KEY_FORWARD) -> atset1:57449 */
50 + "BrowserHome": 0xe032,
51 + /* html:BrowserHome (BrowserHome) -> linux:172 (KEY_HOMEPAGE) -> atset1:57394 */
52 + "BrowserRefresh": 0xe067,
53 + /* html:BrowserRefresh (BrowserRefresh) -> linux:173 (KEY_REFRESH) -> atset1:57447 */
54 + "BrowserSearch": 0xe065,
55 + /* html:BrowserSearch (BrowserSearch) -> linux:217 (KEY_SEARCH) -> atset1:57445 */
56 + "BrowserStop": 0xe068,
57 + /* html:BrowserStop (BrowserStop) -> linux:128 (KEY_STOP) -> atset1:57448 */
58 + "CapsLock": 0x3a,
59 + /* html:CapsLock (CapsLock) -> linux:58 (KEY_CAPSLOCK) -> atset1:58 */
60 + "Comma": 0x33,
61 + /* html:Comma (Comma) -> linux:51 (KEY_COMMA) -> atset1:51 */
62 + "ContextMenu": 0xe05d,
63 + /* html:ContextMenu (ContextMenu) -> linux:127 (KEY_COMPOSE) -> atset1:57437 */
64 + "ControlLeft": 0x1d,
65 + /* html:ControlLeft (ControlLeft) -> linux:29 (KEY_LEFTCTRL) -> atset1:29 */
66 + "ControlRight": 0xe01d,
67 + /* html:ControlRight (ControlRight) -> linux:97 (KEY_RIGHTCTRL) -> atset1:57373 */
68 + "Convert": 0x79,
69 + /* html:Convert (Convert) -> linux:92 (KEY_HENKAN) -> atset1:121 */
70 + "Copy": 0xe078,
71 + /* html:Copy (Copy) -> linux:133 (KEY_COPY) -> atset1:57464 */
72 + "Cut": 0xe03c,
73 + /* html:Cut (Cut) -> linux:137 (KEY_CUT) -> atset1:57404 */
74 + "Delete": 0xe053,
75 + /* html:Delete (Delete) -> linux:111 (KEY_DELETE) -> atset1:57427 */
76 + "Digit0": 0xb,
77 + /* html:Digit0 (Digit0) -> linux:11 (KEY_0) -> atset1:11 */
78 + "Digit1": 0x2,
79 + /* html:Digit1 (Digit1) -> linux:2 (KEY_1) -> atset1:2 */
80 + "Digit2": 0x3,
81 + /* html:Digit2 (Digit2) -> linux:3 (KEY_2) -> atset1:3 */
82 + "Digit3": 0x4,
83 + /* html:Digit3 (Digit3) -> linux:4 (KEY_3) -> atset1:4 */
84 + "Digit4": 0x5,
85 + /* html:Digit4 (Digit4) -> linux:5 (KEY_4) -> atset1:5 */
86 + "Digit5": 0x6,
87 + /* html:Digit5 (Digit5) -> linux:6 (KEY_5) -> atset1:6 */
88 + "Digit6": 0x7,
89 + /* html:Digit6 (Digit6) -> linux:7 (KEY_6) -> atset1:7 */
90 + "Digit7": 0x8,
91 + /* html:Digit7 (Digit7) -> linux:8 (KEY_7) -> atset1:8 */
92 + "Digit8": 0x9,
93 + /* html:Digit8 (Digit8) -> linux:9 (KEY_8) -> atset1:9 */
94 + "Digit9": 0xa,
95 + /* html:Digit9 (Digit9) -> linux:10 (KEY_9) -> atset1:10 */
96 + "Eject": 0xe07d,
97 + /* html:Eject (Eject) -> linux:162 (KEY_EJECTCLOSECD) -> atset1:57469 */
98 + "End": 0xe04f,
99 + /* html:End (End) -> linux:107 (KEY_END) -> atset1:57423 */
100 + "Enter": 0x1c,
101 + /* html:Enter (Enter) -> linux:28 (KEY_ENTER) -> atset1:28 */
102 + "Equal": 0xd,
103 + /* html:Equal (Equal) -> linux:13 (KEY_EQUAL) -> atset1:13 */
104 + "Escape": 0x1,
105 + /* html:Escape (Escape) -> linux:1 (KEY_ESC) -> atset1:1 */
106 + "F1": 0x3b,
107 + /* html:F1 (F1) -> linux:59 (KEY_F1) -> atset1:59 */
108 + "F10": 0x44,
109 + /* html:F10 (F10) -> linux:68 (KEY_F10) -> atset1:68 */
110 + "F11": 0x57,
111 + /* html:F11 (F11) -> linux:87 (KEY_F11) -> atset1:87 */
112 + "F12": 0x58,
113 + /* html:F12 (F12) -> linux:88 (KEY_F12) -> atset1:88 */
114 + "F13": 0x5d,
115 + /* html:F13 (F13) -> linux:183 (KEY_F13) -> atset1:93 */
116 + "F14": 0x5e,
117 + /* html:F14 (F14) -> linux:184 (KEY_F14) -> atset1:94 */
118 + "F15": 0x5f,
119 + /* html:F15 (F15) -> linux:185 (KEY_F15) -> atset1:95 */
120 + "F16": 0x55,
121 + /* html:F16 (F16) -> linux:186 (KEY_F16) -> atset1:85 */
122 + "F17": 0xe003,
123 + /* html:F17 (F17) -> linux:187 (KEY_F17) -> atset1:57347 */
124 + "F18": 0xe077,
125 + /* html:F18 (F18) -> linux:188 (KEY_F18) -> atset1:57463 */
126 + "F19": 0xe004,
127 + /* html:F19 (F19) -> linux:189 (KEY_F19) -> atset1:57348 */
128 + "F2": 0x3c,
129 + /* html:F2 (F2) -> linux:60 (KEY_F2) -> atset1:60 */
130 + "F20": 0x5a,
131 + /* html:F20 (F20) -> linux:190 (KEY_F20) -> atset1:90 */
132 + "F21": 0x74,
133 + /* html:F21 (F21) -> linux:191 (KEY_F21) -> atset1:116 */
134 + "F22": 0xe079,
135 + /* html:F22 (F22) -> linux:192 (KEY_F22) -> atset1:57465 */
136 + "F23": 0x6d,
137 + /* html:F23 (F23) -> linux:193 (KEY_F23) -> atset1:109 */
138 + "F24": 0x6f,
139 + /* html:F24 (F24) -> linux:194 (KEY_F24) -> atset1:111 */
140 + "F3": 0x3d,
141 + /* html:F3 (F3) -> linux:61 (KEY_F3) -> atset1:61 */
142 + "F4": 0x3e,
143 + /* html:F4 (F4) -> linux:62 (KEY_F4) -> atset1:62 */
144 + "F5": 0x3f,
145 + /* html:F5 (F5) -> linux:63 (KEY_F5) -> atset1:63 */
146 + "F6": 0x40,
147 + /* html:F6 (F6) -> linux:64 (KEY_F6) -> atset1:64 */
148 + "F7": 0x41,
149 + /* html:F7 (F7) -> linux:65 (KEY_F7) -> atset1:65 */
150 + "F8": 0x42,
151 + /* html:F8 (F8) -> linux:66 (KEY_F8) -> atset1:66 */
152 + "F9": 0x43,
153 + /* html:F9 (F9) -> linux:67 (KEY_F9) -> atset1:67 */
154 + "Find": 0xe041,
155 + /* html:Find (Find) -> linux:136 (KEY_FIND) -> atset1:57409 */
156 + "Help": 0xe075,
157 + /* html:Help (Help) -> linux:138 (KEY_HELP) -> atset1:57461 */
158 + "Hiragana": 0x77,
159 + /* html:Hiragana (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
160 + "Home": 0xe047,
161 + /* html:Home (Home) -> linux:102 (KEY_HOME) -> atset1:57415 */
162 + "Insert": 0xe052,
163 + /* html:Insert (Insert) -> linux:110 (KEY_INSERT) -> atset1:57426 */
164 + "IntlBackslash": 0x56,
165 + /* html:IntlBackslash (IntlBackslash) -> linux:86 (KEY_102ND) -> atset1:86 */
166 + "IntlRo": 0x73,
167 + /* html:IntlRo (IntlRo) -> linux:89 (KEY_RO) -> atset1:115 */
168 + "IntlYen": 0x7d,
169 + /* html:IntlYen (IntlYen) -> linux:124 (KEY_YEN) -> atset1:125 */
170 + "KanaMode": 0x70,
171 + /* html:KanaMode (KanaMode) -> linux:93 (KEY_KATAKANAHIRAGANA) -> atset1:112 */
172 + "Katakana": 0x78,
173 + /* html:Katakana (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
174 + "KeyA": 0x1e,
175 + /* html:KeyA (KeyA) -> linux:30 (KEY_A) -> atset1:30 */
176 + "KeyB": 0x30,
177 + /* html:KeyB (KeyB) -> linux:48 (KEY_B) -> atset1:48 */
178 + "KeyC": 0x2e,
179 + /* html:KeyC (KeyC) -> linux:46 (KEY_C) -> atset1:46 */
180 + "KeyD": 0x20,
181 + /* html:KeyD (KeyD) -> linux:32 (KEY_D) -> atset1:32 */
182 + "KeyE": 0x12,
183 + /* html:KeyE (KeyE) -> linux:18 (KEY_E) -> atset1:18 */
184 + "KeyF": 0x21,
185 + /* html:KeyF (KeyF) -> linux:33 (KEY_F) -> atset1:33 */
186 + "KeyG": 0x22,
187 + /* html:KeyG (KeyG) -> linux:34 (KEY_G) -> atset1:34 */
188 + "KeyH": 0x23,
189 + /* html:KeyH (KeyH) -> linux:35 (KEY_H) -> atset1:35 */
190 + "KeyI": 0x17,
191 + /* html:KeyI (KeyI) -> linux:23 (KEY_I) -> atset1:23 */
192 + "KeyJ": 0x24,
193 + /* html:KeyJ (KeyJ) -> linux:36 (KEY_J) -> atset1:36 */
194 + "KeyK": 0x25,
195 + /* html:KeyK (KeyK) -> linux:37 (KEY_K) -> atset1:37 */
196 + "KeyL": 0x26,
197 + /* html:KeyL (KeyL) -> linux:38 (KEY_L) -> atset1:38 */
198 + "KeyM": 0x32,
199 + /* html:KeyM (KeyM) -> linux:50 (KEY_M) -> atset1:50 */
200 + "KeyN": 0x31,
201 + /* html:KeyN (KeyN) -> linux:49 (KEY_N) -> atset1:49 */
202 + "KeyO": 0x18,
203 + /* html:KeyO (KeyO) -> linux:24 (KEY_O) -> atset1:24 */
204 + "KeyP": 0x19,
205 + /* html:KeyP (KeyP) -> linux:25 (KEY_P) -> atset1:25 */
206 + "KeyQ": 0x10,
207 + /* html:KeyQ (KeyQ) -> linux:16 (KEY_Q) -> atset1:16 */
208 + "KeyR": 0x13,
209 + /* html:KeyR (KeyR) -> linux:19 (KEY_R) -> atset1:19 */
210 + "KeyS": 0x1f,
211 + /* html:KeyS (KeyS) -> linux:31 (KEY_S) -> atset1:31 */
212 + "KeyT": 0x14,
213 + /* html:KeyT (KeyT) -> linux:20 (KEY_T) -> atset1:20 */
214 + "KeyU": 0x16,
215 + /* html:KeyU (KeyU) -> linux:22 (KEY_U) -> atset1:22 */
216 + "KeyV": 0x2f,
217 + /* html:KeyV (KeyV) -> linux:47 (KEY_V) -> atset1:47 */
218 + "KeyW": 0x11,
219 + /* html:KeyW (KeyW) -> linux:17 (KEY_W) -> atset1:17 */
220 + "KeyX": 0x2d,
221 + /* html:KeyX (KeyX) -> linux:45 (KEY_X) -> atset1:45 */
222 + "KeyY": 0x15,
223 + /* html:KeyY (KeyY) -> linux:21 (KEY_Y) -> atset1:21 */
224 + "KeyZ": 0x2c,
225 + /* html:KeyZ (KeyZ) -> linux:44 (KEY_Z) -> atset1:44 */
226 + "Lang1": 0x72,
227 + /* html:Lang1 (Lang1) -> linux:122 (KEY_HANGEUL) -> atset1:114 */
228 + "Lang2": 0x71,
229 + /* html:Lang2 (Lang2) -> linux:123 (KEY_HANJA) -> atset1:113 */
230 + "Lang3": 0x78,
231 + /* html:Lang3 (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
232 + "Lang4": 0x77,
233 + /* html:Lang4 (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
234 + "Lang5": 0x76,
235 + /* html:Lang5 (Lang5) -> linux:85 (KEY_ZENKAKUHANKAKU) -> atset1:118 */
236 + "LaunchApp1": 0xe06b,
237 + /* html:LaunchApp1 (LaunchApp1) -> linux:157 (KEY_COMPUTER) -> atset1:57451 */
238 + "LaunchApp2": 0xe021,
239 + /* html:LaunchApp2 (LaunchApp2) -> linux:140 (KEY_CALC) -> atset1:57377 */
240 + "LaunchMail": 0xe06c,
241 + /* html:LaunchMail (LaunchMail) -> linux:155 (KEY_MAIL) -> atset1:57452 */
242 + "MediaPlayPause": 0xe022,
243 + /* html:MediaPlayPause (MediaPlayPause) -> linux:164 (KEY_PLAYPAUSE) -> atset1:57378 */
244 + "MediaSelect": 0xe06d,
245 + /* html:MediaSelect (MediaSelect) -> linux:226 (KEY_MEDIA) -> atset1:57453 */
246 + "MediaStop": 0xe024,
247 + /* html:MediaStop (MediaStop) -> linux:166 (KEY_STOPCD) -> atset1:57380 */
248 + "MediaTrackNext": 0xe019,
249 + /* html:MediaTrackNext (MediaTrackNext) -> linux:163 (KEY_NEXTSONG) -> atset1:57369 */
250 + "MediaTrackPrevious": 0xe010,
251 + /* html:MediaTrackPrevious (MediaTrackPrevious) -> linux:165 (KEY_PREVIOUSSONG) -> atset1:57360 */
252 + "MetaLeft": 0xe05b,
253 + /* html:MetaLeft (MetaLeft) -> linux:125 (KEY_LEFTMETA) -> atset1:57435 */
254 + "MetaRight": 0xe05c,
255 + /* html:MetaRight (MetaRight) -> linux:126 (KEY_RIGHTMETA) -> atset1:57436 */
256 + "Minus": 0xc,
257 + /* html:Minus (Minus) -> linux:12 (KEY_MINUS) -> atset1:12 */
258 + "NonConvert": 0x7b,
259 + /* html:NonConvert (NonConvert) -> linux:94 (KEY_MUHENKAN) -> atset1:123 */
260 + "NumLock": 0x45,
261 + /* html:NumLock (NumLock) -> linux:69 (KEY_NUMLOCK) -> atset1:69 */
262 + "Numpad0": 0x52,
263 + /* html:Numpad0 (Numpad0) -> linux:82 (KEY_KP0) -> atset1:82 */
264 + "Numpad1": 0x4f,
265 + /* html:Numpad1 (Numpad1) -> linux:79 (KEY_KP1) -> atset1:79 */
266 + "Numpad2": 0x50,
267 + /* html:Numpad2 (Numpad2) -> linux:80 (KEY_KP2) -> atset1:80 */
268 + "Numpad3": 0x51,
269 + /* html:Numpad3 (Numpad3) -> linux:81 (KEY_KP3) -> atset1:81 */
270 + "Numpad4": 0x4b,
271 + /* html:Numpad4 (Numpad4) -> linux:75 (KEY_KP4) -> atset1:75 */
272 + "Numpad5": 0x4c,
273 + /* html:Numpad5 (Numpad5) -> linux:76 (KEY_KP5) -> atset1:76 */
274 + "Numpad6": 0x4d,
275 + /* html:Numpad6 (Numpad6) -> linux:77 (KEY_KP6) -> atset1:77 */
276 + "Numpad7": 0x47,
277 + /* html:Numpad7 (Numpad7) -> linux:71 (KEY_KP7) -> atset1:71 */
278 + "Numpad8": 0x48,
279 + /* html:Numpad8 (Numpad8) -> linux:72 (KEY_KP8) -> atset1:72 */
280 + "Numpad9": 0x49,
281 + /* html:Numpad9 (Numpad9) -> linux:73 (KEY_KP9) -> atset1:73 */
282 + "NumpadAdd": 0x4e,
283 + /* html:NumpadAdd (NumpadAdd) -> linux:78 (KEY_KPPLUS) -> atset1:78 */
284 + "NumpadComma": 0x7e,
285 + /* html:NumpadComma (NumpadComma) -> linux:121 (KEY_KPCOMMA) -> atset1:126 */
286 + "NumpadDecimal": 0x53,
287 + /* html:NumpadDecimal (NumpadDecimal) -> linux:83 (KEY_KPDOT) -> atset1:83 */
288 + "NumpadDivide": 0xe035,
289 + /* html:NumpadDivide (NumpadDivide) -> linux:98 (KEY_KPSLASH) -> atset1:57397 */
290 + "NumpadEnter": 0xe01c,
291 + /* html:NumpadEnter (NumpadEnter) -> linux:96 (KEY_KPENTER) -> atset1:57372 */
292 + "NumpadEqual": 0x59,
293 + /* html:NumpadEqual (NumpadEqual) -> linux:117 (KEY_KPEQUAL) -> atset1:89 */
294 + "NumpadMultiply": 0x37,
295 + /* html:NumpadMultiply (NumpadMultiply) -> linux:55 (KEY_KPASTERISK) -> atset1:55 */
296 + "NumpadParenLeft": 0xe076,
297 + /* html:NumpadParenLeft (NumpadParenLeft) -> linux:179 (KEY_KPLEFTPAREN) -> atset1:57462 */
298 + "NumpadParenRight": 0xe07b,
299 + /* html:NumpadParenRight (NumpadParenRight) -> linux:180 (KEY_KPRIGHTPAREN) -> atset1:57467 */
300 + "NumpadSubtract": 0x4a,
301 + /* html:NumpadSubtract (NumpadSubtract) -> linux:74 (KEY_KPMINUS) -> atset1:74 */
302 + "Open": 0x64,
303 + /* html:Open (Open) -> linux:134 (KEY_OPEN) -> atset1:100 */
304 + "PageDown": 0xe051,
305 + /* html:PageDown (PageDown) -> linux:109 (KEY_PAGEDOWN) -> atset1:57425 */
306 + "PageUp": 0xe049,
307 + /* html:PageUp (PageUp) -> linux:104 (KEY_PAGEUP) -> atset1:57417 */
308 + "Paste": 0x65,
309 + /* html:Paste (Paste) -> linux:135 (KEY_PASTE) -> atset1:101 */
310 + "Pause": 0xe046,
311 + /* html:Pause (Pause) -> linux:119 (KEY_PAUSE) -> atset1:57414 */
312 + "Period": 0x34,
313 + /* html:Period (Period) -> linux:52 (KEY_DOT) -> atset1:52 */
314 + "Power": 0xe05e,
315 + /* html:Power (Power) -> linux:116 (KEY_POWER) -> atset1:57438 */
316 + "PrintScreen": 0x54,
317 + /* html:PrintScreen (PrintScreen) -> linux:99 (KEY_SYSRQ) -> atset1:84 */
318 + "Props": 0xe006,
319 + /* html:Props (Props) -> linux:130 (KEY_PROPS) -> atset1:57350 */
320 + "Quote": 0x28,
321 + /* html:Quote (Quote) -> linux:40 (KEY_APOSTROPHE) -> atset1:40 */
322 + "ScrollLock": 0x46,
323 + /* html:ScrollLock (ScrollLock) -> linux:70 (KEY_SCROLLLOCK) -> atset1:70 */
324 + "Semicolon": 0x27,
325 + /* html:Semicolon (Semicolon) -> linux:39 (KEY_SEMICOLON) -> atset1:39 */
326 + "ShiftLeft": 0x2a,
327 + /* html:ShiftLeft (ShiftLeft) -> linux:42 (KEY_LEFTSHIFT) -> atset1:42 */
328 + "ShiftRight": 0x36,
329 + /* html:ShiftRight (ShiftRight) -> linux:54 (KEY_RIGHTSHIFT) -> atset1:54 */
330 + "Slash": 0x35,
331 + /* html:Slash (Slash) -> linux:53 (KEY_SLASH) -> atset1:53 */
332 + "Sleep": 0xe05f,
333 + /* html:Sleep (Sleep) -> linux:142 (KEY_SLEEP) -> atset1:57439 */
334 + "Space": 0x39,
335 + /* html:Space (Space) -> linux:57 (KEY_SPACE) -> atset1:57 */
336 + "Suspend": 0xe025,
337 + /* html:Suspend (Suspend) -> linux:205 (KEY_SUSPEND) -> atset1:57381 */
338 + "Tab": 0xf,
339 + /* html:Tab (Tab) -> linux:15 (KEY_TAB) -> atset1:15 */
340 + "Undo": 0xe007,
341 + /* html:Undo (Undo) -> linux:131 (KEY_UNDO) -> atset1:57351 */
342 + "WakeUp": 0xe063 /* html:WakeUp (WakeUp) -> linux:143 (KEY_WAKEUP) -> atset1:57443 */
343 +};
\ No newline at end of file
added public/vendor/novnc/ra2.js +535 −0
@@ -0,0 +1,535 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _strings = require("./util/strings.js");
8 +var _eventtarget = _interopRequireDefault(require("./util/eventtarget.js"));
9 +var _crypto = _interopRequireDefault(require("./crypto/crypto.js"));
10 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11 +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12 +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
13 +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
14 +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
15 +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
16 +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); }
17 +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
18 +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); }
19 +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; }
20 +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); }
21 +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); }); }; }
22 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23 +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); } }
24 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26 +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); }
27 +var RA2Cipher = /*#__PURE__*/function () {
28 + function RA2Cipher() {
29 + _classCallCheck(this, RA2Cipher);
30 + this._cipher = null;
31 + this._counter = new Uint8Array(16);
32 + }
33 + return _createClass(RA2Cipher, [{
34 + key: "setKey",
35 + value: function () {
36 + var _setKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
37 + return _regeneratorRuntime().wrap(function _callee$(_context) {
38 + while (1) switch (_context.prev = _context.next) {
39 + case 0:
40 + _context.next = 2;
41 + return _crypto["default"].importKey("raw", key, {
42 + name: "AES-EAX"
43 + }, false, ["encrypt, decrypt"]);
44 + case 2:
45 + this._cipher = _context.sent;
46 + case 3:
47 + case "end":
48 + return _context.stop();
49 + }
50 + }, _callee, this);
51 + }));
52 + function setKey(_x) {
53 + return _setKey.apply(this, arguments);
54 + }
55 + return setKey;
56 + }()
57 + }, {
58 + key: "makeMessage",
59 + value: function () {
60 + var _makeMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(message) {
61 + var ad, encrypted, i, res;
62 + return _regeneratorRuntime().wrap(function _callee2$(_context2) {
63 + while (1) switch (_context2.prev = _context2.next) {
64 + case 0:
65 + ad = new Uint8Array([(message.length & 0xff00) >>> 8, message.length & 0xff]);
66 + _context2.next = 3;
67 + return _crypto["default"].encrypt({
68 + name: "AES-EAX",
69 + iv: this._counter,
70 + additionalData: ad
71 + }, this._cipher, message);
72 + case 3:
73 + encrypted = _context2.sent;
74 + for (i = 0; i < 16 && this._counter[i]++ === 255; i++);
75 + res = new Uint8Array(message.length + 2 + 16);
76 + res.set(ad);
77 + res.set(encrypted, 2);
78 + return _context2.abrupt("return", res);
79 + case 9:
80 + case "end":
81 + return _context2.stop();
82 + }
83 + }, _callee2, this);
84 + }));
85 + function makeMessage(_x2) {
86 + return _makeMessage.apply(this, arguments);
87 + }
88 + return makeMessage;
89 + }()
90 + }, {
91 + key: "receiveMessage",
92 + value: function () {
93 + var _receiveMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(length, encrypted) {
94 + var ad, res, i;
95 + return _regeneratorRuntime().wrap(function _callee3$(_context3) {
96 + while (1) switch (_context3.prev = _context3.next) {
97 + case 0:
98 + ad = new Uint8Array([(length & 0xff00) >>> 8, length & 0xff]);
99 + _context3.next = 3;
100 + return _crypto["default"].decrypt({
101 + name: "AES-EAX",
102 + iv: this._counter,
103 + additionalData: ad
104 + }, this._cipher, encrypted);
105 + case 3:
106 + res = _context3.sent;
107 + for (i = 0; i < 16 && this._counter[i]++ === 255; i++);
108 + return _context3.abrupt("return", res);
109 + case 6:
110 + case "end":
111 + return _context3.stop();
112 + }
113 + }, _callee3, this);
114 + }));
115 + function receiveMessage(_x3, _x4) {
116 + return _receiveMessage.apply(this, arguments);
117 + }
118 + return receiveMessage;
119 + }()
120 + }]);
121 +}();
122 +var RSAAESAuthenticationState = exports["default"] = /*#__PURE__*/function (_EventTargetMixin) {
123 + function RSAAESAuthenticationState(sock, getCredentials) {
124 + var _this;
125 + _classCallCheck(this, RSAAESAuthenticationState);
126 + _this = _callSuper(this, RSAAESAuthenticationState);
127 + _this._hasStarted = false;
128 + _this._checkSock = null;
129 + _this._checkCredentials = null;
130 + _this._approveServerResolve = null;
131 + _this._sockReject = null;
132 + _this._credentialsReject = null;
133 + _this._approveServerReject = null;
134 + _this._sock = sock;
135 + _this._getCredentials = getCredentials;
136 + return _this;
137 + }
138 + _inherits(RSAAESAuthenticationState, _EventTargetMixin);
139 + return _createClass(RSAAESAuthenticationState, [{
140 + key: "_waitSockAsync",
141 + value: function _waitSockAsync(len) {
142 + var _this2 = this;
143 + return new Promise(function (resolve, reject) {
144 + var hasData = function hasData() {
145 + return !_this2._sock.rQwait('RA2', len);
146 + };
147 + if (hasData()) {
148 + resolve();
149 + } else {
150 + _this2._checkSock = function () {
151 + if (hasData()) {
152 + resolve();
153 + _this2._checkSock = null;
154 + _this2._sockReject = null;
155 + }
156 + };
157 + _this2._sockReject = reject;
158 + }
159 + });
160 + }
161 + }, {
162 + key: "_waitApproveKeyAsync",
163 + value: function _waitApproveKeyAsync() {
164 + var _this3 = this;
165 + return new Promise(function (resolve, reject) {
166 + _this3._approveServerResolve = resolve;
167 + _this3._approveServerReject = reject;
168 + });
169 + }
170 + }, {
171 + key: "_waitCredentialsAsync",
172 + value: function _waitCredentialsAsync(subtype) {
173 + var _this4 = this;
174 + var hasCredentials = function hasCredentials() {
175 + if (subtype === 1 && _this4._getCredentials().username !== undefined && _this4._getCredentials().password !== undefined) {
176 + return true;
177 + } else if (subtype === 2 && _this4._getCredentials().password !== undefined) {
178 + return true;
179 + }
180 + return false;
181 + };
182 + return new Promise(function (resolve, reject) {
183 + if (hasCredentials()) {
184 + resolve();
185 + } else {
186 + _this4._checkCredentials = function () {
187 + if (hasCredentials()) {
188 + resolve();
189 + _this4._checkCredentials = null;
190 + _this4._credentialsReject = null;
191 + }
192 + };
193 + _this4._credentialsReject = reject;
194 + }
195 + });
196 + }
197 + }, {
198 + key: "checkInternalEvents",
199 + value: function checkInternalEvents() {
200 + if (this._checkSock !== null) {
201 + this._checkSock();
202 + }
203 + if (this._checkCredentials !== null) {
204 + this._checkCredentials();
205 + }
206 + }
207 + }, {
208 + key: "approveServer",
209 + value: function approveServer() {
210 + if (this._approveServerResolve !== null) {
211 + this._approveServerResolve();
212 + this._approveServerResolve = null;
213 + }
214 + }
215 + }, {
216 + key: "disconnect",
217 + value: function disconnect() {
218 + if (this._sockReject !== null) {
219 + this._sockReject(new Error("disconnect normally"));
220 + this._sockReject = null;
221 + }
222 + if (this._credentialsReject !== null) {
223 + this._credentialsReject(new Error("disconnect normally"));
224 + this._credentialsReject = null;
225 + }
226 + if (this._approveServerReject !== null) {
227 + this._approveServerReject(new Error("disconnect normally"));
228 + this._approveServerReject = null;
229 + }
230 + }
231 + }, {
232 + key: "negotiateRA2neAuthAsync",
233 + value: function () {
234 + var _negotiateRA2neAuthAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
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 + return _regeneratorRuntime().wrap(function _callee4$(_context4) {
237 + while (1) switch (_context4.prev = _context4.next) {
238 + case 0:
239 + this._hasStarted = true;
240 + // 1: Receive server public key
241 + _context4.next = 3;
242 + return this._waitSockAsync(4);
243 + case 3:
244 + serverKeyLengthBuffer = this._sock.rQpeekBytes(4);
245 + serverKeyLength = this._sock.rQshift32();
246 + if (!(serverKeyLength < 1024)) {
247 + _context4.next = 9;
248 + break;
249 + }
250 + throw new Error("RA2: server public key is too short: " + serverKeyLength);
251 + case 9:
252 + if (!(serverKeyLength > 8192)) {
253 + _context4.next = 11;
254 + break;
255 + }
256 + throw new Error("RA2: server public key is too long: " + serverKeyLength);
257 + case 11:
258 + serverKeyBytes = Math.ceil(serverKeyLength / 8);
259 + _context4.next = 14;
260 + return this._waitSockAsync(serverKeyBytes * 2);
261 + case 14:
262 + serverN = this._sock.rQshiftBytes(serverKeyBytes);
263 + serverE = this._sock.rQshiftBytes(serverKeyBytes);
264 + _context4.next = 18;
265 + return _crypto["default"].importKey("raw", {
266 + n: serverN,
267 + e: serverE
268 + }, {
269 + name: "RSA-PKCS1-v1_5"
270 + }, false, ["encrypt"]);
271 + case 18:
272 + serverRSACipher = _context4.sent;
273 + serverPublickey = new Uint8Array(4 + serverKeyBytes * 2);
274 + serverPublickey.set(serverKeyLengthBuffer);
275 + serverPublickey.set(serverN, 4);
276 + serverPublickey.set(serverE, 4 + serverKeyBytes);
277 +
278 + // verify server public key
279 + approveKey = this._waitApproveKeyAsync();
280 + this.dispatchEvent(new CustomEvent("serververification", {
281 + detail: {
282 + type: "RSA",
283 + publickey: serverPublickey
284 + }
285 + }));
286 + _context4.next = 27;
287 + return approveKey;
288 + case 27:
289 + // 2: Send client public key
290 + clientKeyLength = 2048;
291 + clientKeyBytes = Math.ceil(clientKeyLength / 8);
292 + _context4.next = 31;
293 + return _crypto["default"].generateKey({
294 + name: "RSA-PKCS1-v1_5",
295 + modulusLength: clientKeyLength,
296 + publicExponent: new Uint8Array([1, 0, 1])
297 + }, true, ["encrypt"]);
298 + case 31:
299 + clientRSACipher = _context4.sent.privateKey;
300 + _context4.next = 34;
301 + return _crypto["default"].exportKey("raw", clientRSACipher);
302 + case 34:
303 + clientExportedRSAKey = _context4.sent;
304 + clientN = clientExportedRSAKey.n;
305 + clientE = clientExportedRSAKey.e;
306 + clientPublicKey = new Uint8Array(4 + clientKeyBytes * 2);
307 + clientPublicKey[0] = (clientKeyLength & 0xff000000) >>> 24;
308 + clientPublicKey[1] = (clientKeyLength & 0xff0000) >>> 16;
309 + clientPublicKey[2] = (clientKeyLength & 0xff00) >>> 8;
310 + clientPublicKey[3] = clientKeyLength & 0xff;
311 + clientPublicKey.set(clientN, 4);
312 + clientPublicKey.set(clientE, 4 + clientKeyBytes);
313 + this._sock.sQpushBytes(clientPublicKey);
314 + this._sock.flush();
315 +
316 + // 3: Send client random
317 + clientRandom = new Uint8Array(16);
318 + window.crypto.getRandomValues(clientRandom);
319 + _context4.next = 50;
320 + return _crypto["default"].encrypt({
321 + name: "RSA-PKCS1-v1_5"
322 + }, serverRSACipher, clientRandom);
323 + case 50:
324 + clientEncryptedRandom = _context4.sent;
325 + clientRandomMessage = new Uint8Array(2 + serverKeyBytes);
326 + clientRandomMessage[0] = (serverKeyBytes & 0xff00) >>> 8;
327 + clientRandomMessage[1] = serverKeyBytes & 0xff;
328 + clientRandomMessage.set(clientEncryptedRandom, 2);
329 + this._sock.sQpushBytes(clientRandomMessage);
330 + this._sock.flush();
331 +
332 + // 4: Receive server random
333 + _context4.next = 59;
334 + return this._waitSockAsync(2);
335 + case 59:
336 + if (!(this._sock.rQshift16() !== clientKeyBytes)) {
337 + _context4.next = 61;
338 + break;
339 + }
340 + throw new Error("RA2: wrong encrypted message length");
341 + case 61:
342 + serverEncryptedRandom = this._sock.rQshiftBytes(clientKeyBytes);
343 + _context4.next = 64;
344 + return _crypto["default"].decrypt({
345 + name: "RSA-PKCS1-v1_5"
346 + }, clientRSACipher, serverEncryptedRandom);
347 + case 64:
348 + serverRandom = _context4.sent;
349 + if (!(serverRandom === null || serverRandom.length !== 16)) {
350 + _context4.next = 67;
351 + break;
352 + }
353 + throw new Error("RA2: corrupted server encrypted random");
354 + case 67:
355 + // 5: Compute session keys and set ciphers
356 + clientSessionKey = new Uint8Array(32);
357 + serverSessionKey = new Uint8Array(32);
358 + clientSessionKey.set(serverRandom);
359 + clientSessionKey.set(clientRandom, 16);
360 + serverSessionKey.set(clientRandom);
361 + serverSessionKey.set(serverRandom, 16);
362 + _context4.next = 75;
363 + return window.crypto.subtle.digest("SHA-1", clientSessionKey);
364 + case 75:
365 + clientSessionKey = _context4.sent;
366 + clientSessionKey = new Uint8Array(clientSessionKey).slice(0, 16);
367 + _context4.next = 79;
368 + return window.crypto.subtle.digest("SHA-1", serverSessionKey);
369 + case 79:
370 + serverSessionKey = _context4.sent;
371 + serverSessionKey = new Uint8Array(serverSessionKey).slice(0, 16);
372 + clientCipher = new RA2Cipher();
373 + _context4.next = 84;
374 + return clientCipher.setKey(clientSessionKey);
375 + case 84:
376 + serverCipher = new RA2Cipher();
377 + _context4.next = 87;
378 + return serverCipher.setKey(serverSessionKey);
379 + case 87:
380 + // 6: Compute and exchange hashes
381 + serverHash = new Uint8Array(8 + serverKeyBytes * 2 + clientKeyBytes * 2);
382 + clientHash = new Uint8Array(8 + serverKeyBytes * 2 + clientKeyBytes * 2);
383 + serverHash.set(serverPublickey);
384 + serverHash.set(clientPublicKey, 4 + serverKeyBytes * 2);
385 + clientHash.set(clientPublicKey);
386 + clientHash.set(serverPublickey, 4 + clientKeyBytes * 2);
387 + _context4.next = 95;
388 + return window.crypto.subtle.digest("SHA-1", serverHash);
389 + case 95:
390 + serverHash = _context4.sent;
391 + _context4.next = 98;
392 + return window.crypto.subtle.digest("SHA-1", clientHash);
393 + case 98:
394 + clientHash = _context4.sent;
395 + serverHash = new Uint8Array(serverHash);
396 + clientHash = new Uint8Array(clientHash);
397 + _context4.t0 = this._sock;
398 + _context4.next = 104;
399 + return clientCipher.makeMessage(clientHash);
400 + case 104:
401 + _context4.t1 = _context4.sent;
402 + _context4.t0.sQpushBytes.call(_context4.t0, _context4.t1);
403 + this._sock.flush();
404 + _context4.next = 109;
405 + return this._waitSockAsync(2 + 20 + 16);
406 + case 109:
407 + if (!(this._sock.rQshift16() !== 20)) {
408 + _context4.next = 111;
409 + break;
410 + }
411 + throw new Error("RA2: wrong server hash");
412 + case 111:
413 + _context4.next = 113;
414 + return serverCipher.receiveMessage(20, this._sock.rQshiftBytes(20 + 16));
415 + case 113:
416 + serverHashReceived = _context4.sent;
417 + if (!(serverHashReceived === null)) {
418 + _context4.next = 116;
419 + break;
420 + }
421 + throw new Error("RA2: failed to authenticate the message");
422 + case 116:
423 + i = 0;
424 + case 117:
425 + if (!(i < 20)) {
426 + _context4.next = 123;
427 + break;
428 + }
429 + if (!(serverHashReceived[i] !== serverHash[i])) {
430 + _context4.next = 120;
431 + break;
432 + }
433 + throw new Error("RA2: wrong server hash");
434 + case 120:
435 + i++;
436 + _context4.next = 117;
437 + break;
438 + case 123:
439 + _context4.next = 125;
440 + return this._waitSockAsync(2 + 1 + 16);
441 + case 125:
442 + if (!(this._sock.rQshift16() !== 1)) {
443 + _context4.next = 127;
444 + break;
445 + }
446 + throw new Error("RA2: wrong subtype");
447 + case 127:
448 + _context4.next = 129;
449 + return serverCipher.receiveMessage(1, this._sock.rQshiftBytes(1 + 16));
450 + case 129:
451 + subtype = _context4.sent;
452 + if (!(subtype === null)) {
453 + _context4.next = 132;
454 + break;
455 + }
456 + throw new Error("RA2: failed to authenticate the message");
457 + case 132:
458 + subtype = subtype[0];
459 + waitCredentials = this._waitCredentialsAsync(subtype);
460 + if (!(subtype === 1)) {
461 + _context4.next = 138;
462 + break;
463 + }
464 + if (this._getCredentials().username === undefined || this._getCredentials().password === undefined) {
465 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
466 + detail: {
467 + types: ["username", "password"]
468 + }
469 + }));
470 + }
471 + _context4.next = 143;
472 + break;
473 + case 138:
474 + if (!(subtype === 2)) {
475 + _context4.next = 142;
476 + break;
477 + }
478 + if (this._getCredentials().password === undefined) {
479 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
480 + detail: {
481 + types: ["password"]
482 + }
483 + }));
484 + }
485 + _context4.next = 143;
486 + break;
487 + case 142:
488 + throw new Error("RA2: wrong subtype");
489 + case 143:
490 + _context4.next = 145;
491 + return waitCredentials;
492 + case 145:
493 + if (subtype === 1) {
494 + username = (0, _strings.encodeUTF8)(this._getCredentials().username).slice(0, 255);
495 + } else {
496 + username = "";
497 + }
498 + password = (0, _strings.encodeUTF8)(this._getCredentials().password).slice(0, 255);
499 + credentials = new Uint8Array(username.length + password.length + 2);
500 + credentials[0] = username.length;
501 + credentials[username.length + 1] = password.length;
502 + for (_i = 0; _i < username.length; _i++) {
503 + credentials[_i + 1] = username.charCodeAt(_i);
504 + }
505 + for (_i2 = 0; _i2 < password.length; _i2++) {
506 + credentials[username.length + 2 + _i2] = password.charCodeAt(_i2);
507 + }
508 + _context4.t2 = this._sock;
509 + _context4.next = 155;
510 + return clientCipher.makeMessage(credentials);
511 + case 155:
512 + _context4.t3 = _context4.sent;
513 + _context4.t2.sQpushBytes.call(_context4.t2, _context4.t3);
514 + this._sock.flush();
515 + case 158:
516 + case "end":
517 + return _context4.stop();
518 + }
519 + }, _callee4, this);
520 + }));
521 + function negotiateRA2neAuthAsync() {
522 + return _negotiateRA2neAuthAsync.apply(this, arguments);
523 + }
524 + return negotiateRA2neAuthAsync;
525 + }()
526 + }, {
527 + key: "hasStarted",
528 + get: function get() {
529 + return this._hasStarted;
530 + },
531 + set: function set(s) {
532 + this._hasStarted = s;
533 + }
534 + }]);
535 +}(_eventtarget["default"]);
\ No newline at end of file
added public/vendor/novnc/rfb.js +3398 −0
@@ -0,0 +1,3398 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports["default"] = void 0;
8 +var _int = require("./util/int.js");
9 +var Log = _interopRequireWildcard(require("./util/logging.js"));
10 +var _strings = require("./util/strings.js");
11 +var _browser = require("./util/browser.js");
12 +var _element = require("./util/element.js");
13 +var _events = require("./util/events.js");
14 +var _eventtarget = _interopRequireDefault(require("./util/eventtarget.js"));
15 +var _display = _interopRequireDefault(require("./display.js"));
16 +var _inflator = _interopRequireDefault(require("./inflator.js"));
17 +var _deflator = _interopRequireDefault(require("./deflator.js"));
18 +var _keyboard = _interopRequireDefault(require("./input/keyboard.js"));
19 +var _gesturehandler = _interopRequireDefault(require("./input/gesturehandler.js"));
20 +var _cursor = _interopRequireDefault(require("./util/cursor.js"));
21 +var _websock = _interopRequireDefault(require("./websock.js"));
22 +var _keysym = _interopRequireDefault(require("./input/keysym.js"));
23 +var _xtscancodes = _interopRequireDefault(require("./input/xtscancodes.js"));
24 +var _encodings = require("./encodings.js");
25 +var _ra = _interopRequireDefault(require("./ra2.js"));
26 +var _crypto = _interopRequireDefault(require("./crypto/crypto.js"));
27 +var _raw = _interopRequireDefault(require("./decoders/raw.js"));
28 +var _copyrect = _interopRequireDefault(require("./decoders/copyrect.js"));
29 +var _rre = _interopRequireDefault(require("./decoders/rre.js"));
30 +var _hextile = _interopRequireDefault(require("./decoders/hextile.js"));
31 +var _zlib = _interopRequireDefault(require("./decoders/zlib.js"));
32 +var _tight = _interopRequireDefault(require("./decoders/tight.js"));
33 +var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
34 +var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
35 +var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
36 +var _h = _interopRequireDefault(require("./decoders/h264.js"));
37 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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); }
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; }
40 +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; }
41 +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); }
42 +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); }); }; }
43 +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
44 +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."); }
45 +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; } }
46 +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
47 +function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
48 +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; } }
49 +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; }
50 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
51 +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); } }
52 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
53 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
54 +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); }
55 +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
56 +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
57 +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
58 +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
59 +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
60 +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); }
61 +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
62 + * noVNC: HTML5 VNC client
63 + * Copyright (C) 2020 The noVNC authors
64 + * Licensed under MPL 2.0 (see LICENSE.txt)
65 + *
66 + * See README.md for usage and integration instructions.
67 + *
68 + */
69 +// How many seconds to wait for a disconnect to finish
70 +var DISCONNECT_TIMEOUT = 3;
71 +var DEFAULT_BACKGROUND = 'rgb(40, 40, 40)';
72 +
73 +// Minimum wait (ms) between two mouse moves
74 +var MOUSE_MOVE_DELAY = 17;
75 +
76 +// Wheel thresholds
77 +var WHEEL_STEP = 50; // Pixels needed for one step
78 +var WHEEL_LINE_HEIGHT = 19; // Assumed pixels for one line step
79 +
80 +// Gesture thresholds
81 +var GESTURE_ZOOMSENS = 75;
82 +var GESTURE_SCRLSENS = 50;
83 +var DOUBLE_TAP_TIMEOUT = 1000;
84 +var DOUBLE_TAP_THRESHOLD = 50;
85 +
86 +// Security types
87 +var securityTypeNone = 1;
88 +var securityTypeVNCAuth = 2;
89 +var securityTypeRA2ne = 6;
90 +var securityTypeTight = 16;
91 +var securityTypeVeNCrypt = 19;
92 +var securityTypeXVP = 22;
93 +var securityTypeARD = 30;
94 +var securityTypeMSLogonII = 113;
95 +
96 +// Special Tight security types
97 +var securityTypeUnixLogon = 129;
98 +
99 +// VeNCrypt security types
100 +var securityTypePlain = 256;
101 +
102 +// Extended clipboard pseudo-encoding formats
103 +var extendedClipboardFormatText = 1;
104 +/*eslint-disable no-unused-vars */
105 +var extendedClipboardFormatRtf = 1 << 1;
106 +var extendedClipboardFormatHtml = 1 << 2;
107 +var extendedClipboardFormatDib = 1 << 3;
108 +var extendedClipboardFormatFiles = 1 << 4;
109 +/*eslint-enable */
110 +
111 +// Extended clipboard pseudo-encoding actions
112 +var extendedClipboardActionCaps = 1 << 24;
113 +var extendedClipboardActionRequest = 1 << 25;
114 +var extendedClipboardActionPeek = 1 << 26;
115 +var extendedClipboardActionNotify = 1 << 27;
116 +var extendedClipboardActionProvide = 1 << 28;
117 +var RFB = exports["default"] = /*#__PURE__*/function (_EventTargetMixin) {
118 + function RFB(target, urlOrChannel, options) {
119 + var _this;
120 + _classCallCheck(this, RFB);
121 + if (!target) {
122 + throw new Error("Must specify target");
123 + }
124 + if (!urlOrChannel) {
125 + throw new Error("Must specify URL, WebSocket or RTCDataChannel");
126 + }
127 +
128 + // We rely on modern APIs which might not be available in an
129 + // insecure context
130 + if (!window.isSecureContext) {
131 + Log.Error("noVNC requires a secure context (TLS). Expect crashes!");
132 + }
133 + _this = _callSuper(this, RFB);
134 + _this._target = target;
135 + if (typeof urlOrChannel === "string") {
136 + _this._url = urlOrChannel;
137 + } else {
138 + _this._url = null;
139 + _this._rawChannel = urlOrChannel;
140 + }
141 +
142 + // Connection details
143 + options = options || {};
144 + _this._rfbCredentials = options.credentials || {};
145 + _this._shared = 'shared' in options ? !!options.shared : true;
146 + _this._repeaterID = options.repeaterID || '';
147 + _this._wsProtocols = options.wsProtocols || [];
148 +
149 + // Internal state
150 + _this._rfbConnectionState = '';
151 + _this._rfbInitState = '';
152 + _this._rfbAuthScheme = -1;
153 + _this._rfbCleanDisconnect = true;
154 + _this._rfbRSAAESAuthenticationState = null;
155 +
156 + // Server capabilities
157 + _this._rfbVersion = 0;
158 + _this._rfbMaxVersion = 3.8;
159 + _this._rfbTightVNC = false;
160 + _this._rfbVeNCryptState = 0;
161 + _this._rfbXvpVer = 0;
162 + _this._fbWidth = 0;
163 + _this._fbHeight = 0;
164 + _this._fbName = "";
165 + _this._capabilities = {
166 + power: false
167 + };
168 + _this._supportsFence = false;
169 + _this._supportsContinuousUpdates = false;
170 + _this._enabledContinuousUpdates = false;
171 + _this._supportsSetDesktopSize = false;
172 + _this._screenID = 0;
173 + _this._screenFlags = 0;
174 + _this._pendingRemoteResize = false;
175 + _this._lastResize = 0;
176 + _this._qemuExtKeyEventSupported = false;
177 + _this._extendedPointerEventSupported = false;
178 + _this._clipboardText = null;
179 + _this._clipboardServerCapabilitiesActions = {};
180 + _this._clipboardServerCapabilitiesFormats = {};
181 +
182 + // Internal objects
183 + _this._sock = null; // Websock object
184 + _this._display = null; // Display object
185 + _this._flushing = false; // Display flushing state
186 + _this._keyboard = null; // Keyboard input handler object
187 + _this._gestures = null; // Gesture input handler object
188 + _this._resizeObserver = null; // Resize observer object
189 +
190 + // Timers
191 + _this._disconnTimer = null; // disconnection timer
192 + _this._resizeTimeout = null; // resize rate limiting
193 + _this._mouseMoveTimer = null;
194 +
195 + // Decoder states
196 + _this._decoders = {};
197 + _this._FBU = {
198 + rects: 0,
199 + x: 0,
200 + y: 0,
201 + width: 0,
202 + height: 0,
203 + encoding: null
204 + };
205 +
206 + // Mouse state
207 + _this._mousePos = {};
208 + _this._mouseButtonMask = 0;
209 + _this._mouseLastMoveTime = 0;
210 + _this._viewportDragging = false;
211 + _this._viewportDragPos = {};
212 + _this._viewportHasMoved = false;
213 + _this._accumulatedWheelDeltaX = 0;
214 + _this._accumulatedWheelDeltaY = 0;
215 +
216 + // Gesture state
217 + _this._gestureLastTapTime = null;
218 + _this._gestureFirstDoubleTapEv = null;
219 + _this._gestureLastMagnitudeX = 0;
220 + _this._gestureLastMagnitudeY = 0;
221 +
222 + // Bound event handlers
223 + _this._eventHandlers = {
224 + focusCanvas: _this._focusCanvas.bind(_this),
225 + handleResize: _this._handleResize.bind(_this),
226 + handleMouse: _this._handleMouse.bind(_this),
227 + handleWheel: _this._handleWheel.bind(_this),
228 + handleGesture: _this._handleGesture.bind(_this),
229 + handleRSAAESCredentialsRequired: _this._handleRSAAESCredentialsRequired.bind(_this),
230 + handleRSAAESServerVerification: _this._handleRSAAESServerVerification.bind(_this)
231 + };
232 +
233 + // main setup
234 + Log.Debug(">> RFB.constructor");
235 +
236 + // Create DOM elements
237 + _this._screen = document.createElement('div');
238 + _this._screen.style.display = 'flex';
239 + _this._screen.style.width = '100%';
240 + _this._screen.style.height = '100%';
241 + _this._screen.style.overflow = 'auto';
242 + _this._screen.style.background = DEFAULT_BACKGROUND;
243 + _this._canvas = document.createElement('canvas');
244 + _this._canvas.style.margin = 'auto';
245 + // Some browsers add an outline on focus
246 + _this._canvas.style.outline = 'none';
247 + _this._canvas.width = 0;
248 + _this._canvas.height = 0;
249 + _this._canvas.tabIndex = -1;
250 + _this._screen.appendChild(_this._canvas);
251 +
252 + // Cursor
253 + _this._cursor = new _cursor["default"]();
254 +
255 + // XXX: TightVNC 2.8.11 sends no cursor at all until Windows changes
256 + // it. Result: no cursor at all until a window border or an edit field
257 + // is hit blindly. But there are also VNC servers that draw the cursor
258 + // in the framebuffer and don't send the empty local cursor. There is
259 + // no way to satisfy both sides.
260 + //
261 + // The spec is unclear on this "initial cursor" issue. Many other
262 + // viewers (TigerVNC, RealVNC, Remmina) display an arrow as the
263 + // initial cursor instead.
264 + _this._cursorImage = RFB.cursors.none;
265 +
266 + // populate decoder array with objects
267 + _this._decoders[_encodings.encodings.encodingRaw] = new _raw["default"]();
268 + _this._decoders[_encodings.encodings.encodingCopyRect] = new _copyrect["default"]();
269 + _this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
270 + _this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
271 + _this._decoders[_encodings.encodings.encodingZlib] = new _zlib["default"]();
272 + _this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
273 + _this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
274 + _this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
275 + _this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"]();
276 + _this._decoders[_encodings.encodings.encodingH264] = new _h["default"]();
277 +
278 + // NB: nothing that needs explicit teardown should be done
279 + // before this point, since this can throw an exception
280 + try {
281 + _this._display = new _display["default"](_this._canvas);
282 + } catch (exc) {
283 + Log.Error("Display exception: " + exc);
284 + throw exc;
285 + }
286 + _this._keyboard = new _keyboard["default"](_this._canvas);
287 + _this._keyboard.onkeyevent = _this._handleKeyEvent.bind(_this);
288 + _this._remoteCapsLock = null; // Null indicates unknown or irrelevant
289 + _this._remoteNumLock = null;
290 + _this._gestures = new _gesturehandler["default"]();
291 + _this._sock = new _websock["default"]();
292 + _this._sock.on('open', _this._socketOpen.bind(_this));
293 + _this._sock.on('close', _this._socketClose.bind(_this));
294 + _this._sock.on('message', _this._handleMessage.bind(_this));
295 + _this._sock.on('error', _this._socketError.bind(_this));
296 + _this._expectedClientWidth = null;
297 + _this._expectedClientHeight = null;
298 + _this._resizeObserver = new ResizeObserver(_this._eventHandlers.handleResize);
299 +
300 + // All prepared, kick off the connection
301 + _this._updateConnectionState('connecting');
302 + Log.Debug("<< RFB.constructor");
303 +
304 + // ===== PROPERTIES =====
305 +
306 + _this.dragViewport = false;
307 + _this.focusOnClick = true;
308 + _this._viewOnly = false;
309 + _this._clipViewport = false;
310 + _this._clippingViewport = false;
311 + _this._scaleViewport = false;
312 + _this._resizeSession = false;
313 + _this._showDotCursor = false;
314 + if (options.showDotCursor !== undefined) {
315 + Log.Warn("Specifying showDotCursor as a RFB constructor argument is deprecated");
316 + _this._showDotCursor = options.showDotCursor;
317 + }
318 + _this._qualityLevel = 6;
319 + _this._compressionLevel = 2;
320 + return _this;
321 + }
322 +
323 + // ===== PROPERTIES =====
324 + _inherits(RFB, _EventTargetMixin);
325 + return _createClass(RFB, [{
326 + key: "viewOnly",
327 + get: function get() {
328 + return this._viewOnly;
329 + },
330 + set: function set(viewOnly) {
331 + this._viewOnly = viewOnly;
332 + if (this._rfbConnectionState === "connecting" || this._rfbConnectionState === "connected") {
333 + if (viewOnly) {
334 + this._keyboard.ungrab();
335 + } else {
336 + this._keyboard.grab();
337 + }
338 + }
339 + }
340 + }, {
341 + key: "capabilities",
342 + get: function get() {
343 + return this._capabilities;
344 + }
345 + }, {
346 + key: "clippingViewport",
347 + get: function get() {
348 + return this._clippingViewport;
349 + }
350 + }, {
351 + key: "_setClippingViewport",
352 + value: function _setClippingViewport(on) {
353 + if (on === this._clippingViewport) {
354 + return;
355 + }
356 + this._clippingViewport = on;
357 + this.dispatchEvent(new CustomEvent("clippingviewport", {
358 + detail: this._clippingViewport
359 + }));
360 + }
361 + }, {
362 + key: "touchButton",
363 + get: function get() {
364 + return 0;
365 + },
366 + set: function set(button) {
367 + Log.Warn("Using old API!");
368 + }
369 + }, {
370 + key: "clipViewport",
371 + get: function get() {
372 + return this._clipViewport;
373 + },
374 + set: function set(viewport) {
375 + this._clipViewport = viewport;
376 + this._updateClip();
377 + }
378 + }, {
379 + key: "scaleViewport",
380 + get: function get() {
381 + return this._scaleViewport;
382 + },
383 + set: function set(scale) {
384 + this._scaleViewport = scale;
385 + // Scaling trumps clipping, so we may need to adjust
386 + // clipping when enabling or disabling scaling
387 + if (scale && this._clipViewport) {
388 + this._updateClip();
389 + }
390 + this._updateScale();
391 + if (!scale && this._clipViewport) {
392 + this._updateClip();
393 + }
394 + }
395 + }, {
396 + key: "resizeSession",
397 + get: function get() {
398 + return this._resizeSession;
399 + },
400 + set: function set(resize) {
401 + this._resizeSession = resize;
402 + if (resize) {
403 + this._requestRemoteResize();
404 + }
405 + }
406 + }, {
407 + key: "showDotCursor",
408 + get: function get() {
409 + return this._showDotCursor;
410 + },
411 + set: function set(show) {
412 + this._showDotCursor = show;
413 + this._refreshCursor();
414 + }
415 + }, {
416 + key: "background",
417 + get: function get() {
418 + return this._screen.style.background;
419 + },
420 + set: function set(cssValue) {
421 + this._screen.style.background = cssValue;
422 + }
423 + }, {
424 + key: "qualityLevel",
425 + get: function get() {
426 + return this._qualityLevel;
427 + },
428 + set: function set(qualityLevel) {
429 + if (!Number.isInteger(qualityLevel) || qualityLevel < 0 || qualityLevel > 9) {
430 + Log.Error("qualityLevel must be an integer between 0 and 9");
431 + return;
432 + }
433 + if (this._qualityLevel === qualityLevel) {
434 + return;
435 + }
436 + this._qualityLevel = qualityLevel;
437 + if (this._rfbConnectionState === 'connected') {
438 + this._sendEncodings();
439 + }
440 + }
441 + }, {
442 + key: "compressionLevel",
443 + get: function get() {
444 + return this._compressionLevel;
445 + },
446 + set: function set(compressionLevel) {
447 + if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
448 + Log.Error("compressionLevel must be an integer between 0 and 9");
449 + return;
450 + }
451 + if (this._compressionLevel === compressionLevel) {
452 + return;
453 + }
454 + this._compressionLevel = compressionLevel;
455 + if (this._rfbConnectionState === 'connected') {
456 + this._sendEncodings();
457 + }
458 + }
459 +
460 + // ===== PUBLIC METHODS =====
461 + }, {
462 + key: "disconnect",
463 + value: function disconnect() {
464 + this._updateConnectionState('disconnecting');
465 + this._sock.off('error');
466 + this._sock.off('message');
467 + this._sock.off('open');
468 + if (this._rfbRSAAESAuthenticationState !== null) {
469 + this._rfbRSAAESAuthenticationState.disconnect();
470 + }
471 + }
472 + }, {
473 + key: "approveServer",
474 + value: function approveServer() {
475 + if (this._rfbRSAAESAuthenticationState !== null) {
476 + this._rfbRSAAESAuthenticationState.approveServer();
477 + }
478 + }
479 + }, {
480 + key: "sendCredentials",
481 + value: function sendCredentials(creds) {
482 + this._rfbCredentials = creds;
483 + this._resumeAuthentication();
484 + }
485 + }, {
486 + key: "sendCtrlAltDel",
487 + value: function sendCtrlAltDel() {
488 + if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
489 + return;
490 + }
491 + Log.Info("Sending Ctrl-Alt-Del");
492 + this.sendKey(_keysym["default"].XK_Control_L, "ControlLeft", true);
493 + this.sendKey(_keysym["default"].XK_Alt_L, "AltLeft", true);
494 + this.sendKey(_keysym["default"].XK_Delete, "Delete", true);
495 + this.sendKey(_keysym["default"].XK_Delete, "Delete", false);
496 + this.sendKey(_keysym["default"].XK_Alt_L, "AltLeft", false);
497 + this.sendKey(_keysym["default"].XK_Control_L, "ControlLeft", false);
498 + }
499 + }, {
500 + key: "machineShutdown",
501 + value: function machineShutdown() {
502 + this._xvpOp(1, 2);
503 + }
504 + }, {
505 + key: "machineReboot",
506 + value: function machineReboot() {
507 + this._xvpOp(1, 3);
508 + }
509 + }, {
510 + key: "machineReset",
511 + value: function machineReset() {
512 + this._xvpOp(1, 4);
513 + }
514 +
515 + // Send a key press. If 'down' is not specified then send a down key
516 + // followed by an up key.
517 + }, {
518 + key: "sendKey",
519 + value: function sendKey(keysym, code, down) {
520 + if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
521 + return;
522 + }
523 + if (down === undefined) {
524 + this.sendKey(keysym, code, true);
525 + this.sendKey(keysym, code, false);
526 + return;
527 + }
528 + var scancode = _xtscancodes["default"][code];
529 + if (this._qemuExtKeyEventSupported && scancode) {
530 + // 0 is NoSymbol
531 + keysym = keysym || 0;
532 + Log.Info("Sending key (" + (down ? "down" : "up") + "): keysym " + keysym + ", scancode " + scancode);
533 + RFB.messages.QEMUExtendedKeyEvent(this._sock, keysym, down, scancode);
534 + } else {
535 + if (!keysym) {
536 + return;
537 + }
538 + Log.Info("Sending keysym (" + (down ? "down" : "up") + "): " + keysym);
539 + RFB.messages.keyEvent(this._sock, keysym, down ? 1 : 0);
540 + }
541 + }
542 + }, {
543 + key: "focus",
544 + value: function focus(options) {
545 + this._canvas.focus(options);
546 + }
547 + }, {
548 + key: "blur",
549 + value: function blur() {
550 + this._canvas.blur();
551 + }
552 + }, {
553 + key: "clipboardPasteFrom",
554 + value: function clipboardPasteFrom(text) {
555 + if (this._rfbConnectionState !== 'connected' || this._viewOnly) {
556 + return;
557 + }
558 + if (this._clipboardServerCapabilitiesFormats[extendedClipboardFormatText] && this._clipboardServerCapabilitiesActions[extendedClipboardActionNotify]) {
559 + this._clipboardText = text;
560 + RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
561 + } else {
562 + var length, i;
563 + var data;
564 + length = 0;
565 + // eslint-disable-next-line no-unused-vars
566 + var _iterator = _createForOfIteratorHelper(text),
567 + _step;
568 + try {
569 + for (_iterator.s(); !(_step = _iterator.n()).done;) {
570 + var codePoint = _step.value;
571 + length++;
572 + }
573 + } catch (err) {
574 + _iterator.e(err);
575 + } finally {
576 + _iterator.f();
577 + }
578 + data = new Uint8Array(length);
579 + i = 0;
580 + var _iterator2 = _createForOfIteratorHelper(text),
581 + _step2;
582 + try {
583 + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
584 + var _codePoint = _step2.value;
585 + var code = _codePoint.codePointAt(0);
586 +
587 + /* Only ISO 8859-1 is supported */
588 + if (code > 0xff) {
589 + code = 0x3f; // '?'
590 + }
591 + data[i++] = code;
592 + }
593 + } catch (err) {
594 + _iterator2.e(err);
595 + } finally {
596 + _iterator2.f();
597 + }
598 + RFB.messages.clientCutText(this._sock, data);
599 + }
600 + }
601 + }, {
602 + key: "getImageData",
603 + value: function getImageData() {
604 + return this._display.getImageData();
605 + }
606 + }, {
607 + key: "toDataURL",
608 + value: function toDataURL(type, encoderOptions) {
609 + return this._display.toDataURL(type, encoderOptions);
610 + }
611 + }, {
612 + key: "toBlob",
613 + value: function toBlob(callback, type, quality) {
614 + return this._display.toBlob(callback, type, quality);
615 + }
616 +
617 + // ===== PRIVATE METHODS =====
618 + }, {
619 + key: "_connect",
620 + value: function _connect() {
621 + Log.Debug(">> RFB.connect");
622 + if (this._url) {
623 + Log.Info("connecting to ".concat(this._url));
624 + this._sock.open(this._url, this._wsProtocols);
625 + } else {
626 + Log.Info("attaching ".concat(this._rawChannel, " to Websock"));
627 + this._sock.attach(this._rawChannel);
628 + if (this._sock.readyState === 'closed') {
629 + throw Error("Cannot use already closed WebSocket/RTCDataChannel");
630 + }
631 + if (this._sock.readyState === 'open') {
632 + // FIXME: _socketOpen() can in theory call _fail(), which
633 + // isn't allowed this early, but I'm not sure that can
634 + // happen without a bug messing up our state variables
635 + this._socketOpen();
636 + }
637 + }
638 +
639 + // Make our elements part of the page
640 + this._target.appendChild(this._screen);
641 + this._gestures.attach(this._canvas);
642 + this._cursor.attach(this._canvas);
643 + this._refreshCursor();
644 +
645 + // Monitor size changes of the screen element
646 + this._resizeObserver.observe(this._screen);
647 +
648 + // Always grab focus on some kind of click event
649 + this._canvas.addEventListener("mousedown", this._eventHandlers.focusCanvas);
650 + this._canvas.addEventListener("touchstart", this._eventHandlers.focusCanvas);
651 +
652 + // Mouse events
653 + this._canvas.addEventListener('mousedown', this._eventHandlers.handleMouse);
654 + this._canvas.addEventListener('mouseup', this._eventHandlers.handleMouse);
655 + this._canvas.addEventListener('mousemove', this._eventHandlers.handleMouse);
656 + // Prevent middle-click pasting (see handler for why we bind to document)
657 + this._canvas.addEventListener('click', this._eventHandlers.handleMouse);
658 + // preventDefault() on mousedown doesn't stop this event for some
659 + // reason so we have to explicitly block it
660 + this._canvas.addEventListener('contextmenu', this._eventHandlers.handleMouse);
661 +
662 + // Wheel events
663 + this._canvas.addEventListener("wheel", this._eventHandlers.handleWheel);
664 +
665 + // Gesture events
666 + this._canvas.addEventListener("gesturestart", this._eventHandlers.handleGesture);
667 + this._canvas.addEventListener("gesturemove", this._eventHandlers.handleGesture);
668 + this._canvas.addEventListener("gestureend", this._eventHandlers.handleGesture);
669 + Log.Debug("<< RFB.connect");
670 + }
671 + }, {
672 + key: "_disconnect",
673 + value: function _disconnect() {
674 + Log.Debug(">> RFB.disconnect");
675 + this._cursor.detach();
676 + this._canvas.removeEventListener("gesturestart", this._eventHandlers.handleGesture);
677 + this._canvas.removeEventListener("gesturemove", this._eventHandlers.handleGesture);
678 + this._canvas.removeEventListener("gestureend", this._eventHandlers.handleGesture);
679 + this._canvas.removeEventListener("wheel", this._eventHandlers.handleWheel);
680 + this._canvas.removeEventListener('mousedown', this._eventHandlers.handleMouse);
681 + this._canvas.removeEventListener('mouseup', this._eventHandlers.handleMouse);
682 + this._canvas.removeEventListener('mousemove', this._eventHandlers.handleMouse);
683 + this._canvas.removeEventListener('click', this._eventHandlers.handleMouse);
684 + this._canvas.removeEventListener('contextmenu', this._eventHandlers.handleMouse);
685 + this._canvas.removeEventListener("mousedown", this._eventHandlers.focusCanvas);
686 + this._canvas.removeEventListener("touchstart", this._eventHandlers.focusCanvas);
687 + this._resizeObserver.disconnect();
688 + this._keyboard.ungrab();
689 + this._gestures.detach();
690 + this._sock.close();
691 + try {
692 + this._target.removeChild(this._screen);
693 + } catch (e) {
694 + if (e.name === 'NotFoundError') {
695 + // Some cases where the initial connection fails
696 + // can disconnect before the _screen is created
697 + } else {
698 + throw e;
699 + }
700 + }
701 + clearTimeout(this._resizeTimeout);
702 + clearTimeout(this._mouseMoveTimer);
703 + Log.Debug("<< RFB.disconnect");
704 + }
705 + }, {
706 + key: "_socketOpen",
707 + value: function _socketOpen() {
708 + if (this._rfbConnectionState === 'connecting' && this._rfbInitState === '') {
709 + this._rfbInitState = 'ProtocolVersion';
710 + Log.Debug("Starting VNC handshake");
711 + } else {
712 + this._fail("Unexpected server connection while " + this._rfbConnectionState);
713 + }
714 + }
715 + }, {
716 + key: "_socketClose",
717 + value: function _socketClose(e) {
718 + Log.Debug("WebSocket on-close event");
719 + var msg = "";
720 + if (e.code) {
721 + msg = "(code: " + e.code;
722 + if (e.reason) {
723 + msg += ", reason: " + e.reason;
724 + }
725 + msg += ")";
726 + }
727 + switch (this._rfbConnectionState) {
728 + case 'connecting':
729 + this._fail("Connection closed " + msg);
730 + break;
731 + case 'connected':
732 + // Handle disconnects that were initiated server-side
733 + this._updateConnectionState('disconnecting');
734 + this._updateConnectionState('disconnected');
735 + break;
736 + case 'disconnecting':
737 + // Normal disconnection path
738 + this._updateConnectionState('disconnected');
739 + break;
740 + case 'disconnected':
741 + this._fail("Unexpected server disconnect " + "when already disconnected " + msg);
742 + break;
743 + default:
744 + this._fail("Unexpected server disconnect before connecting " + msg);
745 + break;
746 + }
747 + this._sock.off('close');
748 + // Delete reference to raw channel to allow cleanup.
749 + this._rawChannel = null;
750 + }
751 + }, {
752 + key: "_socketError",
753 + value: function _socketError(e) {
754 + Log.Warn("WebSocket on-error event");
755 + }
756 + }, {
757 + key: "_focusCanvas",
758 + value: function _focusCanvas(event) {
759 + if (!this.focusOnClick) {
760 + return;
761 + }
762 + this.focus({
763 + preventScroll: true
764 + });
765 + }
766 + }, {
767 + key: "_setDesktopName",
768 + value: function _setDesktopName(name) {
769 + this._fbName = name;
770 + this.dispatchEvent(new CustomEvent("desktopname", {
771 + detail: {
772 + name: this._fbName
773 + }
774 + }));
775 + }
776 + }, {
777 + key: "_saveExpectedClientSize",
778 + value: function _saveExpectedClientSize() {
779 + this._expectedClientWidth = this._screen.clientWidth;
780 + this._expectedClientHeight = this._screen.clientHeight;
781 + }
782 + }, {
783 + key: "_currentClientSize",
784 + value: function _currentClientSize() {
785 + return [this._screen.clientWidth, this._screen.clientHeight];
786 + }
787 + }, {
788 + key: "_clientHasExpectedSize",
789 + value: function _clientHasExpectedSize() {
790 + var _this$_currentClientS = this._currentClientSize(),
791 + _this$_currentClientS2 = _slicedToArray(_this$_currentClientS, 2),
792 + currentWidth = _this$_currentClientS2[0],
793 + currentHeight = _this$_currentClientS2[1];
794 + return currentWidth == this._expectedClientWidth && currentHeight == this._expectedClientHeight;
795 + }
796 +
797 + // Handle browser window resizes
798 + }, {
799 + key: "_handleResize",
800 + value: function _handleResize() {
801 + var _this2 = this;
802 + // Don't change anything if the client size is already as expected
803 + if (this._clientHasExpectedSize()) {
804 + return;
805 + }
806 + // If the window resized then our screen element might have
807 + // as well. Update the viewport dimensions.
808 + window.requestAnimationFrame(function () {
809 + _this2._updateClip();
810 + _this2._updateScale();
811 + _this2._saveExpectedClientSize();
812 + });
813 +
814 + // Request changing the resolution of the remote display to
815 + // the size of the local browser viewport.
816 + this._requestRemoteResize();
817 + }
818 +
819 + // Update state of clipping in Display object, and make sure the
820 + // configured viewport matches the current screen size
821 + }, {
822 + key: "_updateClip",
823 + value: function _updateClip() {
824 + var curClip = this._display.clipViewport;
825 + var newClip = this._clipViewport;
826 + if (this._scaleViewport) {
827 + // Disable viewport clipping if we are scaling
828 + newClip = false;
829 + }
830 + if (curClip !== newClip) {
831 + this._display.clipViewport = newClip;
832 + }
833 + if (newClip) {
834 + // When clipping is enabled, the screen is limited to
835 + // the size of the container.
836 + var size = this._screenSize();
837 + this._display.viewportChangeSize(size.w, size.h);
838 + this._fixScrollbars();
839 + this._setClippingViewport(size.w < this._display.width || size.h < this._display.height);
840 + } else {
841 + this._setClippingViewport(false);
842 + }
843 +
844 + // When changing clipping we might show or hide scrollbars.
845 + // This causes the expected client dimensions to change.
846 + if (curClip !== newClip) {
847 + this._saveExpectedClientSize();
848 + }
849 + }
850 + }, {
851 + key: "_updateScale",
852 + value: function _updateScale() {
853 + if (!this._scaleViewport) {
854 + this._display.scale = 1.0;
855 + } else {
856 + var size = this._screenSize();
857 + this._display.autoscale(size.w, size.h);
858 + }
859 + this._fixScrollbars();
860 + }
861 +
862 + // Requests a change of remote desktop size. This message is an extension
863 + // and may only be sent if we have received an ExtendedDesktopSize message
864 + }, {
865 + key: "_requestRemoteResize",
866 + value: function _requestRemoteResize() {
867 + if (!this._resizeSession) {
868 + return;
869 + }
870 + if (this._viewOnly) {
871 + return;
872 + }
873 + if (!this._supportsSetDesktopSize) {
874 + return;
875 + }
876 +
877 + // Rate limit to one pending resize at a time
878 + if (this._pendingRemoteResize) {
879 + return;
880 + }
881 +
882 + // And no more than once every 100ms
883 + if (Date.now() - this._lastResize < 100) {
884 + clearTimeout(this._resizeTimeout);
885 + this._resizeTimeout = setTimeout(this._requestRemoteResize.bind(this), 100 - (Date.now() - this._lastResize));
886 + return;
887 + }
888 + this._resizeTimeout = null;
889 + var size = this._screenSize();
890 +
891 + // Do we actually change anything?
892 + if (size.w === this._fbWidth && size.h === this._fbHeight) {
893 + return;
894 + }
895 + this._pendingRemoteResize = true;
896 + this._lastResize = Date.now();
897 + RFB.messages.setDesktopSize(this._sock, Math.floor(size.w), Math.floor(size.h), this._screenID, this._screenFlags);
898 + Log.Debug('Requested new desktop size: ' + size.w + 'x' + size.h);
899 + }
900 +
901 + // Gets the the size of the available screen
902 + }, {
903 + key: "_screenSize",
904 + value: function _screenSize() {
905 + var r = this._screen.getBoundingClientRect();
906 + return {
907 + w: r.width,
908 + h: r.height
909 + };
910 + }
911 + }, {
912 + key: "_fixScrollbars",
913 + value: function _fixScrollbars() {
914 + // This is a hack because Safari on macOS screws up the calculation
915 + // for when scrollbars are needed. We get scrollbars when making the
916 + // browser smaller, despite remote resize being enabled. So to fix it
917 + // we temporarily toggle them off and on.
918 + var orig = this._screen.style.overflow;
919 + this._screen.style.overflow = 'hidden';
920 + // Force Safari to recalculate the layout by asking for
921 + // an element's dimensions
922 + this._screen.getBoundingClientRect();
923 + this._screen.style.overflow = orig;
924 + }
925 +
926 + /*
927 + * Connection states:
928 + * connecting
929 + * connected
930 + * disconnecting
931 + * disconnected - permanent state
932 + */
933 + }, {
934 + key: "_updateConnectionState",
935 + value: function _updateConnectionState(state) {
936 + var _this3 = this;
937 + var oldstate = this._rfbConnectionState;
938 + if (state === oldstate) {
939 + Log.Debug("Already in state '" + state + "', ignoring");
940 + return;
941 + }
942 +
943 + // The 'disconnected' state is permanent for each RFB object
944 + if (oldstate === 'disconnected') {
945 + Log.Error("Tried changing state of a disconnected RFB object");
946 + return;
947 + }
948 +
949 + // Ensure proper transitions before doing anything
950 + switch (state) {
951 + case 'connected':
952 + if (oldstate !== 'connecting') {
953 + Log.Error("Bad transition to connected state, " + "previous connection state: " + oldstate);
954 + return;
955 + }
956 + break;
957 + case 'disconnected':
958 + if (oldstate !== 'disconnecting') {
959 + Log.Error("Bad transition to disconnected state, " + "previous connection state: " + oldstate);
960 + return;
961 + }
962 + break;
963 + case 'connecting':
964 + if (oldstate !== '') {
965 + Log.Error("Bad transition to connecting state, " + "previous connection state: " + oldstate);
966 + return;
967 + }
968 + break;
969 + case 'disconnecting':
970 + if (oldstate !== 'connected' && oldstate !== 'connecting') {
971 + Log.Error("Bad transition to disconnecting state, " + "previous connection state: " + oldstate);
972 + return;
973 + }
974 + break;
975 + default:
976 + Log.Error("Unknown connection state: " + state);
977 + return;
978 + }
979 +
980 + // State change actions
981 +
982 + this._rfbConnectionState = state;
983 + Log.Debug("New state '" + state + "', was '" + oldstate + "'.");
984 + if (this._disconnTimer && state !== 'disconnecting') {
985 + Log.Debug("Clearing disconnect timer");
986 + clearTimeout(this._disconnTimer);
987 + this._disconnTimer = null;
988 +
989 + // make sure we don't get a double event
990 + this._sock.off('close');
991 + }
992 + switch (state) {
993 + case 'connecting':
994 + this._connect();
995 + break;
996 + case 'connected':
997 + this.dispatchEvent(new CustomEvent("connect", {
998 + detail: {}
999 + }));
1000 + break;
1001 + case 'disconnecting':
1002 + this._disconnect();
1003 + this._disconnTimer = setTimeout(function () {
1004 + Log.Error("Disconnection timed out.");
1005 + _this3._updateConnectionState('disconnected');
1006 + }, DISCONNECT_TIMEOUT * 1000);
1007 + break;
1008 + case 'disconnected':
1009 + this.dispatchEvent(new CustomEvent("disconnect", {
1010 + detail: {
1011 + clean: this._rfbCleanDisconnect
1012 + }
1013 + }));
1014 + break;
1015 + }
1016 + }
1017 +
1018 + /* Print errors and disconnect
1019 + *
1020 + * The parameter 'details' is used for information that
1021 + * should be logged but not sent to the user interface.
1022 + */
1023 + }, {
1024 + key: "_fail",
1025 + value: function _fail(details) {
1026 + switch (this._rfbConnectionState) {
1027 + case 'disconnecting':
1028 + Log.Error("Failed when disconnecting: " + details);
1029 + break;
1030 + case 'connected':
1031 + Log.Error("Failed while connected: " + details);
1032 + break;
1033 + case 'connecting':
1034 + Log.Error("Failed when connecting: " + details);
1035 + break;
1036 + default:
1037 + Log.Error("RFB failure: " + details);
1038 + break;
1039 + }
1040 + this._rfbCleanDisconnect = false; //This is sent to the UI
1041 +
1042 + // Transition to disconnected without waiting for socket to close
1043 + this._updateConnectionState('disconnecting');
1044 + this._updateConnectionState('disconnected');
1045 + return false;
1046 + }
1047 + }, {
1048 + key: "_setCapability",
1049 + value: function _setCapability(cap, val) {
1050 + this._capabilities[cap] = val;
1051 + this.dispatchEvent(new CustomEvent("capabilities", {
1052 + detail: {
1053 + capabilities: this._capabilities
1054 + }
1055 + }));
1056 + }
1057 + }, {
1058 + key: "_handleMessage",
1059 + value: function _handleMessage() {
1060 + if (this._sock.rQwait("message", 1)) {
1061 + Log.Warn("handleMessage called on an empty receive queue");
1062 + return;
1063 + }
1064 + switch (this._rfbConnectionState) {
1065 + case 'disconnected':
1066 + Log.Error("Got data while disconnected");
1067 + break;
1068 + case 'connected':
1069 + while (true) {
1070 + if (this._flushing) {
1071 + break;
1072 + }
1073 + if (!this._normalMsg()) {
1074 + break;
1075 + }
1076 + if (this._sock.rQwait("message", 1)) {
1077 + break;
1078 + }
1079 + }
1080 + break;
1081 + case 'connecting':
1082 + while (this._rfbConnectionState === 'connecting') {
1083 + if (!this._initMsg()) {
1084 + break;
1085 + }
1086 + }
1087 + break;
1088 + default:
1089 + Log.Error("Got data while in an invalid state");
1090 + break;
1091 + }
1092 + }
1093 + }, {
1094 + key: "_handleKeyEvent",
1095 + value: function _handleKeyEvent(keysym, code, down, numlock, capslock) {
1096 + // If remote state of capslock is known, and it doesn't match the local led state of
1097 + // the keyboard, we send a capslock keypress first to bring it into sync.
1098 + // If we just pressed CapsLock, or we toggled it remotely due to it being out of sync
1099 + // we clear the remote state so that we don't send duplicate or spurious fixes,
1100 + // since it may take some time to receive the new remote CapsLock state.
1101 + if (code == 'CapsLock' && down) {
1102 + this._remoteCapsLock = null;
1103 + }
1104 + if (this._remoteCapsLock !== null && capslock !== null && this._remoteCapsLock !== capslock && down) {
1105 + Log.Debug("Fixing remote caps lock");
1106 + this.sendKey(_keysym["default"].XK_Caps_Lock, 'CapsLock', true);
1107 + this.sendKey(_keysym["default"].XK_Caps_Lock, 'CapsLock', false);
1108 + // We clear the remote capsLock state when we do this to prevent issues with doing this twice
1109 + // before we receive an update of the the remote state.
1110 + this._remoteCapsLock = null;
1111 + }
1112 +
1113 + // Logic for numlock is exactly the same.
1114 + if (code == 'NumLock' && down) {
1115 + this._remoteNumLock = null;
1116 + }
1117 + if (this._remoteNumLock !== null && numlock !== null && this._remoteNumLock !== numlock && down) {
1118 + Log.Debug("Fixing remote num lock");
1119 + this.sendKey(_keysym["default"].XK_Num_Lock, 'NumLock', true);
1120 + this.sendKey(_keysym["default"].XK_Num_Lock, 'NumLock', false);
1121 + this._remoteNumLock = null;
1122 + }
1123 + this.sendKey(keysym, code, down);
1124 + }
1125 + }, {
1126 + key: "_handleMouse",
1127 + value: function _handleMouse(ev) {
1128 + /*
1129 + * We don't check connection status or viewOnly here as the
1130 + * mouse events might be used to control the viewport
1131 + */
1132 +
1133 + if (ev.type === 'click') {
1134 + /*
1135 + * Note: This is only needed for the 'click' event as it fails
1136 + * to fire properly for the target element so we have
1137 + * to listen on the document element instead.
1138 + */
1139 + if (ev.target !== this._canvas) {
1140 + return;
1141 + }
1142 + }
1143 +
1144 + // FIXME: if we're in view-only and not dragging,
1145 + // should we stop events?
1146 + ev.stopPropagation();
1147 + ev.preventDefault();
1148 + if (ev.type === 'click' || ev.type === 'contextmenu') {
1149 + return;
1150 + }
1151 + var pos = (0, _element.clientToElement)(ev.clientX, ev.clientY, this._canvas);
1152 + var bmask = RFB._convertButtonMask(ev.buttons);
1153 + var down = ev.type == 'mousedown';
1154 + switch (ev.type) {
1155 + case 'mousedown':
1156 + case 'mouseup':
1157 + if (this.dragViewport) {
1158 + if (down && !this._viewportDragging) {
1159 + this._viewportDragging = true;
1160 + this._viewportDragPos = {
1161 + 'x': pos.x,
1162 + 'y': pos.y
1163 + };
1164 + this._viewportHasMoved = false;
1165 + this._flushMouseMoveTimer(pos.x, pos.y);
1166 +
1167 + // Skip sending mouse events, instead save the current
1168 + // mouse mask so we can send it later.
1169 + this._mouseButtonMask = bmask;
1170 + break;
1171 + } else {
1172 + this._viewportDragging = false;
1173 +
1174 + // If we actually performed a drag then we are done
1175 + // here and should not send any mouse events
1176 + if (this._viewportHasMoved) {
1177 + this._mouseButtonMask = bmask;
1178 + break;
1179 + }
1180 + // Otherwise we treat this as a mouse click event.
1181 + // Send the previously saved button mask, followed
1182 + // by the current button mask at the end of this
1183 + // function.
1184 + this._sendMouse(pos.x, pos.y, this._mouseButtonMask);
1185 + }
1186 + }
1187 + if (down) {
1188 + (0, _events.setCapture)(this._canvas);
1189 + }
1190 + this._handleMouseButton(pos.x, pos.y, bmask);
1191 + break;
1192 + case 'mousemove':
1193 + if (this._viewportDragging) {
1194 + var deltaX = this._viewportDragPos.x - pos.x;
1195 + var deltaY = this._viewportDragPos.y - pos.y;
1196 + if (this._viewportHasMoved || Math.abs(deltaX) > _browser.dragThreshold || Math.abs(deltaY) > _browser.dragThreshold) {
1197 + this._viewportHasMoved = true;
1198 + this._viewportDragPos = {
1199 + 'x': pos.x,
1200 + 'y': pos.y
1201 + };
1202 + this._display.viewportChangePos(deltaX, deltaY);
1203 + }
1204 +
1205 + // Skip sending mouse events
1206 + break;
1207 + }
1208 + this._handleMouseMove(pos.x, pos.y);
1209 + break;
1210 + }
1211 + }
1212 + }, {
1213 + key: "_handleMouseButton",
1214 + value: function _handleMouseButton(x, y, bmask) {
1215 + // Flush waiting move event first
1216 + this._flushMouseMoveTimer(x, y);
1217 + this._mouseButtonMask = bmask;
1218 + this._sendMouse(x, y, this._mouseButtonMask);
1219 + }
1220 + }, {
1221 + key: "_handleMouseMove",
1222 + value: function _handleMouseMove(x, y) {
1223 + var _this4 = this;
1224 + this._mousePos = {
1225 + 'x': x,
1226 + 'y': y
1227 + };
1228 +
1229 + // Limit many mouse move events to one every MOUSE_MOVE_DELAY ms
1230 + if (this._mouseMoveTimer == null) {
1231 + var timeSinceLastMove = Date.now() - this._mouseLastMoveTime;
1232 + if (timeSinceLastMove > MOUSE_MOVE_DELAY) {
1233 + this._sendMouse(x, y, this._mouseButtonMask);
1234 + this._mouseLastMoveTime = Date.now();
1235 + } else {
1236 + // Too soon since the latest move, wait the remaining time
1237 + this._mouseMoveTimer = setTimeout(function () {
1238 + _this4._handleDelayedMouseMove();
1239 + }, MOUSE_MOVE_DELAY - timeSinceLastMove);
1240 + }
1241 + }
1242 + }
1243 + }, {
1244 + key: "_handleDelayedMouseMove",
1245 + value: function _handleDelayedMouseMove() {
1246 + this._mouseMoveTimer = null;
1247 + this._sendMouse(this._mousePos.x, this._mousePos.y, this._mouseButtonMask);
1248 + this._mouseLastMoveTime = Date.now();
1249 + }
1250 + }, {
1251 + key: "_sendMouse",
1252 + value: function _sendMouse(x, y, mask) {
1253 + if (this._rfbConnectionState !== 'connected') {
1254 + return;
1255 + }
1256 + if (this._viewOnly) {
1257 + return;
1258 + } // View only, skip mouse events
1259 +
1260 + // Highest bit in mask is never sent to the server
1261 + if (mask & 0x8000) {
1262 + throw new Error("Illegal mouse button mask (mask: " + mask + ")");
1263 + }
1264 + var extendedMouseButtons = mask & 0x7f80;
1265 + if (this._extendedPointerEventSupported && extendedMouseButtons) {
1266 + RFB.messages.extendedPointerEvent(this._sock, this._display.absX(x), this._display.absY(y), mask);
1267 + } else {
1268 + RFB.messages.pointerEvent(this._sock, this._display.absX(x), this._display.absY(y), mask);
1269 + }
1270 + }
1271 + }, {
1272 + key: "_handleWheel",
1273 + value: function _handleWheel(ev) {
1274 + if (this._rfbConnectionState !== 'connected') {
1275 + return;
1276 + }
1277 + if (this._viewOnly) {
1278 + return;
1279 + } // View only, skip mouse events
1280 +
1281 + ev.stopPropagation();
1282 + ev.preventDefault();
1283 + var pos = (0, _element.clientToElement)(ev.clientX, ev.clientY, this._canvas);
1284 + var bmask = RFB._convertButtonMask(ev.buttons);
1285 + var dX = ev.deltaX;
1286 + var dY = ev.deltaY;
1287 +
1288 + // Pixel units unless it's non-zero.
1289 + // Note that if deltamode is line or page won't matter since we aren't
1290 + // sending the mouse wheel delta to the server anyway.
1291 + // The difference between pixel and line can be important however since
1292 + // we have a threshold that can be smaller than the line height.
1293 + if (ev.deltaMode !== 0) {
1294 + dX *= WHEEL_LINE_HEIGHT;
1295 + dY *= WHEEL_LINE_HEIGHT;
1296 + }
1297 +
1298 + // Mouse wheel events are sent in steps over VNC. This means that the VNC
1299 + // protocol can't handle a wheel event with specific distance or speed.
1300 + // Therefor, if we get a lot of small mouse wheel events we combine them.
1301 + this._accumulatedWheelDeltaX += dX;
1302 + this._accumulatedWheelDeltaY += dY;
1303 +
1304 + // Generate a mouse wheel step event when the accumulated delta
1305 + // for one of the axes is large enough.
1306 + if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) {
1307 + if (this._accumulatedWheelDeltaX < 0) {
1308 + this._handleMouseButton(pos.x, pos.y, bmask | 1 << 5);
1309 + this._handleMouseButton(pos.x, pos.y, bmask);
1310 + } else if (this._accumulatedWheelDeltaX > 0) {
1311 + this._handleMouseButton(pos.x, pos.y, bmask | 1 << 6);
1312 + this._handleMouseButton(pos.x, pos.y, bmask);
1313 + }
1314 + this._accumulatedWheelDeltaX = 0;
1315 + }
1316 + if (Math.abs(this._accumulatedWheelDeltaY) >= WHEEL_STEP) {
1317 + if (this._accumulatedWheelDeltaY < 0) {
1318 + this._handleMouseButton(pos.x, pos.y, bmask | 1 << 3);
1319 + this._handleMouseButton(pos.x, pos.y, bmask);
1320 + } else if (this._accumulatedWheelDeltaY > 0) {
1321 + this._handleMouseButton(pos.x, pos.y, bmask | 1 << 4);
1322 + this._handleMouseButton(pos.x, pos.y, bmask);
1323 + }
1324 + this._accumulatedWheelDeltaY = 0;
1325 + }
1326 + }
1327 + }, {
1328 + key: "_fakeMouseMove",
1329 + value: function _fakeMouseMove(ev, elementX, elementY) {
1330 + this._handleMouseMove(elementX, elementY);
1331 + this._cursor.move(ev.detail.clientX, ev.detail.clientY);
1332 + }
1333 + }, {
1334 + key: "_handleTapEvent",
1335 + value: function _handleTapEvent(ev, bmask) {
1336 + var pos = (0, _element.clientToElement)(ev.detail.clientX, ev.detail.clientY, this._canvas);
1337 +
1338 + // If the user quickly taps multiple times we assume they meant to
1339 + // hit the same spot, so slightly adjust coordinates
1340 +
1341 + if (this._gestureLastTapTime !== null && Date.now() - this._gestureLastTapTime < DOUBLE_TAP_TIMEOUT && this._gestureFirstDoubleTapEv.detail.type === ev.detail.type) {
1342 + var dx = this._gestureFirstDoubleTapEv.detail.clientX - ev.detail.clientX;
1343 + var dy = this._gestureFirstDoubleTapEv.detail.clientY - ev.detail.clientY;
1344 + var distance = Math.hypot(dx, dy);
1345 + if (distance < DOUBLE_TAP_THRESHOLD) {
1346 + pos = (0, _element.clientToElement)(this._gestureFirstDoubleTapEv.detail.clientX, this._gestureFirstDoubleTapEv.detail.clientY, this._canvas);
1347 + } else {
1348 + this._gestureFirstDoubleTapEv = ev;
1349 + }
1350 + } else {
1351 + this._gestureFirstDoubleTapEv = ev;
1352 + }
1353 + this._gestureLastTapTime = Date.now();
1354 + this._fakeMouseMove(this._gestureFirstDoubleTapEv, pos.x, pos.y);
1355 + this._handleMouseButton(pos.x, pos.y, bmask);
1356 + this._handleMouseButton(pos.x, pos.y, 0x0);
1357 + }
1358 + }, {
1359 + key: "_handleGesture",
1360 + value: function _handleGesture(ev) {
1361 + var magnitude;
1362 + var pos = (0, _element.clientToElement)(ev.detail.clientX, ev.detail.clientY, this._canvas);
1363 + switch (ev.type) {
1364 + case 'gesturestart':
1365 + switch (ev.detail.type) {
1366 + case 'onetap':
1367 + this._handleTapEvent(ev, 0x1);
1368 + break;
1369 + case 'twotap':
1370 + this._handleTapEvent(ev, 0x4);
1371 + break;
1372 + case 'threetap':
1373 + this._handleTapEvent(ev, 0x2);
1374 + break;
1375 + case 'drag':
1376 + if (this.dragViewport) {
1377 + this._viewportHasMoved = false;
1378 + this._viewportDragging = true;
1379 + this._viewportDragPos = {
1380 + 'x': pos.x,
1381 + 'y': pos.y
1382 + };
1383 + } else {
1384 + this._fakeMouseMove(ev, pos.x, pos.y);
1385 + this._handleMouseButton(pos.x, pos.y, 0x1);
1386 + }
1387 + break;
1388 + case 'longpress':
1389 + if (this.dragViewport) {
1390 + // If dragViewport is true, we need to wait to see
1391 + // if we have dragged outside the threshold before
1392 + // sending any events to the server.
1393 + this._viewportHasMoved = false;
1394 + this._viewportDragPos = {
1395 + 'x': pos.x,
1396 + 'y': pos.y
1397 + };
1398 + } else {
1399 + this._fakeMouseMove(ev, pos.x, pos.y);
1400 + this._handleMouseButton(pos.x, pos.y, 0x4);
1401 + }
1402 + break;
1403 + case 'twodrag':
1404 + this._gestureLastMagnitudeX = ev.detail.magnitudeX;
1405 + this._gestureLastMagnitudeY = ev.detail.magnitudeY;
1406 + this._fakeMouseMove(ev, pos.x, pos.y);
1407 + break;
1408 + case 'pinch':
1409 + this._gestureLastMagnitudeX = Math.hypot(ev.detail.magnitudeX, ev.detail.magnitudeY);
1410 + this._fakeMouseMove(ev, pos.x, pos.y);
1411 + break;
1412 + }
1413 + break;
1414 + case 'gesturemove':
1415 + switch (ev.detail.type) {
1416 + case 'onetap':
1417 + case 'twotap':
1418 + case 'threetap':
1419 + break;
1420 + case 'drag':
1421 + case 'longpress':
1422 + if (this.dragViewport) {
1423 + this._viewportDragging = true;
1424 + var deltaX = this._viewportDragPos.x - pos.x;
1425 + var deltaY = this._viewportDragPos.y - pos.y;
1426 + if (this._viewportHasMoved || Math.abs(deltaX) > _browser.dragThreshold || Math.abs(deltaY) > _browser.dragThreshold) {
1427 + this._viewportHasMoved = true;
1428 + this._viewportDragPos = {
1429 + 'x': pos.x,
1430 + 'y': pos.y
1431 + };
1432 + this._display.viewportChangePos(deltaX, deltaY);
1433 + }
1434 + } else {
1435 + this._fakeMouseMove(ev, pos.x, pos.y);
1436 + }
1437 + break;
1438 + case 'twodrag':
1439 + // Always scroll in the same position.
1440 + // We don't know if the mouse was moved so we need to move it
1441 + // every update.
1442 + this._fakeMouseMove(ev, pos.x, pos.y);
1443 + while (ev.detail.magnitudeY - this._gestureLastMagnitudeY > GESTURE_SCRLSENS) {
1444 + this._handleMouseButton(pos.x, pos.y, 0x8);
1445 + this._handleMouseButton(pos.x, pos.y, 0x0);
1446 + this._gestureLastMagnitudeY += GESTURE_SCRLSENS;
1447 + }
1448 + while (ev.detail.magnitudeY - this._gestureLastMagnitudeY < -GESTURE_SCRLSENS) {
1449 + this._handleMouseButton(pos.x, pos.y, 0x10);
1450 + this._handleMouseButton(pos.x, pos.y, 0x0);
1451 + this._gestureLastMagnitudeY -= GESTURE_SCRLSENS;
1452 + }
1453 + while (ev.detail.magnitudeX - this._gestureLastMagnitudeX > GESTURE_SCRLSENS) {
1454 + this._handleMouseButton(pos.x, pos.y, 0x20);
1455 + this._handleMouseButton(pos.x, pos.y, 0x0);
1456 + this._gestureLastMagnitudeX += GESTURE_SCRLSENS;
1457 + }
1458 + while (ev.detail.magnitudeX - this._gestureLastMagnitudeX < -GESTURE_SCRLSENS) {
1459 + this._handleMouseButton(pos.x, pos.y, 0x40);
1460 + this._handleMouseButton(pos.x, pos.y, 0x0);
1461 + this._gestureLastMagnitudeX -= GESTURE_SCRLSENS;
1462 + }
1463 + break;
1464 + case 'pinch':
1465 + // Always scroll in the same position.
1466 + // We don't know if the mouse was moved so we need to move it
1467 + // every update.
1468 + this._fakeMouseMove(ev, pos.x, pos.y);
1469 + magnitude = Math.hypot(ev.detail.magnitudeX, ev.detail.magnitudeY);
1470 + if (Math.abs(magnitude - this._gestureLastMagnitudeX) > GESTURE_ZOOMSENS) {
1471 + this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
1472 + while (magnitude - this._gestureLastMagnitudeX > GESTURE_ZOOMSENS) {
1473 + this._handleMouseButton(pos.x, pos.y, 0x8);
1474 + this._handleMouseButton(pos.x, pos.y, 0x0);
1475 + this._gestureLastMagnitudeX += GESTURE_ZOOMSENS;
1476 + }
1477 + while (magnitude - this._gestureLastMagnitudeX < -GESTURE_ZOOMSENS) {
1478 + this._handleMouseButton(pos.x, pos.y, 0x10);
1479 + this._handleMouseButton(pos.x, pos.y, 0x0);
1480 + this._gestureLastMagnitudeX -= GESTURE_ZOOMSENS;
1481 + }
1482 + }
1483 + this._handleKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", false);
1484 + break;
1485 + }
1486 + break;
1487 + case 'gestureend':
1488 + switch (ev.detail.type) {
1489 + case 'onetap':
1490 + case 'twotap':
1491 + case 'threetap':
1492 + case 'pinch':
1493 + case 'twodrag':
1494 + break;
1495 + case 'drag':
1496 + if (this.dragViewport) {
1497 + this._viewportDragging = false;
1498 + } else {
1499 + this._fakeMouseMove(ev, pos.x, pos.y);
1500 + this._handleMouseButton(pos.x, pos.y, 0x0);
1501 + }
1502 + break;
1503 + case 'longpress':
1504 + if (this._viewportHasMoved) {
1505 + // We don't want to send any events if we have moved
1506 + // our viewport
1507 + break;
1508 + }
1509 + if (this.dragViewport && !this._viewportHasMoved) {
1510 + this._fakeMouseMove(ev, pos.x, pos.y);
1511 + // If dragViewport is true, we need to wait to see
1512 + // if we have dragged outside the threshold before
1513 + // sending any events to the server.
1514 + this._handleMouseButton(pos.x, pos.y, 0x4);
1515 + this._handleMouseButton(pos.x, pos.y, 0x0);
1516 + this._viewportDragging = false;
1517 + } else {
1518 + this._fakeMouseMove(ev, pos.x, pos.y);
1519 + this._handleMouseButton(pos.x, pos.y, 0x0);
1520 + }
1521 + break;
1522 + }
1523 + break;
1524 + }
1525 + }
1526 + }, {
1527 + key: "_flushMouseMoveTimer",
1528 + value: function _flushMouseMoveTimer(x, y) {
1529 + if (this._mouseMoveTimer !== null) {
1530 + clearTimeout(this._mouseMoveTimer);
1531 + this._mouseMoveTimer = null;
1532 + this._sendMouse(x, y, this._mouseButtonMask);
1533 + }
1534 + }
1535 +
1536 + // Message handlers
1537 + }, {
1538 + key: "_negotiateProtocolVersion",
1539 + value: function _negotiateProtocolVersion() {
1540 + if (this._sock.rQwait("version", 12)) {
1541 + return false;
1542 + }
1543 + var sversion = this._sock.rQshiftStr(12).substr(4, 7);
1544 + Log.Info("Server ProtocolVersion: " + sversion);
1545 + var isRepeater = 0;
1546 + switch (sversion) {
1547 + case "000.000":
1548 + // UltraVNC repeater
1549 + isRepeater = 1;
1550 + break;
1551 + case "003.003":
1552 + case "003.006":
1553 + // UltraVNC
1554 + this._rfbVersion = 3.3;
1555 + break;
1556 + case "003.007":
1557 + this._rfbVersion = 3.7;
1558 + break;
1559 + case "003.008":
1560 + case "003.889": // Apple Remote Desktop
1561 + case "004.000": // Intel AMT KVM
1562 + case "004.001": // RealVNC 4.6
1563 + case "005.000":
1564 + // RealVNC 5.3
1565 + this._rfbVersion = 3.8;
1566 + break;
1567 + default:
1568 + return this._fail("Invalid server version " + sversion);
1569 + }
1570 + if (isRepeater) {
1571 + var repeaterID = "ID:" + this._repeaterID;
1572 + while (repeaterID.length < 250) {
1573 + repeaterID += "\0";
1574 + }
1575 + this._sock.sQpushString(repeaterID);
1576 + this._sock.flush();
1577 + return true;
1578 + }
1579 + if (this._rfbVersion > this._rfbMaxVersion) {
1580 + this._rfbVersion = this._rfbMaxVersion;
1581 + }
1582 + var cversion = "00" + parseInt(this._rfbVersion, 10) + ".00" + this._rfbVersion * 10 % 10;
1583 + this._sock.sQpushString("RFB " + cversion + "\n");
1584 + this._sock.flush();
1585 + Log.Debug('Sent ProtocolVersion: ' + cversion);
1586 + this._rfbInitState = 'Security';
1587 + }
1588 + }, {
1589 + key: "_isSupportedSecurityType",
1590 + value: function _isSupportedSecurityType(type) {
1591 + var clientTypes = [securityTypeNone, securityTypeVNCAuth, securityTypeRA2ne, securityTypeTight, securityTypeVeNCrypt, securityTypeXVP, securityTypeARD, securityTypeMSLogonII, securityTypePlain];
1592 + return clientTypes.includes(type);
1593 + }
1594 + }, {
1595 + key: "_negotiateSecurity",
1596 + value: function _negotiateSecurity() {
1597 + if (this._rfbVersion >= 3.7) {
1598 + // Server sends supported list, client decides
1599 + var numTypes = this._sock.rQshift8();
1600 + if (this._sock.rQwait("security type", numTypes, 1)) {
1601 + return false;
1602 + }
1603 + if (numTypes === 0) {
1604 + this._rfbInitState = "SecurityReason";
1605 + this._securityContext = "no security types";
1606 + this._securityStatus = 1;
1607 + return true;
1608 + }
1609 + var types = this._sock.rQshiftBytes(numTypes);
1610 + Log.Debug("Server security types: " + types);
1611 +
1612 + // Look for a matching security type in the order that the
1613 + // server prefers
1614 + this._rfbAuthScheme = -1;
1615 + var _iterator3 = _createForOfIteratorHelper(types),
1616 + _step3;
1617 + try {
1618 + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1619 + var type = _step3.value;
1620 + if (this._isSupportedSecurityType(type)) {
1621 + this._rfbAuthScheme = type;
1622 + break;
1623 + }
1624 + }
1625 + } catch (err) {
1626 + _iterator3.e(err);
1627 + } finally {
1628 + _iterator3.f();
1629 + }
1630 + if (this._rfbAuthScheme === -1) {
1631 + return this._fail("Unsupported security types (types: " + types + ")");
1632 + }
1633 + this._sock.sQpush8(this._rfbAuthScheme);
1634 + this._sock.flush();
1635 + } else {
1636 + // Server decides
1637 + if (this._sock.rQwait("security scheme", 4)) {
1638 + return false;
1639 + }
1640 + this._rfbAuthScheme = this._sock.rQshift32();
1641 + if (this._rfbAuthScheme == 0) {
1642 + this._rfbInitState = "SecurityReason";
1643 + this._securityContext = "authentication scheme";
1644 + this._securityStatus = 1;
1645 + return true;
1646 + }
1647 + }
1648 + this._rfbInitState = 'Authentication';
1649 + Log.Debug('Authenticating using scheme: ' + this._rfbAuthScheme);
1650 + return true;
1651 + }
1652 + }, {
1653 + key: "_handleSecurityReason",
1654 + value: function _handleSecurityReason() {
1655 + if (this._sock.rQwait("reason length", 4)) {
1656 + return false;
1657 + }
1658 + var strlen = this._sock.rQshift32();
1659 + var reason = "";
1660 + if (strlen > 0) {
1661 + if (this._sock.rQwait("reason", strlen, 4)) {
1662 + return false;
1663 + }
1664 + reason = this._sock.rQshiftStr(strlen);
1665 + }
1666 + if (reason !== "") {
1667 + this.dispatchEvent(new CustomEvent("securityfailure", {
1668 + detail: {
1669 + status: this._securityStatus,
1670 + reason: reason
1671 + }
1672 + }));
1673 + return this._fail("Security negotiation failed on " + this._securityContext + " (reason: " + reason + ")");
1674 + } else {
1675 + this.dispatchEvent(new CustomEvent("securityfailure", {
1676 + detail: {
1677 + status: this._securityStatus
1678 + }
1679 + }));
1680 + return this._fail("Security negotiation failed on " + this._securityContext);
1681 + }
1682 + }
1683 +
1684 + // authentication
1685 + }, {
1686 + key: "_negotiateXvpAuth",
1687 + value: function _negotiateXvpAuth() {
1688 + if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined || this._rfbCredentials.target === undefined) {
1689 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
1690 + detail: {
1691 + types: ["username", "password", "target"]
1692 + }
1693 + }));
1694 + return false;
1695 + }
1696 + this._sock.sQpush8(this._rfbCredentials.username.length);
1697 + this._sock.sQpush8(this._rfbCredentials.target.length);
1698 + this._sock.sQpushString(this._rfbCredentials.username);
1699 + this._sock.sQpushString(this._rfbCredentials.target);
1700 + this._sock.flush();
1701 + this._rfbAuthScheme = securityTypeVNCAuth;
1702 + return this._negotiateAuthentication();
1703 + }
1704 +
1705 + // VeNCrypt authentication, currently only supports version 0.2 and only Plain subtype
1706 + }, {
1707 + key: "_negotiateVeNCryptAuth",
1708 + value: function _negotiateVeNCryptAuth() {
1709 + // waiting for VeNCrypt version
1710 + if (this._rfbVeNCryptState == 0) {
1711 + if (this._sock.rQwait("vencrypt version", 2)) {
1712 + return false;
1713 + }
1714 + var major = this._sock.rQshift8();
1715 + var minor = this._sock.rQshift8();
1716 + if (!(major == 0 && minor == 2)) {
1717 + return this._fail("Unsupported VeNCrypt version " + major + "." + minor);
1718 + }
1719 + this._sock.sQpush8(0);
1720 + this._sock.sQpush8(2);
1721 + this._sock.flush();
1722 + this._rfbVeNCryptState = 1;
1723 + }
1724 +
1725 + // waiting for ACK
1726 + if (this._rfbVeNCryptState == 1) {
1727 + if (this._sock.rQwait("vencrypt ack", 1)) {
1728 + return false;
1729 + }
1730 + var res = this._sock.rQshift8();
1731 + if (res != 0) {
1732 + return this._fail("VeNCrypt failure " + res);
1733 + }
1734 + this._rfbVeNCryptState = 2;
1735 + }
1736 + // must fall through here (i.e. no "else if"), beacause we may have already received
1737 + // the subtypes length and won't be called again
1738 +
1739 + if (this._rfbVeNCryptState == 2) {
1740 + // waiting for subtypes length
1741 + if (this._sock.rQwait("vencrypt subtypes length", 1)) {
1742 + return false;
1743 + }
1744 + var subtypesLength = this._sock.rQshift8();
1745 + if (subtypesLength < 1) {
1746 + return this._fail("VeNCrypt subtypes empty");
1747 + }
1748 + this._rfbVeNCryptSubtypesLength = subtypesLength;
1749 + this._rfbVeNCryptState = 3;
1750 + }
1751 +
1752 + // waiting for subtypes list
1753 + if (this._rfbVeNCryptState == 3) {
1754 + if (this._sock.rQwait("vencrypt subtypes", 4 * this._rfbVeNCryptSubtypesLength)) {
1755 + return false;
1756 + }
1757 + var subtypes = [];
1758 + for (var i = 0; i < this._rfbVeNCryptSubtypesLength; i++) {
1759 + subtypes.push(this._sock.rQshift32());
1760 + }
1761 +
1762 + // Look for a matching security type in the order that the
1763 + // server prefers
1764 + this._rfbAuthScheme = -1;
1765 + for (var _i = 0, _subtypes = subtypes; _i < _subtypes.length; _i++) {
1766 + var type = _subtypes[_i];
1767 + // Avoid getting in to a loop
1768 + if (type === securityTypeVeNCrypt) {
1769 + continue;
1770 + }
1771 + if (this._isSupportedSecurityType(type)) {
1772 + this._rfbAuthScheme = type;
1773 + break;
1774 + }
1775 + }
1776 + if (this._rfbAuthScheme === -1) {
1777 + return this._fail("Unsupported security types (types: " + subtypes + ")");
1778 + }
1779 + this._sock.sQpush32(this._rfbAuthScheme);
1780 + this._sock.flush();
1781 + this._rfbVeNCryptState = 4;
1782 + return true;
1783 + }
1784 + }
1785 + }, {
1786 + key: "_negotiatePlainAuth",
1787 + value: function _negotiatePlainAuth() {
1788 + if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1789 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
1790 + detail: {
1791 + types: ["username", "password"]
1792 + }
1793 + }));
1794 + return false;
1795 + }
1796 + var user = (0, _strings.encodeUTF8)(this._rfbCredentials.username);
1797 + var pass = (0, _strings.encodeUTF8)(this._rfbCredentials.password);
1798 + this._sock.sQpush32(user.length);
1799 + this._sock.sQpush32(pass.length);
1800 + this._sock.sQpushString(user);
1801 + this._sock.sQpushString(pass);
1802 + this._sock.flush();
1803 + this._rfbInitState = "SecurityResult";
1804 + return true;
1805 + }
1806 + }, {
1807 + key: "_negotiateStdVNCAuth",
1808 + value: function _negotiateStdVNCAuth() {
1809 + if (this._sock.rQwait("auth challenge", 16)) {
1810 + return false;
1811 + }
1812 + if (this._rfbCredentials.password === undefined) {
1813 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
1814 + detail: {
1815 + types: ["password"]
1816 + }
1817 + }));
1818 + return false;
1819 + }
1820 +
1821 + // TODO(directxman12): make genDES not require an Array
1822 + var challenge = Array.prototype.slice.call(this._sock.rQshiftBytes(16));
1823 + var response = RFB.genDES(this._rfbCredentials.password, challenge);
1824 + this._sock.sQpushBytes(response);
1825 + this._sock.flush();
1826 + this._rfbInitState = "SecurityResult";
1827 + return true;
1828 + }
1829 + }, {
1830 + key: "_negotiateARDAuth",
1831 + value: function _negotiateARDAuth() {
1832 + if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1833 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
1834 + detail: {
1835 + types: ["username", "password"]
1836 + }
1837 + }));
1838 + return false;
1839 + }
1840 + if (this._rfbCredentials.ardPublicKey != undefined && this._rfbCredentials.ardCredentials != undefined) {
1841 + // if the async web crypto is done return the results
1842 + this._sock.sQpushBytes(this._rfbCredentials.ardCredentials);
1843 + this._sock.sQpushBytes(this._rfbCredentials.ardPublicKey);
1844 + this._sock.flush();
1845 + this._rfbCredentials.ardCredentials = null;
1846 + this._rfbCredentials.ardPublicKey = null;
1847 + this._rfbInitState = "SecurityResult";
1848 + return true;
1849 + }
1850 + if (this._sock.rQwait("read ard", 4)) {
1851 + return false;
1852 + }
1853 + var generator = this._sock.rQshiftBytes(2); // DH base generator value
1854 +
1855 + var keyLength = this._sock.rQshift16();
1856 + if (this._sock.rQwait("read ard keylength", keyLength * 2, 4)) {
1857 + return false;
1858 + }
1859 +
1860 + // read the server values
1861 + var prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus
1862 + var serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key
1863 +
1864 + var clientKey = _crypto["default"].generateKey({
1865 + name: "DH",
1866 + g: generator,
1867 + p: prime
1868 + }, false, ["deriveBits"]);
1869 + this._negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey);
1870 + return false;
1871 + }
1872 + }, {
1873 + key: "_negotiateARDAuthAsync",
1874 + value: function () {
1875 + var _negotiateARDAuthAsync2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(keyLength, serverPublicKey, clientKey) {
1876 + var clientPublicKey, sharedKey, username, password, credentials, i, _i2, key, cipher, encrypted;
1877 + return _regeneratorRuntime().wrap(function _callee$(_context) {
1878 + while (1) switch (_context.prev = _context.next) {
1879 + case 0:
1880 + clientPublicKey = _crypto["default"].exportKey("raw", clientKey.publicKey);
1881 + sharedKey = _crypto["default"].deriveBits({
1882 + name: "DH",
1883 + "public": serverPublicKey
1884 + }, clientKey.privateKey, keyLength * 8);
1885 + username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 63);
1886 + password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
1887 + credentials = window.crypto.getRandomValues(new Uint8Array(128));
1888 + for (i = 0; i < username.length; i++) {
1889 + credentials[i] = username.charCodeAt(i);
1890 + }
1891 + credentials[username.length] = 0;
1892 + for (_i2 = 0; _i2 < password.length; _i2++) {
1893 + credentials[64 + _i2] = password.charCodeAt(_i2);
1894 + }
1895 + credentials[64 + password.length] = 0;
1896 + _context.next = 11;
1897 + return _crypto["default"].digest("MD5", sharedKey);
1898 + case 11:
1899 + key = _context.sent;
1900 + _context.next = 14;
1901 + return _crypto["default"].importKey("raw", key, {
1902 + name: "AES-ECB"
1903 + }, false, ["encrypt"]);
1904 + case 14:
1905 + cipher = _context.sent;
1906 + _context.next = 17;
1907 + return _crypto["default"].encrypt({
1908 + name: "AES-ECB"
1909 + }, cipher, credentials);
1910 + case 17:
1911 + encrypted = _context.sent;
1912 + this._rfbCredentials.ardCredentials = encrypted;
1913 + this._rfbCredentials.ardPublicKey = clientPublicKey;
1914 + this._resumeAuthentication();
1915 + case 21:
1916 + case "end":
1917 + return _context.stop();
1918 + }
1919 + }, _callee, this);
1920 + }));
1921 + function _negotiateARDAuthAsync(_x, _x2, _x3) {
1922 + return _negotiateARDAuthAsync2.apply(this, arguments);
1923 + }
1924 + return _negotiateARDAuthAsync;
1925 + }()
1926 + }, {
1927 + key: "_negotiateTightUnixAuth",
1928 + value: function _negotiateTightUnixAuth() {
1929 + if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
1930 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
1931 + detail: {
1932 + types: ["username", "password"]
1933 + }
1934 + }));
1935 + return false;
1936 + }
1937 + this._sock.sQpush32(this._rfbCredentials.username.length);
1938 + this._sock.sQpush32(this._rfbCredentials.password.length);
1939 + this._sock.sQpushString(this._rfbCredentials.username);
1940 + this._sock.sQpushString(this._rfbCredentials.password);
1941 + this._sock.flush();
1942 + this._rfbInitState = "SecurityResult";
1943 + return true;
1944 + }
1945 + }, {
1946 + key: "_negotiateTightTunnels",
1947 + value: function _negotiateTightTunnels(numTunnels) {
1948 + var clientSupportedTunnelTypes = {
1949 + 0: {
1950 + vendor: 'TGHT',
1951 + signature: 'NOTUNNEL'
1952 + }
1953 + };
1954 + var serverSupportedTunnelTypes = {};
1955 + // receive tunnel capabilities
1956 + for (var i = 0; i < numTunnels; i++) {
1957 + var capCode = this._sock.rQshift32();
1958 + var capVendor = this._sock.rQshiftStr(4);
1959 + var capSignature = this._sock.rQshiftStr(8);
1960 + serverSupportedTunnelTypes[capCode] = {
1961 + vendor: capVendor,
1962 + signature: capSignature
1963 + };
1964 + }
1965 + Log.Debug("Server Tight tunnel types: " + serverSupportedTunnelTypes);
1966 +
1967 + // Siemens touch panels have a VNC server that supports NOTUNNEL,
1968 + // but forgets to advertise it. Try to detect such servers by
1969 + // looking for their custom tunnel type.
1970 + if (serverSupportedTunnelTypes[1] && serverSupportedTunnelTypes[1].vendor === "SICR" && serverSupportedTunnelTypes[1].signature === "SCHANNEL") {
1971 + Log.Debug("Detected Siemens server. Assuming NOTUNNEL support.");
1972 + serverSupportedTunnelTypes[0] = {
1973 + vendor: 'TGHT',
1974 + signature: 'NOTUNNEL'
1975 + };
1976 + }
1977 +
1978 + // choose the notunnel type
1979 + if (serverSupportedTunnelTypes[0]) {
1980 + if (serverSupportedTunnelTypes[0].vendor != clientSupportedTunnelTypes[0].vendor || serverSupportedTunnelTypes[0].signature != clientSupportedTunnelTypes[0].signature) {
1981 + return this._fail("Client's tunnel type had the incorrect " + "vendor or signature");
1982 + }
1983 + Log.Debug("Selected tunnel type: " + clientSupportedTunnelTypes[0]);
1984 + this._sock.sQpush32(0); // use NOTUNNEL
1985 + this._sock.flush();
1986 + return false; // wait until we receive the sub auth count to continue
1987 + } else {
1988 + return this._fail("Server wanted tunnels, but doesn't support " + "the notunnel type");
1989 + }
1990 + }
1991 + }, {
1992 + key: "_negotiateTightAuth",
1993 + value: function _negotiateTightAuth() {
1994 + if (!this._rfbTightVNC) {
1995 + // first pass, do the tunnel negotiation
1996 + if (this._sock.rQwait("num tunnels", 4)) {
1997 + return false;
1998 + }
1999 + var numTunnels = this._sock.rQshift32();
2000 + if (numTunnels > 0 && this._sock.rQwait("tunnel capabilities", 16 * numTunnels, 4)) {
2001 + return false;
2002 + }
2003 + this._rfbTightVNC = true;
2004 + if (numTunnels > 0) {
2005 + this._negotiateTightTunnels(numTunnels);
2006 + return false; // wait until we receive the sub auth to continue
2007 + }
2008 + }
2009 +
2010 + // second pass, do the sub-auth negotiation
2011 + if (this._sock.rQwait("sub auth count", 4)) {
2012 + return false;
2013 + }
2014 + var subAuthCount = this._sock.rQshift32();
2015 + if (subAuthCount === 0) {
2016 + // empty sub-auth list received means 'no auth' subtype selected
2017 + this._rfbInitState = 'SecurityResult';
2018 + return true;
2019 + }
2020 + if (this._sock.rQwait("sub auth capabilities", 16 * subAuthCount, 4)) {
2021 + return false;
2022 + }
2023 + var clientSupportedTypes = {
2024 + 'STDVNOAUTH__': 1,
2025 + 'STDVVNCAUTH_': 2,
2026 + 'TGHTULGNAUTH': 129
2027 + };
2028 + var serverSupportedTypes = [];
2029 + for (var i = 0; i < subAuthCount; i++) {
2030 + this._sock.rQshift32(); // capNum
2031 + var capabilities = this._sock.rQshiftStr(12);
2032 + serverSupportedTypes.push(capabilities);
2033 + }
2034 + Log.Debug("Server Tight authentication types: " + serverSupportedTypes);
2035 + for (var authType in clientSupportedTypes) {
2036 + if (serverSupportedTypes.indexOf(authType) != -1) {
2037 + this._sock.sQpush32(clientSupportedTypes[authType]);
2038 + this._sock.flush();
2039 + Log.Debug("Selected authentication type: " + authType);
2040 + switch (authType) {
2041 + case 'STDVNOAUTH__':
2042 + // no auth
2043 + this._rfbInitState = 'SecurityResult';
2044 + return true;
2045 + case 'STDVVNCAUTH_':
2046 + this._rfbAuthScheme = securityTypeVNCAuth;
2047 + return true;
2048 + case 'TGHTULGNAUTH':
2049 + this._rfbAuthScheme = securityTypeUnixLogon;
2050 + return true;
2051 + default:
2052 + return this._fail("Unsupported tiny auth scheme " + "(scheme: " + authType + ")");
2053 + }
2054 + }
2055 + }
2056 + return this._fail("No supported sub-auth types!");
2057 + }
2058 + }, {
2059 + key: "_handleRSAAESCredentialsRequired",
2060 + value: function _handleRSAAESCredentialsRequired(event) {
2061 + this.dispatchEvent(event);
2062 + }
2063 + }, {
2064 + key: "_handleRSAAESServerVerification",
2065 + value: function _handleRSAAESServerVerification(event) {
2066 + this.dispatchEvent(event);
2067 + }
2068 + }, {
2069 + key: "_negotiateRA2neAuth",
2070 + value: function _negotiateRA2neAuth() {
2071 + var _this5 = this;
2072 + if (this._rfbRSAAESAuthenticationState === null) {
2073 + this._rfbRSAAESAuthenticationState = new _ra["default"](this._sock, function () {
2074 + return _this5._rfbCredentials;
2075 + });
2076 + this._rfbRSAAESAuthenticationState.addEventListener("serververification", this._eventHandlers.handleRSAAESServerVerification);
2077 + this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
2078 + }
2079 + this._rfbRSAAESAuthenticationState.checkInternalEvents();
2080 + if (!this._rfbRSAAESAuthenticationState.hasStarted) {
2081 + this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync()["catch"](function (e) {
2082 + if (e.message !== "disconnect normally") {
2083 + _this5._fail(e.message);
2084 + }
2085 + }).then(function () {
2086 + _this5._rfbInitState = "SecurityResult";
2087 + return true;
2088 + })["finally"](function () {
2089 + _this5._rfbRSAAESAuthenticationState.removeEventListener("serververification", _this5._eventHandlers.handleRSAAESServerVerification);
2090 + _this5._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired", _this5._eventHandlers.handleRSAAESCredentialsRequired);
2091 + _this5._rfbRSAAESAuthenticationState = null;
2092 + });
2093 + }
2094 + return false;
2095 + }
2096 + }, {
2097 + key: "_negotiateMSLogonIIAuth",
2098 + value: function _negotiateMSLogonIIAuth() {
2099 + if (this._sock.rQwait("mslogonii dh param", 24)) {
2100 + return false;
2101 + }
2102 + if (this._rfbCredentials.username === undefined || this._rfbCredentials.password === undefined) {
2103 + this.dispatchEvent(new CustomEvent("credentialsrequired", {
2104 + detail: {
2105 + types: ["username", "password"]
2106 + }
2107 + }));
2108 + return false;
2109 + }
2110 + var g = this._sock.rQshiftBytes(8);
2111 + var p = this._sock.rQshiftBytes(8);
2112 + var A = this._sock.rQshiftBytes(8);
2113 + var dhKey = _crypto["default"].generateKey({
2114 + name: "DH",
2115 + g: g,
2116 + p: p
2117 + }, true, ["deriveBits"]);
2118 + var B = _crypto["default"].exportKey("raw", dhKey.publicKey);
2119 + var secret = _crypto["default"].deriveBits({
2120 + name: "DH",
2121 + "public": A
2122 + }, dhKey.privateKey, 64);
2123 + var key = _crypto["default"].importKey("raw", secret, {
2124 + name: "DES-CBC"
2125 + }, false, ["encrypt"]);
2126 + var username = (0, _strings.encodeUTF8)(this._rfbCredentials.username).substring(0, 255);
2127 + var password = (0, _strings.encodeUTF8)(this._rfbCredentials.password).substring(0, 63);
2128 + var usernameBytes = new Uint8Array(256);
2129 + var passwordBytes = new Uint8Array(64);
2130 + window.crypto.getRandomValues(usernameBytes);
2131 + window.crypto.getRandomValues(passwordBytes);
2132 + for (var i = 0; i < username.length; i++) {
2133 + usernameBytes[i] = username.charCodeAt(i);
2134 + }
2135 + usernameBytes[username.length] = 0;
2136 + for (var _i3 = 0; _i3 < password.length; _i3++) {
2137 + passwordBytes[_i3] = password.charCodeAt(_i3);
2138 + }
2139 + passwordBytes[password.length] = 0;
2140 + usernameBytes = _crypto["default"].encrypt({
2141 + name: "DES-CBC",
2142 + iv: secret
2143 + }, key, usernameBytes);
2144 + passwordBytes = _crypto["default"].encrypt({
2145 + name: "DES-CBC",
2146 + iv: secret
2147 + }, key, passwordBytes);
2148 + this._sock.sQpushBytes(B);
2149 + this._sock.sQpushBytes(usernameBytes);
2150 + this._sock.sQpushBytes(passwordBytes);
2151 + this._sock.flush();
2152 + this._rfbInitState = "SecurityResult";
2153 + return true;
2154 + }
2155 + }, {
2156 + key: "_negotiateAuthentication",
2157 + value: function _negotiateAuthentication() {
2158 + switch (this._rfbAuthScheme) {
2159 + case securityTypeNone:
2160 + if (this._rfbVersion >= 3.8) {
2161 + this._rfbInitState = 'SecurityResult';
2162 + } else {
2163 + this._rfbInitState = 'ClientInitialisation';
2164 + }
2165 + return true;
2166 + case securityTypeXVP:
2167 + return this._negotiateXvpAuth();
2168 + case securityTypeARD:
2169 + return this._negotiateARDAuth();
2170 + case securityTypeVNCAuth:
2171 + return this._negotiateStdVNCAuth();
2172 + case securityTypeTight:
2173 + return this._negotiateTightAuth();
2174 + case securityTypeVeNCrypt:
2175 + return this._negotiateVeNCryptAuth();
2176 + case securityTypePlain:
2177 + return this._negotiatePlainAuth();
2178 + case securityTypeUnixLogon:
2179 + return this._negotiateTightUnixAuth();
2180 + case securityTypeRA2ne:
2181 + return this._negotiateRA2neAuth();
2182 + case securityTypeMSLogonII:
2183 + return this._negotiateMSLogonIIAuth();
2184 + default:
2185 + return this._fail("Unsupported auth scheme (scheme: " + this._rfbAuthScheme + ")");
2186 + }
2187 + }
2188 + }, {
2189 + key: "_handleSecurityResult",
2190 + value: function _handleSecurityResult() {
2191 + if (this._sock.rQwait('VNC auth response ', 4)) {
2192 + return false;
2193 + }
2194 + var status = this._sock.rQshift32();
2195 + if (status === 0) {
2196 + // OK
2197 + this._rfbInitState = 'ClientInitialisation';
2198 + Log.Debug('Authentication OK');
2199 + return true;
2200 + } else {
2201 + if (this._rfbVersion >= 3.8) {
2202 + this._rfbInitState = "SecurityReason";
2203 + this._securityContext = "security result";
2204 + this._securityStatus = status;
2205 + return true;
2206 + } else {
2207 + this.dispatchEvent(new CustomEvent("securityfailure", {
2208 + detail: {
2209 + status: status
2210 + }
2211 + }));
2212 + return this._fail("Security handshake failed");
2213 + }
2214 + }
2215 + }
2216 + }, {
2217 + key: "_negotiateServerInit",
2218 + value: function _negotiateServerInit() {
2219 + if (this._sock.rQwait("server initialization", 24)) {
2220 + return false;
2221 + }
2222 +
2223 + /* Screen size */
2224 + var width = this._sock.rQshift16();
2225 + var height = this._sock.rQshift16();
2226 +
2227 + /* PIXEL_FORMAT */
2228 + var bpp = this._sock.rQshift8();
2229 + var depth = this._sock.rQshift8();
2230 + var bigEndian = this._sock.rQshift8();
2231 + var trueColor = this._sock.rQshift8();
2232 + var redMax = this._sock.rQshift16();
2233 + var greenMax = this._sock.rQshift16();
2234 + var blueMax = this._sock.rQshift16();
2235 + var redShift = this._sock.rQshift8();
2236 + var greenShift = this._sock.rQshift8();
2237 + var blueShift = this._sock.rQshift8();
2238 + this._sock.rQskipBytes(3); // padding
2239 +
2240 + // NB(directxman12): we don't want to call any callbacks or print messages until
2241 + // *after* we're past the point where we could backtrack
2242 +
2243 + /* Connection name/title */
2244 + var nameLength = this._sock.rQshift32();
2245 + if (this._sock.rQwait('server init name', nameLength, 24)) {
2246 + return false;
2247 + }
2248 + var name = this._sock.rQshiftStr(nameLength);
2249 + name = (0, _strings.decodeUTF8)(name, true);
2250 + if (this._rfbTightVNC) {
2251 + if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + nameLength)) {
2252 + return false;
2253 + }
2254 + // In TightVNC mode, ServerInit message is extended
2255 + var numServerMessages = this._sock.rQshift16();
2256 + var numClientMessages = this._sock.rQshift16();
2257 + var numEncodings = this._sock.rQshift16();
2258 + this._sock.rQskipBytes(2); // padding
2259 +
2260 + var totalMessagesLength = (numServerMessages + numClientMessages + numEncodings) * 16;
2261 + if (this._sock.rQwait('TightVNC extended server init header', totalMessagesLength, 32 + nameLength)) {
2262 + return false;
2263 + }
2264 +
2265 + // we don't actually do anything with the capability information that TIGHT sends,
2266 + // so we just skip the all of this.
2267 +
2268 + // TIGHT server message capabilities
2269 + this._sock.rQskipBytes(16 * numServerMessages);
2270 +
2271 + // TIGHT client message capabilities
2272 + this._sock.rQskipBytes(16 * numClientMessages);
2273 +
2274 + // TIGHT encoding capabilities
2275 + this._sock.rQskipBytes(16 * numEncodings);
2276 + }
2277 +
2278 + // NB(directxman12): these are down here so that we don't run them multiple times
2279 + // if we backtrack
2280 + Log.Info("Screen: " + width + "x" + height + ", bpp: " + bpp + ", depth: " + depth + ", bigEndian: " + bigEndian + ", trueColor: " + trueColor + ", redMax: " + redMax + ", greenMax: " + greenMax + ", blueMax: " + blueMax + ", redShift: " + redShift + ", greenShift: " + greenShift + ", blueShift: " + blueShift);
2281 +
2282 + // we're past the point where we could backtrack, so it's safe to call this
2283 + this._setDesktopName(name);
2284 + this._resize(width, height);
2285 + if (!this._viewOnly) {
2286 + this._keyboard.grab();
2287 + }
2288 + this._fbDepth = 24;
2289 + if (this._fbName === "Intel(r) AMT KVM") {
2290 + Log.Warn("Intel AMT KVM only supports 8/16 bit depths. Using low color mode.");
2291 + this._fbDepth = 8;
2292 + }
2293 + RFB.messages.pixelFormat(this._sock, this._fbDepth, true);
2294 + this._sendEncodings();
2295 + RFB.messages.fbUpdateRequest(this._sock, false, 0, 0, this._fbWidth, this._fbHeight);
2296 + this._updateConnectionState('connected');
2297 + return true;
2298 + }
2299 + }, {
2300 + key: "_sendEncodings",
2301 + value: function _sendEncodings() {
2302 + var encs = [];
2303 +
2304 + // In preference order
2305 + encs.push(_encodings.encodings.encodingCopyRect);
2306 + // Only supported with full depth support
2307 + if (this._fbDepth == 24) {
2308 + if (_browser.supportsWebCodecsH264Decode) {
2309 + encs.push(_encodings.encodings.encodingH264);
2310 + }
2311 + encs.push(_encodings.encodings.encodingTight);
2312 + encs.push(_encodings.encodings.encodingTightPNG);
2313 + encs.push(_encodings.encodings.encodingZRLE);
2314 + encs.push(_encodings.encodings.encodingJPEG);
2315 + encs.push(_encodings.encodings.encodingHextile);
2316 + encs.push(_encodings.encodings.encodingRRE);
2317 + encs.push(_encodings.encodings.encodingZlib);
2318 + }
2319 + encs.push(_encodings.encodings.encodingRaw);
2320 +
2321 + // Psuedo-encoding settings
2322 + encs.push(_encodings.encodings.pseudoEncodingQualityLevel0 + this._qualityLevel);
2323 + encs.push(_encodings.encodings.pseudoEncodingCompressLevel0 + this._compressionLevel);
2324 + encs.push(_encodings.encodings.pseudoEncodingDesktopSize);
2325 + encs.push(_encodings.encodings.pseudoEncodingLastRect);
2326 + encs.push(_encodings.encodings.pseudoEncodingQEMUExtendedKeyEvent);
2327 + encs.push(_encodings.encodings.pseudoEncodingQEMULedEvent);
2328 + encs.push(_encodings.encodings.pseudoEncodingExtendedDesktopSize);
2329 + encs.push(_encodings.encodings.pseudoEncodingXvp);
2330 + encs.push(_encodings.encodings.pseudoEncodingFence);
2331 + encs.push(_encodings.encodings.pseudoEncodingContinuousUpdates);
2332 + encs.push(_encodings.encodings.pseudoEncodingDesktopName);
2333 + encs.push(_encodings.encodings.pseudoEncodingExtendedClipboard);
2334 + encs.push(_encodings.encodings.pseudoEncodingExtendedMouseButtons);
2335 + if (this._fbDepth == 24) {
2336 + encs.push(_encodings.encodings.pseudoEncodingVMwareCursor);
2337 + encs.push(_encodings.encodings.pseudoEncodingCursor);
2338 + }
2339 + RFB.messages.clientEncodings(this._sock, encs);
2340 + }
2341 +
2342 + /* RFB protocol initialization states:
2343 + * ProtocolVersion
2344 + * Security
2345 + * Authentication
2346 + * SecurityResult
2347 + * ClientInitialization - not triggered by server message
2348 + * ServerInitialization
2349 + */
2350 + }, {
2351 + key: "_initMsg",
2352 + value: function _initMsg() {
2353 + switch (this._rfbInitState) {
2354 + case 'ProtocolVersion':
2355 + return this._negotiateProtocolVersion();
2356 + case 'Security':
2357 + return this._negotiateSecurity();
2358 + case 'Authentication':
2359 + return this._negotiateAuthentication();
2360 + case 'SecurityResult':
2361 + return this._handleSecurityResult();
2362 + case 'SecurityReason':
2363 + return this._handleSecurityReason();
2364 + case 'ClientInitialisation':
2365 + this._sock.sQpush8(this._shared ? 1 : 0); // ClientInitialisation
2366 + this._sock.flush();
2367 + this._rfbInitState = 'ServerInitialisation';
2368 + return true;
2369 + case 'ServerInitialisation':
2370 + return this._negotiateServerInit();
2371 + default:
2372 + return this._fail("Unknown init state (state: " + this._rfbInitState + ")");
2373 + }
2374 + }
2375 +
2376 + // Resume authentication handshake after it was paused for some
2377 + // reason, e.g. waiting for a password from the user
2378 + }, {
2379 + key: "_resumeAuthentication",
2380 + value: function _resumeAuthentication() {
2381 + // We use setTimeout() so it's run in its own context, just like
2382 + // it originally did via the WebSocket's event handler
2383 + setTimeout(this._initMsg.bind(this), 0);
2384 + }
2385 + }, {
2386 + key: "_handleSetColourMapMsg",
2387 + value: function _handleSetColourMapMsg() {
2388 + Log.Debug("SetColorMapEntries");
2389 + return this._fail("Unexpected SetColorMapEntries message");
2390 + }
2391 + }, {
2392 + key: "_handleServerCutText",
2393 + value: function _handleServerCutText() {
2394 + Log.Debug("ServerCutText");
2395 + if (this._sock.rQwait("ServerCutText header", 7, 1)) {
2396 + return false;
2397 + }
2398 + this._sock.rQskipBytes(3); // Padding
2399 +
2400 + var length = this._sock.rQshift32();
2401 + length = (0, _int.toSigned32bit)(length);
2402 + if (this._sock.rQwait("ServerCutText content", Math.abs(length), 8)) {
2403 + return false;
2404 + }
2405 + if (length >= 0) {
2406 + //Standard msg
2407 + var text = this._sock.rQshiftStr(length);
2408 + if (this._viewOnly) {
2409 + return true;
2410 + }
2411 + this.dispatchEvent(new CustomEvent("clipboard", {
2412 + detail: {
2413 + text: text
2414 + }
2415 + }));
2416 + } else {
2417 + //Extended msg.
2418 + length = Math.abs(length);
2419 + var flags = this._sock.rQshift32();
2420 + var formats = flags & 0x0000FFFF;
2421 + var actions = flags & 0xFF000000;
2422 + var isCaps = !!(actions & extendedClipboardActionCaps);
2423 + if (isCaps) {
2424 + this._clipboardServerCapabilitiesFormats = {};
2425 + this._clipboardServerCapabilitiesActions = {};
2426 +
2427 + // Update our server capabilities for Formats
2428 + for (var i = 0; i <= 15; i++) {
2429 + var index = 1 << i;
2430 +
2431 + // Check if format flag is set.
2432 + if (formats & index) {
2433 + this._clipboardServerCapabilitiesFormats[index] = true;
2434 + // We don't send unsolicited clipboard, so we
2435 + // ignore the size
2436 + this._sock.rQshift32();
2437 + }
2438 + }
2439 +
2440 + // Update our server capabilities for Actions
2441 + for (var _i4 = 24; _i4 <= 31; _i4++) {
2442 + var _index = 1 << _i4;
2443 + this._clipboardServerCapabilitiesActions[_index] = !!(actions & _index);
2444 + }
2445 +
2446 + /* Caps handling done, send caps with the clients
2447 + capabilities set as a response */
2448 + var clientActions = [extendedClipboardActionCaps, extendedClipboardActionRequest, extendedClipboardActionPeek, extendedClipboardActionNotify, extendedClipboardActionProvide];
2449 + RFB.messages.extendedClipboardCaps(this._sock, clientActions, {
2450 + extendedClipboardFormatText: 0
2451 + });
2452 + } else if (actions === extendedClipboardActionRequest) {
2453 + if (this._viewOnly) {
2454 + return true;
2455 + }
2456 +
2457 + // Check if server has told us it can handle Provide and there is clipboard data to send.
2458 + if (this._clipboardText != null && this._clipboardServerCapabilitiesActions[extendedClipboardActionProvide]) {
2459 + if (formats & extendedClipboardFormatText) {
2460 + RFB.messages.extendedClipboardProvide(this._sock, [extendedClipboardFormatText], [this._clipboardText]);
2461 + }
2462 + }
2463 + } else if (actions === extendedClipboardActionPeek) {
2464 + if (this._viewOnly) {
2465 + return true;
2466 + }
2467 + if (this._clipboardServerCapabilitiesActions[extendedClipboardActionNotify]) {
2468 + if (this._clipboardText != null) {
2469 + RFB.messages.extendedClipboardNotify(this._sock, [extendedClipboardFormatText]);
2470 + } else {
2471 + RFB.messages.extendedClipboardNotify(this._sock, []);
2472 + }
2473 + }
2474 + } else if (actions === extendedClipboardActionNotify) {
2475 + if (this._viewOnly) {
2476 + return true;
2477 + }
2478 + if (this._clipboardServerCapabilitiesActions[extendedClipboardActionRequest]) {
2479 + if (formats & extendedClipboardFormatText) {
2480 + RFB.messages.extendedClipboardRequest(this._sock, [extendedClipboardFormatText]);
2481 + }
2482 + }
2483 + } else if (actions === extendedClipboardActionProvide) {
2484 + if (this._viewOnly) {
2485 + return true;
2486 + }
2487 + if (!(formats & extendedClipboardFormatText)) {
2488 + return true;
2489 + }
2490 + // Ignore what we had in our clipboard client side.
2491 + this._clipboardText = null;
2492 +
2493 + // FIXME: Should probably verify that this data was actually requested
2494 + var zlibStream = this._sock.rQshiftBytes(length - 4);
2495 + var streamInflator = new _inflator["default"]();
2496 + var textData = null;
2497 + streamInflator.setInput(zlibStream);
2498 + for (var _i5 = 0; _i5 <= 15; _i5++) {
2499 + var format = 1 << _i5;
2500 + if (formats & format) {
2501 + var size = 0x00;
2502 + var sizeArray = streamInflator.inflate(4);
2503 + size |= sizeArray[0] << 24;
2504 + size |= sizeArray[1] << 16;
2505 + size |= sizeArray[2] << 8;
2506 + size |= sizeArray[3];
2507 + var chunk = streamInflator.inflate(size);
2508 + if (format === extendedClipboardFormatText) {
2509 + textData = chunk;
2510 + }
2511 + }
2512 + }
2513 + streamInflator.setInput(null);
2514 + if (textData !== null) {
2515 + var tmpText = "";
2516 + for (var _i6 = 0; _i6 < textData.length; _i6++) {
2517 + tmpText += String.fromCharCode(textData[_i6]);
2518 + }
2519 + textData = tmpText;
2520 + textData = (0, _strings.decodeUTF8)(textData);
2521 + if (textData.length > 0 && "\0" === textData.charAt(textData.length - 1)) {
2522 + textData = textData.slice(0, -1);
2523 + }
2524 + textData = textData.replaceAll("\r\n", "\n");
2525 + this.dispatchEvent(new CustomEvent("clipboard", {
2526 + detail: {
2527 + text: textData
2528 + }
2529 + }));
2530 + }
2531 + } else {
2532 + return this._fail("Unexpected action in extended clipboard message: " + actions);
2533 + }
2534 + }
2535 + return true;
2536 + }
2537 + }, {
2538 + key: "_handleServerFenceMsg",
2539 + value: function _handleServerFenceMsg() {
2540 + if (this._sock.rQwait("ServerFence header", 8, 1)) {
2541 + return false;
2542 + }
2543 + this._sock.rQskipBytes(3); // Padding
2544 + var flags = this._sock.rQshift32();
2545 + var length = this._sock.rQshift8();
2546 + if (this._sock.rQwait("ServerFence payload", length, 9)) {
2547 + return false;
2548 + }
2549 + if (length > 64) {
2550 + Log.Warn("Bad payload length (" + length + ") in fence response");
2551 + length = 64;
2552 + }
2553 + var payload = this._sock.rQshiftStr(length);
2554 + this._supportsFence = true;
2555 +
2556 + /*
2557 + * Fence flags
2558 + *
2559 + * (1<<0) - BlockBefore
2560 + * (1<<1) - BlockAfter
2561 + * (1<<2) - SyncNext
2562 + * (1<<31) - Request
2563 + */
2564 +
2565 + if (!(flags & 1 << 31)) {
2566 + return this._fail("Unexpected fence response");
2567 + }
2568 +
2569 + // Filter out unsupported flags
2570 + // FIXME: support syncNext
2571 + flags &= 1 << 0 | 1 << 1;
2572 +
2573 + // BlockBefore and BlockAfter are automatically handled by
2574 + // the fact that we process each incoming message
2575 + // synchronuosly.
2576 + RFB.messages.clientFence(this._sock, flags, payload);
2577 + return true;
2578 + }
2579 + }, {
2580 + key: "_handleXvpMsg",
2581 + value: function _handleXvpMsg() {
2582 + if (this._sock.rQwait("XVP version and message", 3, 1)) {
2583 + return false;
2584 + }
2585 + this._sock.rQskipBytes(1); // Padding
2586 + var xvpVer = this._sock.rQshift8();
2587 + var xvpMsg = this._sock.rQshift8();
2588 + switch (xvpMsg) {
2589 + case 0:
2590 + // XVP_FAIL
2591 + Log.Error("XVP operation failed");
2592 + break;
2593 + case 1:
2594 + // XVP_INIT
2595 + this._rfbXvpVer = xvpVer;
2596 + Log.Info("XVP extensions enabled (version " + this._rfbXvpVer + ")");
2597 + this._setCapability("power", true);
2598 + break;
2599 + default:
2600 + this._fail("Illegal server XVP message (msg: " + xvpMsg + ")");
2601 + break;
2602 + }
2603 + return true;
2604 + }
2605 + }, {
2606 + key: "_normalMsg",
2607 + value: function _normalMsg() {
2608 + var msgType;
2609 + if (this._FBU.rects > 0) {
2610 + msgType = 0;
2611 + } else {
2612 + msgType = this._sock.rQshift8();
2613 + }
2614 + var first, ret;
2615 + switch (msgType) {
2616 + case 0:
2617 + // FramebufferUpdate
2618 + ret = this._framebufferUpdate();
2619 + if (ret && !this._enabledContinuousUpdates) {
2620 + RFB.messages.fbUpdateRequest(this._sock, true, 0, 0, this._fbWidth, this._fbHeight);
2621 + }
2622 + return ret;
2623 + case 1:
2624 + // SetColorMapEntries
2625 + return this._handleSetColourMapMsg();
2626 + case 2:
2627 + // Bell
2628 + Log.Debug("Bell");
2629 + this.dispatchEvent(new CustomEvent("bell", {
2630 + detail: {}
2631 + }));
2632 + return true;
2633 + case 3:
2634 + // ServerCutText
2635 + return this._handleServerCutText();
2636 + case 150:
2637 + // EndOfContinuousUpdates
2638 + first = !this._supportsContinuousUpdates;
2639 + this._supportsContinuousUpdates = true;
2640 + this._enabledContinuousUpdates = false;
2641 + if (first) {
2642 + this._enabledContinuousUpdates = true;
2643 + this._updateContinuousUpdates();
2644 + Log.Info("Enabling continuous updates.");
2645 + } else {
2646 + // FIXME: We need to send a framebufferupdaterequest here
2647 + // if we add support for turning off continuous updates
2648 + }
2649 + return true;
2650 + case 248:
2651 + // ServerFence
2652 + return this._handleServerFenceMsg();
2653 + case 250:
2654 + // XVP
2655 + return this._handleXvpMsg();
2656 + default:
2657 + this._fail("Unexpected server message (type " + msgType + ")");
2658 + Log.Debug("sock.rQpeekBytes(30): " + this._sock.rQpeekBytes(30));
2659 + return true;
2660 + }
2661 + }
2662 + }, {
2663 + key: "_framebufferUpdate",
2664 + value: function _framebufferUpdate() {
2665 + var _this6 = this;
2666 + if (this._FBU.rects === 0) {
2667 + if (this._sock.rQwait("FBU header", 3, 1)) {
2668 + return false;
2669 + }
2670 + this._sock.rQskipBytes(1); // Padding
2671 + this._FBU.rects = this._sock.rQshift16();
2672 +
2673 + // Make sure the previous frame is fully rendered first
2674 + // to avoid building up an excessive queue
2675 + if (this._display.pending()) {
2676 + this._flushing = true;
2677 + this._display.flush().then(function () {
2678 + _this6._flushing = false;
2679 + // Resume processing
2680 + if (!_this6._sock.rQwait("message", 1)) {
2681 + _this6._handleMessage();
2682 + }
2683 + });
2684 + return false;
2685 + }
2686 + }
2687 + while (this._FBU.rects > 0) {
2688 + if (this._FBU.encoding === null) {
2689 + if (this._sock.rQwait("rect header", 12)) {
2690 + return false;
2691 + }
2692 + /* New FramebufferUpdate */
2693 +
2694 + this._FBU.x = this._sock.rQshift16();
2695 + this._FBU.y = this._sock.rQshift16();
2696 + this._FBU.width = this._sock.rQshift16();
2697 + this._FBU.height = this._sock.rQshift16();
2698 + this._FBU.encoding = this._sock.rQshift32();
2699 + /* Encodings are signed */
2700 + this._FBU.encoding >>= 0;
2701 + }
2702 + if (!this._handleRect()) {
2703 + return false;
2704 + }
2705 + this._FBU.rects--;
2706 + this._FBU.encoding = null;
2707 + }
2708 + this._display.flip();
2709 + return true; // We finished this FBU
2710 + }
2711 + }, {
2712 + key: "_handleRect",
2713 + value: function _handleRect() {
2714 + switch (this._FBU.encoding) {
2715 + case _encodings.encodings.pseudoEncodingLastRect:
2716 + this._FBU.rects = 1; // Will be decreased when we return
2717 + return true;
2718 + case _encodings.encodings.pseudoEncodingVMwareCursor:
2719 + return this._handleVMwareCursor();
2720 + case _encodings.encodings.pseudoEncodingCursor:
2721 + return this._handleCursor();
2722 + case _encodings.encodings.pseudoEncodingQEMUExtendedKeyEvent:
2723 + this._qemuExtKeyEventSupported = true;
2724 + return true;
2725 + case _encodings.encodings.pseudoEncodingDesktopName:
2726 + return this._handleDesktopName();
2727 + case _encodings.encodings.pseudoEncodingDesktopSize:
2728 + this._resize(this._FBU.width, this._FBU.height);
2729 + return true;
2730 + case _encodings.encodings.pseudoEncodingExtendedDesktopSize:
2731 + return this._handleExtendedDesktopSize();
2732 + case _encodings.encodings.pseudoEncodingExtendedMouseButtons:
2733 + this._extendedPointerEventSupported = true;
2734 + return true;
2735 + case _encodings.encodings.pseudoEncodingQEMULedEvent:
2736 + return this._handleLedEvent();
2737 + default:
2738 + return this._handleDataRect();
2739 + }
2740 + }
2741 + }, {
2742 + key: "_handleVMwareCursor",
2743 + value: function _handleVMwareCursor() {
2744 + var hotx = this._FBU.x; // hotspot-x
2745 + var hoty = this._FBU.y; // hotspot-y
2746 + var w = this._FBU.width;
2747 + var h = this._FBU.height;
2748 + if (this._sock.rQwait("VMware cursor encoding", 1)) {
2749 + return false;
2750 + }
2751 + var cursorType = this._sock.rQshift8();
2752 + this._sock.rQshift8(); //Padding
2753 +
2754 + var rgba;
2755 + var bytesPerPixel = 4;
2756 +
2757 + //Classic cursor
2758 + if (cursorType == 0) {
2759 + //Used to filter away unimportant bits.
2760 + //OR is used for correct conversion in js.
2761 + var PIXEL_MASK = 0xffffff00 | 0;
2762 + rgba = new Array(w * h * bytesPerPixel);
2763 + if (this._sock.rQwait("VMware cursor classic encoding", w * h * bytesPerPixel * 2, 2)) {
2764 + return false;
2765 + }
2766 + var andMask = new Array(w * h);
2767 + for (var pixel = 0; pixel < w * h; pixel++) {
2768 + andMask[pixel] = this._sock.rQshift32();
2769 + }
2770 + var xorMask = new Array(w * h);
2771 + for (var _pixel = 0; _pixel < w * h; _pixel++) {
2772 + xorMask[_pixel] = this._sock.rQshift32();
2773 + }
2774 + for (var _pixel2 = 0; _pixel2 < w * h; _pixel2++) {
2775 + if (andMask[_pixel2] == 0) {
2776 + //Fully opaque pixel
2777 + var bgr = xorMask[_pixel2];
2778 + var r = bgr >> 8 & 0xff;
2779 + var g = bgr >> 16 & 0xff;
2780 + var b = bgr >> 24 & 0xff;
2781 + rgba[_pixel2 * bytesPerPixel] = r; //r
2782 + rgba[_pixel2 * bytesPerPixel + 1] = g; //g
2783 + rgba[_pixel2 * bytesPerPixel + 2] = b; //b
2784 + rgba[_pixel2 * bytesPerPixel + 3] = 0xff; //a
2785 + } else if ((andMask[_pixel2] & PIXEL_MASK) == PIXEL_MASK) {
2786 + //Only screen value matters, no mouse colouring
2787 + if (xorMask[_pixel2] == 0) {
2788 + //Transparent pixel
2789 + rgba[_pixel2 * bytesPerPixel] = 0x00;
2790 + rgba[_pixel2 * bytesPerPixel + 1] = 0x00;
2791 + rgba[_pixel2 * bytesPerPixel + 2] = 0x00;
2792 + rgba[_pixel2 * bytesPerPixel + 3] = 0x00;
2793 + } else if ((xorMask[_pixel2] & PIXEL_MASK) == PIXEL_MASK) {
2794 + //Inverted pixel, not supported in browsers.
2795 + //Fully opaque instead.
2796 + rgba[_pixel2 * bytesPerPixel] = 0x00;
2797 + rgba[_pixel2 * bytesPerPixel + 1] = 0x00;
2798 + rgba[_pixel2 * bytesPerPixel + 2] = 0x00;
2799 + rgba[_pixel2 * bytesPerPixel + 3] = 0xff;
2800 + } else {
2801 + //Unhandled xorMask
2802 + rgba[_pixel2 * bytesPerPixel] = 0x00;
2803 + rgba[_pixel2 * bytesPerPixel + 1] = 0x00;
2804 + rgba[_pixel2 * bytesPerPixel + 2] = 0x00;
2805 + rgba[_pixel2 * bytesPerPixel + 3] = 0xff;
2806 + }
2807 + } else {
2808 + //Unhandled andMask
2809 + rgba[_pixel2 * bytesPerPixel] = 0x00;
2810 + rgba[_pixel2 * bytesPerPixel + 1] = 0x00;
2811 + rgba[_pixel2 * bytesPerPixel + 2] = 0x00;
2812 + rgba[_pixel2 * bytesPerPixel + 3] = 0xff;
2813 + }
2814 + }
2815 +
2816 + //Alpha cursor.
2817 + } else if (cursorType == 1) {
2818 + if (this._sock.rQwait("VMware cursor alpha encoding", w * h * 4, 2)) {
2819 + return false;
2820 + }
2821 + rgba = new Array(w * h * bytesPerPixel);
2822 + for (var _pixel3 = 0; _pixel3 < w * h; _pixel3++) {
2823 + var data = this._sock.rQshift32();
2824 + rgba[_pixel3 * 4] = data >> 24 & 0xff; //r
2825 + rgba[_pixel3 * 4 + 1] = data >> 16 & 0xff; //g
2826 + rgba[_pixel3 * 4 + 2] = data >> 8 & 0xff; //b
2827 + rgba[_pixel3 * 4 + 3] = data & 0xff; //a
2828 + }
2829 + } else {
2830 + Log.Warn("The given cursor type is not supported: " + cursorType + " given.");
2831 + return false;
2832 + }
2833 + this._updateCursor(rgba, hotx, hoty, w, h);
2834 + return true;
2835 + }
2836 + }, {
2837 + key: "_handleCursor",
2838 + value: function _handleCursor() {
2839 + var hotx = this._FBU.x; // hotspot-x
2840 + var hoty = this._FBU.y; // hotspot-y
2841 + var w = this._FBU.width;
2842 + var h = this._FBU.height;
2843 + var pixelslength = w * h * 4;
2844 + var masklength = Math.ceil(w / 8) * h;
2845 + var bytes = pixelslength + masklength;
2846 + if (this._sock.rQwait("cursor encoding", bytes)) {
2847 + return false;
2848 + }
2849 +
2850 + // Decode from BGRX pixels + bit mask to RGBA
2851 + var pixels = this._sock.rQshiftBytes(pixelslength);
2852 + var mask = this._sock.rQshiftBytes(masklength);
2853 + var rgba = new Uint8Array(w * h * 4);
2854 + var pixIdx = 0;
2855 + for (var y = 0; y < h; y++) {
2856 + for (var x = 0; x < w; x++) {
2857 + var maskIdx = y * Math.ceil(w / 8) + Math.floor(x / 8);
2858 + var alpha = mask[maskIdx] << x % 8 & 0x80 ? 255 : 0;
2859 + rgba[pixIdx] = pixels[pixIdx + 2];
2860 + rgba[pixIdx + 1] = pixels[pixIdx + 1];
2861 + rgba[pixIdx + 2] = pixels[pixIdx];
2862 + rgba[pixIdx + 3] = alpha;
2863 + pixIdx += 4;
2864 + }
2865 + }
2866 + this._updateCursor(rgba, hotx, hoty, w, h);
2867 + return true;
2868 + }
2869 + }, {
2870 + key: "_handleDesktopName",
2871 + value: function _handleDesktopName() {
2872 + if (this._sock.rQwait("DesktopName", 4)) {
2873 + return false;
2874 + }
2875 + var length = this._sock.rQshift32();
2876 + if (this._sock.rQwait("DesktopName", length, 4)) {
2877 + return false;
2878 + }
2879 + var name = this._sock.rQshiftStr(length);
2880 + name = (0, _strings.decodeUTF8)(name, true);
2881 + this._setDesktopName(name);
2882 + return true;
2883 + }
2884 + }, {
2885 + key: "_handleLedEvent",
2886 + value: function _handleLedEvent() {
2887 + if (this._sock.rQwait("LED status", 1)) {
2888 + return false;
2889 + }
2890 + var data = this._sock.rQshift8();
2891 + // ScrollLock state can be retrieved with data & 1. This is currently not needed.
2892 + var numLock = data & 2 ? true : false;
2893 + var capsLock = data & 4 ? true : false;
2894 + this._remoteCapsLock = capsLock;
2895 + this._remoteNumLock = numLock;
2896 + return true;
2897 + }
2898 + }, {
2899 + key: "_handleExtendedDesktopSize",
2900 + value: function _handleExtendedDesktopSize() {
2901 + if (this._sock.rQwait("ExtendedDesktopSize", 4)) {
2902 + return false;
2903 + }
2904 + var numberOfScreens = this._sock.rQpeek8();
2905 + var bytes = 4 + numberOfScreens * 16;
2906 + if (this._sock.rQwait("ExtendedDesktopSize", bytes)) {
2907 + return false;
2908 + }
2909 + var firstUpdate = !this._supportsSetDesktopSize;
2910 + this._supportsSetDesktopSize = true;
2911 + this._sock.rQskipBytes(1); // number-of-screens
2912 + this._sock.rQskipBytes(3); // padding
2913 +
2914 + for (var i = 0; i < numberOfScreens; i += 1) {
2915 + // Save the id and flags of the first screen
2916 + if (i === 0) {
2917 + this._screenID = this._sock.rQshift32(); // id
2918 + this._sock.rQskipBytes(2); // x-position
2919 + this._sock.rQskipBytes(2); // y-position
2920 + this._sock.rQskipBytes(2); // width
2921 + this._sock.rQskipBytes(2); // height
2922 + this._screenFlags = this._sock.rQshift32(); // flags
2923 + } else {
2924 + this._sock.rQskipBytes(16);
2925 + }
2926 + }
2927 +
2928 + /*
2929 + * The x-position indicates the reason for the change:
2930 + *
2931 + * 0 - server resized on its own
2932 + * 1 - this client requested the resize
2933 + * 2 - another client requested the resize
2934 + */
2935 +
2936 + if (this._FBU.x === 1) {
2937 + this._pendingRemoteResize = false;
2938 + }
2939 +
2940 + // We need to handle errors when we requested the resize.
2941 + if (this._FBU.x === 1 && this._FBU.y !== 0) {
2942 + var msg = "";
2943 + // The y-position indicates the status code from the server
2944 + switch (this._FBU.y) {
2945 + case 1:
2946 + msg = "Resize is administratively prohibited";
2947 + break;
2948 + case 2:
2949 + msg = "Out of resources";
2950 + break;
2951 + case 3:
2952 + msg = "Invalid screen layout";
2953 + break;
2954 + default:
2955 + msg = "Unknown reason";
2956 + break;
2957 + }
2958 + Log.Warn("Server did not accept the resize request: " + msg);
2959 + } else {
2960 + this._resize(this._FBU.width, this._FBU.height);
2961 + }
2962 +
2963 + // Normally we only apply the current resize mode after a
2964 + // window resize event. However there is no such trigger on the
2965 + // initial connect. And we don't know if the server supports
2966 + // resizing until we've gotten here.
2967 + if (firstUpdate) {
2968 + this._requestRemoteResize();
2969 + }
2970 + if (this._FBU.x === 1 && this._FBU.y === 0) {
2971 + // We might have resized again whilst waiting for the
2972 + // previous request, so check if we are in sync
2973 + this._requestRemoteResize();
2974 + }
2975 + return true;
2976 + }
2977 + }, {
2978 + key: "_handleDataRect",
2979 + value: function _handleDataRect() {
2980 + var decoder = this._decoders[this._FBU.encoding];
2981 + if (!decoder) {
2982 + this._fail("Unsupported encoding (encoding: " + this._FBU.encoding + ")");
2983 + return false;
2984 + }
2985 + try {
2986 + return decoder.decodeRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, this._sock, this._display, this._fbDepth);
2987 + } catch (err) {
2988 + this._fail("Error decoding rect: " + err);
2989 + return false;
2990 + }
2991 + }
2992 + }, {
2993 + key: "_updateContinuousUpdates",
2994 + value: function _updateContinuousUpdates() {
2995 + if (!this._enabledContinuousUpdates) {
2996 + return;
2997 + }
2998 + RFB.messages.enableContinuousUpdates(this._sock, true, 0, 0, this._fbWidth, this._fbHeight);
2999 + }
3000 +
3001 + // Handle resize-messages from the server
3002 + }, {
3003 + key: "_resize",
3004 + value: function _resize(width, height) {
3005 + this._fbWidth = width;
3006 + this._fbHeight = height;
3007 + this._display.resize(this._fbWidth, this._fbHeight);
3008 +
3009 + // Adjust the visible viewport based on the new dimensions
3010 + this._updateClip();
3011 + this._updateScale();
3012 + this._updateContinuousUpdates();
3013 +
3014 + // Keep this size until browser client size changes
3015 + this._saveExpectedClientSize();
3016 + }
3017 + }, {
3018 + key: "_xvpOp",
3019 + value: function _xvpOp(ver, op) {
3020 + if (this._rfbXvpVer < ver) {
3021 + return;
3022 + }
3023 + Log.Info("Sending XVP operation " + op + " (version " + ver + ")");
3024 + RFB.messages.xvpOp(this._sock, ver, op);
3025 + }
3026 + }, {
3027 + key: "_updateCursor",
3028 + value: function _updateCursor(rgba, hotx, hoty, w, h) {
3029 + this._cursorImage = {
3030 + rgbaPixels: rgba,
3031 + hotx: hotx,
3032 + hoty: hoty,
3033 + w: w,
3034 + h: h
3035 + };
3036 + this._refreshCursor();
3037 + }
3038 + }, {
3039 + key: "_shouldShowDotCursor",
3040 + value: function _shouldShowDotCursor() {
3041 + // Called when this._cursorImage is updated
3042 + if (!this._showDotCursor) {
3043 + // User does not want to see the dot, so...
3044 + return false;
3045 + }
3046 +
3047 + // The dot should not be shown if the cursor is already visible,
3048 + // i.e. contains at least one not-fully-transparent pixel.
3049 + // So iterate through all alpha bytes in rgba and stop at the
3050 + // first non-zero.
3051 + for (var i = 3; i < this._cursorImage.rgbaPixels.length; i += 4) {
3052 + if (this._cursorImage.rgbaPixels[i]) {
3053 + return false;
3054 + }
3055 + }
3056 +
3057 + // At this point, we know that the cursor is fully transparent, and
3058 + // the user wants to see the dot instead of this.
3059 + return true;
3060 + }
3061 + }, {
3062 + key: "_refreshCursor",
3063 + value: function _refreshCursor() {
3064 + if (this._rfbConnectionState !== "connecting" && this._rfbConnectionState !== "connected") {
3065 + return;
3066 + }
3067 + var image = this._shouldShowDotCursor() ? RFB.cursors.dot : this._cursorImage;
3068 + this._cursor.change(image.rgbaPixels, image.hotx, image.hoty, image.w, image.h);
3069 + }
3070 + }], [{
3071 + key: "_convertButtonMask",
3072 + value: function _convertButtonMask(buttons) {
3073 + /* The bits in MouseEvent.buttons property correspond
3074 + * to the following mouse buttons:
3075 + * 0: Left
3076 + * 1: Right
3077 + * 2: Middle
3078 + * 3: Back
3079 + * 4: Forward
3080 + *
3081 + * These bits needs to be converted to what they are defined as
3082 + * in the RFB protocol.
3083 + */
3084 +
3085 + var buttonMaskMap = {
3086 + 0: 1 << 0,
3087 + // Left
3088 + 1: 1 << 2,
3089 + // Right
3090 + 2: 1 << 1,
3091 + // Middle
3092 + 3: 1 << 7,
3093 + // Back
3094 + 4: 1 << 8 // Forward
3095 + };
3096 + var bmask = 0;
3097 + for (var i = 0; i < 5; i++) {
3098 + if (buttons & 1 << i) {
3099 + bmask |= buttonMaskMap[i];
3100 + }
3101 + }
3102 + return bmask;
3103 + }
3104 + }, {
3105 + key: "genDES",
3106 + value: function genDES(password, challenge) {
3107 + var passwordChars = password.split('').map(function (c) {
3108 + return c.charCodeAt(0);
3109 + });
3110 + var key = _crypto["default"].importKey("raw", passwordChars, {
3111 + name: "DES-ECB"
3112 + }, false, ["encrypt"]);
3113 + return _crypto["default"].encrypt({
3114 + name: "DES-ECB"
3115 + }, key, challenge);
3116 + }
3117 + }]);
3118 +}(_eventtarget["default"]); // Class Methods
3119 +RFB.messages = {
3120 + keyEvent: function keyEvent(sock, keysym, down) {
3121 + sock.sQpush8(4); // msg-type
3122 + sock.sQpush8(down);
3123 + sock.sQpush16(0);
3124 + sock.sQpush32(keysym);
3125 + sock.flush();
3126 + },
3127 + QEMUExtendedKeyEvent: function QEMUExtendedKeyEvent(sock, keysym, down, keycode) {
3128 + function getRFBkeycode(xtScanCode) {
3129 + var upperByte = keycode >> 8;
3130 + var lowerByte = keycode & 0x00ff;
3131 + if (upperByte === 0xe0 && lowerByte < 0x7f) {
3132 + return lowerByte | 0x80;
3133 + }
3134 + return xtScanCode;
3135 + }
3136 + sock.sQpush8(255); // msg-type
3137 + sock.sQpush8(0); // sub msg-type
3138 +
3139 + sock.sQpush16(down);
3140 + sock.sQpush32(keysym);
3141 + var RFBkeycode = getRFBkeycode(keycode);
3142 + sock.sQpush32(RFBkeycode);
3143 + sock.flush();
3144 + },
3145 + pointerEvent: function pointerEvent(sock, x, y, mask) {
3146 + sock.sQpush8(5); // msg-type
3147 +
3148 + // Marker bit must be set to 0, otherwise the server might
3149 + // confuse the marker bit with the highest bit in a normal
3150 + // PointerEvent message.
3151 + mask = mask & 0x7f;
3152 + sock.sQpush8(mask);
3153 + sock.sQpush16(x);
3154 + sock.sQpush16(y);
3155 + sock.flush();
3156 + },
3157 + extendedPointerEvent: function extendedPointerEvent(sock, x, y, mask) {
3158 + sock.sQpush8(5); // msg-type
3159 +
3160 + var higherBits = mask >> 7 & 0xff;
3161 +
3162 + // Bits 2-7 are reserved
3163 + if (higherBits & 0xfc) {
3164 + throw new Error("Invalid mouse button mask: " + mask);
3165 + }
3166 + var lowerBits = mask & 0x7f;
3167 + lowerBits |= 0x80; // Set marker bit to 1
3168 +
3169 + sock.sQpush8(lowerBits);
3170 + sock.sQpush16(x);
3171 + sock.sQpush16(y);
3172 + sock.sQpush8(higherBits);
3173 + sock.flush();
3174 + },
3175 + // Used to build Notify and Request data.
3176 + _buildExtendedClipboardFlags: function _buildExtendedClipboardFlags(actions, formats) {
3177 + var data = new Uint8Array(4);
3178 + var formatFlag = 0x00000000;
3179 + var actionFlag = 0x00000000;
3180 + for (var i = 0; i < actions.length; i++) {
3181 + actionFlag |= actions[i];
3182 + }
3183 + for (var _i7 = 0; _i7 < formats.length; _i7++) {
3184 + formatFlag |= formats[_i7];
3185 + }
3186 + data[0] = actionFlag >> 24; // Actions
3187 + data[1] = 0x00; // Reserved
3188 + data[2] = 0x00; // Reserved
3189 + data[3] = formatFlag; // Formats
3190 +
3191 + return data;
3192 + },
3193 + extendedClipboardProvide: function extendedClipboardProvide(sock, formats, inData) {
3194 + // Deflate incomming data and their sizes
3195 + var deflator = new _deflator["default"]();
3196 + var dataToDeflate = [];
3197 + for (var i = 0; i < formats.length; i++) {
3198 + // We only support the format Text at this time
3199 + if (formats[i] != extendedClipboardFormatText) {
3200 + throw new Error("Unsupported extended clipboard format for Provide message.");
3201 + }
3202 +
3203 + // Change lone \r or \n into \r\n as defined in rfbproto
3204 + inData[i] = inData[i].replace(/\r\n|\r|\n/gm, "\r\n");
3205 +
3206 + // Check if it already has \0
3207 + var text = (0, _strings.encodeUTF8)(inData[i] + "\0");
3208 + dataToDeflate.push(text.length >> 24 & 0xFF, text.length >> 16 & 0xFF, text.length >> 8 & 0xFF, text.length & 0xFF);
3209 + for (var j = 0; j < text.length; j++) {
3210 + dataToDeflate.push(text.charCodeAt(j));
3211 + }
3212 + }
3213 + var deflatedData = deflator.deflate(new Uint8Array(dataToDeflate));
3214 +
3215 + // Build data to send
3216 + var data = new Uint8Array(4 + deflatedData.length);
3217 + data.set(RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionProvide], formats));
3218 + data.set(deflatedData, 4);
3219 + RFB.messages.clientCutText(sock, data, true);
3220 + },
3221 + extendedClipboardNotify: function extendedClipboardNotify(sock, formats) {
3222 + var flags = RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionNotify], formats);
3223 + RFB.messages.clientCutText(sock, flags, true);
3224 + },
3225 + extendedClipboardRequest: function extendedClipboardRequest(sock, formats) {
3226 + var flags = RFB.messages._buildExtendedClipboardFlags([extendedClipboardActionRequest], formats);
3227 + RFB.messages.clientCutText(sock, flags, true);
3228 + },
3229 + extendedClipboardCaps: function extendedClipboardCaps(sock, actions, formats) {
3230 + var formatKeys = Object.keys(formats);
3231 + var data = new Uint8Array(4 + 4 * formatKeys.length);
3232 + formatKeys.map(function (x) {
3233 + return parseInt(x);
3234 + });
3235 + formatKeys.sort(function (a, b) {
3236 + return a - b;
3237 + });
3238 + data.set(RFB.messages._buildExtendedClipboardFlags(actions, []));
3239 + var loopOffset = 4;
3240 + for (var i = 0; i < formatKeys.length; i++) {
3241 + data[loopOffset] = formats[formatKeys[i]] >> 24;
3242 + data[loopOffset + 1] = formats[formatKeys[i]] >> 16;
3243 + data[loopOffset + 2] = formats[formatKeys[i]] >> 8;
3244 + data[loopOffset + 3] = formats[formatKeys[i]] >> 0;
3245 + loopOffset += 4;
3246 + data[3] |= 1 << formatKeys[i]; // Update our format flags
3247 + }
3248 + RFB.messages.clientCutText(sock, data, true);
3249 + },
3250 + clientCutText: function clientCutText(sock, data) {
3251 + var extended = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3252 + sock.sQpush8(6); // msg-type
3253 +
3254 + sock.sQpush8(0); // padding
3255 + sock.sQpush8(0); // padding
3256 + sock.sQpush8(0); // padding
3257 +
3258 + var length;
3259 + if (extended) {
3260 + length = (0, _int.toUnsigned32bit)(-data.length);
3261 + } else {
3262 + length = data.length;
3263 + }
3264 + sock.sQpush32(length);
3265 + sock.sQpushBytes(data);
3266 + sock.flush();
3267 + },
3268 + setDesktopSize: function setDesktopSize(sock, width, height, id, flags) {
3269 + sock.sQpush8(251); // msg-type
3270 +
3271 + sock.sQpush8(0); // padding
3272 +
3273 + sock.sQpush16(width);
3274 + sock.sQpush16(height);
3275 + sock.sQpush8(1); // number-of-screens
3276 +
3277 + sock.sQpush8(0); // padding
3278 +
3279 + // screen array
3280 + sock.sQpush32(id);
3281 + sock.sQpush16(0); // x-position
3282 + sock.sQpush16(0); // y-position
3283 + sock.sQpush16(width);
3284 + sock.sQpush16(height);
3285 + sock.sQpush32(flags);
3286 + sock.flush();
3287 + },
3288 + clientFence: function clientFence(sock, flags, payload) {
3289 + sock.sQpush8(248); // msg-type
3290 +
3291 + sock.sQpush8(0); // padding
3292 + sock.sQpush8(0); // padding
3293 + sock.sQpush8(0); // padding
3294 +
3295 + sock.sQpush32(flags);
3296 + sock.sQpush8(payload.length);
3297 + sock.sQpushString(payload);
3298 + sock.flush();
3299 + },
3300 + enableContinuousUpdates: function enableContinuousUpdates(sock, enable, x, y, width, height) {
3301 + sock.sQpush8(150); // msg-type
3302 +
3303 + sock.sQpush8(enable);
3304 + sock.sQpush16(x);
3305 + sock.sQpush16(y);
3306 + sock.sQpush16(width);
3307 + sock.sQpush16(height);
3308 + sock.flush();
3309 + },
3310 + pixelFormat: function pixelFormat(sock, depth, trueColor) {
3311 + var bpp;
3312 + if (depth > 16) {
3313 + bpp = 32;
3314 + } else if (depth > 8) {
3315 + bpp = 16;
3316 + } else {
3317 + bpp = 8;
3318 + }
3319 + var bits = Math.floor(depth / 3);
3320 + sock.sQpush8(0); // msg-type
3321 +
3322 + sock.sQpush8(0); // padding
3323 + sock.sQpush8(0); // padding
3324 + sock.sQpush8(0); // padding
3325 +
3326 + sock.sQpush8(bpp);
3327 + sock.sQpush8(depth);
3328 + sock.sQpush8(0); // little-endian
3329 + sock.sQpush8(trueColor ? 1 : 0);
3330 + sock.sQpush16((1 << bits) - 1); // red-max
3331 + sock.sQpush16((1 << bits) - 1); // green-max
3332 + sock.sQpush16((1 << bits) - 1); // blue-max
3333 +
3334 + sock.sQpush8(bits * 0); // red-shift
3335 + sock.sQpush8(bits * 1); // green-shift
3336 + sock.sQpush8(bits * 2); // blue-shift
3337 +
3338 + sock.sQpush8(0); // padding
3339 + sock.sQpush8(0); // padding
3340 + sock.sQpush8(0); // padding
3341 +
3342 + sock.flush();
3343 + },
3344 + clientEncodings: function clientEncodings(sock, encodings) {
3345 + sock.sQpush8(2); // msg-type
3346 +
3347 + sock.sQpush8(0); // padding
3348 +
3349 + sock.sQpush16(encodings.length);
3350 + for (var i = 0; i < encodings.length; i++) {
3351 + sock.sQpush32(encodings[i]);
3352 + }
3353 + sock.flush();
3354 + },
3355 + fbUpdateRequest: function fbUpdateRequest(sock, incremental, x, y, w, h) {
3356 + if (typeof x === "undefined") {
3357 + x = 0;
3358 + }
3359 + if (typeof y === "undefined") {
3360 + y = 0;
3361 + }
3362 + sock.sQpush8(3); // msg-type
3363 +
3364 + sock.sQpush8(incremental ? 1 : 0);
3365 + sock.sQpush16(x);
3366 + sock.sQpush16(y);
3367 + sock.sQpush16(w);
3368 + sock.sQpush16(h);
3369 + sock.flush();
3370 + },
3371 + xvpOp: function xvpOp(sock, ver, op) {
3372 + sock.sQpush8(250); // msg-type
3373 +
3374 + sock.sQpush8(0); // padding
3375 +
3376 + sock.sQpush8(ver);
3377 + sock.sQpush8(op);
3378 + sock.flush();
3379 + }
3380 +};
3381 +RFB.cursors = {
3382 + none: {
3383 + rgbaPixels: new Uint8Array(),
3384 + w: 0,
3385 + h: 0,
3386 + hotx: 0,
3387 + hoty: 0
3388 + },
3389 + dot: {
3390 + /* eslint-disable indent */
3391 + rgbaPixels: new Uint8Array([255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255]),
3392 + /* eslint-enable indent */
3393 + w: 3,
3394 + h: 3,
3395 + hotx: 1,
3396 + hoty: 1
3397 + }
3398 +};
\ No newline at end of file
added public/vendor/novnc/util/browser.js +239 −0
@@ -0,0 +1,239 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.hasScrollbarGutter = exports.dragThreshold = void 0;
7 +exports.isAndroid = isAndroid;
8 +exports.isBlink = isBlink;
9 +exports.isChrome = isChrome;
10 +exports.isChromeOS = isChromeOS;
11 +exports.isChromium = isChromium;
12 +exports.isEdge = isEdge;
13 +exports.isFirefox = isFirefox;
14 +exports.isGecko = isGecko;
15 +exports.isIOS = isIOS;
16 +exports.isMac = isMac;
17 +exports.isOpera = isOpera;
18 +exports.isSafari = isSafari;
19 +exports.isTouchDevice = void 0;
20 +exports.isWebKit = isWebKit;
21 +exports.isWindows = isWindows;
22 +exports.supportsWebCodecsH264Decode = exports.supportsCursorURIs = void 0;
23 +var Log = _interopRequireWildcard(require("./logging.js"));
24 +var _base = _interopRequireDefault(require("../base64.js"));
25 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
26 +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); }
27 +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; }
28 +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); }
29 +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; }
30 +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); }
31 +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); }); }; } /*
32 + * noVNC: HTML5 VNC client
33 + * Copyright (C) 2019 The noVNC authors
34 + * Licensed under MPL 2.0 (see LICENSE.txt)
35 + *
36 + * See README.md for usage and integration instructions.
37 + *
38 + * Browser feature support detection
39 + */
40 +// Touch detection
41 +var isTouchDevice = exports.isTouchDevice = 'ontouchstart' in document.documentElement ||
42 +// required for Chrome debugger
43 +document.ontouchstart !== undefined ||
44 +// required for MS Surface
45 +navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
46 +window.addEventListener('touchstart', function onFirstTouch() {
47 + exports.isTouchDevice = isTouchDevice = true;
48 + window.removeEventListener('touchstart', onFirstTouch, false);
49 +}, false);
50 +
51 +// The goal is to find a certain physical width, the devicePixelRatio
52 +// brings us a bit closer but is not optimal.
53 +var dragThreshold = exports.dragThreshold = 10 * (window.devicePixelRatio || 1);
54 +var _supportsCursorURIs = false;
55 +try {
56 + var target = document.createElement('canvas');
57 + target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
58 + if (target.style.cursor.indexOf("url") === 0) {
59 + Log.Info("Data URI scheme cursor supported");
60 + _supportsCursorURIs = true;
61 + } else {
62 + Log.Warn("Data URI scheme cursor not supported");
63 + }
64 +} catch (exc) {
65 + Log.Error("Data URI scheme cursor test exception: " + exc);
66 +}
67 +var supportsCursorURIs = exports.supportsCursorURIs = _supportsCursorURIs;
68 +var _hasScrollbarGutter = true;
69 +try {
70 + // Create invisible container
71 + var container = document.createElement('div');
72 + container.style.visibility = 'hidden';
73 + container.style.overflow = 'scroll'; // forcing scrollbars
74 + document.body.appendChild(container);
75 +
76 + // Create a div and place it in the container
77 + var child = document.createElement('div');
78 + container.appendChild(child);
79 +
80 + // Calculate the difference between the container's full width
81 + // and the child's width - the difference is the scrollbars
82 + var scrollbarWidth = container.offsetWidth - child.offsetWidth;
83 +
84 + // Clean up
85 + container.parentNode.removeChild(container);
86 + _hasScrollbarGutter = scrollbarWidth != 0;
87 +} catch (exc) {
88 + Log.Error("Scrollbar test exception: " + exc);
89 +}
90 +var hasScrollbarGutter = exports.hasScrollbarGutter = _hasScrollbarGutter;
91 +var supportsWebCodecsH264Decode = exports.supportsWebCodecsH264Decode = false;
92 +function _checkWebCodecsH264DecodeSupport() {
93 + return _checkWebCodecsH264DecodeSupport2.apply(this, arguments);
94 +}
95 +function _checkWebCodecsH264DecodeSupport2() {
96 + _checkWebCodecsH264DecodeSupport2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
97 + var config, support, data, gotframe, _error, decoder, chunk;
98 + return _regeneratorRuntime().wrap(function _callee$(_context) {
99 + while (1) switch (_context.prev = _context.next) {
100 + case 0:
101 + if ('VideoDecoder' in window) {
102 + _context.next = 2;
103 + break;
104 + }
105 + return _context.abrupt("return", false);
106 + case 2:
107 + // We'll need to make do with some placeholders here
108 + config = {
109 + codec: 'avc1.42401f',
110 + codedWidth: 1920,
111 + codedHeight: 1080,
112 + optimizeForLatency: true
113 + };
114 + _context.next = 5;
115 + return VideoDecoder.isConfigSupported(config);
116 + case 5:
117 + support = _context.sent;
118 + if (support.supported) {
119 + _context.next = 8;
120 + break;
121 + }
122 + return _context.abrupt("return", false);
123 + case 8:
124 + // Firefox incorrectly reports supports for H.264 under some
125 + // circumstances, so we need to actually test a real frame
126 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1932392
127 + data = new Uint8Array(_base["default"].decode('AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4Hc' + 'Rem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5Zjkg' + 'LSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIz' + 'IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9u' + 'czogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4' + 'MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4' + 'ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4' + 'OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJv' + 'bWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0x' + 'IHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9' + 'MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVz' + 'PTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNj' + 'ZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9' + 'YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAu' + 'NjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFx' + 'PTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw=='));
128 + gotframe = false;
129 + _error = null;
130 + decoder = new VideoDecoder({
131 + output: function output(frame) {
132 + gotframe = true;
133 + },
134 + error: function error(e) {
135 + _error = e;
136 + }
137 + });
138 + chunk = new EncodedVideoChunk({
139 + timestamp: 0,
140 + type: 'key',
141 + data: data
142 + });
143 + decoder.configure(config);
144 + decoder.decode(chunk);
145 + _context.prev = 15;
146 + _context.next = 18;
147 + return decoder.flush();
148 + case 18:
149 + _context.next = 23;
150 + break;
151 + case 20:
152 + _context.prev = 20;
153 + _context.t0 = _context["catch"](15);
154 + // Firefox incorrectly throws an exception here
155 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1932566
156 + _error = _context.t0;
157 + case 23:
158 + if (gotframe) {
159 + _context.next = 25;
160 + break;
161 + }
162 + return _context.abrupt("return", false);
163 + case 25:
164 + if (!(_error !== null)) {
165 + _context.next = 27;
166 + break;
167 + }
168 + return _context.abrupt("return", false);
169 + case 27:
170 + return _context.abrupt("return", true);
171 + case 28:
172 + case "end":
173 + return _context.stop();
174 + }
175 + }, _callee, null, [[15, 20]]);
176 + }));
177 + return _checkWebCodecsH264DecodeSupport2.apply(this, arguments);
178 +}
179 +exports.supportsWebCodecsH264Decode = supportsWebCodecsH264Decode = await _checkWebCodecsH264DecodeSupport();
180 +
181 +/*
182 + * The functions for detection of platforms and browsers below are exported
183 + * but the use of these should be minimized as much as possible.
184 + *
185 + * It's better to use feature detection than platform detection.
186 + */
187 +
188 +/* OS */
189 +
190 +function isMac() {
191 + return !!/mac/i.exec(navigator.platform);
192 +}
193 +function isWindows() {
194 + return !!/win/i.exec(navigator.platform);
195 +}
196 +function isIOS() {
197 + return !!/ipad/i.exec(navigator.platform) || !!/iphone/i.exec(navigator.platform) || !!/ipod/i.exec(navigator.platform);
198 +}
199 +function isAndroid() {
200 + /* Android sets navigator.platform to Linux :/ */
201 + return !!navigator.userAgent.match('Android ');
202 +}
203 +function isChromeOS() {
204 + /* ChromeOS sets navigator.platform to Linux :/ */
205 + return !!navigator.userAgent.match(' CrOS ');
206 +}
207 +
208 +/* Browser */
209 +
210 +function isSafari() {
211 + return !!navigator.userAgent.match('Safari/...') && !navigator.userAgent.match('Chrome/...') && !navigator.userAgent.match('Chromium/...') && !navigator.userAgent.match('Epiphany/...');
212 +}
213 +function isFirefox() {
214 + return !!navigator.userAgent.match('Firefox/...') && !navigator.userAgent.match('Seamonkey/...');
215 +}
216 +function isChrome() {
217 + return !!navigator.userAgent.match('Chrome/...') && !navigator.userAgent.match('Chromium/...') && !navigator.userAgent.match('Edg/...') && !navigator.userAgent.match('OPR/...');
218 +}
219 +function isChromium() {
220 + return !!navigator.userAgent.match('Chromium/...');
221 +}
222 +function isOpera() {
223 + return !!navigator.userAgent.match('OPR/...');
224 +}
225 +function isEdge() {
226 + return !!navigator.userAgent.match('Edg/...');
227 +}
228 +
229 +/* Engine */
230 +
231 +function isGecko() {
232 + return !!navigator.userAgent.match('Gecko/...');
233 +}
234 +function isWebKit() {
235 + return !!navigator.userAgent.match('AppleWebKit/...') && !navigator.userAgent.match('Chrome/...');
236 +}
237 +function isBlink() {
238 + return !!navigator.userAgent.match('Chrome/...');
239 +}
\ No newline at end of file
added public/vendor/novnc/util/cursor.js +269 −0
@@ -0,0 +1,269 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _browser = require("./browser.js");
8 +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); }
9 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10 +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); } }
11 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13 +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); } /*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2019 The noVNC authors
16 + * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
17 + */
18 +var useFallback = !_browser.supportsCursorURIs || _browser.isTouchDevice;
19 +var Cursor = exports["default"] = /*#__PURE__*/function () {
20 + function Cursor() {
21 + _classCallCheck(this, Cursor);
22 + this._target = null;
23 + this._canvas = document.createElement('canvas');
24 + if (useFallback) {
25 + this._canvas.style.position = 'fixed';
26 + this._canvas.style.zIndex = '65535';
27 + this._canvas.style.pointerEvents = 'none';
28 + // Safari on iOS can select the cursor image
29 + // https://bugs.webkit.org/show_bug.cgi?id=249223
30 + this._canvas.style.userSelect = 'none';
31 + this._canvas.style.WebkitUserSelect = 'none';
32 + // Can't use "display" because of Firefox bug #1445997
33 + this._canvas.style.visibility = 'hidden';
34 + }
35 + this._position = {
36 + x: 0,
37 + y: 0
38 + };
39 + this._hotSpot = {
40 + x: 0,
41 + y: 0
42 + };
43 + this._eventHandlers = {
44 + 'mouseover': this._handleMouseOver.bind(this),
45 + 'mouseleave': this._handleMouseLeave.bind(this),
46 + 'mousemove': this._handleMouseMove.bind(this),
47 + 'mouseup': this._handleMouseUp.bind(this)
48 + };
49 + }
50 + return _createClass(Cursor, [{
51 + key: "attach",
52 + value: function attach(target) {
53 + if (this._target) {
54 + this.detach();
55 + }
56 + this._target = target;
57 + if (useFallback) {
58 + document.body.appendChild(this._canvas);
59 + var options = {
60 + capture: true,
61 + passive: true
62 + };
63 + this._target.addEventListener('mouseover', this._eventHandlers.mouseover, options);
64 + this._target.addEventListener('mouseleave', this._eventHandlers.mouseleave, options);
65 + this._target.addEventListener('mousemove', this._eventHandlers.mousemove, options);
66 + this._target.addEventListener('mouseup', this._eventHandlers.mouseup, options);
67 + }
68 + this.clear();
69 + }
70 + }, {
71 + key: "detach",
72 + value: function detach() {
73 + if (!this._target) {
74 + return;
75 + }
76 + if (useFallback) {
77 + var options = {
78 + capture: true,
79 + passive: true
80 + };
81 + this._target.removeEventListener('mouseover', this._eventHandlers.mouseover, options);
82 + this._target.removeEventListener('mouseleave', this._eventHandlers.mouseleave, options);
83 + this._target.removeEventListener('mousemove', this._eventHandlers.mousemove, options);
84 + this._target.removeEventListener('mouseup', this._eventHandlers.mouseup, options);
85 + if (document.contains(this._canvas)) {
86 + document.body.removeChild(this._canvas);
87 + }
88 + }
89 + this._target = null;
90 + }
91 + }, {
92 + key: "change",
93 + value: function change(rgba, hotx, hoty, w, h) {
94 + if (w === 0 || h === 0) {
95 + this.clear();
96 + return;
97 + }
98 + this._position.x = this._position.x + this._hotSpot.x - hotx;
99 + this._position.y = this._position.y + this._hotSpot.y - hoty;
100 + this._hotSpot.x = hotx;
101 + this._hotSpot.y = hoty;
102 + var ctx = this._canvas.getContext('2d');
103 + this._canvas.width = w;
104 + this._canvas.height = h;
105 + var img = new ImageData(new Uint8ClampedArray(rgba), w, h);
106 + ctx.clearRect(0, 0, w, h);
107 + ctx.putImageData(img, 0, 0);
108 + if (useFallback) {
109 + this._updatePosition();
110 + } else {
111 + var url = this._canvas.toDataURL();
112 + this._target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
113 + }
114 + }
115 + }, {
116 + key: "clear",
117 + value: function clear() {
118 + this._target.style.cursor = 'none';
119 + this._canvas.width = 0;
120 + this._canvas.height = 0;
121 + this._position.x = this._position.x + this._hotSpot.x;
122 + this._position.y = this._position.y + this._hotSpot.y;
123 + this._hotSpot.x = 0;
124 + this._hotSpot.y = 0;
125 + }
126 +
127 + // Mouse events might be emulated, this allows
128 + // moving the cursor in such cases
129 + }, {
130 + key: "move",
131 + value: function move(clientX, clientY) {
132 + if (!useFallback) {
133 + return;
134 + }
135 + // clientX/clientY are relative the _visual viewport_,
136 + // but our position is relative the _layout viewport_,
137 + // so try to compensate when we can
138 + if (window.visualViewport) {
139 + this._position.x = clientX + window.visualViewport.offsetLeft;
140 + this._position.y = clientY + window.visualViewport.offsetTop;
141 + } else {
142 + this._position.x = clientX;
143 + this._position.y = clientY;
144 + }
145 + this._updatePosition();
146 + var target = document.elementFromPoint(clientX, clientY);
147 + this._updateVisibility(target);
148 + }
149 + }, {
150 + key: "_handleMouseOver",
151 + value: function _handleMouseOver(event) {
152 + // This event could be because we're entering the target, or
153 + // moving around amongst its sub elements. Let the move handler
154 + // sort things out.
155 + this._handleMouseMove(event);
156 + }
157 + }, {
158 + key: "_handleMouseLeave",
159 + value: function _handleMouseLeave(event) {
160 + // Check if we should show the cursor on the element we are leaving to
161 + this._updateVisibility(event.relatedTarget);
162 + }
163 + }, {
164 + key: "_handleMouseMove",
165 + value: function _handleMouseMove(event) {
166 + this._updateVisibility(event.target);
167 + this._position.x = event.clientX - this._hotSpot.x;
168 + this._position.y = event.clientY - this._hotSpot.y;
169 + this._updatePosition();
170 + }
171 + }, {
172 + key: "_handleMouseUp",
173 + value: function _handleMouseUp(event) {
174 + var _this = this;
175 + // We might get this event because of a drag operation that
176 + // moved outside of the target. Check what's under the cursor
177 + // now and adjust visibility based on that.
178 + var target = document.elementFromPoint(event.clientX, event.clientY);
179 + this._updateVisibility(target);
180 +
181 + // Captures end with a mouseup but we can't know the event order of
182 + // mouseup vs releaseCapture.
183 + //
184 + // In the cases when releaseCapture comes first, the code above is
185 + // enough.
186 + //
187 + // In the cases when the mouseup comes first, we need wait for the
188 + // browser to flush all events and then check again if the cursor
189 + // should be visible.
190 + if (this._captureIsActive()) {
191 + window.setTimeout(function () {
192 + // We might have detached at this point
193 + if (!_this._target) {
194 + return;
195 + }
196 + // Refresh the target from elementFromPoint since queued events
197 + // might have altered the DOM
198 + target = document.elementFromPoint(event.clientX, event.clientY);
199 + _this._updateVisibility(target);
200 + }, 0);
201 + }
202 + }
203 + }, {
204 + key: "_showCursor",
205 + value: function _showCursor() {
206 + if (this._canvas.style.visibility === 'hidden') {
207 + this._canvas.style.visibility = '';
208 + }
209 + }
210 + }, {
211 + key: "_hideCursor",
212 + value: function _hideCursor() {
213 + if (this._canvas.style.visibility !== 'hidden') {
214 + this._canvas.style.visibility = 'hidden';
215 + }
216 + }
217 +
218 + // Should we currently display the cursor?
219 + // (i.e. are we over the target, or a child of the target without a
220 + // different cursor set)
221 + }, {
222 + key: "_shouldShowCursor",
223 + value: function _shouldShowCursor(target) {
224 + if (!target) {
225 + return false;
226 + }
227 + // Easy case
228 + if (target === this._target) {
229 + return true;
230 + }
231 + // Other part of the DOM?
232 + if (!this._target.contains(target)) {
233 + return false;
234 + }
235 + // Has the child its own cursor?
236 + // FIXME: How can we tell that a sub element has an
237 + // explicit "cursor: none;"?
238 + if (window.getComputedStyle(target).cursor !== 'none') {
239 + return false;
240 + }
241 + return true;
242 + }
243 + }, {
244 + key: "_updateVisibility",
245 + value: function _updateVisibility(target) {
246 + // When the cursor target has capture we want to show the cursor.
247 + // So, if a capture is active - look at the captured element instead.
248 + if (this._captureIsActive()) {
249 + target = document.captureElement;
250 + }
251 + if (this._shouldShowCursor(target)) {
252 + this._showCursor();
253 + } else {
254 + this._hideCursor();
255 + }
256 + }
257 + }, {
258 + key: "_updatePosition",
259 + value: function _updatePosition() {
260 + this._canvas.style.left = this._position.x + "px";
261 + this._canvas.style.top = this._position.y + "px";
262 + }
263 + }, {
264 + key: "_captureIsActive",
265 + value: function _captureIsActive() {
266 + return document.captureElement && document.documentElement.contains(document.captureElement);
267 + }
268 + }]);
269 +}();
\ No newline at end of file
added public/vendor/novnc/util/element.js +41 −0
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.clientToElement = clientToElement;
7 +/*
8 + * noVNC: HTML5 VNC client
9 + * Copyright (C) 2020 The noVNC authors
10 + * Licensed under MPL 2.0 (see LICENSE.txt)
11 + *
12 + * See README.md for usage and integration instructions.
13 + */
14 +
15 +/*
16 + * HTML element utility functions
17 + */
18 +
19 +function clientToElement(x, y, elem) {
20 + var bounds = elem.getBoundingClientRect();
21 + var pos = {
22 + x: 0,
23 + y: 0
24 + };
25 + // Clip to target bounds
26 + if (x < bounds.left) {
27 + pos.x = 0;
28 + } else if (x >= bounds.right) {
29 + pos.x = bounds.width - 1;
30 + } else {
31 + pos.x = x - bounds.left;
32 + }
33 + if (y < bounds.top) {
34 + pos.y = 0;
35 + } else if (y >= bounds.bottom) {
36 + pos.y = bounds.height - 1;
37 + } else {
38 + pos.y = y - bounds.top;
39 + }
40 + return pos;
41 +}
\ No newline at end of file
added public/vendor/novnc/util/events.js +133 −0
@@ -0,0 +1,133 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.getPointerEvent = getPointerEvent;
7 +exports.releaseCapture = releaseCapture;
8 +exports.setCapture = setCapture;
9 +exports.stopEvent = stopEvent;
10 +/*
11 + * noVNC: HTML5 VNC client
12 + * Copyright (C) 2018 The noVNC authors
13 + * Licensed under MPL 2.0 (see LICENSE.txt)
14 + *
15 + * See README.md for usage and integration instructions.
16 + */
17 +
18 +/*
19 + * Cross-browser event and position routines
20 + */
21 +
22 +function getPointerEvent(e) {
23 + return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e;
24 +}
25 +function stopEvent(e) {
26 + e.stopPropagation();
27 + e.preventDefault();
28 +}
29 +
30 +// Emulate Element.setCapture() when not supported
31 +var _captureRecursion = false;
32 +var _elementForUnflushedEvents = null;
33 +document.captureElement = null;
34 +function _captureProxy(e) {
35 + // Recursion protection as we'll see our own event
36 + if (_captureRecursion) return;
37 +
38 + // Clone the event as we cannot dispatch an already dispatched event
39 + var newEv = new e.constructor(e.type, e);
40 + _captureRecursion = true;
41 + if (document.captureElement) {
42 + document.captureElement.dispatchEvent(newEv);
43 + } else {
44 + _elementForUnflushedEvents.dispatchEvent(newEv);
45 + }
46 + _captureRecursion = false;
47 +
48 + // Avoid double events
49 + e.stopPropagation();
50 +
51 + // Respect the wishes of the redirected event handlers
52 + if (newEv.defaultPrevented) {
53 + e.preventDefault();
54 + }
55 +
56 + // Implicitly release the capture on button release
57 + if (e.type === "mouseup") {
58 + releaseCapture();
59 + }
60 +}
61 +
62 +// Follow cursor style of target element
63 +function _capturedElemChanged() {
64 + var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
65 + proxyElem.style.cursor = window.getComputedStyle(document.captureElement).cursor;
66 +}
67 +var _captureObserver = new MutationObserver(_capturedElemChanged);
68 +function setCapture(target) {
69 + if (target.setCapture) {
70 + target.setCapture();
71 + document.captureElement = target;
72 + } else {
73 + // Release any existing capture in case this method is
74 + // called multiple times without coordination
75 + releaseCapture();
76 + var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
77 + if (proxyElem === null) {
78 + proxyElem = document.createElement("div");
79 + proxyElem.id = "noVNC_mouse_capture_elem";
80 + proxyElem.style.position = "fixed";
81 + proxyElem.style.top = "0px";
82 + proxyElem.style.left = "0px";
83 + proxyElem.style.width = "100%";
84 + proxyElem.style.height = "100%";
85 + proxyElem.style.zIndex = 10000;
86 + proxyElem.style.display = "none";
87 + document.body.appendChild(proxyElem);
88 +
89 + // This is to make sure callers don't get confused by having
90 + // our blocking element as the target
91 + proxyElem.addEventListener('contextmenu', _captureProxy);
92 + proxyElem.addEventListener('mousemove', _captureProxy);
93 + proxyElem.addEventListener('mouseup', _captureProxy);
94 + }
95 + document.captureElement = target;
96 +
97 + // Track cursor and get initial cursor
98 + _captureObserver.observe(target, {
99 + attributes: true
100 + });
101 + _capturedElemChanged();
102 + proxyElem.style.display = "";
103 +
104 + // We listen to events on window in order to keep tracking if it
105 + // happens to leave the viewport
106 + window.addEventListener('mousemove', _captureProxy);
107 + window.addEventListener('mouseup', _captureProxy);
108 + }
109 +}
110 +function releaseCapture() {
111 + if (document.releaseCapture) {
112 + document.releaseCapture();
113 + document.captureElement = null;
114 + } else {
115 + if (!document.captureElement) {
116 + return;
117 + }
118 +
119 + // There might be events already queued. The event proxy needs
120 + // access to the captured element for these queued events.
121 + // E.g. contextmenu (right-click) in Microsoft Edge
122 + //
123 + // Before removing the capturedElem pointer we save it to a
124 + // temporary variable that the unflushed events can use.
125 + _elementForUnflushedEvents = document.captureElement;
126 + document.captureElement = null;
127 + _captureObserver.disconnect();
128 + var proxyElem = document.getElementById("noVNC_mouse_capture_elem");
129 + proxyElem.style.display = "none";
130 + window.removeEventListener('mousemove', _captureProxy);
131 + window.removeEventListener('mouseup', _captureProxy);
132 + }
133 +}
\ No newline at end of file
added public/vendor/novnc/util/eventtarget.js +53 −0
@@ -0,0 +1,53 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +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); }
8 +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9 +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); } }
10 +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11 +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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 +/*
14 + * noVNC: HTML5 VNC client
15 + * Copyright (C) 2019 The noVNC authors
16 + * Licensed under MPL 2.0 (see LICENSE.txt)
17 + *
18 + * See README.md for usage and integration instructions.
19 + */
20 +var EventTargetMixin = exports["default"] = /*#__PURE__*/function () {
21 + function EventTargetMixin() {
22 + _classCallCheck(this, EventTargetMixin);
23 + this._listeners = new Map();
24 + }
25 + return _createClass(EventTargetMixin, [{
26 + key: "addEventListener",
27 + value: function addEventListener(type, callback) {
28 + if (!this._listeners.has(type)) {
29 + this._listeners.set(type, new Set());
30 + }
31 + this._listeners.get(type).add(callback);
32 + }
33 + }, {
34 + key: "removeEventListener",
35 + value: function removeEventListener(type, callback) {
36 + if (this._listeners.has(type)) {
37 + this._listeners.get(type)["delete"](callback);
38 + }
39 + }
40 + }, {
41 + key: "dispatchEvent",
42 + value: function dispatchEvent(event) {
43 + var _this = this;
44 + if (!this._listeners.has(event.type)) {
45 + return true;
46 + }
47 + this._listeners.get(event.type).forEach(function (callback) {
48 + return callback.call(_this, event);
49 + });
50 + return !event.defaultPrevented;
51 + }
52 + }]);
53 +}();
\ No newline at end of file
added public/vendor/novnc/util/int.js +21 −0
@@ -0,0 +1,21 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.toSigned32bit = toSigned32bit;
7 +exports.toUnsigned32bit = toUnsigned32bit;
8 +/*
9 + * noVNC: HTML5 VNC client
10 + * Copyright (C) 2020 The noVNC authors
11 + * Licensed under MPL 2.0 (see LICENSE.txt)
12 + *
13 + * See README.md for usage and integration instructions.
14 + */
15 +
16 +function toUnsigned32bit(toConvert) {
17 + return toConvert >>> 0;
18 +}
19 +function toSigned32bit(toConvert) {
20 + return toConvert | 0;
21 +}
\ No newline at end of file
added public/vendor/novnc/util/logging.js +56 −0
@@ -0,0 +1,56 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Warn = exports.Info = exports.Error = exports.Debug = void 0;
7 +exports.getLogging = getLogging;
8 +exports.initLogging = initLogging;
9 +/*
10 + * noVNC: HTML5 VNC client
11 + * Copyright (C) 2019 The noVNC authors
12 + * Licensed under MPL 2.0 (see LICENSE.txt)
13 + *
14 + * See README.md for usage and integration instructions.
15 + */
16 +
17 +/*
18 + * Logging/debug routines
19 + */
20 +
21 +var _logLevel = 'warn';
22 +var Debug = exports.Debug = function Debug() {};
23 +var Info = exports.Info = function Info() {};
24 +var Warn = exports.Warn = function Warn() {};
25 +var Error = exports.Error = function Error() {};
26 +function initLogging(level) {
27 + if (typeof level === 'undefined') {
28 + level = _logLevel;
29 + } else {
30 + _logLevel = level;
31 + }
32 + exports.Debug = Debug = exports.Info = Info = exports.Warn = Warn = exports.Error = Error = function Error() {};
33 + if (typeof window.console !== "undefined") {
34 + /* eslint-disable no-console, no-fallthrough */
35 + switch (level) {
36 + case 'debug':
37 + exports.Debug = Debug = console.debug.bind(window.console);
38 + case 'info':
39 + exports.Info = Info = console.info.bind(window.console);
40 + case 'warn':
41 + exports.Warn = Warn = console.warn.bind(window.console);
42 + case 'error':
43 + exports.Error = Error = console.error.bind(window.console);
44 + case 'none':
45 + break;
46 + default:
47 + throw new window.Error("invalid logging type '" + level + "'");
48 + }
49 + /* eslint-enable no-console, no-fallthrough */
50 + }
51 +}
52 +function getLogging() {
53 + return _logLevel;
54 +}
55 +// Initialize logging level
56 +initLogging();
\ No newline at end of file
added public/vendor/novnc/util/strings.js +36 −0
@@ -0,0 +1,36 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.decodeUTF8 = decodeUTF8;
7 +exports.encodeUTF8 = encodeUTF8;
8 +/*
9 + * noVNC: HTML5 VNC client
10 + * Copyright (C) 2019 The noVNC authors
11 + * Licensed under MPL 2.0 (see LICENSE.txt)
12 + *
13 + * See README.md for usage and integration instructions.
14 + */
15 +
16 +// Decode from UTF-8
17 +function decodeUTF8(utf8string) {
18 + var allowLatin1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19 + try {
20 + return decodeURIComponent(escape(utf8string));
21 + } catch (e) {
22 + if (e instanceof URIError) {
23 + if (allowLatin1) {
24 + // If we allow Latin1 we can ignore any decoding fails
25 + // and in these cases return the original string
26 + return utf8string;
27 + }
28 + }
29 + throw e;
30 + }
31 +}
32 +
33 +// Encode to UTF-8
34 +function encodeUTF8(DOMString) {
35 + return unescape(encodeURIComponent(DOMString));
36 +}
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/utils/common.js +55 −0
@@ -0,0 +1,55 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Buf8 = exports.Buf32 = exports.Buf16 = void 0;
7 +exports.arraySet = arraySet;
8 +exports.flattenChunks = flattenChunks;
9 +exports.shrinkBuf = shrinkBuf;
10 +// reduce buffer size, avoiding mem copy
11 +function shrinkBuf(buf, size) {
12 + if (buf.length === size) {
13 + return buf;
14 + }
15 + if (buf.subarray) {
16 + return buf.subarray(0, size);
17 + }
18 + buf.length = size;
19 + return buf;
20 +}
21 +;
22 +function arraySet(dest, src, src_offs, len, dest_offs) {
23 + if (src.subarray && dest.subarray) {
24 + dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
25 + return;
26 + }
27 + // Fallback to ordinary array
28 + for (var i = 0; i < len; i++) {
29 + dest[dest_offs + i] = src[src_offs + i];
30 + }
31 +}
32 +
33 +// Join array of chunks to single array.
34 +function flattenChunks(chunks) {
35 + var i, l, len, pos, chunk, result;
36 +
37 + // calculate data length
38 + len = 0;
39 + for (i = 0, l = chunks.length; i < l; i++) {
40 + len += chunks[i].length;
41 + }
42 +
43 + // join chunks
44 + result = new Uint8Array(len);
45 + pos = 0;
46 + for (i = 0, l = chunks.length; i < l; i++) {
47 + chunk = chunks[i];
48 + result.set(chunk, pos);
49 + pos += chunk.length;
50 + }
51 + return result;
52 +}
53 +var Buf8 = exports.Buf8 = Uint8Array;
54 +var Buf16 = exports.Buf16 = Uint16Array;
55 +var Buf32 = exports.Buf32 = Int32Array;
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/adler32.js +29 −0
@@ -0,0 +1,29 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = adler32;
7 +// Note: adler32 takes 12% for level 0 and 2% for level 6.
8 +// It doesn't worth to make additional optimizationa as in original.
9 +// Small size is preferable.
10 +
11 +function adler32(adler, buf, len, pos) {
12 + var s1 = adler & 0xffff | 0,
13 + s2 = adler >>> 16 & 0xffff | 0,
14 + n = 0;
15 + while (len !== 0) {
16 + // Set limit ~ twice less than 5552, to keep
17 + // s2 in 31-bits, because we force signed ints.
18 + // in other case %= will fail.
19 + n = len > 2000 ? 2000 : len;
20 + len -= n;
21 + do {
22 + s1 = s1 + buf[pos++] | 0;
23 + s2 = s2 + s1 | 0;
24 + } while (--n);
25 + s1 %= 65521;
26 + s2 %= 65521;
27 + }
28 + return s1 | s2 << 16 | 0;
29 +}
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/constants.js +47 −0
@@ -0,0 +1,47 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _default = exports["default"] = {
8 + /* Allowed flush values; see deflate() and inflate() below for details */
9 + Z_NO_FLUSH: 0,
10 + Z_PARTIAL_FLUSH: 1,
11 + Z_SYNC_FLUSH: 2,
12 + Z_FULL_FLUSH: 3,
13 + Z_FINISH: 4,
14 + Z_BLOCK: 5,
15 + Z_TREES: 6,
16 + /* Return codes for the compression/decompression functions. Negative values
17 + * are errors, positive values are used for special but normal events.
18 + */
19 + Z_OK: 0,
20 + Z_STREAM_END: 1,
21 + Z_NEED_DICT: 2,
22 + Z_ERRNO: -1,
23 + Z_STREAM_ERROR: -2,
24 + Z_DATA_ERROR: -3,
25 + //Z_MEM_ERROR: -4,
26 + Z_BUF_ERROR: -5,
27 + //Z_VERSION_ERROR: -6,
28 +
29 + /* compression levels */
30 + Z_NO_COMPRESSION: 0,
31 + Z_BEST_SPEED: 1,
32 + Z_BEST_COMPRESSION: 9,
33 + Z_DEFAULT_COMPRESSION: -1,
34 + Z_FILTERED: 1,
35 + Z_HUFFMAN_ONLY: 2,
36 + Z_RLE: 3,
37 + Z_FIXED: 4,
38 + Z_DEFAULT_STRATEGY: 0,
39 + /* Possible values of the data_type field (though see inflate()) */
40 + Z_BINARY: 0,
41 + Z_TEXT: 1,
42 + //Z_ASCII: 1, // = Z_TEXT (deprecated)
43 + Z_UNKNOWN: 2,
44 + /* The deflate compression method */
45 + Z_DEFLATED: 8
46 + //Z_NULL: null // Use -1 or null inline, depending on var type
47 +};
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/crc32.js +35 −0
@@ -0,0 +1,35 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = makeTable;
7 +// Note: we can't get significant speed boost here.
8 +// So write code to minimize size - no pregenerated tables
9 +// and array tools dependencies.
10 +
11 +// Use ordinary array, since untyped makes no boost here
12 +function makeTable() {
13 + var c,
14 + table = [];
15 + for (var n = 0; n < 256; n++) {
16 + c = n;
17 + for (var k = 0; k < 8; k++) {
18 + c = c & 1 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
19 + }
20 + table[n] = c;
21 + }
22 + return table;
23 +}
24 +
25 +// Create table on load. Just 255 signed longs. Not a problem.
26 +var crcTable = makeTable();
27 +function crc32(crc, buf, len, pos) {
28 + var t = crcTable,
29 + end = pos + len;
30 + crc ^= -1;
31 + for (var i = pos; i < end; i++) {
32 + crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 0xFF];
33 + }
34 + return crc ^ -1; // >>> 0;
35 +}
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/deflate.js +1721 −0
@@ -0,0 +1,1721 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports.Z_UNKNOWN = exports.Z_STREAM_ERROR = exports.Z_STREAM_END = exports.Z_RLE = exports.Z_PARTIAL_FLUSH = exports.Z_OK = exports.Z_NO_FLUSH = exports.Z_HUFFMAN_ONLY = exports.Z_FULL_FLUSH = exports.Z_FIXED = exports.Z_FINISH = exports.Z_FILTERED = exports.Z_DEFLATED = exports.Z_DEFAULT_STRATEGY = exports.Z_DEFAULT_COMPRESSION = exports.Z_DATA_ERROR = exports.Z_BUF_ERROR = exports.Z_BLOCK = void 0;
8 +exports.deflate = deflate;
9 +exports.deflateEnd = deflateEnd;
10 +exports.deflateInfo = void 0;
11 +exports.deflateInit = deflateInit;
12 +exports.deflateInit2 = deflateInit2;
13 +exports.deflateReset = deflateReset;
14 +exports.deflateResetKeep = deflateResetKeep;
15 +exports.deflateSetDictionary = deflateSetDictionary;
16 +exports.deflateSetHeader = deflateSetHeader;
17 +var utils = _interopRequireWildcard(require("../utils/common.js"));
18 +var trees = _interopRequireWildcard(require("./trees.js"));
19 +var _adler = _interopRequireDefault(require("./adler32.js"));
20 +var _crc = _interopRequireDefault(require("./crc32.js"));
21 +var _messages = _interopRequireDefault(require("./messages.js"));
22 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
23 +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); }
24 +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; }
25 +/* Public constants ==========================================================*/
26 +/* ===========================================================================*/
27 +
28 +/* Allowed flush values; see deflate() and inflate() below for details */
29 +var Z_NO_FLUSH = exports.Z_NO_FLUSH = 0;
30 +var Z_PARTIAL_FLUSH = exports.Z_PARTIAL_FLUSH = 1;
31 +//export const Z_SYNC_FLUSH = 2;
32 +var Z_FULL_FLUSH = exports.Z_FULL_FLUSH = 3;
33 +var Z_FINISH = exports.Z_FINISH = 4;
34 +var Z_BLOCK = exports.Z_BLOCK = 5;
35 +//export const Z_TREES = 6;
36 +
37 +/* Return codes for the compression/decompression functions. Negative values
38 + * are errors, positive values are used for special but normal events.
39 + */
40 +var Z_OK = exports.Z_OK = 0;
41 +var Z_STREAM_END = exports.Z_STREAM_END = 1;
42 +//export const Z_NEED_DICT = 2;
43 +//export const Z_ERRNO = -1;
44 +var Z_STREAM_ERROR = exports.Z_STREAM_ERROR = -2;
45 +var Z_DATA_ERROR = exports.Z_DATA_ERROR = -3;
46 +//export const Z_MEM_ERROR = -4;
47 +var Z_BUF_ERROR = exports.Z_BUF_ERROR = -5;
48 +//export const Z_VERSION_ERROR = -6;
49 +
50 +/* compression levels */
51 +//export const Z_NO_COMPRESSION = 0;
52 +//export const Z_BEST_SPEED = 1;
53 +//export const Z_BEST_COMPRESSION = 9;
54 +var Z_DEFAULT_COMPRESSION = exports.Z_DEFAULT_COMPRESSION = -1;
55 +var Z_FILTERED = exports.Z_FILTERED = 1;
56 +var Z_HUFFMAN_ONLY = exports.Z_HUFFMAN_ONLY = 2;
57 +var Z_RLE = exports.Z_RLE = 3;
58 +var Z_FIXED = exports.Z_FIXED = 4;
59 +var Z_DEFAULT_STRATEGY = exports.Z_DEFAULT_STRATEGY = 0;
60 +
61 +/* Possible values of the data_type field (though see inflate()) */
62 +//export const Z_BINARY = 0;
63 +//export const Z_TEXT = 1;
64 +//export const Z_ASCII = 1; // = Z_TEXT
65 +var Z_UNKNOWN = exports.Z_UNKNOWN = 2;
66 +
67 +/* The deflate compression method */
68 +var Z_DEFLATED = exports.Z_DEFLATED = 8;
69 +
70 +/*============================================================================*/
71 +
72 +var MAX_MEM_LEVEL = 9;
73 +/* Maximum value for memLevel in deflateInit2 */
74 +var MAX_WBITS = 15;
75 +/* 32K LZ77 window */
76 +var DEF_MEM_LEVEL = 8;
77 +var LENGTH_CODES = 29;
78 +/* number of length codes, not counting the special END_BLOCK code */
79 +var LITERALS = 256;
80 +/* number of literal bytes 0..255 */
81 +var L_CODES = LITERALS + 1 + LENGTH_CODES;
82 +/* number of Literal or Length codes, including the END_BLOCK code */
83 +var D_CODES = 30;
84 +/* number of distance codes */
85 +var BL_CODES = 19;
86 +/* number of codes used to transfer the bit lengths */
87 +var HEAP_SIZE = 2 * L_CODES + 1;
88 +/* maximum heap size */
89 +var MAX_BITS = 15;
90 +/* All codes must not exceed MAX_BITS bits */
91 +
92 +var MIN_MATCH = 3;
93 +var MAX_MATCH = 258;
94 +var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1;
95 +var PRESET_DICT = 0x20;
96 +var INIT_STATE = 42;
97 +var EXTRA_STATE = 69;
98 +var NAME_STATE = 73;
99 +var COMMENT_STATE = 91;
100 +var HCRC_STATE = 103;
101 +var BUSY_STATE = 113;
102 +var FINISH_STATE = 666;
103 +var BS_NEED_MORE = 1; /* block not completed, need more input or more output */
104 +var BS_BLOCK_DONE = 2; /* block flush performed */
105 +var BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */
106 +var BS_FINISH_DONE = 4; /* finish done, accept no more input or output */
107 +
108 +var OS_CODE = 0x03; // Unix :) . Don't detect, use this default.
109 +
110 +function err(strm, errorCode) {
111 + strm.msg = _messages["default"][errorCode];
112 + return errorCode;
113 +}
114 +function rank(f) {
115 + return (f << 1) - (f > 4 ? 9 : 0);
116 +}
117 +function zero(buf) {
118 + var len = buf.length;
119 + while (--len >= 0) {
120 + buf[len] = 0;
121 + }
122 +}
123 +
124 +/* =========================================================================
125 + * Flush as much pending output as possible. All deflate() output goes
126 + * through this function so some applications may wish to modify it
127 + * to avoid allocating a large strm->output buffer and copying into it.
128 + * (See also read_buf()).
129 + */
130 +function flush_pending(strm) {
131 + var s = strm.state;
132 +
133 + //_tr_flush_bits(s);
134 + var len = s.pending;
135 + if (len > strm.avail_out) {
136 + len = strm.avail_out;
137 + }
138 + if (len === 0) {
139 + return;
140 + }
141 + utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
142 + strm.next_out += len;
143 + s.pending_out += len;
144 + strm.total_out += len;
145 + strm.avail_out -= len;
146 + s.pending -= len;
147 + if (s.pending === 0) {
148 + s.pending_out = 0;
149 + }
150 +}
151 +function flush_block_only(s, last) {
152 + trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last);
153 + s.block_start = s.strstart;
154 + flush_pending(s.strm);
155 +}
156 +function put_byte(s, b) {
157 + s.pending_buf[s.pending++] = b;
158 +}
159 +
160 +/* =========================================================================
161 + * Put a short in the pending buffer. The 16-bit value is put in MSB order.
162 + * IN assertion: the stream state is correct and there is enough room in
163 + * pending_buf.
164 + */
165 +function putShortMSB(s, b) {
166 + // put_byte(s, (Byte)(b >> 8));
167 + // put_byte(s, (Byte)(b & 0xff));
168 + s.pending_buf[s.pending++] = b >>> 8 & 0xff;
169 + s.pending_buf[s.pending++] = b & 0xff;
170 +}
171 +
172 +/* ===========================================================================
173 + * Read a new buffer from the current input stream, update the adler32
174 + * and total number of bytes read. All deflate() input goes through
175 + * this function so some applications may wish to modify it to avoid
176 + * allocating a large strm->input buffer and copying from it.
177 + * (See also flush_pending()).
178 + */
179 +function read_buf(strm, buf, start, size) {
180 + var len = strm.avail_in;
181 + if (len > size) {
182 + len = size;
183 + }
184 + if (len === 0) {
185 + return 0;
186 + }
187 + strm.avail_in -= len;
188 +
189 + // zmemcpy(buf, strm->next_in, len);
190 + utils.arraySet(buf, strm.input, strm.next_in, len, start);
191 + if (strm.state.wrap === 1) {
192 + strm.adler = (0, _adler["default"])(strm.adler, buf, len, start);
193 + } else if (strm.state.wrap === 2) {
194 + strm.adler = (0, _crc["default"])(strm.adler, buf, len, start);
195 + }
196 + strm.next_in += len;
197 + strm.total_in += len;
198 + return len;
199 +}
200 +
201 +/* ===========================================================================
202 + * Set match_start to the longest match starting at the given string and
203 + * return its length. Matches shorter or equal to prev_length are discarded,
204 + * in which case the result is equal to prev_length and match_start is
205 + * garbage.
206 + * IN assertions: cur_match is the head of the hash chain for the current
207 + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
208 + * OUT assertion: the match length is not greater than s->lookahead.
209 + */
210 +function longest_match(s, cur_match) {
211 + var chain_length = s.max_chain_length; /* max hash chain length */
212 + var scan = s.strstart; /* current string */
213 + var match; /* matched string */
214 + var len; /* length of current match */
215 + var best_len = s.prev_length; /* best match length so far */
216 + var nice_match = s.nice_match; /* stop if match long enough */
217 + var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0 /*NIL*/;
218 + var _win = s.window; // shortcut
219 +
220 + var wmask = s.w_mask;
221 + var prev = s.prev;
222 +
223 + /* Stop when cur_match becomes <= limit. To simplify the code,
224 + * we prevent matches with the string of window index 0.
225 + */
226 +
227 + var strend = s.strstart + MAX_MATCH;
228 + var scan_end1 = _win[scan + best_len - 1];
229 + var scan_end = _win[scan + best_len];
230 +
231 + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
232 + * It is easy to get rid of this optimization if necessary.
233 + */
234 + // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
235 +
236 + /* Do not waste too much time if we already have a good match: */
237 + if (s.prev_length >= s.good_match) {
238 + chain_length >>= 2;
239 + }
240 + /* Do not look for matches beyond the end of the input. This is necessary
241 + * to make deflate deterministic.
242 + */
243 + if (nice_match > s.lookahead) {
244 + nice_match = s.lookahead;
245 + }
246 +
247 + // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
248 +
249 + do {
250 + // Assert(cur_match < s->strstart, "no future");
251 + match = cur_match;
252 +
253 + /* Skip to next match if the match length cannot increase
254 + * or if the match length is less than 2. Note that the checks below
255 + * for insufficient lookahead only occur occasionally for performance
256 + * reasons. Therefore uninitialized memory will be accessed, and
257 + * conditional jumps will be made that depend on those values.
258 + * However the length of the match is limited to the lookahead, so
259 + * the output of deflate is not affected by the uninitialized values.
260 + */
261 +
262 + if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) {
263 + continue;
264 + }
265 +
266 + /* The check at best_len-1 can be removed because it will be made
267 + * again later. (This heuristic is not always a win.)
268 + * It is not necessary to compare scan[2] and match[2] since they
269 + * are always equal when the other bytes match, given that
270 + * the hash keys are equal and that HASH_BITS >= 8.
271 + */
272 + scan += 2;
273 + match++;
274 + // Assert(*scan == *match, "match[2]?");
275 +
276 + /* We check for insufficient lookahead only every 8th comparison;
277 + * the 256th check will be made at strstart+258.
278 + */
279 + do {
280 + // Do nothing
281 + } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend);
282 +
283 + // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
284 +
285 + len = MAX_MATCH - (strend - scan);
286 + scan = strend - MAX_MATCH;
287 + if (len > best_len) {
288 + s.match_start = cur_match;
289 + best_len = len;
290 + if (len >= nice_match) {
291 + break;
292 + }
293 + scan_end1 = _win[scan + best_len - 1];
294 + scan_end = _win[scan + best_len];
295 + }
296 + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);
297 + if (best_len <= s.lookahead) {
298 + return best_len;
299 + }
300 + return s.lookahead;
301 +}
302 +
303 +/* ===========================================================================
304 + * Fill the window when the lookahead becomes insufficient.
305 + * Updates strstart and lookahead.
306 + *
307 + * IN assertion: lookahead < MIN_LOOKAHEAD
308 + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
309 + * At least one byte has been read, or avail_in == 0; reads are
310 + * performed for at least two bytes (required for the zip translate_eol
311 + * option -- not supported here).
312 + */
313 +function fill_window(s) {
314 + var _w_size = s.w_size;
315 + var p, n, m, more, str;
316 +
317 + //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
318 +
319 + do {
320 + more = s.window_size - s.lookahead - s.strstart;
321 +
322 + // JS ints have 32 bit, block below not needed
323 + /* Deal with !@#$% 64K limit: */
324 + //if (sizeof(int) <= 2) {
325 + // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
326 + // more = wsize;
327 + //
328 + // } else if (more == (unsigned)(-1)) {
329 + // /* Very unlikely, but possible on 16 bit machine if
330 + // * strstart == 0 && lookahead == 1 (input done a byte at time)
331 + // */
332 + // more--;
333 + // }
334 + //}
335 +
336 + /* If the window is almost full and there is insufficient lookahead,
337 + * move the upper half to the lower one to make room in the upper half.
338 + */
339 + if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
340 + utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
341 + s.match_start -= _w_size;
342 + s.strstart -= _w_size;
343 + /* we now have strstart >= MAX_DIST */
344 + s.block_start -= _w_size;
345 +
346 + /* Slide the hash table (could be avoided with 32 bit values
347 + at the expense of memory usage). We slide even when level == 0
348 + to keep the hash table consistent if we switch back to level > 0
349 + later. (Using level 0 permanently is not an optimal usage of
350 + zlib, so we don't care about this pathological case.)
351 + */
352 +
353 + n = s.hash_size;
354 + p = n;
355 + do {
356 + m = s.head[--p];
357 + s.head[p] = m >= _w_size ? m - _w_size : 0;
358 + } while (--n);
359 + n = _w_size;
360 + p = n;
361 + do {
362 + m = s.prev[--p];
363 + s.prev[p] = m >= _w_size ? m - _w_size : 0;
364 + /* If n is not on any hash chain, prev[n] is garbage but
365 + * its value will never be used.
366 + */
367 + } while (--n);
368 + more += _w_size;
369 + }
370 + if (s.strm.avail_in === 0) {
371 + break;
372 + }
373 +
374 + /* If there was no sliding:
375 + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
376 + * more == window_size - lookahead - strstart
377 + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
378 + * => more >= window_size - 2*WSIZE + 2
379 + * In the BIG_MEM or MMAP case (not yet supported),
380 + * window_size == input_size + MIN_LOOKAHEAD &&
381 + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
382 + * Otherwise, window_size == 2*WSIZE so more >= 2.
383 + * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
384 + */
385 + //Assert(more >= 2, "more < 2");
386 + n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
387 + s.lookahead += n;
388 +
389 + /* Initialize the hash value now that we have some input: */
390 + if (s.lookahead + s.insert >= MIN_MATCH) {
391 + str = s.strstart - s.insert;
392 + s.ins_h = s.window[str];
393 +
394 + /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
395 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask;
396 + //#if MIN_MATCH != 3
397 + // Call update_hash() MIN_MATCH-3 more times
398 + //#endif
399 + while (s.insert) {
400 + /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
401 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
402 + s.prev[str & s.w_mask] = s.head[s.ins_h];
403 + s.head[s.ins_h] = str;
404 + str++;
405 + s.insert--;
406 + if (s.lookahead + s.insert < MIN_MATCH) {
407 + break;
408 + }
409 + }
410 + }
411 + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
412 + * but this is not important since only literal bytes will be emitted.
413 + */
414 + } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
415 +
416 + /* If the WIN_INIT bytes after the end of the current data have never been
417 + * written, then zero those bytes in order to avoid memory check reports of
418 + * the use of uninitialized (or uninitialised as Julian writes) bytes by
419 + * the longest match routines. Update the high water mark for the next
420 + * time through here. WIN_INIT is set to MAX_MATCH since the longest match
421 + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
422 + */
423 + // if (s.high_water < s.window_size) {
424 + // var curr = s.strstart + s.lookahead;
425 + // var init = 0;
426 + //
427 + // if (s.high_water < curr) {
428 + // /* Previous high water mark below current data -- zero WIN_INIT
429 + // * bytes or up to end of window, whichever is less.
430 + // */
431 + // init = s.window_size - curr;
432 + // if (init > WIN_INIT)
433 + // init = WIN_INIT;
434 + // zmemzero(s->window + curr, (unsigned)init);
435 + // s->high_water = curr + init;
436 + // }
437 + // else if (s->high_water < (ulg)curr + WIN_INIT) {
438 + // /* High water mark at or above current data, but below current data
439 + // * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
440 + // * to end of window, whichever is less.
441 + // */
442 + // init = (ulg)curr + WIN_INIT - s->high_water;
443 + // if (init > s->window_size - s->high_water)
444 + // init = s->window_size - s->high_water;
445 + // zmemzero(s->window + s->high_water, (unsigned)init);
446 + // s->high_water += init;
447 + // }
448 + // }
449 + //
450 + // Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
451 + // "not enough room for search");
452 +}
453 +
454 +/* ===========================================================================
455 + * Copy without compression as much as possible from the input stream, return
456 + * the current block state.
457 + * This function does not insert new strings in the dictionary since
458 + * uncompressible data is probably not useful. This function is used
459 + * only for the level=0 compression option.
460 + * NOTE: this function should be optimized to avoid extra copying from
461 + * window to pending_buf.
462 + */
463 +function deflate_stored(s, flush) {
464 + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
465 + * to pending_buf_size, and each stored block has a 5 byte header:
466 + */
467 + var max_block_size = 0xffff;
468 + if (max_block_size > s.pending_buf_size - 5) {
469 + max_block_size = s.pending_buf_size - 5;
470 + }
471 +
472 + /* Copy as much as possible from input to output: */
473 + for (;;) {
474 + /* Fill the window as much as possible: */
475 + if (s.lookahead <= 1) {
476 + //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
477 + // s->block_start >= (long)s->w_size, "slide too late");
478 + // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
479 + // s.block_start >= s.w_size)) {
480 + // throw new Error("slide too late");
481 + // }
482 +
483 + fill_window(s);
484 + if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
485 + return BS_NEED_MORE;
486 + }
487 + if (s.lookahead === 0) {
488 + break;
489 + }
490 + /* flush the current block */
491 + }
492 + //Assert(s->block_start >= 0L, "block gone");
493 + // if (s.block_start < 0) throw new Error("block gone");
494 +
495 + s.strstart += s.lookahead;
496 + s.lookahead = 0;
497 +
498 + /* Emit a stored block if pending_buf will be full: */
499 + var max_start = s.block_start + max_block_size;
500 + if (s.strstart === 0 || s.strstart >= max_start) {
501 + /* strstart == 0 is possible when wraparound on 16-bit machine */
502 + s.lookahead = s.strstart - max_start;
503 + s.strstart = max_start;
504 + /*** FLUSH_BLOCK(s, 0); ***/
505 + flush_block_only(s, false);
506 + if (s.strm.avail_out === 0) {
507 + return BS_NEED_MORE;
508 + }
509 + /***/
510 + }
511 + /* Flush if we may have to slide, otherwise block_start may become
512 + * negative and the data will be gone:
513 + */
514 + if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
515 + /*** FLUSH_BLOCK(s, 0); ***/
516 + flush_block_only(s, false);
517 + if (s.strm.avail_out === 0) {
518 + return BS_NEED_MORE;
519 + }
520 + /***/
521 + }
522 + }
523 + s.insert = 0;
524 + if (flush === Z_FINISH) {
525 + /*** FLUSH_BLOCK(s, 1); ***/
526 + flush_block_only(s, true);
527 + if (s.strm.avail_out === 0) {
528 + return BS_FINISH_STARTED;
529 + }
530 + /***/
531 + return BS_FINISH_DONE;
532 + }
533 + if (s.strstart > s.block_start) {
534 + /*** FLUSH_BLOCK(s, 0); ***/
535 + flush_block_only(s, false);
536 + if (s.strm.avail_out === 0) {
537 + return BS_NEED_MORE;
538 + }
539 + /***/
540 + }
541 + return BS_NEED_MORE;
542 +}
543 +
544 +/* ===========================================================================
545 + * Compress as much as possible from the input stream, return the current
546 + * block state.
547 + * This function does not perform lazy evaluation of matches and inserts
548 + * new strings in the dictionary only for unmatched strings or for short
549 + * matches. It is used only for the fast compression options.
550 + */
551 +function deflate_fast(s, flush) {
552 + var hash_head; /* head of the hash chain */
553 + var bflush; /* set if current block must be flushed */
554 +
555 + for (;;) {
556 + /* Make sure that we always have enough lookahead, except
557 + * at the end of the input file. We need MAX_MATCH bytes
558 + * for the next match, plus MIN_MATCH bytes to insert the
559 + * string following the next match.
560 + */
561 + if (s.lookahead < MIN_LOOKAHEAD) {
562 + fill_window(s);
563 + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
564 + return BS_NEED_MORE;
565 + }
566 + if (s.lookahead === 0) {
567 + break; /* flush the current block */
568 + }
569 + }
570 +
571 + /* Insert the string window[strstart .. strstart+2] in the
572 + * dictionary, and set hash_head to the head of the hash chain:
573 + */
574 + hash_head = 0 /*NIL*/;
575 + if (s.lookahead >= MIN_MATCH) {
576 + /*** INSERT_STRING(s, s.strstart, hash_head); ***/
577 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
578 + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
579 + s.head[s.ins_h] = s.strstart;
580 + /***/
581 + }
582 +
583 + /* Find the longest match, discarding those <= prev_length.
584 + * At this point we have always match_length < MIN_MATCH
585 + */
586 + if (hash_head !== 0 /*NIL*/ && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
587 + /* To simplify the code, we prevent matches with the string
588 + * of window index 0 (in particular we have to avoid a match
589 + * of the string with itself at the start of the input file).
590 + */
591 + s.match_length = longest_match(s, hash_head);
592 + /* longest_match() sets match_start */
593 + }
594 + if (s.match_length >= MIN_MATCH) {
595 + // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only
596 +
597 + /*** _tr_tally_dist(s, s.strstart - s.match_start,
598 + s.match_length - MIN_MATCH, bflush); ***/
599 + bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
600 + s.lookahead -= s.match_length;
601 +
602 + /* Insert new strings in the hash table only if the match length
603 + * is not too large. This saves time but degrades compression.
604 + */
605 + if (s.match_length <= s.max_lazy_match /*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
606 + s.match_length--; /* string at strstart already in table */
607 + do {
608 + s.strstart++;
609 + /*** INSERT_STRING(s, s.strstart, hash_head); ***/
610 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
611 + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
612 + s.head[s.ins_h] = s.strstart;
613 + /***/
614 + /* strstart never exceeds WSIZE-MAX_MATCH, so there are
615 + * always MIN_MATCH bytes ahead.
616 + */
617 + } while (--s.match_length !== 0);
618 + s.strstart++;
619 + } else {
620 + s.strstart += s.match_length;
621 + s.match_length = 0;
622 + s.ins_h = s.window[s.strstart];
623 + /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
624 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask;
625 +
626 + //#if MIN_MATCH != 3
627 + // Call UPDATE_HASH() MIN_MATCH-3 more times
628 + //#endif
629 + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
630 + * matter since it will be recomputed at next deflate call.
631 + */
632 + }
633 + } else {
634 + /* No match, output a literal byte */
635 + //Tracevv((stderr,"%c", s.window[s.strstart]));
636 + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
637 + bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
638 + s.lookahead--;
639 + s.strstart++;
640 + }
641 + if (bflush) {
642 + /*** FLUSH_BLOCK(s, 0); ***/
643 + flush_block_only(s, false);
644 + if (s.strm.avail_out === 0) {
645 + return BS_NEED_MORE;
646 + }
647 + /***/
648 + }
649 + }
650 + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
651 + if (flush === Z_FINISH) {
652 + /*** FLUSH_BLOCK(s, 1); ***/
653 + flush_block_only(s, true);
654 + if (s.strm.avail_out === 0) {
655 + return BS_FINISH_STARTED;
656 + }
657 + /***/
658 + return BS_FINISH_DONE;
659 + }
660 + if (s.last_lit) {
661 + /*** FLUSH_BLOCK(s, 0); ***/
662 + flush_block_only(s, false);
663 + if (s.strm.avail_out === 0) {
664 + return BS_NEED_MORE;
665 + }
666 + /***/
667 + }
668 + return BS_BLOCK_DONE;
669 +}
670 +
671 +/* ===========================================================================
672 + * Same as above, but achieves better compression. We use a lazy
673 + * evaluation for matches: a match is finally adopted only if there is
674 + * no better match at the next window position.
675 + */
676 +function deflate_slow(s, flush) {
677 + var hash_head; /* head of hash chain */
678 + var bflush; /* set if current block must be flushed */
679 +
680 + var max_insert;
681 +
682 + /* Process the input block. */
683 + for (;;) {
684 + /* Make sure that we always have enough lookahead, except
685 + * at the end of the input file. We need MAX_MATCH bytes
686 + * for the next match, plus MIN_MATCH bytes to insert the
687 + * string following the next match.
688 + */
689 + if (s.lookahead < MIN_LOOKAHEAD) {
690 + fill_window(s);
691 + if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
692 + return BS_NEED_MORE;
693 + }
694 + if (s.lookahead === 0) {
695 + break;
696 + } /* flush the current block */
697 + }
698 +
699 + /* Insert the string window[strstart .. strstart+2] in the
700 + * dictionary, and set hash_head to the head of the hash chain:
701 + */
702 + hash_head = 0 /*NIL*/;
703 + if (s.lookahead >= MIN_MATCH) {
704 + /*** INSERT_STRING(s, s.strstart, hash_head); ***/
705 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
706 + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
707 + s.head[s.ins_h] = s.strstart;
708 + /***/
709 + }
710 +
711 + /* Find the longest match, discarding those <= prev_length.
712 + */
713 + s.prev_length = s.match_length;
714 + s.prev_match = s.match_start;
715 + s.match_length = MIN_MATCH - 1;
716 + if (hash_head !== 0 /*NIL*/ && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD /*MAX_DIST(s)*/) {
717 + /* To simplify the code, we prevent matches with the string
718 + * of window index 0 (in particular we have to avoid a match
719 + * of the string with itself at the start of the input file).
720 + */
721 + s.match_length = longest_match(s, hash_head);
722 + /* longest_match() sets match_start */
723 +
724 + if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096 /*TOO_FAR*/)) {
725 + /* If prev_match is also MIN_MATCH, match_start is garbage
726 + * but we will ignore the current match anyway.
727 + */
728 + s.match_length = MIN_MATCH - 1;
729 + }
730 + }
731 + /* If there was a match at the previous step and the current
732 + * match is not better, output the previous match:
733 + */
734 + if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
735 + max_insert = s.strstart + s.lookahead - MIN_MATCH;
736 + /* Do not insert strings in hash table beyond this. */
737 +
738 + //check_match(s, s.strstart-1, s.prev_match, s.prev_length);
739 +
740 + /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
741 + s.prev_length - MIN_MATCH, bflush);***/
742 + bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
743 + /* Insert in hash table all strings up to the end of the match.
744 + * strstart-1 and strstart are already inserted. If there is not
745 + * enough lookahead, the last two strings are not inserted in
746 + * the hash table.
747 + */
748 + s.lookahead -= s.prev_length - 1;
749 + s.prev_length -= 2;
750 + do {
751 + if (++s.strstart <= max_insert) {
752 + /*** INSERT_STRING(s, s.strstart, hash_head); ***/
753 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
754 + hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
755 + s.head[s.ins_h] = s.strstart;
756 + /***/
757 + }
758 + } while (--s.prev_length !== 0);
759 + s.match_available = 0;
760 + s.match_length = MIN_MATCH - 1;
761 + s.strstart++;
762 + if (bflush) {
763 + /*** FLUSH_BLOCK(s, 0); ***/
764 + flush_block_only(s, false);
765 + if (s.strm.avail_out === 0) {
766 + return BS_NEED_MORE;
767 + }
768 + /***/
769 + }
770 + } else if (s.match_available) {
771 + /* If there was no match at the previous position, output a
772 + * single literal. If there was a match but the current match
773 + * is longer, truncate the previous match to a single literal.
774 + */
775 + //Tracevv((stderr,"%c", s->window[s->strstart-1]));
776 + /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
777 + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
778 + if (bflush) {
779 + /*** FLUSH_BLOCK_ONLY(s, 0) ***/
780 + flush_block_only(s, false);
781 + /***/
782 + }
783 + s.strstart++;
784 + s.lookahead--;
785 + if (s.strm.avail_out === 0) {
786 + return BS_NEED_MORE;
787 + }
788 + } else {
789 + /* There is no previous match to compare with, wait for
790 + * the next step to decide.
791 + */
792 + s.match_available = 1;
793 + s.strstart++;
794 + s.lookahead--;
795 + }
796 + }
797 + //Assert (flush != Z_NO_FLUSH, "no flush?");
798 + if (s.match_available) {
799 + //Tracevv((stderr,"%c", s->window[s->strstart-1]));
800 + /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
801 + bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
802 + s.match_available = 0;
803 + }
804 + s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
805 + if (flush === Z_FINISH) {
806 + /*** FLUSH_BLOCK(s, 1); ***/
807 + flush_block_only(s, true);
808 + if (s.strm.avail_out === 0) {
809 + return BS_FINISH_STARTED;
810 + }
811 + /***/
812 + return BS_FINISH_DONE;
813 + }
814 + if (s.last_lit) {
815 + /*** FLUSH_BLOCK(s, 0); ***/
816 + flush_block_only(s, false);
817 + if (s.strm.avail_out === 0) {
818 + return BS_NEED_MORE;
819 + }
820 + /***/
821 + }
822 + return BS_BLOCK_DONE;
823 +}
824 +
825 +/* ===========================================================================
826 + * For Z_RLE, simply look for runs of bytes, generate matches only of distance
827 + * one. Do not maintain a hash table. (It will be regenerated if this run of
828 + * deflate switches away from Z_RLE.)
829 + */
830 +function deflate_rle(s, flush) {
831 + var bflush; /* set if current block must be flushed */
832 + var prev; /* byte at distance one to match */
833 + var scan, strend; /* scan goes up to strend for length of run */
834 +
835 + var _win = s.window;
836 + for (;;) {
837 + /* Make sure that we always have enough lookahead, except
838 + * at the end of the input file. We need MAX_MATCH bytes
839 + * for the longest run, plus one for the unrolled loop.
840 + */
841 + if (s.lookahead <= MAX_MATCH) {
842 + fill_window(s);
843 + if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
844 + return BS_NEED_MORE;
845 + }
846 + if (s.lookahead === 0) {
847 + break;
848 + } /* flush the current block */
849 + }
850 +
851 + /* See how many times the previous byte repeats */
852 + s.match_length = 0;
853 + if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
854 + scan = s.strstart - 1;
855 + prev = _win[scan];
856 + if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
857 + strend = s.strstart + MAX_MATCH;
858 + do {
859 + // Do nothing
860 + } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend);
861 + s.match_length = MAX_MATCH - (strend - scan);
862 + if (s.match_length > s.lookahead) {
863 + s.match_length = s.lookahead;
864 + }
865 + }
866 + //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
867 + }
868 +
869 + /* Emit match if have run of MIN_MATCH or longer, else emit literal */
870 + if (s.match_length >= MIN_MATCH) {
871 + //check_match(s, s.strstart, s.strstart - 1, s.match_length);
872 +
873 + /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/
874 + bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
875 + s.lookahead -= s.match_length;
876 + s.strstart += s.match_length;
877 + s.match_length = 0;
878 + } else {
879 + /* No match, output a literal byte */
880 + //Tracevv((stderr,"%c", s->window[s->strstart]));
881 + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
882 + bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
883 + s.lookahead--;
884 + s.strstart++;
885 + }
886 + if (bflush) {
887 + /*** FLUSH_BLOCK(s, 0); ***/
888 + flush_block_only(s, false);
889 + if (s.strm.avail_out === 0) {
890 + return BS_NEED_MORE;
891 + }
892 + /***/
893 + }
894 + }
895 + s.insert = 0;
896 + if (flush === Z_FINISH) {
897 + /*** FLUSH_BLOCK(s, 1); ***/
898 + flush_block_only(s, true);
899 + if (s.strm.avail_out === 0) {
900 + return BS_FINISH_STARTED;
901 + }
902 + /***/
903 + return BS_FINISH_DONE;
904 + }
905 + if (s.last_lit) {
906 + /*** FLUSH_BLOCK(s, 0); ***/
907 + flush_block_only(s, false);
908 + if (s.strm.avail_out === 0) {
909 + return BS_NEED_MORE;
910 + }
911 + /***/
912 + }
913 + return BS_BLOCK_DONE;
914 +}
915 +
916 +/* ===========================================================================
917 + * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
918 + * (It will be regenerated if this run of deflate switches away from Huffman.)
919 + */
920 +function deflate_huff(s, flush) {
921 + var bflush; /* set if current block must be flushed */
922 +
923 + for (;;) {
924 + /* Make sure that we have a literal to write. */
925 + if (s.lookahead === 0) {
926 + fill_window(s);
927 + if (s.lookahead === 0) {
928 + if (flush === Z_NO_FLUSH) {
929 + return BS_NEED_MORE;
930 + }
931 + break; /* flush the current block */
932 + }
933 + }
934 +
935 + /* Output a literal byte */
936 + s.match_length = 0;
937 + //Tracevv((stderr,"%c", s->window[s->strstart]));
938 + /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
939 + bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
940 + s.lookahead--;
941 + s.strstart++;
942 + if (bflush) {
943 + /*** FLUSH_BLOCK(s, 0); ***/
944 + flush_block_only(s, false);
945 + if (s.strm.avail_out === 0) {
946 + return BS_NEED_MORE;
947 + }
948 + /***/
949 + }
950 + }
951 + s.insert = 0;
952 + if (flush === Z_FINISH) {
953 + /*** FLUSH_BLOCK(s, 1); ***/
954 + flush_block_only(s, true);
955 + if (s.strm.avail_out === 0) {
956 + return BS_FINISH_STARTED;
957 + }
958 + /***/
959 + return BS_FINISH_DONE;
960 + }
961 + if (s.last_lit) {
962 + /*** FLUSH_BLOCK(s, 0); ***/
963 + flush_block_only(s, false);
964 + if (s.strm.avail_out === 0) {
965 + return BS_NEED_MORE;
966 + }
967 + /***/
968 + }
969 + return BS_BLOCK_DONE;
970 +}
971 +
972 +/* Values for max_lazy_match, good_match and max_chain_length, depending on
973 + * the desired pack level (0..9). The values given below have been tuned to
974 + * exclude worst case performance for pathological files. Better values may be
975 + * found for specific files.
976 + */
977 +function Config(good_length, max_lazy, nice_length, max_chain, func) {
978 + this.good_length = good_length;
979 + this.max_lazy = max_lazy;
980 + this.nice_length = nice_length;
981 + this.max_chain = max_chain;
982 + this.func = func;
983 +}
984 +var configuration_table;
985 +configuration_table = [/* good lazy nice chain */
986 +new Config(0, 0, 0, 0, deflate_stored), /* 0 store only */
987 +new Config(4, 4, 8, 4, deflate_fast), /* 1 max speed, no lazy matches */
988 +new Config(4, 5, 16, 8, deflate_fast), /* 2 */
989 +new Config(4, 6, 32, 32, deflate_fast), /* 3 */
990 +
991 +new Config(4, 4, 16, 16, deflate_slow), /* 4 lazy matches */
992 +new Config(8, 16, 32, 32, deflate_slow), /* 5 */
993 +new Config(8, 16, 128, 128, deflate_slow), /* 6 */
994 +new Config(8, 32, 128, 256, deflate_slow), /* 7 */
995 +new Config(32, 128, 258, 1024, deflate_slow), /* 8 */
996 +new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */];
997 +
998 +/* ===========================================================================
999 + * Initialize the "longest match" routines for a new zlib stream
1000 + */
1001 +function lm_init(s) {
1002 + s.window_size = 2 * s.w_size;
1003 +
1004 + /*** CLEAR_HASH(s); ***/
1005 + zero(s.head); // Fill with NIL (= 0);
1006 +
1007 + /* Set the default configuration parameters:
1008 + */
1009 + s.max_lazy_match = configuration_table[s.level].max_lazy;
1010 + s.good_match = configuration_table[s.level].good_length;
1011 + s.nice_match = configuration_table[s.level].nice_length;
1012 + s.max_chain_length = configuration_table[s.level].max_chain;
1013 + s.strstart = 0;
1014 + s.block_start = 0;
1015 + s.lookahead = 0;
1016 + s.insert = 0;
1017 + s.match_length = s.prev_length = MIN_MATCH - 1;
1018 + s.match_available = 0;
1019 + s.ins_h = 0;
1020 +}
1021 +function DeflateState() {
1022 + this.strm = null; /* pointer back to this zlib stream */
1023 + this.status = 0; /* as the name implies */
1024 + this.pending_buf = null; /* output still pending */
1025 + this.pending_buf_size = 0; /* size of pending_buf */
1026 + this.pending_out = 0; /* next pending byte to output to the stream */
1027 + this.pending = 0; /* nb of bytes in the pending buffer */
1028 + this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
1029 + this.gzhead = null; /* gzip header information to write */
1030 + this.gzindex = 0; /* where in extra, name, or comment */
1031 + this.method = Z_DEFLATED; /* can only be DEFLATED */
1032 + this.last_flush = -1; /* value of flush param for previous deflate call */
1033 +
1034 + this.w_size = 0; /* LZ77 window size (32K by default) */
1035 + this.w_bits = 0; /* log2(w_size) (8..16) */
1036 + this.w_mask = 0; /* w_size - 1 */
1037 +
1038 + this.window = null;
1039 + /* Sliding window. Input bytes are read into the second half of the window,
1040 + * and move to the first half later to keep a dictionary of at least wSize
1041 + * bytes. With this organization, matches are limited to a distance of
1042 + * wSize-MAX_MATCH bytes, but this ensures that IO is always
1043 + * performed with a length multiple of the block size.
1044 + */
1045 +
1046 + this.window_size = 0;
1047 + /* Actual size of window: 2*wSize, except when the user input buffer
1048 + * is directly used as sliding window.
1049 + */
1050 +
1051 + this.prev = null;
1052 + /* Link to older string with same hash index. To limit the size of this
1053 + * array to 64K, this link is maintained only for the last 32K strings.
1054 + * An index in this array is thus a window index modulo 32K.
1055 + */
1056 +
1057 + this.head = null; /* Heads of the hash chains or NIL. */
1058 +
1059 + this.ins_h = 0; /* hash index of string to be inserted */
1060 + this.hash_size = 0; /* number of elements in hash table */
1061 + this.hash_bits = 0; /* log2(hash_size) */
1062 + this.hash_mask = 0; /* hash_size-1 */
1063 +
1064 + this.hash_shift = 0;
1065 + /* Number of bits by which ins_h must be shifted at each input
1066 + * step. It must be such that after MIN_MATCH steps, the oldest
1067 + * byte no longer takes part in the hash key, that is:
1068 + * hash_shift * MIN_MATCH >= hash_bits
1069 + */
1070 +
1071 + this.block_start = 0;
1072 + /* Window position at the beginning of the current output block. Gets
1073 + * negative when the window is moved backwards.
1074 + */
1075 +
1076 + this.match_length = 0; /* length of best match */
1077 + this.prev_match = 0; /* previous match */
1078 + this.match_available = 0; /* set if previous match exists */
1079 + this.strstart = 0; /* start of string to insert */
1080 + this.match_start = 0; /* start of matching string */
1081 + this.lookahead = 0; /* number of valid bytes ahead in window */
1082 +
1083 + this.prev_length = 0;
1084 + /* Length of the best match at previous step. Matches not greater than this
1085 + * are discarded. This is used in the lazy match evaluation.
1086 + */
1087 +
1088 + this.max_chain_length = 0;
1089 + /* To speed up deflation, hash chains are never searched beyond this
1090 + * length. A higher limit improves compression ratio but degrades the
1091 + * speed.
1092 + */
1093 +
1094 + this.max_lazy_match = 0;
1095 + /* Attempt to find a better match only when the current match is strictly
1096 + * smaller than this value. This mechanism is used only for compression
1097 + * levels >= 4.
1098 + */
1099 + // That's alias to max_lazy_match, don't use directly
1100 + //this.max_insert_length = 0;
1101 + /* Insert new strings in the hash table only if the match length is not
1102 + * greater than this length. This saves time but degrades compression.
1103 + * max_insert_length is used only for compression levels <= 3.
1104 + */
1105 +
1106 + this.level = 0; /* compression level (1..9) */
1107 + this.strategy = 0; /* favor or force Huffman coding*/
1108 +
1109 + this.good_match = 0;
1110 + /* Use a faster search when the previous match is longer than this */
1111 +
1112 + this.nice_match = 0; /* Stop searching when current match exceeds this */
1113 +
1114 + /* used by trees.c: */
1115 +
1116 + /* Didn't use ct_data typedef below to suppress compiler warning */
1117 +
1118 + // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
1119 + // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
1120 + // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
1121 +
1122 + // Use flat array of DOUBLE size, with interleaved fata,
1123 + // because JS does not support effective
1124 + this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2);
1125 + this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2);
1126 + this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2);
1127 + zero(this.dyn_ltree);
1128 + zero(this.dyn_dtree);
1129 + zero(this.bl_tree);
1130 + this.l_desc = null; /* desc. for literal tree */
1131 + this.d_desc = null; /* desc. for distance tree */
1132 + this.bl_desc = null; /* desc. for bit length tree */
1133 +
1134 + //ush bl_count[MAX_BITS+1];
1135 + this.bl_count = new utils.Buf16(MAX_BITS + 1);
1136 + /* number of codes at each bit length for an optimal tree */
1137 +
1138 + //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
1139 + this.heap = new utils.Buf16(2 * L_CODES + 1); /* heap used to build the Huffman trees */
1140 + zero(this.heap);
1141 + this.heap_len = 0; /* number of elements in the heap */
1142 + this.heap_max = 0; /* element of largest frequency */
1143 + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
1144 + * The same heap array is used to build all trees.
1145 + */
1146 +
1147 + this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];
1148 + zero(this.depth);
1149 + /* Depth of each subtree used as tie breaker for trees of equal frequency
1150 + */
1151 +
1152 + this.l_buf = 0; /* buffer index for literals or lengths */
1153 +
1154 + this.lit_bufsize = 0;
1155 + /* Size of match buffer for literals/lengths. There are 4 reasons for
1156 + * limiting lit_bufsize to 64K:
1157 + * - frequencies can be kept in 16 bit counters
1158 + * - if compression is not successful for the first block, all input
1159 + * data is still in the window so we can still emit a stored block even
1160 + * when input comes from standard input. (This can also be done for
1161 + * all blocks if lit_bufsize is not greater than 32K.)
1162 + * - if compression is not successful for a file smaller than 64K, we can
1163 + * even emit a stored file instead of a stored block (saving 5 bytes).
1164 + * This is applicable only for zip (not gzip or zlib).
1165 + * - creating new Huffman trees less frequently may not provide fast
1166 + * adaptation to changes in the input data statistics. (Take for
1167 + * example a binary file with poorly compressible code followed by
1168 + * a highly compressible string table.) Smaller buffer sizes give
1169 + * fast adaptation but have of course the overhead of transmitting
1170 + * trees more frequently.
1171 + * - I can't count above 4
1172 + */
1173 +
1174 + this.last_lit = 0; /* running index in l_buf */
1175 +
1176 + this.d_buf = 0;
1177 + /* Buffer index for distances. To simplify the code, d_buf and l_buf have
1178 + * the same number of elements. To use different lengths, an extra flag
1179 + * array would be necessary.
1180 + */
1181 +
1182 + this.opt_len = 0; /* bit length of current block with optimal trees */
1183 + this.static_len = 0; /* bit length of current block with static trees */
1184 + this.matches = 0; /* number of string matches in current block */
1185 + this.insert = 0; /* bytes at end of window left to insert */
1186 +
1187 + this.bi_buf = 0;
1188 + /* Output buffer. bits are inserted starting at the bottom (least
1189 + * significant bits).
1190 + */
1191 + this.bi_valid = 0;
1192 + /* Number of valid bits in bi_buf. All bits above the last valid bit
1193 + * are always zero.
1194 + */
1195 +
1196 + // Used for window memory init. We safely ignore it for JS. That makes
1197 + // sense only for pointers and memory check tools.
1198 + //this.high_water = 0;
1199 + /* High water mark offset in window for initialized bytes -- bytes above
1200 + * this are set to zero in order to avoid memory check warnings when
1201 + * longest match routines access bytes past the input. This is then
1202 + * updated to the new high water mark.
1203 + */
1204 +}
1205 +function deflateResetKeep(strm) {
1206 + var s;
1207 + if (!strm || !strm.state) {
1208 + return err(strm, Z_STREAM_ERROR);
1209 + }
1210 + strm.total_in = strm.total_out = 0;
1211 + strm.data_type = Z_UNKNOWN;
1212 + s = strm.state;
1213 + s.pending = 0;
1214 + s.pending_out = 0;
1215 + if (s.wrap < 0) {
1216 + s.wrap = -s.wrap;
1217 + /* was made negative by deflate(..., Z_FINISH); */
1218 + }
1219 + s.status = s.wrap ? INIT_STATE : BUSY_STATE;
1220 + strm.adler = s.wrap === 2 ? 0 // crc32(0, Z_NULL, 0)
1221 + : 1; // adler32(0, Z_NULL, 0)
1222 + s.last_flush = Z_NO_FLUSH;
1223 + trees._tr_init(s);
1224 + return Z_OK;
1225 +}
1226 +function deflateReset(strm) {
1227 + var ret = deflateResetKeep(strm);
1228 + if (ret === Z_OK) {
1229 + lm_init(strm.state);
1230 + }
1231 + return ret;
1232 +}
1233 +function deflateSetHeader(strm, head) {
1234 + if (!strm || !strm.state) {
1235 + return Z_STREAM_ERROR;
1236 + }
1237 + if (strm.state.wrap !== 2) {
1238 + return Z_STREAM_ERROR;
1239 + }
1240 + strm.state.gzhead = head;
1241 + return Z_OK;
1242 +}
1243 +function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
1244 + if (!strm) {
1245 + // === Z_NULL
1246 + return Z_STREAM_ERROR;
1247 + }
1248 + var wrap = 1;
1249 + if (level === Z_DEFAULT_COMPRESSION) {
1250 + level = 6;
1251 + }
1252 + if (windowBits < 0) {
1253 + /* suppress zlib wrapper */
1254 + wrap = 0;
1255 + windowBits = -windowBits;
1256 + } else if (windowBits > 15) {
1257 + wrap = 2; /* write gzip wrapper instead */
1258 + windowBits -= 16;
1259 + }
1260 + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
1261 + return err(strm, Z_STREAM_ERROR);
1262 + }
1263 + if (windowBits === 8) {
1264 + windowBits = 9;
1265 + }
1266 + /* until 256-byte window bug fixed */
1267 +
1268 + var s = new DeflateState();
1269 + strm.state = s;
1270 + s.strm = strm;
1271 + s.wrap = wrap;
1272 + s.gzhead = null;
1273 + s.w_bits = windowBits;
1274 + s.w_size = 1 << s.w_bits;
1275 + s.w_mask = s.w_size - 1;
1276 + s.hash_bits = memLevel + 7;
1277 + s.hash_size = 1 << s.hash_bits;
1278 + s.hash_mask = s.hash_size - 1;
1279 + s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
1280 + s.window = new utils.Buf8(s.w_size * 2);
1281 + s.head = new utils.Buf16(s.hash_size);
1282 + s.prev = new utils.Buf16(s.w_size);
1283 +
1284 + // Don't need mem init magic for JS.
1285 + //s.high_water = 0; /* nothing written to s->window yet */
1286 +
1287 + s.lit_bufsize = 1 << memLevel + 6; /* 16K elements by default */
1288 +
1289 + s.pending_buf_size = s.lit_bufsize * 4;
1290 +
1291 + //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
1292 + //s->pending_buf = (uchf *) overlay;
1293 + s.pending_buf = new utils.Buf8(s.pending_buf_size);
1294 +
1295 + // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
1296 + //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
1297 + s.d_buf = 1 * s.lit_bufsize;
1298 +
1299 + //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
1300 + s.l_buf = (1 + 2) * s.lit_bufsize;
1301 + s.level = level;
1302 + s.strategy = strategy;
1303 + s.method = method;
1304 + return deflateReset(strm);
1305 +}
1306 +function deflateInit(strm, level) {
1307 + return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
1308 +}
1309 +function deflate(strm, flush) {
1310 + var old_flush, s;
1311 + var beg, val; // for gzip header write only
1312 +
1313 + if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
1314 + return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
1315 + }
1316 + s = strm.state;
1317 + if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) {
1318 + return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR);
1319 + }
1320 + s.strm = strm; /* just in case */
1321 + old_flush = s.last_flush;
1322 + s.last_flush = flush;
1323 +
1324 + /* Write the header */
1325 + if (s.status === INIT_STATE) {
1326 + if (s.wrap === 2) {
1327 + // GZIP header
1328 + strm.adler = 0; //crc32(0L, Z_NULL, 0);
1329 + put_byte(s, 31);
1330 + put_byte(s, 139);
1331 + put_byte(s, 8);
1332 + if (!s.gzhead) {
1333 + // s->gzhead == Z_NULL
1334 + put_byte(s, 0);
1335 + put_byte(s, 0);
1336 + put_byte(s, 0);
1337 + put_byte(s, 0);
1338 + put_byte(s, 0);
1339 + put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
1340 + put_byte(s, OS_CODE);
1341 + s.status = BUSY_STATE;
1342 + } else {
1343 + put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16));
1344 + put_byte(s, s.gzhead.time & 0xff);
1345 + put_byte(s, s.gzhead.time >> 8 & 0xff);
1346 + put_byte(s, s.gzhead.time >> 16 & 0xff);
1347 + put_byte(s, s.gzhead.time >> 24 & 0xff);
1348 + put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0);
1349 + put_byte(s, s.gzhead.os & 0xff);
1350 + if (s.gzhead.extra && s.gzhead.extra.length) {
1351 + put_byte(s, s.gzhead.extra.length & 0xff);
1352 + put_byte(s, s.gzhead.extra.length >> 8 & 0xff);
1353 + }
1354 + if (s.gzhead.hcrc) {
1355 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending, 0);
1356 + }
1357 + s.gzindex = 0;
1358 + s.status = EXTRA_STATE;
1359 + }
1360 + } else
1361 + // DEFLATE header
1362 + {
1363 + var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8;
1364 + var level_flags = -1;
1365 + if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
1366 + level_flags = 0;
1367 + } else if (s.level < 6) {
1368 + level_flags = 1;
1369 + } else if (s.level === 6) {
1370 + level_flags = 2;
1371 + } else {
1372 + level_flags = 3;
1373 + }
1374 + header |= level_flags << 6;
1375 + if (s.strstart !== 0) {
1376 + header |= PRESET_DICT;
1377 + }
1378 + header += 31 - header % 31;
1379 + s.status = BUSY_STATE;
1380 + putShortMSB(s, header);
1381 +
1382 + /* Save the adler32 of the preset dictionary: */
1383 + if (s.strstart !== 0) {
1384 + putShortMSB(s, strm.adler >>> 16);
1385 + putShortMSB(s, strm.adler & 0xffff);
1386 + }
1387 + strm.adler = 1; // adler32(0L, Z_NULL, 0);
1388 + }
1389 + }
1390 +
1391 + //#ifdef GZIP
1392 + if (s.status === EXTRA_STATE) {
1393 + if (s.gzhead.extra /* != Z_NULL*/) {
1394 + beg = s.pending; /* start of bytes to update crc */
1395 +
1396 + while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
1397 + if (s.pending === s.pending_buf_size) {
1398 + if (s.gzhead.hcrc && s.pending > beg) {
1399 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1400 + }
1401 + flush_pending(strm);
1402 + beg = s.pending;
1403 + if (s.pending === s.pending_buf_size) {
1404 + break;
1405 + }
1406 + }
1407 + put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
1408 + s.gzindex++;
1409 + }
1410 + if (s.gzhead.hcrc && s.pending > beg) {
1411 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1412 + }
1413 + if (s.gzindex === s.gzhead.extra.length) {
1414 + s.gzindex = 0;
1415 + s.status = NAME_STATE;
1416 + }
1417 + } else {
1418 + s.status = NAME_STATE;
1419 + }
1420 + }
1421 + if (s.status === NAME_STATE) {
1422 + if (s.gzhead.name /* != Z_NULL*/) {
1423 + beg = s.pending; /* start of bytes to update crc */
1424 + //int val;
1425 +
1426 + do {
1427 + if (s.pending === s.pending_buf_size) {
1428 + if (s.gzhead.hcrc && s.pending > beg) {
1429 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1430 + }
1431 + flush_pending(strm);
1432 + beg = s.pending;
1433 + if (s.pending === s.pending_buf_size) {
1434 + val = 1;
1435 + break;
1436 + }
1437 + }
1438 + // JS specific: little magic to add zero terminator to end of string
1439 + if (s.gzindex < s.gzhead.name.length) {
1440 + val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
1441 + } else {
1442 + val = 0;
1443 + }
1444 + put_byte(s, val);
1445 + } while (val !== 0);
1446 + if (s.gzhead.hcrc && s.pending > beg) {
1447 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1448 + }
1449 + if (val === 0) {
1450 + s.gzindex = 0;
1451 + s.status = COMMENT_STATE;
1452 + }
1453 + } else {
1454 + s.status = COMMENT_STATE;
1455 + }
1456 + }
1457 + if (s.status === COMMENT_STATE) {
1458 + if (s.gzhead.comment /* != Z_NULL*/) {
1459 + beg = s.pending; /* start of bytes to update crc */
1460 + //int val;
1461 +
1462 + do {
1463 + if (s.pending === s.pending_buf_size) {
1464 + if (s.gzhead.hcrc && s.pending > beg) {
1465 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1466 + }
1467 + flush_pending(strm);
1468 + beg = s.pending;
1469 + if (s.pending === s.pending_buf_size) {
1470 + val = 1;
1471 + break;
1472 + }
1473 + }
1474 + // JS specific: little magic to add zero terminator to end of string
1475 + if (s.gzindex < s.gzhead.comment.length) {
1476 + val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
1477 + } else {
1478 + val = 0;
1479 + }
1480 + put_byte(s, val);
1481 + } while (val !== 0);
1482 + if (s.gzhead.hcrc && s.pending > beg) {
1483 + strm.adler = (0, _crc["default"])(strm.adler, s.pending_buf, s.pending - beg, beg);
1484 + }
1485 + if (val === 0) {
1486 + s.status = HCRC_STATE;
1487 + }
1488 + } else {
1489 + s.status = HCRC_STATE;
1490 + }
1491 + }
1492 + if (s.status === HCRC_STATE) {
1493 + if (s.gzhead.hcrc) {
1494 + if (s.pending + 2 > s.pending_buf_size) {
1495 + flush_pending(strm);
1496 + }
1497 + if (s.pending + 2 <= s.pending_buf_size) {
1498 + put_byte(s, strm.adler & 0xff);
1499 + put_byte(s, strm.adler >> 8 & 0xff);
1500 + strm.adler = 0; //crc32(0L, Z_NULL, 0);
1501 + s.status = BUSY_STATE;
1502 + }
1503 + } else {
1504 + s.status = BUSY_STATE;
1505 + }
1506 + }
1507 + //#endif
1508 +
1509 + /* Flush as much pending output as possible */
1510 + if (s.pending !== 0) {
1511 + flush_pending(strm);
1512 + if (strm.avail_out === 0) {
1513 + /* Since avail_out is 0, deflate will be called again with
1514 + * more output space, but possibly with both pending and
1515 + * avail_in equal to zero. There won't be anything to do,
1516 + * but this is not an error situation so make sure we
1517 + * return OK instead of BUF_ERROR at next call of deflate:
1518 + */
1519 + s.last_flush = -1;
1520 + return Z_OK;
1521 + }
1522 +
1523 + /* Make sure there is something to do and avoid duplicate consecutive
1524 + * flushes. For repeated and useless calls with Z_FINISH, we keep
1525 + * returning Z_STREAM_END instead of Z_BUF_ERROR.
1526 + */
1527 + } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) {
1528 + return err(strm, Z_BUF_ERROR);
1529 + }
1530 +
1531 + /* User must not provide more input after the first FINISH: */
1532 + if (s.status === FINISH_STATE && strm.avail_in !== 0) {
1533 + return err(strm, Z_BUF_ERROR);
1534 + }
1535 +
1536 + /* Start a new block or continue the current one.
1537 + */
1538 + if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) {
1539 + var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush);
1540 + if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
1541 + s.status = FINISH_STATE;
1542 + }
1543 + if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
1544 + if (strm.avail_out === 0) {
1545 + s.last_flush = -1;
1546 + /* avoid BUF_ERROR next call, see above */
1547 + }
1548 + return Z_OK;
1549 + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1550 + * of deflate should use the same flush parameter to make sure
1551 + * that the flush is complete. So we don't have to output an
1552 + * empty block here, this will be done at next call. This also
1553 + * ensures that for a very small output buffer, we emit at most
1554 + * one empty block.
1555 + */
1556 + }
1557 + if (bstate === BS_BLOCK_DONE) {
1558 + if (flush === Z_PARTIAL_FLUSH) {
1559 + trees._tr_align(s);
1560 + } else if (flush !== Z_BLOCK) {
1561 + /* FULL_FLUSH or SYNC_FLUSH */
1562 +
1563 + trees._tr_stored_block(s, 0, 0, false);
1564 + /* For a full flush, this empty block will be recognized
1565 + * as a special marker by inflate_sync().
1566 + */
1567 + if (flush === Z_FULL_FLUSH) {
1568 + /*** CLEAR_HASH(s); ***/ /* forget history */
1569 + zero(s.head); // Fill with NIL (= 0);
1570 +
1571 + if (s.lookahead === 0) {
1572 + s.strstart = 0;
1573 + s.block_start = 0;
1574 + s.insert = 0;
1575 + }
1576 + }
1577 + }
1578 + flush_pending(strm);
1579 + if (strm.avail_out === 0) {
1580 + s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1581 + return Z_OK;
1582 + }
1583 + }
1584 + }
1585 + //Assert(strm->avail_out > 0, "bug2");
1586 + //if (strm.avail_out <= 0) { throw new Error("bug2");}
1587 +
1588 + if (flush !== Z_FINISH) {
1589 + return Z_OK;
1590 + }
1591 + if (s.wrap <= 0) {
1592 + return Z_STREAM_END;
1593 + }
1594 +
1595 + /* Write the trailer */
1596 + if (s.wrap === 2) {
1597 + put_byte(s, strm.adler & 0xff);
1598 + put_byte(s, strm.adler >> 8 & 0xff);
1599 + put_byte(s, strm.adler >> 16 & 0xff);
1600 + put_byte(s, strm.adler >> 24 & 0xff);
1601 + put_byte(s, strm.total_in & 0xff);
1602 + put_byte(s, strm.total_in >> 8 & 0xff);
1603 + put_byte(s, strm.total_in >> 16 & 0xff);
1604 + put_byte(s, strm.total_in >> 24 & 0xff);
1605 + } else {
1606 + putShortMSB(s, strm.adler >>> 16);
1607 + putShortMSB(s, strm.adler & 0xffff);
1608 + }
1609 + flush_pending(strm);
1610 + /* If avail_out is zero, the application will call deflate again
1611 + * to flush the rest.
1612 + */
1613 + if (s.wrap > 0) {
1614 + s.wrap = -s.wrap;
1615 + }
1616 + /* write the trailer only once! */
1617 + return s.pending !== 0 ? Z_OK : Z_STREAM_END;
1618 +}
1619 +function deflateEnd(strm) {
1620 + var status;
1621 + if (!strm /*== Z_NULL*/ || !strm.state /*== Z_NULL*/) {
1622 + return Z_STREAM_ERROR;
1623 + }
1624 + status = strm.state.status;
1625 + if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) {
1626 + return err(strm, Z_STREAM_ERROR);
1627 + }
1628 + strm.state = null;
1629 + return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;
1630 +}
1631 +
1632 +/* =========================================================================
1633 + * Initializes the compression dictionary from the given byte
1634 + * sequence without producing any compressed output.
1635 + */
1636 +function deflateSetDictionary(strm, dictionary) {
1637 + var dictLength = dictionary.length;
1638 + var s;
1639 + var str, n;
1640 + var wrap;
1641 + var avail;
1642 + var next;
1643 + var input;
1644 + var tmpDict;
1645 + if (!strm /*== Z_NULL*/ || !strm.state /*== Z_NULL*/) {
1646 + return Z_STREAM_ERROR;
1647 + }
1648 + s = strm.state;
1649 + wrap = s.wrap;
1650 + if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) {
1651 + return Z_STREAM_ERROR;
1652 + }
1653 +
1654 + /* when using zlib wrappers, compute Adler-32 for provided dictionary */
1655 + if (wrap === 1) {
1656 + /* adler32(strm->adler, dictionary, dictLength); */
1657 + strm.adler = (0, _adler["default"])(strm.adler, dictionary, dictLength, 0);
1658 + }
1659 + s.wrap = 0; /* avoid computing Adler-32 in read_buf */
1660 +
1661 + /* if dictionary would fill window, just replace the history */
1662 + if (dictLength >= s.w_size) {
1663 + if (wrap === 0) {
1664 + /* already empty otherwise */
1665 + /*** CLEAR_HASH(s); ***/
1666 + zero(s.head); // Fill with NIL (= 0);
1667 + s.strstart = 0;
1668 + s.block_start = 0;
1669 + s.insert = 0;
1670 + }
1671 + /* use the tail */
1672 + // dictionary = dictionary.slice(dictLength - s.w_size);
1673 + tmpDict = new utils.Buf8(s.w_size);
1674 + utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
1675 + dictionary = tmpDict;
1676 + dictLength = s.w_size;
1677 + }
1678 + /* insert dictionary into window and hash */
1679 + avail = strm.avail_in;
1680 + next = strm.next_in;
1681 + input = strm.input;
1682 + strm.avail_in = dictLength;
1683 + strm.next_in = 0;
1684 + strm.input = dictionary;
1685 + fill_window(s);
1686 + while (s.lookahead >= MIN_MATCH) {
1687 + str = s.strstart;
1688 + n = s.lookahead - (MIN_MATCH - 1);
1689 + do {
1690 + /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
1691 + s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
1692 + s.prev[str & s.w_mask] = s.head[s.ins_h];
1693 + s.head[s.ins_h] = str;
1694 + str++;
1695 + } while (--n);
1696 + s.strstart = str;
1697 + s.lookahead = MIN_MATCH - 1;
1698 + fill_window(s);
1699 + }
1700 + s.strstart += s.lookahead;
1701 + s.block_start = s.strstart;
1702 + s.insert = s.lookahead;
1703 + s.lookahead = 0;
1704 + s.match_length = s.prev_length = MIN_MATCH - 1;
1705 + s.match_available = 0;
1706 + strm.next_in = next;
1707 + strm.input = input;
1708 + strm.avail_in = avail;
1709 + s.wrap = wrap;
1710 + return Z_OK;
1711 +}
1712 +var deflateInfo = exports.deflateInfo = 'pako deflate (from Nodeca project)';
1713 +
1714 +/* Not implemented
1715 +exports.deflateBound = deflateBound;
1716 +exports.deflateCopy = deflateCopy;
1717 +exports.deflateParams = deflateParams;
1718 +exports.deflatePending = deflatePending;
1719 +exports.deflatePrime = deflatePrime;
1720 +exports.deflateTune = deflateTune;
1721 +*/
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/gzheader.js +41 −0
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = GZheader;
7 +function GZheader() {
8 + /* true if compressed data believed to be text */
9 + this.text = 0;
10 + /* modification time */
11 + this.time = 0;
12 + /* extra flags (not used when writing a gzip file) */
13 + this.xflags = 0;
14 + /* operating system */
15 + this.os = 0;
16 + /* pointer to extra field or Z_NULL if none */
17 + this.extra = null;
18 + /* extra field length (valid if extra != Z_NULL) */
19 + this.extra_len = 0; // Actually, we don't need it in JS,
20 + // but leave for few code modifications
21 +
22 + //
23 + // Setup limits is not necessary because in js we should not preallocate memory
24 + // for inflate use constant limit in 65536 bytes
25 + //
26 +
27 + /* space at extra (only when reading header) */
28 + // this.extra_max = 0;
29 + /* pointer to zero-terminated file name or Z_NULL */
30 + this.name = '';
31 + /* space at name (only when reading header) */
32 + // this.name_max = 0;
33 + /* pointer to zero-terminated comment or Z_NULL */
34 + this.comment = '';
35 + /* space at comment (only when reading header) */
36 + // this.comm_max = 0;
37 + /* true if there was or will be a header crc */
38 + this.hcrc = 0;
39 + /* true when done reading gzip header (not used when writing a gzip file) */
40 + this.done = false;
41 +}
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/inffast.js +327 −0
@@ -0,0 +1,327 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = inflate_fast;
7 +// See state defs from inflate.js
8 +var BAD = 30; /* got a data error -- remain here until reset */
9 +var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
10 +
11 +/*
12 + Decode literal, length, and distance codes and write out the resulting
13 + literal and match bytes until either not enough input or output is
14 + available, an end-of-block is encountered, or a data error is encountered.
15 + When large enough input and output buffers are supplied to inflate(), for
16 + example, a 16K input buffer and a 64K output buffer, more than 95% of the
17 + inflate execution time is spent in this routine.
18 +
19 + Entry assumptions:
20 +
21 + state.mode === LEN
22 + strm.avail_in >= 6
23 + strm.avail_out >= 258
24 + start >= strm.avail_out
25 + state.bits < 8
26 +
27 + On return, state.mode is one of:
28 +
29 + LEN -- ran out of enough output space or enough available input
30 + TYPE -- reached end of block code, inflate() to interpret next block
31 + BAD -- error in block data
32 +
33 + Notes:
34 +
35 + - The maximum input bits used by a length/distance pair is 15 bits for the
36 + length code, 5 bits for the length extra, 15 bits for the distance code,
37 + and 13 bits for the distance extra. This totals 48 bits, or six bytes.
38 + Therefore if strm.avail_in >= 6, then there is enough input to avoid
39 + checking for available input while decoding.
40 +
41 + - The maximum bytes that a single length/distance pair can output is 258
42 + bytes, which is the maximum length that can be coded. inflate_fast()
43 + requires strm.avail_out >= 258 for each loop to avoid checking for
44 + output space.
45 + */
46 +function inflate_fast(strm, start) {
47 + var state;
48 + var _in; /* local strm.input */
49 + var last; /* have enough input while in < last */
50 + var _out; /* local strm.output */
51 + var beg; /* inflate()'s initial strm.output */
52 + var end; /* while out < end, enough space available */
53 + //#ifdef INFLATE_STRICT
54 + var dmax; /* maximum distance from zlib header */
55 + //#endif
56 + var wsize; /* window size or zero if not using window */
57 + var whave; /* valid bytes in the window */
58 + var wnext; /* window write index */
59 + // Use `s_window` instead `window`, avoid conflict with instrumentation tools
60 + var s_window; /* allocated sliding window, if wsize != 0 */
61 + var hold; /* local strm.hold */
62 + var bits; /* local strm.bits */
63 + var lcode; /* local strm.lencode */
64 + var dcode; /* local strm.distcode */
65 + var lmask; /* mask for first level of length codes */
66 + var dmask; /* mask for first level of distance codes */
67 + var here; /* retrieved table entry */
68 + var op; /* code bits, operation, extra bits, or */
69 + /* window position, window bytes to copy */
70 + var len; /* match length, unused bytes */
71 + var dist; /* match distance */
72 + var from; /* where to copy match from */
73 + var from_source;
74 + var input, output; // JS specific, because we have no pointers
75 +
76 + /* copy state to local variables */
77 + state = strm.state;
78 + //here = state.here;
79 + _in = strm.next_in;
80 + input = strm.input;
81 + last = _in + (strm.avail_in - 5);
82 + _out = strm.next_out;
83 + output = strm.output;
84 + beg = _out - (start - strm.avail_out);
85 + end = _out + (strm.avail_out - 257);
86 + //#ifdef INFLATE_STRICT
87 + dmax = state.dmax;
88 + //#endif
89 + wsize = state.wsize;
90 + whave = state.whave;
91 + wnext = state.wnext;
92 + s_window = state.window;
93 + hold = state.hold;
94 + bits = state.bits;
95 + lcode = state.lencode;
96 + dcode = state.distcode;
97 + lmask = (1 << state.lenbits) - 1;
98 + dmask = (1 << state.distbits) - 1;
99 +
100 + /* decode literals and length/distances until end-of-block or not enough
101 + input data or output space */
102 +
103 + top: do {
104 + if (bits < 15) {
105 + hold += input[_in++] << bits;
106 + bits += 8;
107 + hold += input[_in++] << bits;
108 + bits += 8;
109 + }
110 + here = lcode[hold & lmask];
111 + dolen: for (;;) {
112 + // Goto emulation
113 + op = here >>> 24 /*here.bits*/;
114 + hold >>>= op;
115 + bits -= op;
116 + op = here >>> 16 & 0xff /*here.op*/;
117 + if (op === 0) {
118 + /* literal */
119 + //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
120 + // "inflate: literal '%c'\n" :
121 + // "inflate: literal 0x%02x\n", here.val));
122 + output[_out++] = here & 0xffff /*here.val*/;
123 + } else if (op & 16) {
124 + /* length base */
125 + len = here & 0xffff /*here.val*/;
126 + op &= 15; /* number of extra bits */
127 + if (op) {
128 + if (bits < op) {
129 + hold += input[_in++] << bits;
130 + bits += 8;
131 + }
132 + len += hold & (1 << op) - 1;
133 + hold >>>= op;
134 + bits -= op;
135 + }
136 + //Tracevv((stderr, "inflate: length %u\n", len));
137 + if (bits < 15) {
138 + hold += input[_in++] << bits;
139 + bits += 8;
140 + hold += input[_in++] << bits;
141 + bits += 8;
142 + }
143 + here = dcode[hold & dmask];
144 + dodist: for (;;) {
145 + // goto emulation
146 + op = here >>> 24 /*here.bits*/;
147 + hold >>>= op;
148 + bits -= op;
149 + op = here >>> 16 & 0xff /*here.op*/;
150 + if (op & 16) {
151 + /* distance base */
152 + dist = here & 0xffff /*here.val*/;
153 + op &= 15; /* number of extra bits */
154 + if (bits < op) {
155 + hold += input[_in++] << bits;
156 + bits += 8;
157 + if (bits < op) {
158 + hold += input[_in++] << bits;
159 + bits += 8;
160 + }
161 + }
162 + dist += hold & (1 << op) - 1;
163 + //#ifdef INFLATE_STRICT
164 + if (dist > dmax) {
165 + strm.msg = 'invalid distance too far back';
166 + state.mode = BAD;
167 + break top;
168 + }
169 + //#endif
170 + hold >>>= op;
171 + bits -= op;
172 + //Tracevv((stderr, "inflate: distance %u\n", dist));
173 + op = _out - beg; /* max distance in output */
174 + if (dist > op) {
175 + /* see if copy from window */
176 + op = dist - op; /* distance back in window */
177 + if (op > whave) {
178 + if (state.sane) {
179 + strm.msg = 'invalid distance too far back';
180 + state.mode = BAD;
181 + break top;
182 + }
183 +
184 + // (!) This block is disabled in zlib defailts,
185 + // don't enable it for binary compatibility
186 + //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
187 + // if (len <= op - whave) {
188 + // do {
189 + // output[_out++] = 0;
190 + // } while (--len);
191 + // continue top;
192 + // }
193 + // len -= op - whave;
194 + // do {
195 + // output[_out++] = 0;
196 + // } while (--op > whave);
197 + // if (op === 0) {
198 + // from = _out - dist;
199 + // do {
200 + // output[_out++] = output[from++];
201 + // } while (--len);
202 + // continue top;
203 + // }
204 + //#endif
205 + }
206 + from = 0; // window index
207 + from_source = s_window;
208 + if (wnext === 0) {
209 + /* very common case */
210 + from += wsize - op;
211 + if (op < len) {
212 + /* some from window */
213 + len -= op;
214 + do {
215 + output[_out++] = s_window[from++];
216 + } while (--op);
217 + from = _out - dist; /* rest from output */
218 + from_source = output;
219 + }
220 + } else if (wnext < op) {
221 + /* wrap around window */
222 + from += wsize + wnext - op;
223 + op -= wnext;
224 + if (op < len) {
225 + /* some from end of window */
226 + len -= op;
227 + do {
228 + output[_out++] = s_window[from++];
229 + } while (--op);
230 + from = 0;
231 + if (wnext < len) {
232 + /* some from start of window */
233 + op = wnext;
234 + len -= op;
235 + do {
236 + output[_out++] = s_window[from++];
237 + } while (--op);
238 + from = _out - dist; /* rest from output */
239 + from_source = output;
240 + }
241 + }
242 + } else {
243 + /* contiguous in window */
244 + from += wnext - op;
245 + if (op < len) {
246 + /* some from window */
247 + len -= op;
248 + do {
249 + output[_out++] = s_window[from++];
250 + } while (--op);
251 + from = _out - dist; /* rest from output */
252 + from_source = output;
253 + }
254 + }
255 + while (len > 2) {
256 + output[_out++] = from_source[from++];
257 + output[_out++] = from_source[from++];
258 + output[_out++] = from_source[from++];
259 + len -= 3;
260 + }
261 + if (len) {
262 + output[_out++] = from_source[from++];
263 + if (len > 1) {
264 + output[_out++] = from_source[from++];
265 + }
266 + }
267 + } else {
268 + from = _out - dist; /* copy direct from output */
269 + do {
270 + /* minimum length is three */
271 + output[_out++] = output[from++];
272 + output[_out++] = output[from++];
273 + output[_out++] = output[from++];
274 + len -= 3;
275 + } while (len > 2);
276 + if (len) {
277 + output[_out++] = output[from++];
278 + if (len > 1) {
279 + output[_out++] = output[from++];
280 + }
281 + }
282 + }
283 + } else if ((op & 64) === 0) {
284 + /* 2nd level distance code */
285 + here = dcode[(here & 0xffff /*here.val*/) + (hold & (1 << op) - 1)];
286 + continue dodist;
287 + } else {
288 + strm.msg = 'invalid distance code';
289 + state.mode = BAD;
290 + break top;
291 + }
292 + break; // need to emulate goto via "continue"
293 + }
294 + } else if ((op & 64) === 0) {
295 + /* 2nd level length code */
296 + here = lcode[(here & 0xffff /*here.val*/) + (hold & (1 << op) - 1)];
297 + continue dolen;
298 + } else if (op & 32) {
299 + /* end-of-block */
300 + //Tracevv((stderr, "inflate: end of block\n"));
301 + state.mode = TYPE;
302 + break top;
303 + } else {
304 + strm.msg = 'invalid literal/length code';
305 + state.mode = BAD;
306 + break top;
307 + }
308 + break; // need to emulate goto via "continue"
309 + }
310 + } while (_in < last && _out < end);
311 +
312 + /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
313 + len = bits >> 3;
314 + _in -= len;
315 + bits -= len << 3;
316 + hold &= (1 << bits) - 1;
317 +
318 + /* update state and return */
319 + strm.next_in = _in;
320 + strm.next_out = _out;
321 + strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
322 + strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
323 + state.hold = hold;
324 + state.bits = bits;
325 + return;
326 +}
327 +;
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/inflate.js +1602 −0
@@ -0,0 +1,1602 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports.Z_TREES = exports.Z_STREAM_ERROR = exports.Z_STREAM_END = exports.Z_OK = exports.Z_NEED_DICT = exports.Z_MEM_ERROR = exports.Z_FINISH = exports.Z_DEFLATED = exports.Z_DATA_ERROR = exports.Z_BUF_ERROR = exports.Z_BLOCK = void 0;
8 +exports.inflate = inflate;
9 +exports.inflateEnd = inflateEnd;
10 +exports.inflateGetHeader = inflateGetHeader;
11 +exports.inflateInfo = void 0;
12 +exports.inflateInit = inflateInit;
13 +exports.inflateInit2 = inflateInit2;
14 +exports.inflateReset = inflateReset;
15 +exports.inflateReset2 = inflateReset2;
16 +exports.inflateResetKeep = inflateResetKeep;
17 +exports.inflateSetDictionary = inflateSetDictionary;
18 +var utils = _interopRequireWildcard(require("../utils/common.js"));
19 +var _adler = _interopRequireDefault(require("./adler32.js"));
20 +var _crc = _interopRequireDefault(require("./crc32.js"));
21 +var _inffast = _interopRequireDefault(require("./inffast.js"));
22 +var _inftrees = _interopRequireDefault(require("./inftrees.js"));
23 +function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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); }
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; }
26 +var CODES = 0;
27 +var LENS = 1;
28 +var DISTS = 2;
29 +
30 +/* Public constants ==========================================================*/
31 +/* ===========================================================================*/
32 +
33 +/* Allowed flush values; see deflate() and inflate() below for details */
34 +//export const Z_NO_FLUSH = 0;
35 +//export const Z_PARTIAL_FLUSH = 1;
36 +//export const Z_SYNC_FLUSH = 2;
37 +//export const Z_FULL_FLUSH = 3;
38 +var Z_FINISH = exports.Z_FINISH = 4;
39 +var Z_BLOCK = exports.Z_BLOCK = 5;
40 +var Z_TREES = exports.Z_TREES = 6;
41 +
42 +/* Return codes for the compression/decompression functions. Negative values
43 + * are errors, positive values are used for special but normal events.
44 + */
45 +var Z_OK = exports.Z_OK = 0;
46 +var Z_STREAM_END = exports.Z_STREAM_END = 1;
47 +var Z_NEED_DICT = exports.Z_NEED_DICT = 2;
48 +//export const Z_ERRNO = -1;
49 +var Z_STREAM_ERROR = exports.Z_STREAM_ERROR = -2;
50 +var Z_DATA_ERROR = exports.Z_DATA_ERROR = -3;
51 +var Z_MEM_ERROR = exports.Z_MEM_ERROR = -4;
52 +var Z_BUF_ERROR = exports.Z_BUF_ERROR = -5;
53 +//export const Z_VERSION_ERROR = -6;
54 +
55 +/* The deflate compression method */
56 +var Z_DEFLATED = exports.Z_DEFLATED = 8;
57 +
58 +/* STATES ====================================================================*/
59 +/* ===========================================================================*/
60 +
61 +var HEAD = 1; /* i: waiting for magic header */
62 +var FLAGS = 2; /* i: waiting for method and flags (gzip) */
63 +var TIME = 3; /* i: waiting for modification time (gzip) */
64 +var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
65 +var EXLEN = 5; /* i: waiting for extra length (gzip) */
66 +var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
67 +var NAME = 7; /* i: waiting for end of file name (gzip) */
68 +var COMMENT = 8; /* i: waiting for end of comment (gzip) */
69 +var HCRC = 9; /* i: waiting for header crc (gzip) */
70 +var DICTID = 10; /* i: waiting for dictionary check value */
71 +var DICT = 11; /* waiting for inflateSetDictionary() call */
72 +var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
73 +var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
74 +var STORED = 14; /* i: waiting for stored size (length and complement) */
75 +var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
76 +var COPY = 16; /* i/o: waiting for input or output to copy stored block */
77 +var TABLE = 17; /* i: waiting for dynamic block table lengths */
78 +var LENLENS = 18; /* i: waiting for code length code lengths */
79 +var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
80 +var LEN_ = 20; /* i: same as LEN below, but only first time in */
81 +var LEN = 21; /* i: waiting for length/lit/eob code */
82 +var LENEXT = 22; /* i: waiting for length extra bits */
83 +var DIST = 23; /* i: waiting for distance code */
84 +var DISTEXT = 24; /* i: waiting for distance extra bits */
85 +var MATCH = 25; /* o: waiting for output space to copy string */
86 +var LIT = 26; /* o: waiting for output space to write literal */
87 +var CHECK = 27; /* i: waiting for 32-bit check value */
88 +var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
89 +var DONE = 29; /* finished check, done -- remain here until reset */
90 +var BAD = 30; /* got a data error -- remain here until reset */
91 +var MEM = 31; /* got an inflate() memory error -- remain here until reset */
92 +var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
93 +
94 +/* ===========================================================================*/
95 +
96 +var ENOUGH_LENS = 852;
97 +var ENOUGH_DISTS = 592;
98 +//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
99 +
100 +var MAX_WBITS = 15;
101 +/* 32K LZ77 window */
102 +var DEF_WBITS = MAX_WBITS;
103 +function zswap32(q) {
104 + return (q >>> 24 & 0xff) + (q >>> 8 & 0xff00) + ((q & 0xff00) << 8) + ((q & 0xff) << 24);
105 +}
106 +function InflateState() {
107 + this.mode = 0; /* current inflate mode */
108 + this.last = false; /* true if processing last block */
109 + this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
110 + this.havedict = false; /* true if dictionary provided */
111 + this.flags = 0; /* gzip header method and flags (0 if zlib) */
112 + this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
113 + this.check = 0; /* protected copy of check value */
114 + this.total = 0; /* protected copy of output count */
115 + // TODO: may be {}
116 + this.head = null; /* where to save gzip header information */
117 +
118 + /* sliding window */
119 + this.wbits = 0; /* log base 2 of requested window size */
120 + this.wsize = 0; /* window size or zero if not using window */
121 + this.whave = 0; /* valid bytes in the window */
122 + this.wnext = 0; /* window write index */
123 + this.window = null; /* allocated sliding window, if needed */
124 +
125 + /* bit accumulator */
126 + this.hold = 0; /* input bit accumulator */
127 + this.bits = 0; /* number of bits in "in" */
128 +
129 + /* for string and stored block copying */
130 + this.length = 0; /* literal or length of data to copy */
131 + this.offset = 0; /* distance back to copy string from */
132 +
133 + /* for table and code decoding */
134 + this.extra = 0; /* extra bits needed */
135 +
136 + /* fixed and dynamic code tables */
137 + this.lencode = null; /* starting table for length/literal codes */
138 + this.distcode = null; /* starting table for distance codes */
139 + this.lenbits = 0; /* index bits for lencode */
140 + this.distbits = 0; /* index bits for distcode */
141 +
142 + /* dynamic table building */
143 + this.ncode = 0; /* number of code length code lengths */
144 + this.nlen = 0; /* number of length code lengths */
145 + this.ndist = 0; /* number of distance code lengths */
146 + this.have = 0; /* number of code lengths in lens[] */
147 + this.next = null; /* next available space in codes[] */
148 +
149 + this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
150 + this.work = new utils.Buf16(288); /* work area for code table building */
151 +
152 + /*
153 + because we don't have pointers in js, we use lencode and distcode directly
154 + as buffers so we don't need codes
155 + */
156 + //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
157 + this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
158 + this.distdyn = null; /* dynamic table for distance codes (JS specific) */
159 + this.sane = 0; /* if false, allow invalid distance too far */
160 + this.back = 0; /* bits back of last unprocessed length/lit */
161 + this.was = 0; /* initial length of match */
162 +}
163 +function inflateResetKeep(strm) {
164 + var state;
165 + if (!strm || !strm.state) {
166 + return Z_STREAM_ERROR;
167 + }
168 + state = strm.state;
169 + strm.total_in = strm.total_out = state.total = 0;
170 + strm.msg = ''; /*Z_NULL*/
171 + if (state.wrap) {
172 + /* to support ill-conceived Java test suite */
173 + strm.adler = state.wrap & 1;
174 + }
175 + state.mode = HEAD;
176 + state.last = 0;
177 + state.havedict = 0;
178 + state.dmax = 32768;
179 + state.head = null /*Z_NULL*/;
180 + state.hold = 0;
181 + state.bits = 0;
182 + //state.lencode = state.distcode = state.next = state.codes;
183 + state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
184 + state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
185 + state.sane = 1;
186 + state.back = -1;
187 + //Tracev((stderr, "inflate: reset\n"));
188 + return Z_OK;
189 +}
190 +function inflateReset(strm) {
191 + var state;
192 + if (!strm || !strm.state) {
193 + return Z_STREAM_ERROR;
194 + }
195 + state = strm.state;
196 + state.wsize = 0;
197 + state.whave = 0;
198 + state.wnext = 0;
199 + return inflateResetKeep(strm);
200 +}
201 +function inflateReset2(strm, windowBits) {
202 + var wrap;
203 + var state;
204 +
205 + /* get the state */
206 + if (!strm || !strm.state) {
207 + return Z_STREAM_ERROR;
208 + }
209 + state = strm.state;
210 +
211 + /* extract wrap request from windowBits parameter */
212 + if (windowBits < 0) {
213 + wrap = 0;
214 + windowBits = -windowBits;
215 + } else {
216 + wrap = (windowBits >> 4) + 1;
217 + if (windowBits < 48) {
218 + windowBits &= 15;
219 + }
220 + }
221 +
222 + /* set number of window bits, free window if different */
223 + if (windowBits && (windowBits < 8 || windowBits > 15)) {
224 + return Z_STREAM_ERROR;
225 + }
226 + if (state.window !== null && state.wbits !== windowBits) {
227 + state.window = null;
228 + }
229 +
230 + /* update state and reset the rest of it */
231 + state.wrap = wrap;
232 + state.wbits = windowBits;
233 + return inflateReset(strm);
234 +}
235 +function inflateInit2(strm, windowBits) {
236 + var ret;
237 + var state;
238 + if (!strm) {
239 + return Z_STREAM_ERROR;
240 + }
241 + //strm.msg = Z_NULL; /* in case we return an error */
242 +
243 + state = new InflateState();
244 +
245 + //if (state === Z_NULL) return Z_MEM_ERROR;
246 + //Tracev((stderr, "inflate: allocated\n"));
247 + strm.state = state;
248 + state.window = null /*Z_NULL*/;
249 + ret = inflateReset2(strm, windowBits);
250 + if (ret !== Z_OK) {
251 + strm.state = null /*Z_NULL*/;
252 + }
253 + return ret;
254 +}
255 +function inflateInit(strm) {
256 + return inflateInit2(strm, DEF_WBITS);
257 +}
258 +
259 +/*
260 + Return state with length and distance decoding tables and index sizes set to
261 + fixed code decoding. Normally this returns fixed tables from inffixed.h.
262 + If BUILDFIXED is defined, then instead this routine builds the tables the
263 + first time it's called, and returns those tables the first time and
264 + thereafter. This reduces the size of the code by about 2K bytes, in
265 + exchange for a little execution time. However, BUILDFIXED should not be
266 + used for threaded applications, since the rewriting of the tables and virgin
267 + may not be thread-safe.
268 + */
269 +var virgin = true;
270 +var lenfix, distfix; // We have no pointers in JS, so keep tables separate
271 +
272 +function fixedtables(state) {
273 + /* build fixed huffman tables if first call (may not be thread safe) */
274 + if (virgin) {
275 + var sym;
276 + lenfix = new utils.Buf32(512);
277 + distfix = new utils.Buf32(32);
278 +
279 + /* literal/length table */
280 + sym = 0;
281 + while (sym < 144) {
282 + state.lens[sym++] = 8;
283 + }
284 + while (sym < 256) {
285 + state.lens[sym++] = 9;
286 + }
287 + while (sym < 280) {
288 + state.lens[sym++] = 7;
289 + }
290 + while (sym < 288) {
291 + state.lens[sym++] = 8;
292 + }
293 + (0, _inftrees["default"])(LENS, state.lens, 0, 288, lenfix, 0, state.work, {
294 + bits: 9
295 + });
296 +
297 + /* distance table */
298 + sym = 0;
299 + while (sym < 32) {
300 + state.lens[sym++] = 5;
301 + }
302 + (0, _inftrees["default"])(DISTS, state.lens, 0, 32, distfix, 0, state.work, {
303 + bits: 5
304 + });
305 +
306 + /* do this just once */
307 + virgin = false;
308 + }
309 + state.lencode = lenfix;
310 + state.lenbits = 9;
311 + state.distcode = distfix;
312 + state.distbits = 5;
313 +}
314 +
315 +/*
316 + Update the window with the last wsize (normally 32K) bytes written before
317 + returning. If window does not exist yet, create it. This is only called
318 + when a window is already in use, or when output has been written during this
319 + inflate call, but the end of the deflate stream has not been reached yet.
320 + It is also called to create a window for dictionary data when a dictionary
321 + is loaded.
322 +
323 + Providing output buffers larger than 32K to inflate() should provide a speed
324 + advantage, since only the last 32K of output is copied to the sliding window
325 + upon return from inflate(), and since all distances after the first 32K of
326 + output will fall in the output data, making match copies simpler and faster.
327 + The advantage may be dependent on the size of the processor's data caches.
328 + */
329 +function updatewindow(strm, src, end, copy) {
330 + var dist;
331 + var state = strm.state;
332 +
333 + /* if it hasn't been done already, allocate space for the window */
334 + if (state.window === null) {
335 + state.wsize = 1 << state.wbits;
336 + state.wnext = 0;
337 + state.whave = 0;
338 + state.window = new utils.Buf8(state.wsize);
339 + }
340 +
341 + /* copy state->wsize or less output bytes into the circular window */
342 + if (copy >= state.wsize) {
343 + utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
344 + state.wnext = 0;
345 + state.whave = state.wsize;
346 + } else {
347 + dist = state.wsize - state.wnext;
348 + if (dist > copy) {
349 + dist = copy;
350 + }
351 + //zmemcpy(state->window + state->wnext, end - copy, dist);
352 + utils.arraySet(state.window, src, end - copy, dist, state.wnext);
353 + copy -= dist;
354 + if (copy) {
355 + //zmemcpy(state->window, end - copy, copy);
356 + utils.arraySet(state.window, src, end - copy, copy, 0);
357 + state.wnext = copy;
358 + state.whave = state.wsize;
359 + } else {
360 + state.wnext += dist;
361 + if (state.wnext === state.wsize) {
362 + state.wnext = 0;
363 + }
364 + if (state.whave < state.wsize) {
365 + state.whave += dist;
366 + }
367 + }
368 + }
369 + return 0;
370 +}
371 +function inflate(strm, flush) {
372 + var state;
373 + var input, output; // input/output buffers
374 + var next; /* next input INDEX */
375 + var put; /* next output INDEX */
376 + var have, left; /* available input and output */
377 + var hold; /* bit buffer */
378 + var bits; /* bits in bit buffer */
379 + var _in, _out; /* save starting available input and output */
380 + var copy; /* number of stored or match bytes to copy */
381 + var from; /* where to copy match bytes from */
382 + var from_source;
383 + var here = 0; /* current decoding table entry */
384 + var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
385 + //var last; /* parent table entry */
386 + var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
387 + var len; /* length to copy for repeats, bits to drop */
388 + var ret; /* return code */
389 + var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
390 + var opts;
391 + var n; // temporary var for NEED_BITS
392 +
393 + var order = /* permutation of code lengths */
394 + [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
395 + if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
396 + return Z_STREAM_ERROR;
397 + }
398 + state = strm.state;
399 + if (state.mode === TYPE) {
400 + state.mode = TYPEDO;
401 + } /* skip check */
402 +
403 + //--- LOAD() ---
404 + put = strm.next_out;
405 + output = strm.output;
406 + left = strm.avail_out;
407 + next = strm.next_in;
408 + input = strm.input;
409 + have = strm.avail_in;
410 + hold = state.hold;
411 + bits = state.bits;
412 + //---
413 +
414 + _in = have;
415 + _out = left;
416 + ret = Z_OK;
417 + inf_leave:
418 + // goto emulation
419 + for (;;) {
420 + switch (state.mode) {
421 + case HEAD:
422 + if (state.wrap === 0) {
423 + state.mode = TYPEDO;
424 + break;
425 + }
426 + //=== NEEDBITS(16);
427 + while (bits < 16) {
428 + if (have === 0) {
429 + break inf_leave;
430 + }
431 + have--;
432 + hold += input[next++] << bits;
433 + bits += 8;
434 + }
435 + //===//
436 + if (state.wrap & 2 && hold === 0x8b1f) {
437 + /* gzip header */
438 + state.check = 0 /*crc32(0L, Z_NULL, 0)*/;
439 + //=== CRC2(state.check, hold);
440 + hbuf[0] = hold & 0xff;
441 + hbuf[1] = hold >>> 8 & 0xff;
442 + state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
443 + //===//
444 +
445 + //=== INITBITS();
446 + hold = 0;
447 + bits = 0;
448 + //===//
449 + state.mode = FLAGS;
450 + break;
451 + }
452 + state.flags = 0; /* expect zlib header */
453 + if (state.head) {
454 + state.head.done = false;
455 + }
456 + if (!(state.wrap & 1) || /* check if zlib header allowed */
457 + (((hold & 0xff /*BITS(8)*/) << 8) + (hold >> 8)) % 31) {
458 + strm.msg = 'incorrect header check';
459 + state.mode = BAD;
460 + break;
461 + }
462 + if ((hold & 0x0f /*BITS(4)*/) !== Z_DEFLATED) {
463 + strm.msg = 'unknown compression method';
464 + state.mode = BAD;
465 + break;
466 + }
467 + //--- DROPBITS(4) ---//
468 + hold >>>= 4;
469 + bits -= 4;
470 + //---//
471 + len = (hold & 0x0f /*BITS(4)*/) + 8;
472 + if (state.wbits === 0) {
473 + state.wbits = len;
474 + } else if (len > state.wbits) {
475 + strm.msg = 'invalid window size';
476 + state.mode = BAD;
477 + break;
478 + }
479 + state.dmax = 1 << len;
480 + //Tracev((stderr, "inflate: zlib header ok\n"));
481 + strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/;
482 + state.mode = hold & 0x200 ? DICTID : TYPE;
483 + //=== INITBITS();
484 + hold = 0;
485 + bits = 0;
486 + //===//
487 + break;
488 + case FLAGS:
489 + //=== NEEDBITS(16); */
490 + while (bits < 16) {
491 + if (have === 0) {
492 + break inf_leave;
493 + }
494 + have--;
495 + hold += input[next++] << bits;
496 + bits += 8;
497 + }
498 + //===//
499 + state.flags = hold;
500 + if ((state.flags & 0xff) !== Z_DEFLATED) {
501 + strm.msg = 'unknown compression method';
502 + state.mode = BAD;
503 + break;
504 + }
505 + if (state.flags & 0xe000) {
506 + strm.msg = 'unknown header flags set';
507 + state.mode = BAD;
508 + break;
509 + }
510 + if (state.head) {
511 + state.head.text = hold >> 8 & 1;
512 + }
513 + if (state.flags & 0x0200) {
514 + //=== CRC2(state.check, hold);
515 + hbuf[0] = hold & 0xff;
516 + hbuf[1] = hold >>> 8 & 0xff;
517 + state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
518 + //===//
519 + }
520 + //=== INITBITS();
521 + hold = 0;
522 + bits = 0;
523 + //===//
524 + state.mode = TIME;
525 + /* falls through */
526 + case TIME:
527 + //=== NEEDBITS(32); */
528 + while (bits < 32) {
529 + if (have === 0) {
530 + break inf_leave;
531 + }
532 + have--;
533 + hold += input[next++] << bits;
534 + bits += 8;
535 + }
536 + //===//
537 + if (state.head) {
538 + state.head.time = hold;
539 + }
540 + if (state.flags & 0x0200) {
541 + //=== CRC4(state.check, hold)
542 + hbuf[0] = hold & 0xff;
543 + hbuf[1] = hold >>> 8 & 0xff;
544 + hbuf[2] = hold >>> 16 & 0xff;
545 + hbuf[3] = hold >>> 24 & 0xff;
546 + state.check = (0, _crc["default"])(state.check, hbuf, 4, 0);
547 + //===
548 + }
549 + //=== INITBITS();
550 + hold = 0;
551 + bits = 0;
552 + //===//
553 + state.mode = OS;
554 + /* falls through */
555 + case OS:
556 + //=== NEEDBITS(16); */
557 + while (bits < 16) {
558 + if (have === 0) {
559 + break inf_leave;
560 + }
561 + have--;
562 + hold += input[next++] << bits;
563 + bits += 8;
564 + }
565 + //===//
566 + if (state.head) {
567 + state.head.xflags = hold & 0xff;
568 + state.head.os = hold >> 8;
569 + }
570 + if (state.flags & 0x0200) {
571 + //=== CRC2(state.check, hold);
572 + hbuf[0] = hold & 0xff;
573 + hbuf[1] = hold >>> 8 & 0xff;
574 + state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
575 + //===//
576 + }
577 + //=== INITBITS();
578 + hold = 0;
579 + bits = 0;
580 + //===//
581 + state.mode = EXLEN;
582 + /* falls through */
583 + case EXLEN:
584 + if (state.flags & 0x0400) {
585 + //=== NEEDBITS(16); */
586 + while (bits < 16) {
587 + if (have === 0) {
588 + break inf_leave;
589 + }
590 + have--;
591 + hold += input[next++] << bits;
592 + bits += 8;
593 + }
594 + //===//
595 + state.length = hold;
596 + if (state.head) {
597 + state.head.extra_len = hold;
598 + }
599 + if (state.flags & 0x0200) {
600 + //=== CRC2(state.check, hold);
601 + hbuf[0] = hold & 0xff;
602 + hbuf[1] = hold >>> 8 & 0xff;
603 + state.check = (0, _crc["default"])(state.check, hbuf, 2, 0);
604 + //===//
605 + }
606 + //=== INITBITS();
607 + hold = 0;
608 + bits = 0;
609 + //===//
610 + } else if (state.head) {
611 + state.head.extra = null /*Z_NULL*/;
612 + }
613 + state.mode = EXTRA;
614 + /* falls through */
615 + case EXTRA:
616 + if (state.flags & 0x0400) {
617 + copy = state.length;
618 + if (copy > have) {
619 + copy = have;
620 + }
621 + if (copy) {
622 + if (state.head) {
623 + len = state.head.extra_len - state.length;
624 + if (!state.head.extra) {
625 + // Use untyped array for more conveniend processing later
626 + state.head.extra = new Array(state.head.extra_len);
627 + }
628 + utils.arraySet(state.head.extra, input, next,
629 + // extra field is limited to 65536 bytes
630 + // - no need for additional size check
631 + copy, /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
632 + len);
633 + //zmemcpy(state.head.extra + len, next,
634 + // len + copy > state.head.extra_max ?
635 + // state.head.extra_max - len : copy);
636 + }
637 + if (state.flags & 0x0200) {
638 + state.check = (0, _crc["default"])(state.check, input, copy, next);
639 + }
640 + have -= copy;
641 + next += copy;
642 + state.length -= copy;
643 + }
644 + if (state.length) {
645 + break inf_leave;
646 + }
647 + }
648 + state.length = 0;
649 + state.mode = NAME;
650 + /* falls through */
651 + case NAME:
652 + if (state.flags & 0x0800) {
653 + if (have === 0) {
654 + break inf_leave;
655 + }
656 + copy = 0;
657 + do {
658 + // TODO: 2 or 1 bytes?
659 + len = input[next + copy++];
660 + /* use constant limit because in js we should not preallocate memory */
661 + if (state.head && len && state.length < 65536 /*state.head.name_max*/) {
662 + state.head.name += String.fromCharCode(len);
663 + }
664 + } while (len && copy < have);
665 + if (state.flags & 0x0200) {
666 + state.check = (0, _crc["default"])(state.check, input, copy, next);
667 + }
668 + have -= copy;
669 + next += copy;
670 + if (len) {
671 + break inf_leave;
672 + }
673 + } else if (state.head) {
674 + state.head.name = null;
675 + }
676 + state.length = 0;
677 + state.mode = COMMENT;
678 + /* falls through */
679 + case COMMENT:
680 + if (state.flags & 0x1000) {
681 + if (have === 0) {
682 + break inf_leave;
683 + }
684 + copy = 0;
685 + do {
686 + len = input[next + copy++];
687 + /* use constant limit because in js we should not preallocate memory */
688 + if (state.head && len && state.length < 65536 /*state.head.comm_max*/) {
689 + state.head.comment += String.fromCharCode(len);
690 + }
691 + } while (len && copy < have);
692 + if (state.flags & 0x0200) {
693 + state.check = (0, _crc["default"])(state.check, input, copy, next);
694 + }
695 + have -= copy;
696 + next += copy;
697 + if (len) {
698 + break inf_leave;
699 + }
700 + } else if (state.head) {
701 + state.head.comment = null;
702 + }
703 + state.mode = HCRC;
704 + /* falls through */
705 + case HCRC:
706 + if (state.flags & 0x0200) {
707 + //=== NEEDBITS(16); */
708 + while (bits < 16) {
709 + if (have === 0) {
710 + break inf_leave;
711 + }
712 + have--;
713 + hold += input[next++] << bits;
714 + bits += 8;
715 + }
716 + //===//
717 + if (hold !== (state.check & 0xffff)) {
718 + strm.msg = 'header crc mismatch';
719 + state.mode = BAD;
720 + break;
721 + }
722 + //=== INITBITS();
723 + hold = 0;
724 + bits = 0;
725 + //===//
726 + }
727 + if (state.head) {
728 + state.head.hcrc = state.flags >> 9 & 1;
729 + state.head.done = true;
730 + }
731 + strm.adler = state.check = 0;
732 + state.mode = TYPE;
733 + break;
734 + case DICTID:
735 + //=== NEEDBITS(32); */
736 + while (bits < 32) {
737 + if (have === 0) {
738 + break inf_leave;
739 + }
740 + have--;
741 + hold += input[next++] << bits;
742 + bits += 8;
743 + }
744 + //===//
745 + strm.adler = state.check = zswap32(hold);
746 + //=== INITBITS();
747 + hold = 0;
748 + bits = 0;
749 + //===//
750 + state.mode = DICT;
751 + /* falls through */
752 + case DICT:
753 + if (state.havedict === 0) {
754 + //--- RESTORE() ---
755 + strm.next_out = put;
756 + strm.avail_out = left;
757 + strm.next_in = next;
758 + strm.avail_in = have;
759 + state.hold = hold;
760 + state.bits = bits;
761 + //---
762 + return Z_NEED_DICT;
763 + }
764 + strm.adler = state.check = 1 /*adler32(0L, Z_NULL, 0)*/;
765 + state.mode = TYPE;
766 + /* falls through */
767 + case TYPE:
768 + if (flush === Z_BLOCK || flush === Z_TREES) {
769 + break inf_leave;
770 + }
771 + /* falls through */
772 + case TYPEDO:
773 + if (state.last) {
774 + //--- BYTEBITS() ---//
775 + hold >>>= bits & 7;
776 + bits -= bits & 7;
777 + //---//
778 + state.mode = CHECK;
779 + break;
780 + }
781 + //=== NEEDBITS(3); */
782 + while (bits < 3) {
783 + if (have === 0) {
784 + break inf_leave;
785 + }
786 + have--;
787 + hold += input[next++] << bits;
788 + bits += 8;
789 + }
790 + //===//
791 + state.last = hold & 0x01 /*BITS(1)*/;
792 + //--- DROPBITS(1) ---//
793 + hold >>>= 1;
794 + bits -= 1;
795 + //---//
796 +
797 + switch (hold & 0x03 /*BITS(2)*/) {
798 + case 0:
799 + /* stored block */
800 + //Tracev((stderr, "inflate: stored block%s\n",
801 + // state.last ? " (last)" : ""));
802 + state.mode = STORED;
803 + break;
804 + case 1:
805 + /* fixed block */
806 + fixedtables(state);
807 + //Tracev((stderr, "inflate: fixed codes block%s\n",
808 + // state.last ? " (last)" : ""));
809 + state.mode = LEN_; /* decode codes */
810 + if (flush === Z_TREES) {
811 + //--- DROPBITS(2) ---//
812 + hold >>>= 2;
813 + bits -= 2;
814 + //---//
815 + break inf_leave;
816 + }
817 + break;
818 + case 2:
819 + /* dynamic block */
820 + //Tracev((stderr, "inflate: dynamic codes block%s\n",
821 + // state.last ? " (last)" : ""));
822 + state.mode = TABLE;
823 + break;
824 + case 3:
825 + strm.msg = 'invalid block type';
826 + state.mode = BAD;
827 + }
828 + //--- DROPBITS(2) ---//
829 + hold >>>= 2;
830 + bits -= 2;
831 + //---//
832 + break;
833 + case STORED:
834 + //--- BYTEBITS() ---// /* go to byte boundary */
835 + hold >>>= bits & 7;
836 + bits -= bits & 7;
837 + //---//
838 + //=== NEEDBITS(32); */
839 + while (bits < 32) {
840 + if (have === 0) {
841 + break inf_leave;
842 + }
843 + have--;
844 + hold += input[next++] << bits;
845 + bits += 8;
846 + }
847 + //===//
848 + if ((hold & 0xffff) !== (hold >>> 16 ^ 0xffff)) {
849 + strm.msg = 'invalid stored block lengths';
850 + state.mode = BAD;
851 + break;
852 + }
853 + state.length = hold & 0xffff;
854 + //Tracev((stderr, "inflate: stored length %u\n",
855 + // state.length));
856 + //=== INITBITS();
857 + hold = 0;
858 + bits = 0;
859 + //===//
860 + state.mode = COPY_;
861 + if (flush === Z_TREES) {
862 + break inf_leave;
863 + }
864 + /* falls through */
865 + case COPY_:
866 + state.mode = COPY;
867 + /* falls through */
868 + case COPY:
869 + copy = state.length;
870 + if (copy) {
871 + if (copy > have) {
872 + copy = have;
873 + }
874 + if (copy > left) {
875 + copy = left;
876 + }
877 + if (copy === 0) {
878 + break inf_leave;
879 + }
880 + //--- zmemcpy(put, next, copy); ---
881 + utils.arraySet(output, input, next, copy, put);
882 + //---//
883 + have -= copy;
884 + next += copy;
885 + left -= copy;
886 + put += copy;
887 + state.length -= copy;
888 + break;
889 + }
890 + //Tracev((stderr, "inflate: stored end\n"));
891 + state.mode = TYPE;
892 + break;
893 + case TABLE:
894 + //=== NEEDBITS(14); */
895 + while (bits < 14) {
896 + if (have === 0) {
897 + break inf_leave;
898 + }
899 + have--;
900 + hold += input[next++] << bits;
901 + bits += 8;
902 + }
903 + //===//
904 + state.nlen = (hold & 0x1f /*BITS(5)*/) + 257;
905 + //--- DROPBITS(5) ---//
906 + hold >>>= 5;
907 + bits -= 5;
908 + //---//
909 + state.ndist = (hold & 0x1f /*BITS(5)*/) + 1;
910 + //--- DROPBITS(5) ---//
911 + hold >>>= 5;
912 + bits -= 5;
913 + //---//
914 + state.ncode = (hold & 0x0f /*BITS(4)*/) + 4;
915 + //--- DROPBITS(4) ---//
916 + hold >>>= 4;
917 + bits -= 4;
918 + //---//
919 + //#ifndef PKZIP_BUG_WORKAROUND
920 + if (state.nlen > 286 || state.ndist > 30) {
921 + strm.msg = 'too many length or distance symbols';
922 + state.mode = BAD;
923 + break;
924 + }
925 + //#endif
926 + //Tracev((stderr, "inflate: table sizes ok\n"));
927 + state.have = 0;
928 + state.mode = LENLENS;
929 + /* falls through */
930 + case LENLENS:
931 + while (state.have < state.ncode) {
932 + //=== NEEDBITS(3);
933 + while (bits < 3) {
934 + if (have === 0) {
935 + break inf_leave;
936 + }
937 + have--;
938 + hold += input[next++] << bits;
939 + bits += 8;
940 + }
941 + //===//
942 + state.lens[order[state.have++]] = hold & 0x07; //BITS(3);
943 + //--- DROPBITS(3) ---//
944 + hold >>>= 3;
945 + bits -= 3;
946 + //---//
947 + }
948 + while (state.have < 19) {
949 + state.lens[order[state.have++]] = 0;
950 + }
951 + // We have separate tables & no pointers. 2 commented lines below not needed.
952 + //state.next = state.codes;
953 + //state.lencode = state.next;
954 + // Switch to use dynamic table
955 + state.lencode = state.lendyn;
956 + state.lenbits = 7;
957 + opts = {
958 + bits: state.lenbits
959 + };
960 + ret = (0, _inftrees["default"])(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
961 + state.lenbits = opts.bits;
962 + if (ret) {
963 + strm.msg = 'invalid code lengths set';
964 + state.mode = BAD;
965 + break;
966 + }
967 + //Tracev((stderr, "inflate: code lengths ok\n"));
968 + state.have = 0;
969 + state.mode = CODELENS;
970 + /* falls through */
971 + case CODELENS:
972 + while (state.have < state.nlen + state.ndist) {
973 + for (;;) {
974 + here = state.lencode[hold & (1 << state.lenbits) - 1]; /*BITS(state.lenbits)*/
975 + here_bits = here >>> 24;
976 + here_op = here >>> 16 & 0xff;
977 + here_val = here & 0xffff;
978 + if (here_bits <= bits) {
979 + break;
980 + }
981 + //--- PULLBYTE() ---//
982 + if (have === 0) {
983 + break inf_leave;
984 + }
985 + have--;
986 + hold += input[next++] << bits;
987 + bits += 8;
988 + //---//
989 + }
990 + if (here_val < 16) {
991 + //--- DROPBITS(here.bits) ---//
992 + hold >>>= here_bits;
993 + bits -= here_bits;
994 + //---//
995 + state.lens[state.have++] = here_val;
996 + } else {
997 + if (here_val === 16) {
998 + //=== NEEDBITS(here.bits + 2);
999 + n = here_bits + 2;
1000 + while (bits < n) {
1001 + if (have === 0) {
1002 + break inf_leave;
1003 + }
1004 + have--;
1005 + hold += input[next++] << bits;
1006 + bits += 8;
1007 + }
1008 + //===//
1009 + //--- DROPBITS(here.bits) ---//
1010 + hold >>>= here_bits;
1011 + bits -= here_bits;
1012 + //---//
1013 + if (state.have === 0) {
1014 + strm.msg = 'invalid bit length repeat';
1015 + state.mode = BAD;
1016 + break;
1017 + }
1018 + len = state.lens[state.have - 1];
1019 + copy = 3 + (hold & 0x03); //BITS(2);
1020 + //--- DROPBITS(2) ---//
1021 + hold >>>= 2;
1022 + bits -= 2;
1023 + //---//
1024 + } else if (here_val === 17) {
1025 + //=== NEEDBITS(here.bits + 3);
1026 + n = here_bits + 3;
1027 + while (bits < n) {
1028 + if (have === 0) {
1029 + break inf_leave;
1030 + }
1031 + have--;
1032 + hold += input[next++] << bits;
1033 + bits += 8;
1034 + }
1035 + //===//
1036 + //--- DROPBITS(here.bits) ---//
1037 + hold >>>= here_bits;
1038 + bits -= here_bits;
1039 + //---//
1040 + len = 0;
1041 + copy = 3 + (hold & 0x07); //BITS(3);
1042 + //--- DROPBITS(3) ---//
1043 + hold >>>= 3;
1044 + bits -= 3;
1045 + //---//
1046 + } else {
1047 + //=== NEEDBITS(here.bits + 7);
1048 + n = here_bits + 7;
1049 + while (bits < n) {
1050 + if (have === 0) {
1051 + break inf_leave;
1052 + }
1053 + have--;
1054 + hold += input[next++] << bits;
1055 + bits += 8;
1056 + }
1057 + //===//
1058 + //--- DROPBITS(here.bits) ---//
1059 + hold >>>= here_bits;
1060 + bits -= here_bits;
1061 + //---//
1062 + len = 0;
1063 + copy = 11 + (hold & 0x7f); //BITS(7);
1064 + //--- DROPBITS(7) ---//
1065 + hold >>>= 7;
1066 + bits -= 7;
1067 + //---//
1068 + }
1069 + if (state.have + copy > state.nlen + state.ndist) {
1070 + strm.msg = 'invalid bit length repeat';
1071 + state.mode = BAD;
1072 + break;
1073 + }
1074 + while (copy--) {
1075 + state.lens[state.have++] = len;
1076 + }
1077 + }
1078 + }
1079 +
1080 + /* handle error breaks in while */
1081 + if (state.mode === BAD) {
1082 + break;
1083 + }
1084 +
1085 + /* check for end-of-block code (better have one) */
1086 + if (state.lens[256] === 0) {
1087 + strm.msg = 'invalid code -- missing end-of-block';
1088 + state.mode = BAD;
1089 + break;
1090 + }
1091 +
1092 + /* build code tables -- note: do not change the lenbits or distbits
1093 + values here (9 and 6) without reading the comments in inftrees.h
1094 + concerning the ENOUGH constants, which depend on those values */
1095 + state.lenbits = 9;
1096 + opts = {
1097 + bits: state.lenbits
1098 + };
1099 + ret = (0, _inftrees["default"])(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
1100 + // We have separate tables & no pointers. 2 commented lines below not needed.
1101 + // state.next_index = opts.table_index;
1102 + state.lenbits = opts.bits;
1103 + // state.lencode = state.next;
1104 +
1105 + if (ret) {
1106 + strm.msg = 'invalid literal/lengths set';
1107 + state.mode = BAD;
1108 + break;
1109 + }
1110 + state.distbits = 6;
1111 + //state.distcode.copy(state.codes);
1112 + // Switch to use dynamic table
1113 + state.distcode = state.distdyn;
1114 + opts = {
1115 + bits: state.distbits
1116 + };
1117 + ret = (0, _inftrees["default"])(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
1118 + // We have separate tables & no pointers. 2 commented lines below not needed.
1119 + // state.next_index = opts.table_index;
1120 + state.distbits = opts.bits;
1121 + // state.distcode = state.next;
1122 +
1123 + if (ret) {
1124 + strm.msg = 'invalid distances set';
1125 + state.mode = BAD;
1126 + break;
1127 + }
1128 + //Tracev((stderr, 'inflate: codes ok\n'));
1129 + state.mode = LEN_;
1130 + if (flush === Z_TREES) {
1131 + break inf_leave;
1132 + }
1133 + /* falls through */
1134 + case LEN_:
1135 + state.mode = LEN;
1136 + /* falls through */
1137 + case LEN:
1138 + if (have >= 6 && left >= 258) {
1139 + //--- RESTORE() ---
1140 + strm.next_out = put;
1141 + strm.avail_out = left;
1142 + strm.next_in = next;
1143 + strm.avail_in = have;
1144 + state.hold = hold;
1145 + state.bits = bits;
1146 + //---
1147 + (0, _inffast["default"])(strm, _out);
1148 + //--- LOAD() ---
1149 + put = strm.next_out;
1150 + output = strm.output;
1151 + left = strm.avail_out;
1152 + next = strm.next_in;
1153 + input = strm.input;
1154 + have = strm.avail_in;
1155 + hold = state.hold;
1156 + bits = state.bits;
1157 + //---
1158 +
1159 + if (state.mode === TYPE) {
1160 + state.back = -1;
1161 + }
1162 + break;
1163 + }
1164 + state.back = 0;
1165 + for (;;) {
1166 + here = state.lencode[hold & (1 << state.lenbits) - 1]; /*BITS(state.lenbits)*/
1167 + here_bits = here >>> 24;
1168 + here_op = here >>> 16 & 0xff;
1169 + here_val = here & 0xffff;
1170 + if (here_bits <= bits) {
1171 + break;
1172 + }
1173 + //--- PULLBYTE() ---//
1174 + if (have === 0) {
1175 + break inf_leave;
1176 + }
1177 + have--;
1178 + hold += input[next++] << bits;
1179 + bits += 8;
1180 + //---//
1181 + }
1182 + if (here_op && (here_op & 0xf0) === 0) {
1183 + last_bits = here_bits;
1184 + last_op = here_op;
1185 + last_val = here_val;
1186 + for (;;) {
1187 + here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1 /*BITS(last.bits + last.op)*/) >> last_bits)];
1188 + here_bits = here >>> 24;
1189 + here_op = here >>> 16 & 0xff;
1190 + here_val = here & 0xffff;
1191 + if (last_bits + here_bits <= bits) {
1192 + break;
1193 + }
1194 + //--- PULLBYTE() ---//
1195 + if (have === 0) {
1196 + break inf_leave;
1197 + }
1198 + have--;
1199 + hold += input[next++] << bits;
1200 + bits += 8;
1201 + //---//
1202 + }
1203 + //--- DROPBITS(last.bits) ---//
1204 + hold >>>= last_bits;
1205 + bits -= last_bits;
1206 + //---//
1207 + state.back += last_bits;
1208 + }
1209 + //--- DROPBITS(here.bits) ---//
1210 + hold >>>= here_bits;
1211 + bits -= here_bits;
1212 + //---//
1213 + state.back += here_bits;
1214 + state.length = here_val;
1215 + if (here_op === 0) {
1216 + //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
1217 + // "inflate: literal '%c'\n" :
1218 + // "inflate: literal 0x%02x\n", here.val));
1219 + state.mode = LIT;
1220 + break;
1221 + }
1222 + if (here_op & 32) {
1223 + //Tracevv((stderr, "inflate: end of block\n"));
1224 + state.back = -1;
1225 + state.mode = TYPE;
1226 + break;
1227 + }
1228 + if (here_op & 64) {
1229 + strm.msg = 'invalid literal/length code';
1230 + state.mode = BAD;
1231 + break;
1232 + }
1233 + state.extra = here_op & 15;
1234 + state.mode = LENEXT;
1235 + /* falls through */
1236 + case LENEXT:
1237 + if (state.extra) {
1238 + //=== NEEDBITS(state.extra);
1239 + n = state.extra;
1240 + while (bits < n) {
1241 + if (have === 0) {
1242 + break inf_leave;
1243 + }
1244 + have--;
1245 + hold += input[next++] << bits;
1246 + bits += 8;
1247 + }
1248 + //===//
1249 + state.length += hold & (1 << state.extra) - 1 /*BITS(state.extra)*/;
1250 + //--- DROPBITS(state.extra) ---//
1251 + hold >>>= state.extra;
1252 + bits -= state.extra;
1253 + //---//
1254 + state.back += state.extra;
1255 + }
1256 + //Tracevv((stderr, "inflate: length %u\n", state.length));
1257 + state.was = state.length;
1258 + state.mode = DIST;
1259 + /* falls through */
1260 + case DIST:
1261 + for (;;) {
1262 + here = state.distcode[hold & (1 << state.distbits) - 1]; /*BITS(state.distbits)*/
1263 + here_bits = here >>> 24;
1264 + here_op = here >>> 16 & 0xff;
1265 + here_val = here & 0xffff;
1266 + if (here_bits <= bits) {
1267 + break;
1268 + }
1269 + //--- PULLBYTE() ---//
1270 + if (have === 0) {
1271 + break inf_leave;
1272 + }
1273 + have--;
1274 + hold += input[next++] << bits;
1275 + bits += 8;
1276 + //---//
1277 + }
1278 + if ((here_op & 0xf0) === 0) {
1279 + last_bits = here_bits;
1280 + last_op = here_op;
1281 + last_val = here_val;
1282 + for (;;) {
1283 + here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1 /*BITS(last.bits + last.op)*/) >> last_bits)];
1284 + here_bits = here >>> 24;
1285 + here_op = here >>> 16 & 0xff;
1286 + here_val = here & 0xffff;
1287 + if (last_bits + here_bits <= bits) {
1288 + break;
1289 + }
1290 + //--- PULLBYTE() ---//
1291 + if (have === 0) {
1292 + break inf_leave;
1293 + }
1294 + have--;
1295 + hold += input[next++] << bits;
1296 + bits += 8;
1297 + //---//
1298 + }
1299 + //--- DROPBITS(last.bits) ---//
1300 + hold >>>= last_bits;
1301 + bits -= last_bits;
1302 + //---//
1303 + state.back += last_bits;
1304 + }
1305 + //--- DROPBITS(here.bits) ---//
1306 + hold >>>= here_bits;
1307 + bits -= here_bits;
1308 + //---//
1309 + state.back += here_bits;
1310 + if (here_op & 64) {
1311 + strm.msg = 'invalid distance code';
1312 + state.mode = BAD;
1313 + break;
1314 + }
1315 + state.offset = here_val;
1316 + state.extra = here_op & 15;
1317 + state.mode = DISTEXT;
1318 + /* falls through */
1319 + case DISTEXT:
1320 + if (state.extra) {
1321 + //=== NEEDBITS(state.extra);
1322 + n = state.extra;
1323 + while (bits < n) {
1324 + if (have === 0) {
1325 + break inf_leave;
1326 + }
1327 + have--;
1328 + hold += input[next++] << bits;
1329 + bits += 8;
1330 + }
1331 + //===//
1332 + state.offset += hold & (1 << state.extra) - 1 /*BITS(state.extra)*/;
1333 + //--- DROPBITS(state.extra) ---//
1334 + hold >>>= state.extra;
1335 + bits -= state.extra;
1336 + //---//
1337 + state.back += state.extra;
1338 + }
1339 + //#ifdef INFLATE_STRICT
1340 + if (state.offset > state.dmax) {
1341 + strm.msg = 'invalid distance too far back';
1342 + state.mode = BAD;
1343 + break;
1344 + }
1345 + //#endif
1346 + //Tracevv((stderr, "inflate: distance %u\n", state.offset));
1347 + state.mode = MATCH;
1348 + /* falls through */
1349 + case MATCH:
1350 + if (left === 0) {
1351 + break inf_leave;
1352 + }
1353 + copy = _out - left;
1354 + if (state.offset > copy) {
1355 + /* copy from window */
1356 + copy = state.offset - copy;
1357 + if (copy > state.whave) {
1358 + if (state.sane) {
1359 + strm.msg = 'invalid distance too far back';
1360 + state.mode = BAD;
1361 + break;
1362 + }
1363 + // (!) This block is disabled in zlib defailts,
1364 + // don't enable it for binary compatibility
1365 + //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1366 + // Trace((stderr, "inflate.c too far\n"));
1367 + // copy -= state.whave;
1368 + // if (copy > state.length) { copy = state.length; }
1369 + // if (copy > left) { copy = left; }
1370 + // left -= copy;
1371 + // state.length -= copy;
1372 + // do {
1373 + // output[put++] = 0;
1374 + // } while (--copy);
1375 + // if (state.length === 0) { state.mode = LEN; }
1376 + // break;
1377 + //#endif
1378 + }
1379 + if (copy > state.wnext) {
1380 + copy -= state.wnext;
1381 + from = state.wsize - copy;
1382 + } else {
1383 + from = state.wnext - copy;
1384 + }
1385 + if (copy > state.length) {
1386 + copy = state.length;
1387 + }
1388 + from_source = state.window;
1389 + } else {
1390 + /* copy from output */
1391 + from_source = output;
1392 + from = put - state.offset;
1393 + copy = state.length;
1394 + }
1395 + if (copy > left) {
1396 + copy = left;
1397 + }
1398 + left -= copy;
1399 + state.length -= copy;
1400 + do {
1401 + output[put++] = from_source[from++];
1402 + } while (--copy);
1403 + if (state.length === 0) {
1404 + state.mode = LEN;
1405 + }
1406 + break;
1407 + case LIT:
1408 + if (left === 0) {
1409 + break inf_leave;
1410 + }
1411 + output[put++] = state.length;
1412 + left--;
1413 + state.mode = LEN;
1414 + break;
1415 + case CHECK:
1416 + if (state.wrap) {
1417 + //=== NEEDBITS(32);
1418 + while (bits < 32) {
1419 + if (have === 0) {
1420 + break inf_leave;
1421 + }
1422 + have--;
1423 + // Use '|' insdead of '+' to make sure that result is signed
1424 + hold |= input[next++] << bits;
1425 + bits += 8;
1426 + }
1427 + //===//
1428 + _out -= left;
1429 + strm.total_out += _out;
1430 + state.total += _out;
1431 + if (_out) {
1432 + strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
1433 + state.flags ? (0, _crc["default"])(state.check, output, _out, put - _out) : (0, _adler["default"])(state.check, output, _out, put - _out);
1434 + }
1435 + _out = left;
1436 + // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
1437 + if ((state.flags ? hold : zswap32(hold)) !== state.check) {
1438 + strm.msg = 'incorrect data check';
1439 + state.mode = BAD;
1440 + break;
1441 + }
1442 + //=== INITBITS();
1443 + hold = 0;
1444 + bits = 0;
1445 + //===//
1446 + //Tracev((stderr, "inflate: check matches trailer\n"));
1447 + }
1448 + state.mode = LENGTH;
1449 + /* falls through */
1450 + case LENGTH:
1451 + if (state.wrap && state.flags) {
1452 + //=== NEEDBITS(32);
1453 + while (bits < 32) {
1454 + if (have === 0) {
1455 + break inf_leave;
1456 + }
1457 + have--;
1458 + hold += input[next++] << bits;
1459 + bits += 8;
1460 + }
1461 + //===//
1462 + if (hold !== (state.total & 0xffffffff)) {
1463 + strm.msg = 'incorrect length check';
1464 + state.mode = BAD;
1465 + break;
1466 + }
1467 + //=== INITBITS();
1468 + hold = 0;
1469 + bits = 0;
1470 + //===//
1471 + //Tracev((stderr, "inflate: length matches trailer\n"));
1472 + }
1473 + state.mode = DONE;
1474 + /* falls through */
1475 + case DONE:
1476 + ret = Z_STREAM_END;
1477 + break inf_leave;
1478 + case BAD:
1479 + ret = Z_DATA_ERROR;
1480 + break inf_leave;
1481 + case MEM:
1482 + return Z_MEM_ERROR;
1483 + case SYNC:
1484 + /* falls through */
1485 + default:
1486 + return Z_STREAM_ERROR;
1487 + }
1488 + }
1489 +
1490 + // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
1491 +
1492 + /*
1493 + Return from inflate(), updating the total counts and the check value.
1494 + If there was no progress during the inflate() call, return a buffer
1495 + error. Call updatewindow() to create and/or update the window state.
1496 + Note: a memory error from inflate() is non-recoverable.
1497 + */
1498 +
1499 + //--- RESTORE() ---
1500 + strm.next_out = put;
1501 + strm.avail_out = left;
1502 + strm.next_in = next;
1503 + strm.avail_in = have;
1504 + state.hold = hold;
1505 + state.bits = bits;
1506 + //---
1507 +
1508 + if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
1509 + if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
1510 + state.mode = MEM;
1511 + return Z_MEM_ERROR;
1512 + }
1513 + }
1514 + _in -= strm.avail_in;
1515 + _out -= strm.avail_out;
1516 + strm.total_in += _in;
1517 + strm.total_out += _out;
1518 + state.total += _out;
1519 + if (state.wrap && _out) {
1520 + strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
1521 + state.flags ? (0, _crc["default"])(state.check, output, _out, strm.next_out - _out) : (0, _adler["default"])(state.check, output, _out, strm.next_out - _out);
1522 + }
1523 + strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
1524 + if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
1525 + ret = Z_BUF_ERROR;
1526 + }
1527 + return ret;
1528 +}
1529 +function inflateEnd(strm) {
1530 + if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
1531 + return Z_STREAM_ERROR;
1532 + }
1533 + var state = strm.state;
1534 + if (state.window) {
1535 + state.window = null;
1536 + }
1537 + strm.state = null;
1538 + return Z_OK;
1539 +}
1540 +function inflateGetHeader(strm, head) {
1541 + var state;
1542 +
1543 + /* check state */
1544 + if (!strm || !strm.state) {
1545 + return Z_STREAM_ERROR;
1546 + }
1547 + state = strm.state;
1548 + if ((state.wrap & 2) === 0) {
1549 + return Z_STREAM_ERROR;
1550 + }
1551 +
1552 + /* save header structure */
1553 + state.head = head;
1554 + head.done = false;
1555 + return Z_OK;
1556 +}
1557 +function inflateSetDictionary(strm, dictionary) {
1558 + var dictLength = dictionary.length;
1559 + var state;
1560 + var dictid;
1561 + var ret;
1562 +
1563 + /* check state */
1564 + if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) {
1565 + return Z_STREAM_ERROR;
1566 + }
1567 + state = strm.state;
1568 + if (state.wrap !== 0 && state.mode !== DICT) {
1569 + return Z_STREAM_ERROR;
1570 + }
1571 +
1572 + /* check for correct dictionary identifier */
1573 + if (state.mode === DICT) {
1574 + dictid = 1; /* adler32(0, null, 0)*/
1575 + /* dictid = adler32(dictid, dictionary, dictLength); */
1576 + dictid = (0, _adler["default"])(dictid, dictionary, dictLength, 0);
1577 + if (dictid !== state.check) {
1578 + return Z_DATA_ERROR;
1579 + }
1580 + }
1581 + /* copy dictionary to window using updatewindow(), which will amend the
1582 + existing dictionary if appropriate */
1583 + ret = updatewindow(strm, dictionary, dictLength, dictLength);
1584 + if (ret) {
1585 + state.mode = MEM;
1586 + return Z_MEM_ERROR;
1587 + }
1588 + state.havedict = 1;
1589 + // Tracev((stderr, "inflate: dictionary set\n"));
1590 + return Z_OK;
1591 +}
1592 +var inflateInfo = exports.inflateInfo = 'pako inflate (from Nodeca project)';
1593 +
1594 +/* Not implemented
1595 +exports.inflateCopy = inflateCopy;
1596 +exports.inflateGetDictionary = inflateGetDictionary;
1597 +exports.inflateMark = inflateMark;
1598 +exports.inflatePrime = inflatePrime;
1599 +exports.inflateSync = inflateSync;
1600 +exports.inflateSyncPoint = inflateSyncPoint;
1601 +exports.inflateUndermine = inflateUndermine;
1602 +*/
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/inftrees.js +310 −0
@@ -0,0 +1,310 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports["default"] = inflate_table;
8 +var utils = _interopRequireWildcard(require("../utils/common.js"));
9 +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); }
10 +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; }
11 +var MAXBITS = 15;
12 +var ENOUGH_LENS = 852;
13 +var ENOUGH_DISTS = 592;
14 +//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
15 +
16 +var CODES = 0;
17 +var LENS = 1;
18 +var DISTS = 2;
19 +var lbase = [/* Length codes 257..285 base */
20 +3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0];
21 +var lext = [/* Length codes 257..285 extra */
22 +16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78];
23 +var dbase = [/* Distance codes 0..29 base */
24 +1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0];
25 +var dext = [/* Distance codes 0..29 extra */
26 +16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64];
27 +function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
28 + var bits = opts.bits;
29 + //here = opts.here; /* table entry for duplication */
30 +
31 + var len = 0; /* a code's length in bits */
32 + var sym = 0; /* index of code symbols */
33 + var min = 0,
34 + max = 0; /* minimum and maximum code lengths */
35 + var root = 0; /* number of index bits for root table */
36 + var curr = 0; /* number of index bits for current table */
37 + var drop = 0; /* code bits to drop for sub-table */
38 + var left = 0; /* number of prefix codes available */
39 + var used = 0; /* code entries in table used */
40 + var huff = 0; /* Huffman code */
41 + var incr; /* for incrementing code, index */
42 + var fill; /* index for replicating entries */
43 + var low; /* low bits for current root entry */
44 + var mask; /* mask for low root bits */
45 + var next; /* next available space in table */
46 + var base = null; /* base value table to use */
47 + var base_index = 0;
48 + // var shoextra; /* extra bits table to use */
49 + var end; /* use base and extra for symbol > end */
50 + var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
51 + var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
52 + var extra = null;
53 + var extra_index = 0;
54 + var here_bits, here_op, here_val;
55 +
56 + /*
57 + Process a set of code lengths to create a canonical Huffman code. The
58 + code lengths are lens[0..codes-1]. Each length corresponds to the
59 + symbols 0..codes-1. The Huffman code is generated by first sorting the
60 + symbols by length from short to long, and retaining the symbol order
61 + for codes with equal lengths. Then the code starts with all zero bits
62 + for the first code of the shortest length, and the codes are integer
63 + increments for the same length, and zeros are appended as the length
64 + increases. For the deflate format, these bits are stored backwards
65 + from their more natural integer increment ordering, and so when the
66 + decoding tables are built in the large loop below, the integer codes
67 + are incremented backwards.
68 + This routine assumes, but does not check, that all of the entries in
69 + lens[] are in the range 0..MAXBITS. The caller must assure this.
70 + 1..MAXBITS is interpreted as that code length. zero means that that
71 + symbol does not occur in this code.
72 + The codes are sorted by computing a count of codes for each length,
73 + creating from that a table of starting indices for each length in the
74 + sorted table, and then entering the symbols in order in the sorted
75 + table. The sorted table is work[], with that space being provided by
76 + the caller.
77 + The length counts are used for other purposes as well, i.e. finding
78 + the minimum and maximum length codes, determining if there are any
79 + codes at all, checking for a valid set of lengths, and looking ahead
80 + at length counts to determine sub-table sizes when building the
81 + decoding tables.
82 + */
83 +
84 + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
85 + for (len = 0; len <= MAXBITS; len++) {
86 + count[len] = 0;
87 + }
88 + for (sym = 0; sym < codes; sym++) {
89 + count[lens[lens_index + sym]]++;
90 + }
91 +
92 + /* bound code lengths, force root to be within code lengths */
93 + root = bits;
94 + for (max = MAXBITS; max >= 1; max--) {
95 + if (count[max] !== 0) {
96 + break;
97 + }
98 + }
99 + if (root > max) {
100 + root = max;
101 + }
102 + if (max === 0) {
103 + /* no symbols to code at all */
104 + //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
105 + //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
106 + //table.val[opts.table_index++] = 0; //here.val = (var short)0;
107 + table[table_index++] = 1 << 24 | 64 << 16 | 0;
108 +
109 + //table.op[opts.table_index] = 64;
110 + //table.bits[opts.table_index] = 1;
111 + //table.val[opts.table_index++] = 0;
112 + table[table_index++] = 1 << 24 | 64 << 16 | 0;
113 + opts.bits = 1;
114 + return 0; /* no symbols, but wait for decoding to report error */
115 + }
116 + for (min = 1; min < max; min++) {
117 + if (count[min] !== 0) {
118 + break;
119 + }
120 + }
121 + if (root < min) {
122 + root = min;
123 + }
124 +
125 + /* check for an over-subscribed or incomplete set of lengths */
126 + left = 1;
127 + for (len = 1; len <= MAXBITS; len++) {
128 + left <<= 1;
129 + left -= count[len];
130 + if (left < 0) {
131 + return -1;
132 + } /* over-subscribed */
133 + }
134 + if (left > 0 && (type === CODES || max !== 1)) {
135 + return -1; /* incomplete set */
136 + }
137 +
138 + /* generate offsets into symbol table for each length for sorting */
139 + offs[1] = 0;
140 + for (len = 1; len < MAXBITS; len++) {
141 + offs[len + 1] = offs[len] + count[len];
142 + }
143 +
144 + /* sort symbols by length, by symbol order within each length */
145 + for (sym = 0; sym < codes; sym++) {
146 + if (lens[lens_index + sym] !== 0) {
147 + work[offs[lens[lens_index + sym]]++] = sym;
148 + }
149 + }
150 +
151 + /*
152 + Create and fill in decoding tables. In this loop, the table being
153 + filled is at next and has curr index bits. The code being used is huff
154 + with length len. That code is converted to an index by dropping drop
155 + bits off of the bottom. For codes where len is less than drop + curr,
156 + those top drop + curr - len bits are incremented through all values to
157 + fill the table with replicated entries.
158 + root is the number of index bits for the root table. When len exceeds
159 + root, sub-tables are created pointed to by the root entry with an index
160 + of the low root bits of huff. This is saved in low to check for when a
161 + new sub-table should be started. drop is zero when the root table is
162 + being filled, and drop is root when sub-tables are being filled.
163 + When a new sub-table is needed, it is necessary to look ahead in the
164 + code lengths to determine what size sub-table is needed. The length
165 + counts are used for this, and so count[] is decremented as codes are
166 + entered in the tables.
167 + used keeps track of how many table entries have been allocated from the
168 + provided *table space. It is checked for LENS and DIST tables against
169 + the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
170 + the initial root table size constants. See the comments in inftrees.h
171 + for more information.
172 + sym increments through all symbols, and the loop terminates when
173 + all codes of length max, i.e. all codes, have been processed. This
174 + routine permits incomplete codes, so another loop after this one fills
175 + in the rest of the decoding tables with invalid code markers.
176 + */
177 +
178 + /* set up for code type */
179 + // poor man optimization - use if-else instead of switch,
180 + // to avoid deopts in old v8
181 + if (type === CODES) {
182 + base = extra = work; /* dummy value--not used */
183 + end = 19;
184 + } else if (type === LENS) {
185 + base = lbase;
186 + base_index -= 257;
187 + extra = lext;
188 + extra_index -= 257;
189 + end = 256;
190 + } else {
191 + /* DISTS */
192 + base = dbase;
193 + extra = dext;
194 + end = -1;
195 + }
196 +
197 + /* initialize opts for loop */
198 + huff = 0; /* starting code */
199 + sym = 0; /* starting code symbol */
200 + len = min; /* starting code length */
201 + next = table_index; /* current table to fill in */
202 + curr = root; /* current table index bits */
203 + drop = 0; /* current bits to drop from code for index */
204 + low = -1; /* trigger new sub-table when len > root */
205 + used = 1 << root; /* use root table entries */
206 + mask = used - 1; /* mask for comparing low */
207 +
208 + /* check available table space */
209 + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
210 + return 1;
211 + }
212 +
213 + /* process all codes and make table entries */
214 + for (;;) {
215 + /* create table entry */
216 + here_bits = len - drop;
217 + if (work[sym] < end) {
218 + here_op = 0;
219 + here_val = work[sym];
220 + } else if (work[sym] > end) {
221 + here_op = extra[extra_index + work[sym]];
222 + here_val = base[base_index + work[sym]];
223 + } else {
224 + here_op = 32 + 64; /* end of block */
225 + here_val = 0;
226 + }
227 +
228 + /* replicate for those indices with low len bits equal to huff */
229 + incr = 1 << len - drop;
230 + fill = 1 << curr;
231 + min = fill; /* save offset to next table */
232 + do {
233 + fill -= incr;
234 + table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
235 + } while (fill !== 0);
236 +
237 + /* backwards increment the len-bit code huff */
238 + incr = 1 << len - 1;
239 + while (huff & incr) {
240 + incr >>= 1;
241 + }
242 + if (incr !== 0) {
243 + huff &= incr - 1;
244 + huff += incr;
245 + } else {
246 + huff = 0;
247 + }
248 +
249 + /* go to next symbol, update count, len */
250 + sym++;
251 + if (--count[len] === 0) {
252 + if (len === max) {
253 + break;
254 + }
255 + len = lens[lens_index + work[sym]];
256 + }
257 +
258 + /* create new sub-table if needed */
259 + if (len > root && (huff & mask) !== low) {
260 + /* if first time, transition to sub-tables */
261 + if (drop === 0) {
262 + drop = root;
263 + }
264 +
265 + /* increment past last table */
266 + next += min; /* here min is 1 << curr */
267 +
268 + /* determine length of next table */
269 + curr = len - drop;
270 + left = 1 << curr;
271 + while (curr + drop < max) {
272 + left -= count[curr + drop];
273 + if (left <= 0) {
274 + break;
275 + }
276 + curr++;
277 + left <<= 1;
278 + }
279 +
280 + /* check for enough space */
281 + used += 1 << curr;
282 + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
283 + return 1;
284 + }
285 +
286 + /* point entry in root table to sub-table */
287 + low = huff & mask;
288 + /*table.op[low] = curr;
289 + table.bits[low] = root;
290 + table.val[low] = next - opts.table_index;*/
291 + table[low] = root << 24 | curr << 16 | next - table_index | 0;
292 + }
293 + }
294 +
295 + /* fill in remaining table entry if code is incomplete (guaranteed to have
296 + at most one remaining entry, since if the code is incomplete, the
297 + maximum code length that was allowed to get this far is one bit) */
298 + if (huff !== 0) {
299 + //table.op[next + huff] = 64; /* invalid code marker */
300 + //table.bits[next + huff] = len - drop;
301 + //table.val[next + huff] = 0;
302 + table[next + huff] = len - drop << 24 | 64 << 16 | 0;
303 + }
304 +
305 + /* set return parameters */
306 + //opts.table_index += used;
307 + opts.bits = root;
308 + return 0;
309 +}
310 +;
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/messages.js +25 −0
@@ -0,0 +1,25 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = void 0;
7 +var _default = exports["default"] = {
8 + 2: 'need dictionary',
9 + /* Z_NEED_DICT 2 */
10 + 1: 'stream end',
11 + /* Z_STREAM_END 1 */
12 + 0: '',
13 + /* Z_OK 0 */
14 + '-1': 'file error',
15 + /* Z_ERRNO (-1) */
16 + '-2': 'stream error',
17 + /* Z_STREAM_ERROR (-2) */
18 + '-3': 'data error',
19 + /* Z_DATA_ERROR (-3) */
20 + '-4': 'insufficient memory',
21 + /* Z_MEM_ERROR (-4) */
22 + '-5': 'buffer error',
23 + /* Z_BUF_ERROR (-5) */
24 + '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
25 +};
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/trees.js +1150 −0
@@ -0,0 +1,1150 @@
1 +"use strict";
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 +Object.defineProperty(exports, "__esModule", {
5 + value: true
6 +});
7 +exports._tr_align = _tr_align;
8 +exports._tr_flush_block = _tr_flush_block;
9 +exports._tr_init = _tr_init;
10 +exports._tr_stored_block = _tr_stored_block;
11 +exports._tr_tally = _tr_tally;
12 +var utils = _interopRequireWildcard(require("../utils/common.js"));
13 +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); }
14 +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; }
15 +/* Public constants ==========================================================*/
16 +/* ===========================================================================*/
17 +
18 +//var Z_FILTERED = 1;
19 +//var Z_HUFFMAN_ONLY = 2;
20 +//var Z_RLE = 3;
21 +var Z_FIXED = 4;
22 +//var Z_DEFAULT_STRATEGY = 0;
23 +
24 +/* Possible values of the data_type field (though see inflate()) */
25 +var Z_BINARY = 0;
26 +var Z_TEXT = 1;
27 +//var Z_ASCII = 1; // = Z_TEXT
28 +var Z_UNKNOWN = 2;
29 +
30 +/*============================================================================*/
31 +
32 +function zero(buf) {
33 + var len = buf.length;
34 + while (--len >= 0) {
35 + buf[len] = 0;
36 + }
37 +}
38 +
39 +// From zutil.h
40 +
41 +var STORED_BLOCK = 0;
42 +var STATIC_TREES = 1;
43 +var DYN_TREES = 2;
44 +/* The three kinds of block type */
45 +
46 +var MIN_MATCH = 3;
47 +var MAX_MATCH = 258;
48 +/* The minimum and maximum match lengths */
49 +
50 +// From deflate.h
51 +/* ===========================================================================
52 + * Internal compression state.
53 + */
54 +
55 +var LENGTH_CODES = 29;
56 +/* number of length codes, not counting the special END_BLOCK code */
57 +
58 +var LITERALS = 256;
59 +/* number of literal bytes 0..255 */
60 +
61 +var L_CODES = LITERALS + 1 + LENGTH_CODES;
62 +/* number of Literal or Length codes, including the END_BLOCK code */
63 +
64 +var D_CODES = 30;
65 +/* number of distance codes */
66 +
67 +var BL_CODES = 19;
68 +/* number of codes used to transfer the bit lengths */
69 +
70 +var HEAP_SIZE = 2 * L_CODES + 1;
71 +/* maximum heap size */
72 +
73 +var MAX_BITS = 15;
74 +/* All codes must not exceed MAX_BITS bits */
75 +
76 +var Buf_size = 16;
77 +/* size of bit buffer in bi_buf */
78 +
79 +/* ===========================================================================
80 + * Constants
81 + */
82 +
83 +var MAX_BL_BITS = 7;
84 +/* Bit length codes must not exceed MAX_BL_BITS bits */
85 +
86 +var END_BLOCK = 256;
87 +/* end of block literal code */
88 +
89 +var REP_3_6 = 16;
90 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */
91 +
92 +var REPZ_3_10 = 17;
93 +/* repeat a zero length 3-10 times (3 bits of repeat count) */
94 +
95 +var REPZ_11_138 = 18;
96 +/* repeat a zero length 11-138 times (7 bits of repeat count) */
97 +
98 +/* eslint-disable comma-spacing,array-bracket-spacing */
99 +var extra_lbits = /* extra bits for each length code */
100 +[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0];
101 +var extra_dbits = /* extra bits for each distance code */
102 +[0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
103 +var extra_blbits = /* extra bits for each bit length code */
104 +[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7];
105 +var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
106 +/* eslint-enable comma-spacing,array-bracket-spacing */
107 +
108 +/* The lengths of the bit length codes are sent in order of decreasing
109 + * probability, to avoid transmitting the lengths for unused bit length codes.
110 + */
111 +
112 +/* ===========================================================================
113 + * Local data. These are initialized only once.
114 + */
115 +
116 +// We pre-fill arrays with 0 to avoid uninitialized gaps
117 +
118 +var DIST_CODE_LEN = 512; /* see definition of array dist_code below */
119 +
120 +// !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1
121 +var static_ltree = new Array((L_CODES + 2) * 2);
122 +zero(static_ltree);
123 +/* The static literal tree. Since the bit lengths are imposed, there is no
124 + * need for the L_CODES extra codes used during heap construction. However
125 + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
126 + * below).
127 + */
128 +
129 +var static_dtree = new Array(D_CODES * 2);
130 +zero(static_dtree);
131 +/* The static distance tree. (Actually a trivial tree since all codes use
132 + * 5 bits.)
133 + */
134 +
135 +var _dist_code = new Array(DIST_CODE_LEN);
136 +zero(_dist_code);
137 +/* Distance codes. The first 256 values correspond to the distances
138 + * 3 .. 258, the last 256 values correspond to the top 8 bits of
139 + * the 15 bit distances.
140 + */
141 +
142 +var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
143 +zero(_length_code);
144 +/* length code for each normalized match length (0 == MIN_MATCH) */
145 +
146 +var base_length = new Array(LENGTH_CODES);
147 +zero(base_length);
148 +/* First normalized length for each code (0 = MIN_MATCH) */
149 +
150 +var base_dist = new Array(D_CODES);
151 +zero(base_dist);
152 +/* First normalized distance for each code (0 = distance of 1) */
153 +
154 +function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
155 + this.static_tree = static_tree; /* static tree or NULL */
156 + this.extra_bits = extra_bits; /* extra bits for each code or NULL */
157 + this.extra_base = extra_base; /* base index for extra_bits */
158 + this.elems = elems; /* max number of elements in the tree */
159 + this.max_length = max_length; /* max bit length for the codes */
160 +
161 + // show if `static_tree` has data or dummy - needed for monomorphic objects
162 + this.has_stree = static_tree && static_tree.length;
163 +}
164 +var static_l_desc;
165 +var static_d_desc;
166 +var static_bl_desc;
167 +function TreeDesc(dyn_tree, stat_desc) {
168 + this.dyn_tree = dyn_tree; /* the dynamic tree */
169 + this.max_code = 0; /* largest code with non zero frequency */
170 + this.stat_desc = stat_desc; /* the corresponding static tree */
171 +}
172 +function d_code(dist) {
173 + return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
174 +}
175 +
176 +/* ===========================================================================
177 + * Output a short LSB first on the stream.
178 + * IN assertion: there is enough room in pendingBuf.
179 + */
180 +function put_short(s, w) {
181 + // put_byte(s, (uch)((w) & 0xff));
182 + // put_byte(s, (uch)((ush)(w) >> 8));
183 + s.pending_buf[s.pending++] = w & 0xff;
184 + s.pending_buf[s.pending++] = w >>> 8 & 0xff;
185 +}
186 +
187 +/* ===========================================================================
188 + * Send a value on a given number of bits.
189 + * IN assertion: length <= 16 and value fits in length bits.
190 + */
191 +function send_bits(s, value, length) {
192 + if (s.bi_valid > Buf_size - length) {
193 + s.bi_buf |= value << s.bi_valid & 0xffff;
194 + put_short(s, s.bi_buf);
195 + s.bi_buf = value >> Buf_size - s.bi_valid;
196 + s.bi_valid += length - Buf_size;
197 + } else {
198 + s.bi_buf |= value << s.bi_valid & 0xffff;
199 + s.bi_valid += length;
200 + }
201 +}
202 +function send_code(s, c, tree) {
203 + send_bits(s, tree[c * 2] /*.Code*/, tree[c * 2 + 1] /*.Len*/);
204 +}
205 +
206 +/* ===========================================================================
207 + * Reverse the first len bits of a code, using straightforward code (a faster
208 + * method would use a table)
209 + * IN assertion: 1 <= len <= 15
210 + */
211 +function bi_reverse(code, len) {
212 + var res = 0;
213 + do {
214 + res |= code & 1;
215 + code >>>= 1;
216 + res <<= 1;
217 + } while (--len > 0);
218 + return res >>> 1;
219 +}
220 +
221 +/* ===========================================================================
222 + * Flush the bit buffer, keeping at most 7 bits in it.
223 + */
224 +function bi_flush(s) {
225 + if (s.bi_valid === 16) {
226 + put_short(s, s.bi_buf);
227 + s.bi_buf = 0;
228 + s.bi_valid = 0;
229 + } else if (s.bi_valid >= 8) {
230 + s.pending_buf[s.pending++] = s.bi_buf & 0xff;
231 + s.bi_buf >>= 8;
232 + s.bi_valid -= 8;
233 + }
234 +}
235 +
236 +/* ===========================================================================
237 + * Compute the optimal bit lengths for a tree and update the total bit length
238 + * for the current block.
239 + * IN assertion: the fields freq and dad are set, heap[heap_max] and
240 + * above are the tree nodes sorted by increasing frequency.
241 + * OUT assertions: the field len is set to the optimal bit length, the
242 + * array bl_count contains the frequencies for each bit length.
243 + * The length opt_len is updated; static_len is also updated if stree is
244 + * not null.
245 + */
246 +function gen_bitlen(s, desc)
247 +// deflate_state *s;
248 +// tree_desc *desc; /* the tree descriptor */
249 +{
250 + var tree = desc.dyn_tree;
251 + var max_code = desc.max_code;
252 + var stree = desc.stat_desc.static_tree;
253 + var has_stree = desc.stat_desc.has_stree;
254 + var extra = desc.stat_desc.extra_bits;
255 + var base = desc.stat_desc.extra_base;
256 + var max_length = desc.stat_desc.max_length;
257 + var h; /* heap index */
258 + var n, m; /* iterate over the tree elements */
259 + var bits; /* bit length */
260 + var xbits; /* extra bits */
261 + var f; /* frequency */
262 + var overflow = 0; /* number of elements with bit length too large */
263 +
264 + for (bits = 0; bits <= MAX_BITS; bits++) {
265 + s.bl_count[bits] = 0;
266 + }
267 +
268 + /* In a first pass, compute the optimal bit lengths (which may
269 + * overflow in the case of the bit length tree).
270 + */
271 + tree[s.heap[s.heap_max] * 2 + 1] /*.Len*/ = 0; /* root of the heap */
272 +
273 + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
274 + n = s.heap[h];
275 + bits = tree[tree[n * 2 + 1] /*.Dad*/ * 2 + 1] /*.Len*/ + 1;
276 + if (bits > max_length) {
277 + bits = max_length;
278 + overflow++;
279 + }
280 + tree[n * 2 + 1] /*.Len*/ = bits;
281 + /* We overwrite tree[n].Dad which is no longer needed */
282 +
283 + if (n > max_code) {
284 + continue;
285 + } /* not a leaf node */
286 +
287 + s.bl_count[bits]++;
288 + xbits = 0;
289 + if (n >= base) {
290 + xbits = extra[n - base];
291 + }
292 + f = tree[n * 2] /*.Freq*/;
293 + s.opt_len += f * (bits + xbits);
294 + if (has_stree) {
295 + s.static_len += f * (stree[n * 2 + 1] /*.Len*/ + xbits);
296 + }
297 + }
298 + if (overflow === 0) {
299 + return;
300 + }
301 +
302 + // Trace((stderr,"\nbit length overflow\n"));
303 + /* This happens for example on obj2 and pic of the Calgary corpus */
304 +
305 + /* Find the first bit length which could increase: */
306 + do {
307 + bits = max_length - 1;
308 + while (s.bl_count[bits] === 0) {
309 + bits--;
310 + }
311 + s.bl_count[bits]--; /* move one leaf down the tree */
312 + s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */
313 + s.bl_count[max_length]--;
314 + /* The brother of the overflow item also moves one step up,
315 + * but this does not affect bl_count[max_length]
316 + */
317 + overflow -= 2;
318 + } while (overflow > 0);
319 +
320 + /* Now recompute all bit lengths, scanning in increasing frequency.
321 + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
322 + * lengths instead of fixing only the wrong ones. This idea is taken
323 + * from 'ar' written by Haruhiko Okumura.)
324 + */
325 + for (bits = max_length; bits !== 0; bits--) {
326 + n = s.bl_count[bits];
327 + while (n !== 0) {
328 + m = s.heap[--h];
329 + if (m > max_code) {
330 + continue;
331 + }
332 + if (tree[m * 2 + 1] /*.Len*/ !== bits) {
333 + // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
334 + s.opt_len += (bits - tree[m * 2 + 1] /*.Len*/) * tree[m * 2] /*.Freq*/;
335 + tree[m * 2 + 1] /*.Len*/ = bits;
336 + }
337 + n--;
338 + }
339 + }
340 +}
341 +
342 +/* ===========================================================================
343 + * Generate the codes for a given tree and bit counts (which need not be
344 + * optimal).
345 + * IN assertion: the array bl_count contains the bit length statistics for
346 + * the given tree and the field len is set for all tree elements.
347 + * OUT assertion: the field code is set for all tree elements of non
348 + * zero code length.
349 + */
350 +function gen_codes(tree, max_code, bl_count)
351 +// ct_data *tree; /* the tree to decorate */
352 +// int max_code; /* largest code with non zero frequency */
353 +// ushf *bl_count; /* number of codes at each bit length */
354 +{
355 + var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */
356 + var code = 0; /* running code value */
357 + var bits; /* bit index */
358 + var n; /* code index */
359 +
360 + /* The distribution counts are first used to generate the code values
361 + * without bit reversal.
362 + */
363 + for (bits = 1; bits <= MAX_BITS; bits++) {
364 + next_code[bits] = code = code + bl_count[bits - 1] << 1;
365 + }
366 + /* Check that the bit counts in bl_count are consistent. The last code
367 + * must be all ones.
368 + */
369 + //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
370 + // "inconsistent bit counts");
371 + //Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
372 +
373 + for (n = 0; n <= max_code; n++) {
374 + var len = tree[n * 2 + 1] /*.Len*/;
375 + if (len === 0) {
376 + continue;
377 + }
378 + /* Now reverse the bits */
379 + tree[n * 2] /*.Code*/ = bi_reverse(next_code[len]++, len);
380 +
381 + //Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
382 + // n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
383 + }
384 +}
385 +
386 +/* ===========================================================================
387 + * Initialize the various 'constant' tables.
388 + */
389 +function tr_static_init() {
390 + var n; /* iterates over tree elements */
391 + var bits; /* bit counter */
392 + var length; /* length value */
393 + var code; /* code value */
394 + var dist; /* distance index */
395 + var bl_count = new Array(MAX_BITS + 1);
396 + /* number of codes at each bit length for an optimal tree */
397 +
398 + // do check in _tr_init()
399 + //if (static_init_done) return;
400 +
401 + /* For some embedded targets, global variables are not initialized: */
402 + /*#ifdef NO_INIT_GLOBAL_POINTERS
403 + static_l_desc.static_tree = static_ltree;
404 + static_l_desc.extra_bits = extra_lbits;
405 + static_d_desc.static_tree = static_dtree;
406 + static_d_desc.extra_bits = extra_dbits;
407 + static_bl_desc.extra_bits = extra_blbits;
408 + #endif*/
409 +
410 + /* Initialize the mapping length (0..255) -> length code (0..28) */
411 + length = 0;
412 + for (code = 0; code < LENGTH_CODES - 1; code++) {
413 + base_length[code] = length;
414 + for (n = 0; n < 1 << extra_lbits[code]; n++) {
415 + _length_code[length++] = code;
416 + }
417 + }
418 + //Assert (length == 256, "tr_static_init: length != 256");
419 + /* Note that the length 255 (match length 258) can be represented
420 + * in two different ways: code 284 + 5 bits or code 285, so we
421 + * overwrite length_code[255] to use the best encoding:
422 + */
423 + _length_code[length - 1] = code;
424 +
425 + /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
426 + dist = 0;
427 + for (code = 0; code < 16; code++) {
428 + base_dist[code] = dist;
429 + for (n = 0; n < 1 << extra_dbits[code]; n++) {
430 + _dist_code[dist++] = code;
431 + }
432 + }
433 + //Assert (dist == 256, "tr_static_init: dist != 256");
434 + dist >>= 7; /* from now on, all distances are divided by 128 */
435 + for (; code < D_CODES; code++) {
436 + base_dist[code] = dist << 7;
437 + for (n = 0; n < 1 << extra_dbits[code] - 7; n++) {
438 + _dist_code[256 + dist++] = code;
439 + }
440 + }
441 + //Assert (dist == 256, "tr_static_init: 256+dist != 512");
442 +
443 + /* Construct the codes of the static literal tree */
444 + for (bits = 0; bits <= MAX_BITS; bits++) {
445 + bl_count[bits] = 0;
446 + }
447 + n = 0;
448 + while (n <= 143) {
449 + static_ltree[n * 2 + 1] /*.Len*/ = 8;
450 + n++;
451 + bl_count[8]++;
452 + }
453 + while (n <= 255) {
454 + static_ltree[n * 2 + 1] /*.Len*/ = 9;
455 + n++;
456 + bl_count[9]++;
457 + }
458 + while (n <= 279) {
459 + static_ltree[n * 2 + 1] /*.Len*/ = 7;
460 + n++;
461 + bl_count[7]++;
462 + }
463 + while (n <= 287) {
464 + static_ltree[n * 2 + 1] /*.Len*/ = 8;
465 + n++;
466 + bl_count[8]++;
467 + }
468 + /* Codes 286 and 287 do not exist, but we must include them in the
469 + * tree construction to get a canonical Huffman tree (longest code
470 + * all ones)
471 + */
472 + gen_codes(static_ltree, L_CODES + 1, bl_count);
473 +
474 + /* The static distance tree is trivial: */
475 + for (n = 0; n < D_CODES; n++) {
476 + static_dtree[n * 2 + 1] /*.Len*/ = 5;
477 + static_dtree[n * 2] /*.Code*/ = bi_reverse(n, 5);
478 + }
479 +
480 + // Now data ready and we can init static trees
481 + static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);
482 + static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS);
483 + static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS);
484 +
485 + //static_init_done = true;
486 +}
487 +
488 +/* ===========================================================================
489 + * Initialize a new block.
490 + */
491 +function init_block(s) {
492 + var n; /* iterates over tree elements */
493 +
494 + /* Initialize the trees. */
495 + for (n = 0; n < L_CODES; n++) {
496 + s.dyn_ltree[n * 2] /*.Freq*/ = 0;
497 + }
498 + for (n = 0; n < D_CODES; n++) {
499 + s.dyn_dtree[n * 2] /*.Freq*/ = 0;
500 + }
501 + for (n = 0; n < BL_CODES; n++) {
502 + s.bl_tree[n * 2] /*.Freq*/ = 0;
503 + }
504 + s.dyn_ltree[END_BLOCK * 2] /*.Freq*/ = 1;
505 + s.opt_len = s.static_len = 0;
506 + s.last_lit = s.matches = 0;
507 +}
508 +
509 +/* ===========================================================================
510 + * Flush the bit buffer and align the output on a byte boundary
511 + */
512 +function bi_windup(s) {
513 + if (s.bi_valid > 8) {
514 + put_short(s, s.bi_buf);
515 + } else if (s.bi_valid > 0) {
516 + //put_byte(s, (Byte)s->bi_buf);
517 + s.pending_buf[s.pending++] = s.bi_buf;
518 + }
519 + s.bi_buf = 0;
520 + s.bi_valid = 0;
521 +}
522 +
523 +/* ===========================================================================
524 + * Copy a stored block, storing first the length and its
525 + * one's complement if requested.
526 + */
527 +function copy_block(s, buf, len, header)
528 +//DeflateState *s;
529 +//charf *buf; /* the input data */
530 +//unsigned len; /* its length */
531 +//int header; /* true if block header must be written */
532 +{
533 + bi_windup(s); /* align on byte boundary */
534 +
535 + if (header) {
536 + put_short(s, len);
537 + put_short(s, ~len);
538 + }
539 + // while (len--) {
540 + // put_byte(s, *buf++);
541 + // }
542 + utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
543 + s.pending += len;
544 +}
545 +
546 +/* ===========================================================================
547 + * Compares to subtrees, using the tree depth as tie breaker when
548 + * the subtrees have equal frequency. This minimizes the worst case length.
549 + */
550 +function smaller(tree, n, m, depth) {
551 + var _n2 = n * 2;
552 + var _m2 = m * 2;
553 + return tree[_n2] /*.Freq*/ < tree[_m2] /*.Freq*/ || tree[_n2] /*.Freq*/ === tree[_m2] /*.Freq*/ && depth[n] <= depth[m];
554 +}
555 +
556 +/* ===========================================================================
557 + * Restore the heap property by moving down the tree starting at node k,
558 + * exchanging a node with the smallest of its two sons if necessary, stopping
559 + * when the heap property is re-established (each father smaller than its
560 + * two sons).
561 + */
562 +function pqdownheap(s, tree, k)
563 +// deflate_state *s;
564 +// ct_data *tree; /* the tree to restore */
565 +// int k; /* node to move down */
566 +{
567 + var v = s.heap[k];
568 + var j = k << 1; /* left son of k */
569 + while (j <= s.heap_len) {
570 + /* Set j to the smallest of the two sons: */
571 + if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
572 + j++;
573 + }
574 + /* Exit if v is smaller than both sons */
575 + if (smaller(tree, v, s.heap[j], s.depth)) {
576 + break;
577 + }
578 +
579 + /* Exchange v with the smallest son */
580 + s.heap[k] = s.heap[j];
581 + k = j;
582 +
583 + /* And continue down the tree, setting j to the left son of k */
584 + j <<= 1;
585 + }
586 + s.heap[k] = v;
587 +}
588 +
589 +// inlined manually
590 +// var SMALLEST = 1;
591 +
592 +/* ===========================================================================
593 + * Send the block data compressed using the given Huffman trees
594 + */
595 +function compress_block(s, ltree, dtree)
596 +// deflate_state *s;
597 +// const ct_data *ltree; /* literal tree */
598 +// const ct_data *dtree; /* distance tree */
599 +{
600 + var dist; /* distance of matched string */
601 + var lc; /* match length or unmatched char (if dist == 0) */
602 + var lx = 0; /* running index in l_buf */
603 + var code; /* the code to send */
604 + var extra; /* number of extra bits to send */
605 +
606 + if (s.last_lit !== 0) {
607 + do {
608 + dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1];
609 + lc = s.pending_buf[s.l_buf + lx];
610 + lx++;
611 + if (dist === 0) {
612 + send_code(s, lc, ltree); /* send a literal byte */
613 + //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
614 + } else {
615 + /* Here, lc is the match length - MIN_MATCH */
616 + code = _length_code[lc];
617 + send_code(s, code + LITERALS + 1, ltree); /* send the length code */
618 + extra = extra_lbits[code];
619 + if (extra !== 0) {
620 + lc -= base_length[code];
621 + send_bits(s, lc, extra); /* send the extra length bits */
622 + }
623 + dist--; /* dist is now the match distance - 1 */
624 + code = d_code(dist);
625 + //Assert (code < D_CODES, "bad d_code");
626 +
627 + send_code(s, code, dtree); /* send the distance code */
628 + extra = extra_dbits[code];
629 + if (extra !== 0) {
630 + dist -= base_dist[code];
631 + send_bits(s, dist, extra); /* send the extra distance bits */
632 + }
633 + } /* literal or match pair ? */
634 +
635 + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
636 + //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
637 + // "pendingBuf overflow");
638 + } while (lx < s.last_lit);
639 + }
640 + send_code(s, END_BLOCK, ltree);
641 +}
642 +
643 +/* ===========================================================================
644 + * Construct one Huffman tree and assigns the code bit strings and lengths.
645 + * Update the total bit length for the current block.
646 + * IN assertion: the field freq is set for all tree elements.
647 + * OUT assertions: the fields len and code are set to the optimal bit length
648 + * and corresponding code. The length opt_len is updated; static_len is
649 + * also updated if stree is not null. The field max_code is set.
650 + */
651 +function build_tree(s, desc)
652 +// deflate_state *s;
653 +// tree_desc *desc; /* the tree descriptor */
654 +{
655 + var tree = desc.dyn_tree;
656 + var stree = desc.stat_desc.static_tree;
657 + var has_stree = desc.stat_desc.has_stree;
658 + var elems = desc.stat_desc.elems;
659 + var n, m; /* iterate over heap elements */
660 + var max_code = -1; /* largest code with non zero frequency */
661 + var node; /* new node being created */
662 +
663 + /* Construct the initial heap, with least frequent element in
664 + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
665 + * heap[0] is not used.
666 + */
667 + s.heap_len = 0;
668 + s.heap_max = HEAP_SIZE;
669 + for (n = 0; n < elems; n++) {
670 + if (tree[n * 2] /*.Freq*/ !== 0) {
671 + s.heap[++s.heap_len] = max_code = n;
672 + s.depth[n] = 0;
673 + } else {
674 + tree[n * 2 + 1] /*.Len*/ = 0;
675 + }
676 + }
677 +
678 + /* The pkzip format requires that at least one distance code exists,
679 + * and that at least one bit should be sent even if there is only one
680 + * possible code. So to avoid special checks later on we force at least
681 + * two codes of non zero frequency.
682 + */
683 + while (s.heap_len < 2) {
684 + node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0;
685 + tree[node * 2] /*.Freq*/ = 1;
686 + s.depth[node] = 0;
687 + s.opt_len--;
688 + if (has_stree) {
689 + s.static_len -= stree[node * 2 + 1] /*.Len*/;
690 + }
691 + /* node is 0 or 1 so it does not have extra bits */
692 + }
693 + desc.max_code = max_code;
694 +
695 + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
696 + * establish sub-heaps of increasing lengths:
697 + */
698 + for (n = s.heap_len >> 1 /*int /2*/; n >= 1; n--) {
699 + pqdownheap(s, tree, n);
700 + }
701 +
702 + /* Construct the Huffman tree by repeatedly combining the least two
703 + * frequent nodes.
704 + */
705 + node = elems; /* next internal node of the tree */
706 + do {
707 + //pqremove(s, tree, n); /* n = node of least frequency */
708 + /*** pqremove ***/
709 + n = s.heap[1 /*SMALLEST*/];
710 + s.heap[1 /*SMALLEST*/] = s.heap[s.heap_len--];
711 + pqdownheap(s, tree, 1 /*SMALLEST*/);
712 + /***/
713 +
714 + m = s.heap[1 /*SMALLEST*/]; /* m = node of next least frequency */
715 +
716 + s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */
717 + s.heap[--s.heap_max] = m;
718 +
719 + /* Create a new node father of n and m */
720 + tree[node * 2] /*.Freq*/ = tree[n * 2] /*.Freq*/ + tree[m * 2] /*.Freq*/;
721 + s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
722 + tree[n * 2 + 1] /*.Dad*/ = tree[m * 2 + 1] /*.Dad*/ = node;
723 +
724 + /* and insert the new node in the heap */
725 + s.heap[1 /*SMALLEST*/] = node++;
726 + pqdownheap(s, tree, 1 /*SMALLEST*/);
727 + } while (s.heap_len >= 2);
728 + s.heap[--s.heap_max] = s.heap[1 /*SMALLEST*/];
729 +
730 + /* At this point, the fields freq and dad are set. We can now
731 + * generate the bit lengths.
732 + */
733 + gen_bitlen(s, desc);
734 +
735 + /* The field len is now set, we can generate the bit codes */
736 + gen_codes(tree, max_code, s.bl_count);
737 +}
738 +
739 +/* ===========================================================================
740 + * Scan a literal or distance tree to determine the frequencies of the codes
741 + * in the bit length tree.
742 + */
743 +function scan_tree(s, tree, max_code)
744 +// deflate_state *s;
745 +// ct_data *tree; /* the tree to be scanned */
746 +// int max_code; /* and its largest code of non zero frequency */
747 +{
748 + var n; /* iterates over all tree elements */
749 + var prevlen = -1; /* last emitted length */
750 + var curlen; /* length of current code */
751 +
752 + var nextlen = tree[0 * 2 + 1] /*.Len*/; /* length of next code */
753 +
754 + var count = 0; /* repeat count of the current code */
755 + var max_count = 7; /* max repeat count */
756 + var min_count = 4; /* min repeat count */
757 +
758 + if (nextlen === 0) {
759 + max_count = 138;
760 + min_count = 3;
761 + }
762 + tree[(max_code + 1) * 2 + 1] /*.Len*/ = 0xffff; /* guard */
763 +
764 + for (n = 0; n <= max_code; n++) {
765 + curlen = nextlen;
766 + nextlen = tree[(n + 1) * 2 + 1] /*.Len*/;
767 + if (++count < max_count && curlen === nextlen) {
768 + continue;
769 + } else if (count < min_count) {
770 + s.bl_tree[curlen * 2] /*.Freq*/ += count;
771 + } else if (curlen !== 0) {
772 + if (curlen !== prevlen) {
773 + s.bl_tree[curlen * 2] /*.Freq*/++;
774 + }
775 + s.bl_tree[REP_3_6 * 2] /*.Freq*/++;
776 + } else if (count <= 10) {
777 + s.bl_tree[REPZ_3_10 * 2] /*.Freq*/++;
778 + } else {
779 + s.bl_tree[REPZ_11_138 * 2] /*.Freq*/++;
780 + }
781 + count = 0;
782 + prevlen = curlen;
783 + if (nextlen === 0) {
784 + max_count = 138;
785 + min_count = 3;
786 + } else if (curlen === nextlen) {
787 + max_count = 6;
788 + min_count = 3;
789 + } else {
790 + max_count = 7;
791 + min_count = 4;
792 + }
793 + }
794 +}
795 +
796 +/* ===========================================================================
797 + * Send a literal or distance tree in compressed form, using the codes in
798 + * bl_tree.
799 + */
800 +function send_tree(s, tree, max_code)
801 +// deflate_state *s;
802 +// ct_data *tree; /* the tree to be scanned */
803 +// int max_code; /* and its largest code of non zero frequency */
804 +{
805 + var n; /* iterates over all tree elements */
806 + var prevlen = -1; /* last emitted length */
807 + var curlen; /* length of current code */
808 +
809 + var nextlen = tree[0 * 2 + 1] /*.Len*/; /* length of next code */
810 +
811 + var count = 0; /* repeat count of the current code */
812 + var max_count = 7; /* max repeat count */
813 + var min_count = 4; /* min repeat count */
814 +
815 + /* tree[max_code+1].Len = -1; */ /* guard already set */
816 + if (nextlen === 0) {
817 + max_count = 138;
818 + min_count = 3;
819 + }
820 + for (n = 0; n <= max_code; n++) {
821 + curlen = nextlen;
822 + nextlen = tree[(n + 1) * 2 + 1] /*.Len*/;
823 + if (++count < max_count && curlen === nextlen) {
824 + continue;
825 + } else if (count < min_count) {
826 + do {
827 + send_code(s, curlen, s.bl_tree);
828 + } while (--count !== 0);
829 + } else if (curlen !== 0) {
830 + if (curlen !== prevlen) {
831 + send_code(s, curlen, s.bl_tree);
832 + count--;
833 + }
834 + //Assert(count >= 3 && count <= 6, " 3_6?");
835 + send_code(s, REP_3_6, s.bl_tree);
836 + send_bits(s, count - 3, 2);
837 + } else if (count <= 10) {
838 + send_code(s, REPZ_3_10, s.bl_tree);
839 + send_bits(s, count - 3, 3);
840 + } else {
841 + send_code(s, REPZ_11_138, s.bl_tree);
842 + send_bits(s, count - 11, 7);
843 + }
844 + count = 0;
845 + prevlen = curlen;
846 + if (nextlen === 0) {
847 + max_count = 138;
848 + min_count = 3;
849 + } else if (curlen === nextlen) {
850 + max_count = 6;
851 + min_count = 3;
852 + } else {
853 + max_count = 7;
854 + min_count = 4;
855 + }
856 + }
857 +}
858 +
859 +/* ===========================================================================
860 + * Construct the Huffman tree for the bit lengths and return the index in
861 + * bl_order of the last bit length code to send.
862 + */
863 +function build_bl_tree(s) {
864 + var max_blindex; /* index of last bit length code of non zero freq */
865 +
866 + /* Determine the bit length frequencies for literal and distance trees */
867 + scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
868 + scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
869 +
870 + /* Build the bit length tree: */
871 + build_tree(s, s.bl_desc);
872 + /* opt_len now includes the length of the tree representations, except
873 + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
874 + */
875 +
876 + /* Determine the number of bit length codes to send. The pkzip format
877 + * requires that at least 4 bit length codes be sent. (appnote.txt says
878 + * 3 but the actual value used is 4.)
879 + */
880 + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {
881 + if (s.bl_tree[bl_order[max_blindex] * 2 + 1] /*.Len*/ !== 0) {
882 + break;
883 + }
884 + }
885 + /* Update opt_len to include the bit length tree and counts */
886 + s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
887 + //Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
888 + // s->opt_len, s->static_len));
889 +
890 + return max_blindex;
891 +}
892 +
893 +/* ===========================================================================
894 + * Send the header for a block using dynamic Huffman trees: the counts, the
895 + * lengths of the bit length codes, the literal tree and the distance tree.
896 + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
897 + */
898 +function send_all_trees(s, lcodes, dcodes, blcodes)
899 +// deflate_state *s;
900 +// int lcodes, dcodes, blcodes; /* number of codes for each tree */
901 +{
902 + var rank; /* index in bl_order */
903 +
904 + //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
905 + //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
906 + // "too many codes");
907 + //Tracev((stderr, "\nbl counts: "));
908 + send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
909 + send_bits(s, dcodes - 1, 5);
910 + send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
911 + for (rank = 0; rank < blcodes; rank++) {
912 + //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
913 + send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1] /*.Len*/, 3);
914 + }
915 + //Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
916 +
917 + send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */
918 + //Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
919 +
920 + send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */
921 + //Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
922 +}
923 +
924 +/* ===========================================================================
925 + * Check if the data type is TEXT or BINARY, using the following algorithm:
926 + * - TEXT if the two conditions below are satisfied:
927 + * a) There are no non-portable control characters belonging to the
928 + * "black list" (0..6, 14..25, 28..31).
929 + * b) There is at least one printable character belonging to the
930 + * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
931 + * - BINARY otherwise.
932 + * - The following partially-portable control characters form a
933 + * "gray list" that is ignored in this detection algorithm:
934 + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
935 + * IN assertion: the fields Freq of dyn_ltree are set.
936 + */
937 +function detect_data_type(s) {
938 + /* black_mask is the bit mask of black-listed bytes
939 + * set bits 0..6, 14..25, and 28..31
940 + * 0xf3ffc07f = binary 11110011111111111100000001111111
941 + */
942 + var black_mask = 0xf3ffc07f;
943 + var n;
944 +
945 + /* Check for non-textual ("black-listed") bytes. */
946 + for (n = 0; n <= 31; n++, black_mask >>>= 1) {
947 + if (black_mask & 1 && s.dyn_ltree[n * 2] /*.Freq*/ !== 0) {
948 + return Z_BINARY;
949 + }
950 + }
951 +
952 + /* Check for textual ("white-listed") bytes. */
953 + if (s.dyn_ltree[9 * 2] /*.Freq*/ !== 0 || s.dyn_ltree[10 * 2] /*.Freq*/ !== 0 || s.dyn_ltree[13 * 2] /*.Freq*/ !== 0) {
954 + return Z_TEXT;
955 + }
956 + for (n = 32; n < LITERALS; n++) {
957 + if (s.dyn_ltree[n * 2] /*.Freq*/ !== 0) {
958 + return Z_TEXT;
959 + }
960 + }
961 +
962 + /* There are no "black-listed" or "white-listed" bytes:
963 + * this stream either is empty or has tolerated ("gray-listed") bytes only.
964 + */
965 + return Z_BINARY;
966 +}
967 +var static_init_done = false;
968 +
969 +/* ===========================================================================
970 + * Initialize the tree data structures for a new zlib stream.
971 + */
972 +function _tr_init(s) {
973 + if (!static_init_done) {
974 + tr_static_init();
975 + static_init_done = true;
976 + }
977 + s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
978 + s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
979 + s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
980 + s.bi_buf = 0;
981 + s.bi_valid = 0;
982 +
983 + /* Initialize the first block of the first file: */
984 + init_block(s);
985 +}
986 +
987 +/* ===========================================================================
988 + * Send a stored block
989 + */
990 +function _tr_stored_block(s, buf, stored_len, last)
991 +//DeflateState *s;
992 +//charf *buf; /* input block */
993 +//ulg stored_len; /* length of input block */
994 +//int last; /* one if this is the last block for a file */
995 +{
996 + send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
997 + copy_block(s, buf, stored_len, true); /* with header */
998 +}
999 +
1000 +/* ===========================================================================
1001 + * Send one empty static block to give enough lookahead for inflate.
1002 + * This takes 10 bits, of which 7 may remain in the bit buffer.
1003 + */
1004 +function _tr_align(s) {
1005 + send_bits(s, STATIC_TREES << 1, 3);
1006 + send_code(s, END_BLOCK, static_ltree);
1007 + bi_flush(s);
1008 +}
1009 +
1010 +/* ===========================================================================
1011 + * Determine the best encoding for the current block: dynamic trees, static
1012 + * trees or store, and output the encoded block to the zip file.
1013 + */
1014 +function _tr_flush_block(s, buf, stored_len, last)
1015 +//DeflateState *s;
1016 +//charf *buf; /* input block, or NULL if too old */
1017 +//ulg stored_len; /* length of input block */
1018 +//int last; /* one if this is the last block for a file */
1019 +{
1020 + var opt_lenb, static_lenb; /* opt_len and static_len in bytes */
1021 + var max_blindex = 0; /* index of last bit length code of non zero freq */
1022 +
1023 + /* Build the Huffman trees unless a stored block is forced */
1024 + if (s.level > 0) {
1025 + /* Check if the file is binary or text */
1026 + if (s.strm.data_type === Z_UNKNOWN) {
1027 + s.strm.data_type = detect_data_type(s);
1028 + }
1029 +
1030 + /* Construct the literal and distance trees */
1031 + build_tree(s, s.l_desc);
1032 + // Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
1033 + // s->static_len));
1034 +
1035 + build_tree(s, s.d_desc);
1036 + // Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
1037 + // s->static_len));
1038 + /* At this point, opt_len and static_len are the total bit lengths of
1039 + * the compressed block data, excluding the tree representations.
1040 + */
1041 +
1042 + /* Build the bit length tree for the above two trees, and get the index
1043 + * in bl_order of the last bit length code to send.
1044 + */
1045 + max_blindex = build_bl_tree(s);
1046 +
1047 + /* Determine the best encoding. Compute the block lengths in bytes. */
1048 + opt_lenb = s.opt_len + 3 + 7 >>> 3;
1049 + static_lenb = s.static_len + 3 + 7 >>> 3;
1050 +
1051 + // Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
1052 + // opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
1053 + // s->last_lit));
1054 +
1055 + if (static_lenb <= opt_lenb) {
1056 + opt_lenb = static_lenb;
1057 + }
1058 + } else {
1059 + // Assert(buf != (char*)0, "lost buf");
1060 + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
1061 + }
1062 + if (stored_len + 4 <= opt_lenb && buf !== -1) {
1063 + /* 4: two words for the lengths */
1064 +
1065 + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
1066 + * Otherwise we can't have processed more than WSIZE input bytes since
1067 + * the last block flush, because compression would have been
1068 + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
1069 + * transform a block into a stored block.
1070 + */
1071 + _tr_stored_block(s, buf, stored_len, last);
1072 + } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
1073 + send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
1074 + compress_block(s, static_ltree, static_dtree);
1075 + } else {
1076 + send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
1077 + send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
1078 + compress_block(s, s.dyn_ltree, s.dyn_dtree);
1079 + }
1080 + // Assert (s->compressed_len == s->bits_sent, "bad compressed size");
1081 + /* The above check is made mod 2^32, for files larger than 512 MB
1082 + * and uLong implemented on 32 bits.
1083 + */
1084 + init_block(s);
1085 + if (last) {
1086 + bi_windup(s);
1087 + }
1088 + // Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
1089 + // s->compressed_len-7*last));
1090 +}
1091 +
1092 +/* ===========================================================================
1093 + * Save the match info and tally the frequency counts. Return true if
1094 + * the current block must be flushed.
1095 + */
1096 +function _tr_tally(s, dist, lc)
1097 +// deflate_state *s;
1098 +// unsigned dist; /* distance of matched string */
1099 +// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
1100 +{
1101 + //var out_length, in_length, dcode;
1102 +
1103 + s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 0xff;
1104 + s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
1105 + s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
1106 + s.last_lit++;
1107 + if (dist === 0) {
1108 + /* lc is the unmatched char */
1109 + s.dyn_ltree[lc * 2] /*.Freq*/++;
1110 + } else {
1111 + s.matches++;
1112 + /* Here, lc is the match length - MIN_MATCH */
1113 + dist--; /* dist = match distance - 1 */
1114 + //Assert((ush)dist < (ush)MAX_DIST(s) &&
1115 + // (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
1116 + // (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
1117 +
1118 + s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2] /*.Freq*/++;
1119 + s.dyn_dtree[d_code(dist) * 2] /*.Freq*/++;
1120 + }
1121 +
1122 + // (!) This block is disabled in zlib defailts,
1123 + // don't enable it for binary compatibility
1124 +
1125 + //#ifdef TRUNCATE_BLOCK
1126 + // /* Try to guess if it is profitable to stop the current block here */
1127 + // if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
1128 + // /* Compute an upper bound for the compressed length */
1129 + // out_length = s.last_lit*8;
1130 + // in_length = s.strstart - s.block_start;
1131 + //
1132 + // for (dcode = 0; dcode < D_CODES; dcode++) {
1133 + // out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
1134 + // }
1135 + // out_length >>>= 3;
1136 + // //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
1137 + // // s->last_lit, in_length, out_length,
1138 + // // 100L - out_length*100L/in_length));
1139 + // if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
1140 + // return true;
1141 + // }
1142 + // }
1143 + //#endif
1144 +
1145 + return s.last_lit === s.lit_bufsize - 1;
1146 + /* We avoid equality with lit_bufsize because of wraparound at 64K
1147 + * on 16 bit machines and because stored blocks are restricted to
1148 + * 64K-1 bytes.
1149 + */
1150 +}
\ No newline at end of file
added public/vendor/novnc/vendor/pako/lib/zlib/zstream.js +30 −0
@@ -0,0 +1,30 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = ZStream;
7 +function ZStream() {
8 + /* next input byte */
9 + this.input = null; // JS specific, because we have no pointers
10 + this.next_in = 0;
11 + /* number of bytes available at input */
12 + this.avail_in = 0;
13 + /* total number of input bytes read so far */
14 + this.total_in = 0;
15 + /* next output byte should be put there */
16 + this.output = null; // JS specific, because we have no pointers
17 + this.next_out = 0;
18 + /* remaining free space at output */
19 + this.avail_out = 0;
20 + /* total number of bytes output so far */
21 + this.total_out = 0;
22 + /* last error message, NULL if no error */
23 + this.msg = '' /*Z_NULL*/;
24 + /* not visible by applications */
25 + this.state = null;
26 + /* best guess about the data type: binary or text */
27 + this.data_type = 2 /*Z_UNKNOWN*/;
28 + /* adler32 value of the uncompressed data */
29 + this.adler = 0;
30 +}
\ No newline at end of file
added public/vendor/novnc/websock.js +395 −0
@@ -0,0 +1,395 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports["default"] = 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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
12 +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
15 +function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
16 +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; }
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 + * Websock: high-performance buffering wrapper
23 + * Copyright (C) 2019 The noVNC authors
24 + * Licensed under MPL 2.0 (see LICENSE.txt)
25 + *
26 + * Websock is similar to the standard WebSocket / RTCDataChannel object
27 + * but with extra buffer handling.
28 + *
29 + * Websock has built-in receive queue buffering; the message event
30 + * does not contain actual data but is simply a notification that
31 + * there is new data available. Several rQ* methods are available to
32 + * read binary data off of the receive queue.
33 + */
34 +// this has performance issues in some versions Chromium, and
35 +// doesn't gain a tremendous amount of performance increase in Firefox
36 +// at the moment. It may be valuable to turn it on in the future.
37 +var MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
38 +
39 +// Constants pulled from RTCDataChannelState enum
40 +// https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/readyState#RTCDataChannelState_enum
41 +var DataChannel = {
42 + CONNECTING: "connecting",
43 + OPEN: "open",
44 + CLOSING: "closing",
45 + CLOSED: "closed"
46 +};
47 +var ReadyStates = {
48 + CONNECTING: [WebSocket.CONNECTING, DataChannel.CONNECTING],
49 + OPEN: [WebSocket.OPEN, DataChannel.OPEN],
50 + CLOSING: [WebSocket.CLOSING, DataChannel.CLOSING],
51 + CLOSED: [WebSocket.CLOSED, DataChannel.CLOSED]
52 +};
53 +
54 +// Properties a raw channel must have, WebSocket and RTCDataChannel are two examples
55 +var rawChannelProps = ["send", "close", "binaryType", "onerror", "onmessage", "onopen", "protocol", "readyState"];
56 +var Websock = exports["default"] = /*#__PURE__*/function () {
57 + function Websock() {
58 + _classCallCheck(this, Websock);
59 + this._websocket = null; // WebSocket or RTCDataChannel object
60 +
61 + this._rQi = 0; // Receive queue index
62 + this._rQlen = 0; // Next write position in the receive queue
63 + this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB)
64 + // called in init: this._rQ = new Uint8Array(this._rQbufferSize);
65 + this._rQ = null; // Receive queue
66 +
67 + this._sQbufferSize = 1024 * 10; // 10 KiB
68 + // called in init: this._sQ = new Uint8Array(this._sQbufferSize);
69 + this._sQlen = 0;
70 + this._sQ = null; // Send queue
71 +
72 + this._eventHandlers = {
73 + message: function message() {},
74 + open: function open() {},
75 + close: function close() {},
76 + error: function error() {}
77 + };
78 + }
79 +
80 + // Getters and setters
81 + return _createClass(Websock, [{
82 + key: "readyState",
83 + get: function get() {
84 + var subState;
85 + if (this._websocket === null) {
86 + return "unused";
87 + }
88 + subState = this._websocket.readyState;
89 + if (ReadyStates.CONNECTING.includes(subState)) {
90 + return "connecting";
91 + } else if (ReadyStates.OPEN.includes(subState)) {
92 + return "open";
93 + } else if (ReadyStates.CLOSING.includes(subState)) {
94 + return "closing";
95 + } else if (ReadyStates.CLOSED.includes(subState)) {
96 + return "closed";
97 + }
98 + return "unknown";
99 + }
100 +
101 + // Receive queue
102 + }, {
103 + key: "rQpeek8",
104 + value: function rQpeek8() {
105 + return this._rQ[this._rQi];
106 + }
107 + }, {
108 + key: "rQskipBytes",
109 + value: function rQskipBytes(bytes) {
110 + this._rQi += bytes;
111 + }
112 + }, {
113 + key: "rQshift8",
114 + value: function rQshift8() {
115 + return this._rQshift(1);
116 + }
117 + }, {
118 + key: "rQshift16",
119 + value: function rQshift16() {
120 + return this._rQshift(2);
121 + }
122 + }, {
123 + key: "rQshift32",
124 + value: function rQshift32() {
125 + return this._rQshift(4);
126 + }
127 +
128 + // TODO(directxman12): test performance with these vs a DataView
129 + }, {
130 + key: "_rQshift",
131 + value: function _rQshift(bytes) {
132 + var res = 0;
133 + for (var _byte = bytes - 1; _byte >= 0; _byte--) {
134 + res += this._rQ[this._rQi++] << _byte * 8;
135 + }
136 + return res >>> 0;
137 + }
138 + }, {
139 + key: "rQshiftStr",
140 + value: function rQshiftStr(len) {
141 + var str = "";
142 + // Handle large arrays in steps to avoid long strings on the stack
143 + for (var i = 0; i < len; i += 4096) {
144 + var part = this.rQshiftBytes(Math.min(4096, len - i), false);
145 + str += String.fromCharCode.apply(null, part);
146 + }
147 + return str;
148 + }
149 + }, {
150 + key: "rQshiftBytes",
151 + value: function rQshiftBytes(len) {
152 + var copy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
153 + this._rQi += len;
154 + if (copy) {
155 + return this._rQ.slice(this._rQi - len, this._rQi);
156 + } else {
157 + return this._rQ.subarray(this._rQi - len, this._rQi);
158 + }
159 + }
160 + }, {
161 + key: "rQshiftTo",
162 + value: function rQshiftTo(target, len) {
163 + // TODO: make this just use set with views when using a ArrayBuffer to store the rQ
164 + target.set(new Uint8Array(this._rQ.buffer, this._rQi, len));
165 + this._rQi += len;
166 + }
167 + }, {
168 + key: "rQpeekBytes",
169 + value: function rQpeekBytes(len) {
170 + var copy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
171 + if (copy) {
172 + return this._rQ.slice(this._rQi, this._rQi + len);
173 + } else {
174 + return this._rQ.subarray(this._rQi, this._rQi + len);
175 + }
176 + }
177 +
178 + // Check to see if we must wait for 'num' bytes (default to FBU.bytes)
179 + // to be available in the receive queue. Return true if we need to
180 + // wait (and possibly print a debug message), otherwise false.
181 + }, {
182 + key: "rQwait",
183 + value: function rQwait(msg, num, goback) {
184 + if (this._rQlen - this._rQi < num) {
185 + if (goback) {
186 + if (this._rQi < goback) {
187 + throw new Error("rQwait cannot backup " + goback + " bytes");
188 + }
189 + this._rQi -= goback;
190 + }
191 + return true; // true means need more data
192 + }
193 + return false;
194 + }
195 +
196 + // Send queue
197 + }, {
198 + key: "sQpush8",
199 + value: function sQpush8(num) {
200 + this._sQensureSpace(1);
201 + this._sQ[this._sQlen++] = num;
202 + }
203 + }, {
204 + key: "sQpush16",
205 + value: function sQpush16(num) {
206 + this._sQensureSpace(2);
207 + this._sQ[this._sQlen++] = num >> 8 & 0xff;
208 + this._sQ[this._sQlen++] = num >> 0 & 0xff;
209 + }
210 + }, {
211 + key: "sQpush32",
212 + value: function sQpush32(num) {
213 + this._sQensureSpace(4);
214 + this._sQ[this._sQlen++] = num >> 24 & 0xff;
215 + this._sQ[this._sQlen++] = num >> 16 & 0xff;
216 + this._sQ[this._sQlen++] = num >> 8 & 0xff;
217 + this._sQ[this._sQlen++] = num >> 0 & 0xff;
218 + }
219 + }, {
220 + key: "sQpushString",
221 + value: function sQpushString(str) {
222 + var bytes = str.split('').map(function (chr) {
223 + return chr.charCodeAt(0);
224 + });
225 + this.sQpushBytes(new Uint8Array(bytes));
226 + }
227 + }, {
228 + key: "sQpushBytes",
229 + value: function sQpushBytes(bytes) {
230 + for (var offset = 0; offset < bytes.length;) {
231 + this._sQensureSpace(1);
232 + var chunkSize = this._sQbufferSize - this._sQlen;
233 + if (chunkSize > bytes.length - offset) {
234 + chunkSize = bytes.length - offset;
235 + }
236 + this._sQ.set(bytes.subarray(offset, offset + chunkSize), this._sQlen);
237 + this._sQlen += chunkSize;
238 + offset += chunkSize;
239 + }
240 + }
241 + }, {
242 + key: "flush",
243 + value: function flush() {
244 + if (this._sQlen > 0 && this.readyState === 'open') {
245 + this._websocket.send(new Uint8Array(this._sQ.buffer, 0, this._sQlen));
246 + this._sQlen = 0;
247 + }
248 + }
249 + }, {
250 + key: "_sQensureSpace",
251 + value: function _sQensureSpace(bytes) {
252 + if (this._sQbufferSize - this._sQlen < bytes) {
253 + this.flush();
254 + }
255 + }
256 +
257 + // Event handlers
258 + }, {
259 + key: "off",
260 + value: function off(evt) {
261 + this._eventHandlers[evt] = function () {};
262 + }
263 + }, {
264 + key: "on",
265 + value: function on(evt, handler) {
266 + this._eventHandlers[evt] = handler;
267 + }
268 + }, {
269 + key: "_allocateBuffers",
270 + value: function _allocateBuffers() {
271 + this._rQ = new Uint8Array(this._rQbufferSize);
272 + this._sQ = new Uint8Array(this._sQbufferSize);
273 + }
274 + }, {
275 + key: "init",
276 + value: function init() {
277 + this._allocateBuffers();
278 + this._rQi = 0;
279 + this._websocket = null;
280 + }
281 + }, {
282 + key: "open",
283 + value: function open(uri, protocols) {
284 + this.attach(new WebSocket(uri, protocols));
285 + }
286 + }, {
287 + key: "attach",
288 + value: function attach(rawChannel) {
289 + var _this = this;
290 + this.init();
291 +
292 + // Must get object and class methods to be compatible with the tests.
293 + var channelProps = [].concat(_toConsumableArray(Object.keys(rawChannel)), _toConsumableArray(Object.getOwnPropertyNames(Object.getPrototypeOf(rawChannel))));
294 + for (var i = 0; i < rawChannelProps.length; i++) {
295 + var prop = rawChannelProps[i];
296 + if (channelProps.indexOf(prop) < 0) {
297 + throw new Error('Raw channel missing property: ' + prop);
298 + }
299 + }
300 + this._websocket = rawChannel;
301 + this._websocket.binaryType = "arraybuffer";
302 + this._websocket.onmessage = this._recvMessage.bind(this);
303 + this._websocket.onopen = function () {
304 + Log.Debug('>> WebSock.onopen');
305 + if (_this._websocket.protocol) {
306 + Log.Info("Server choose sub-protocol: " + _this._websocket.protocol);
307 + }
308 + _this._eventHandlers.open();
309 + Log.Debug("<< WebSock.onopen");
310 + };
311 + this._websocket.onclose = function (e) {
312 + Log.Debug(">> WebSock.onclose");
313 + _this._eventHandlers.close(e);
314 + Log.Debug("<< WebSock.onclose");
315 + };
316 + this._websocket.onerror = function (e) {
317 + Log.Debug(">> WebSock.onerror: " + e);
318 + _this._eventHandlers.error(e);
319 + Log.Debug("<< WebSock.onerror: " + e);
320 + };
321 + }
322 + }, {
323 + key: "close",
324 + value: function close() {
325 + if (this._websocket) {
326 + if (this.readyState === 'connecting' || this.readyState === 'open') {
327 + Log.Info("Closing WebSocket connection");
328 + this._websocket.close();
329 + }
330 + this._websocket.onmessage = function () {};
331 + }
332 + }
333 +
334 + // private methods
335 +
336 + // We want to move all the unread data to the start of the queue,
337 + // e.g. compacting.
338 + // The function also expands the receive que if needed, and for
339 + // performance reasons we combine these two actions to avoid
340 + // unnecessary copying.
341 + }, {
342 + key: "_expandCompactRQ",
343 + value: function _expandCompactRQ(minFit) {
344 + // if we're using less than 1/8th of the buffer even with the incoming bytes, compact in place
345 + // instead of resizing
346 + var requiredBufferSize = (this._rQlen - this._rQi + minFit) * 8;
347 + var resizeNeeded = this._rQbufferSize < requiredBufferSize;
348 + if (resizeNeeded) {
349 + // Make sure we always *at least* double the buffer size, and have at least space for 8x
350 + // the current amount of data
351 + this._rQbufferSize = Math.max(this._rQbufferSize * 2, requiredBufferSize);
352 + }
353 +
354 + // we don't want to grow unboundedly
355 + if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
356 + this._rQbufferSize = MAX_RQ_GROW_SIZE;
357 + if (this._rQbufferSize - (this._rQlen - this._rQi) < minFit) {
358 + throw new Error("Receive queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
359 + }
360 + }
361 + if (resizeNeeded) {
362 + var oldRQbuffer = this._rQ.buffer;
363 + this._rQ = new Uint8Array(this._rQbufferSize);
364 + this._rQ.set(new Uint8Array(oldRQbuffer, this._rQi, this._rQlen - this._rQi));
365 + } else {
366 + this._rQ.copyWithin(0, this._rQi, this._rQlen);
367 + }
368 + this._rQlen = this._rQlen - this._rQi;
369 + this._rQi = 0;
370 + }
371 +
372 + // push arraybuffer values onto the end of the receive que
373 + }, {
374 + key: "_recvMessage",
375 + value: function _recvMessage(e) {
376 + if (this._rQlen == this._rQi) {
377 + // All data has now been processed, this means we
378 + // can reset the receive queue.
379 + this._rQlen = 0;
380 + this._rQi = 0;
381 + }
382 + var u8 = new Uint8Array(e.data);
383 + if (u8.length > this._rQbufferSize - this._rQlen) {
384 + this._expandCompactRQ(u8.length);
385 + }
386 + this._rQ.set(u8, this._rQlen);
387 + this._rQlen += u8.length;
388 + if (this._rQlen - this._rQi > 0) {
389 + this._eventHandlers.message();
390 + } else {
391 + Log.Debug("Ignoring empty message");
392 + }
393 + }
394 + }]);
395 +}();
\ No newline at end of file
modified server/server.js +23 −2
@@ -2,6 +2,7 @@
2 2 // Sessions détachées (survivent à la déconnexion du client), permissions
3 3 // relayées en cartes, monitoring Écosystème temps réel.
4 4 import http from 'node:http';
5 +import net from 'node:net';
5 6 import crypto from 'node:crypto';
6 7 import fs from 'node:fs';
7 8 import path from 'node:path';
@@ -665,6 +666,7 @@ const server = http.createServer(async (req, res) => {
665 666 return json(res, 200, { text: out.stdout || out.error || '(vide)' });
666 667 }
667 668 // --- Social : publication automatique + a la demande ---
669 + if (p === '/api/social/vncpw' && req.method === 'GET') return json(res, 200, { password: config.vncPassword || '492592' });
668 670 if (p === '/api/social/state' && req.method === 'GET') {
669 671 return json(res, 200, { state: socialState(), log: socialLog(40) });
670 672 }
@@ -751,13 +753,32 @@ const server = http.createServer(async (req, res) => {
751 753 // ---------- WebSocket ----------
752 754 const wss = new WebSocketServer({ noServer: true });
753 755
756 +// --- pont VNC : WebSocket (noVNC dans l'admin) <-> Partage d'écran du nœud (127.0.0.1:5900) ---
757 +const vncWss = new WebSocketServer({ noServer: true });
758 +vncWss.on('connection', (ws) => {
759 + const tcp = net.connect(5900, '127.0.0.1');
760 + tcp.on('data', (d) => { if (ws.readyState === 1) ws.send(d); });
761 + tcp.on('close', () => { try { ws.close(); } catch {} });
762 + tcp.on('error', () => { try { ws.close(); } catch {} });
763 + ws.on('message', (d) => { try { tcp.write(d); } catch {} });
764 + ws.on('close', () => { try { tcp.end(); } catch {} });
765 + ws.on('error', () => { try { tcp.destroy(); } catch {} });
766 +});
767 +
754 768 server.on('upgrade', (req, socket, head) => {
755 769 const url = new URL(req.url, 'http://x');
756 − if (url.pathname !== '/ws' || !getSession(req)) {
770 + if (!getSession(req)) {
757 771 socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
758 772 return socket.destroy();
759 773 }
760 − wss.handleUpgrade(req, socket, head, (ws) => wss.emit('connection', ws, req));
774 + if (url.pathname === '/ws') {
775 + wss.handleUpgrade(req, socket, head, (ws) => wss.emit('connection', ws, req));
776 + } else if (url.pathname === '/vncws') {
777 + vncWss.handleUpgrade(req, socket, head, (ws) => vncWss.emit('connection', ws, req));
778 + } else {
779 + socket.write('HTTP/1.1 404 Not Found\r\n\r\n');
780 + socket.destroy();
781 + }
761 782 });
762 783
763 784 wss.on('connection', (ws) => {
modified server/social/make_reel.py +44 −15
@@ -10,8 +10,8 @@ CTX = ssl.create_default_context(); CTX.check_hostname=False; CTX.verify_mode=ss
10 10 FFMPEG = "/opt/homebrew/bin/ffmpeg"
11 11 MOIS=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]
12 12 FONT="'Avenir Next','SF Pro Display','Helvetica Neue',Helvetica,Arial,sans-serif"
13 −DUR=9.0 # secondes
14 −HREEL=int(os.environ.get("KA_REEL_H","1350"))
13 +DUR=10.0 # secondes
14 +HREEL=int(os.environ.get("KA_REEL_H","1920"))
15 15
16 16 PALETTES={
17 17 "lou-ka":{"a":"#ff6a00","b":"#ff9d4d","g1":"#2a1403","g2":"#0d0b09"},
@@ -112,8 +112,8 @@ def build_html(ins):
112 112 def record_webm(html_path, out_webm, tmpdir):
113 113 from playwright.sync_api import sync_playwright
114 114 with sync_playwright() as pw:
115 − b=pw.chromium.launch(args=["--no-sandbox","--force-device-scale-factor=1"])
116 − ctx=b.new_context(viewport={"width":1080,"height":HREEL},
115 + b=pw.chromium.launch(args=["--no-sandbox"])
116 + ctx=b.new_context(viewport={"width":1080,"height":HREEL}, device_scale_factor=2,
117 117 record_video_dir=tmpdir, record_video_size={"width":1080,"height":HREEL})
118 118 pg=ctx.new_page()
119 119 pg.goto("file://"+html_path)
@@ -124,17 +124,46 @@ def record_webm(html_path, out_webm, tmpdir):
124 124 os.replace(path, out_webm)
125 125
126 126 def make_music(dur, out_wav):
127 − # nappe d'accord douce (Am : A3+C4+E4) + tremolo + passe-bas
128 − subprocess.run([FFMPEG,"-y",
129 − "-f","lavfi","-i",f"sine=frequency=220:duration={dur}",
130 − "-f","lavfi","-i",f"sine=frequency=261.63:duration={dur}",
131 − "-f","lavfi","-i",f"sine=frequency=329.63:duration={dur}",
132 − "-f","lavfi","-i",f"sine=frequency=110:duration={dur}",
127 + """Lit musical pro : progression Am-F-C-G (pad) + kick 4-temps + shaker + réverbe."""
128 + tmpdir=os.path.dirname(out_wav)
129 + chords=[(220.00,261.63,329.63),(174.61,220.00,261.63),(261.63,329.63,392.00),(196.00,246.94,293.66)]
130 + seg=round(dur/len(chords),3)
131 + parts=[]
132 + for i,(f1,f2,f3) in enumerate(chords):
133 + w=os.path.join(tmpdir,f"ch{i}.wav")
134 + subprocess.run([FFMPEG,"-y",
135 + "-f","lavfi","-i",f"sine=frequency={f1}:duration={seg}",
136 + "-f","lavfi","-i",f"sine=frequency={f2}:duration={seg}",
137 + "-f","lavfi","-i",f"sine=frequency={f3}:duration={seg}",
138 + "-filter_complex",
139 + f"[0][1][2]amix=inputs=3:normalize=0,volume=0.22,lowpass=f=1300,"
140 + f"afade=t=in:st=0:d=0.25,afade=t=out:st={seg-0.35}:d=0.35[a]",
141 + "-map","[a]",w],capture_output=True)
142 + parts.append(w)
143 + # concat des accords -> pad
144 + lst=os.path.join(tmpdir,"chords.txt")
145 + open(lst,"w").write("".join(f"file '{w}'\n" for w in parts))
146 + pad=os.path.join(tmpdir,"pad.wav")
147 + subprocess.run([FFMPEG,"-y","-f","concat","-safe","0","-i",lst,"-c","copy",pad],capture_output=True)
148 + # kick 4-temps (120 BPM) + shaker offbeat, synthétisés
149 + kick=os.path.join(tmpdir,"kick.wav")
150 + subprocess.run([FFMPEG,"-y","-f","lavfi",
151 + "-i",f"aevalsrc=0.7*sin(2*PI*55*t)*exp(-9*mod(t\,0.5)):d={dur}:s=44100",
152 + kick],capture_output=True)
153 + hat=os.path.join(tmpdir,"hat.wav")
154 + subprocess.run([FFMPEG,"-y","-f","lavfi",
155 + "-i",f"aevalsrc=0.12*(random(0)*2-1)*exp(-45*mod(t+0.25\,0.5)):d={dur}:s=44100",
156 + "-af","highpass=f=6000",hat],capture_output=True)
157 + # mix final : pad + kick + hat, réverbe douce, master fades
158 + subprocess.run([FFMPEG,"-y","-i",pad,"-i",kick,"-i",hat,
133 159 "-filter_complex",
134 − "[0][1][2]amix=inputs=3:normalize=0,volume=0.18,tremolo=f=4.5:d=0.4,lowpass=f=1400[pad];"
135 − "[3]volume=0.10,tremolo=f=2:d=0.6[sub];"
136 − "[pad][sub]amix=inputs=2:normalize=0,afade=t=in:st=0:d=1.2,afade=t=out:st="+str(dur-1.5)+":d=1.5[a]",
137 − "-map","[a]",out_wav],capture_output=True)
160 + f"[0]volume=1.0[p];[1]volume=0.9[k];[2]volume=0.5[h];"
161 + f"[p][k][h]amix=inputs=3:normalize=0,"
162 + f"aecho=0.8:0.85:60:0.25,"
163 + f"acompressor=threshold=-16dB:ratio=3:attack=8:release=180,"
164 + f"alimiter=limit=0.95,"
165 + f"afade=t=in:st=0:d=0.5,afade=t=out:st={dur-1.6}:d=1.6[a]",
166 + "-map","[a]","-ar","44100",out_wav],capture_output=True)
138 167
139 168 def render(ins, out_dir):
140 169 os.makedirs(out_dir,exist_ok=True)
@@ -146,7 +175,7 @@ def render(ins, out_dir):
146 175 out=os.path.join(out_dir,f"reel-{ins['site']}-{ins.get('insight_id','x')}.mp4")
147 176 subprocess.run([FFMPEG,"-y","-i",webm,"-i",wav,
148 177 "-filter_complex","[0:v]scale=1080:"+str(HREEL)+":force_original_aspect_ratio=increase,crop=1080:"+str(HREEL)+",fps=30,format=yuv420p[v]",
149 − "-map","[v]","-map","1:a","-c:v","libx264","-preset","medium","-crf","20",
178 + "-map","[v]","-map","1:a","-c:v","libx264","-preset","slow","-crf","18",
150 179 "-c:a","aac","-b:a","160k","-pix_fmt","yuv420p","-movflags","+faststart","-shortest",out],
151 180 capture_output=True)
152 181 # nettoyage
153 182