@jait/gateway 0.1.256 → 0.1.257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/preview.d.ts.map +1 -1
- package/dist/routes/preview.js +39 -0
- package/dist/routes/preview.js.map +1 -1
- package/dist/security/sandbox-manager.d.ts +1 -0
- package/dist/security/sandbox-manager.d.ts.map +1 -1
- package/dist/security/sandbox-manager.js +11 -0
- package/dist/security/sandbox-manager.js.map +1 -1
- package/dist/services/live-view-manager.d.ts +20 -0
- package/dist/services/live-view-manager.d.ts.map +1 -0
- package/dist/services/live-view-manager.js +114 -0
- package/dist/services/live-view-manager.js.map +1 -0
- package/dist/services/preview.d.ts +16 -1
- package/dist/services/preview.d.ts.map +1 -1
- package/dist/services/preview.js +112 -2
- package/dist/services/preview.js.map +1 -1
- package/dist/surfaces/browser.d.ts +12 -0
- package/dist/surfaces/browser.d.ts.map +1 -1
- package/dist/surfaces/browser.js +31 -1
- package/dist/surfaces/browser.js.map +1 -1
- package/package.json +1 -1
- package/web-dist/assets/{_basePickBy-B5ojxQyY.js → _basePickBy-B2KkoWFz.js} +1 -1
- package/web-dist/assets/{_baseUniq-BVcMC3e3.js → _baseUniq-DFNflT4F.js} +1 -1
- package/web-dist/assets/{arc-B8rKyks5.js → arc-C7JI0CHt.js} +1 -1
- package/web-dist/assets/{architectureDiagram-2XIMDMQ5-D5Rn0_M_.js → architectureDiagram-2XIMDMQ5-bI95Cgh9.js} +1 -1
- package/web-dist/assets/{blockDiagram-WCTKOSBZ-Dn0EedHT.js → blockDiagram-WCTKOSBZ-DgfGN-sd.js} +1 -1
- package/web-dist/assets/{c4Diagram-IC4MRINW-BYTFS9YT.js → c4Diagram-IC4MRINW-xM9CGMLf.js} +1 -1
- package/web-dist/assets/channel-otEtLTdD.js +1 -0
- package/web-dist/assets/{chunk-4BX2VUAB-c51Qw6zZ.js → chunk-4BX2VUAB-C66ZLhus.js} +1 -1
- package/web-dist/assets/{chunk-55IACEB6-BLJEbYZY.js → chunk-55IACEB6-ByPuHMYM.js} +1 -1
- package/web-dist/assets/{chunk-FMBD7UC4-BTQRsQCz.js → chunk-FMBD7UC4-CMH4hMhI.js} +1 -1
- package/web-dist/assets/{chunk-JSJVCQXG-BCQCgV3v.js → chunk-JSJVCQXG-BJLuo8dM.js} +1 -1
- package/web-dist/assets/{chunk-KX2RTZJC-BdxNziNu.js → chunk-KX2RTZJC-CU0ZE2mJ.js} +1 -1
- package/web-dist/assets/{chunk-NQ4KR5QH-DvtJCn0C.js → chunk-NQ4KR5QH-CD4JSx3E.js} +1 -1
- package/web-dist/assets/{chunk-QZHKN3VN-Bv5UUhJr.js → chunk-QZHKN3VN-BhZcwDDX.js} +1 -1
- package/web-dist/assets/{chunk-WL4C6EOR-DgCZzsOT.js → chunk-WL4C6EOR-CScYiORQ.js} +1 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-D3uA1Ef5.js +1 -0
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-D3uA1Ef5.js +1 -0
- package/web-dist/assets/clone-CAAX5MRw.js +1 -0
- package/web-dist/assets/{cose-bilkent-S5V4N54A-CmDdGIef.js → cose-bilkent-S5V4N54A-DTphha5A.js} +1 -1
- package/web-dist/assets/{dagre-KLK3FWXG-BzeF6p1D.js → dagre-KLK3FWXG-Dm5HIzgU.js} +1 -1
- package/web-dist/assets/{diagram-E7M64L7V-lDeWArgl.js → diagram-E7M64L7V-BafxXR5t.js} +1 -1
- package/web-dist/assets/{diagram-IFDJBPK2-BguEZbUg.js → diagram-IFDJBPK2-DDMAYAl_.js} +1 -1
- package/web-dist/assets/{diagram-P4PSJMXO-CnTxg2wa.js → diagram-P4PSJMXO-DHvyv48k.js} +1 -1
- package/web-dist/assets/{erDiagram-INFDFZHY-D2aGee-H.js → erDiagram-INFDFZHY-B_xrbbBo.js} +1 -1
- package/web-dist/assets/{flowDiagram-PKNHOUZH-DYPu_lOt.js → flowDiagram-PKNHOUZH-CRcTFuaU.js} +1 -1
- package/web-dist/assets/{ganttDiagram-A5KZAMGK-D-9aApiK.js → ganttDiagram-A5KZAMGK-CeIGrgW3.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-CGHZTbqZ.js → gitGraphDiagram-K3NZZRJ6-B8p3GzsB.js} +1 -1
- package/web-dist/assets/{graph-xl1n4wd4.js → graph-DgPXX2YH.js} +1 -1
- package/web-dist/assets/{index-CNdW3yYd.js → index-Dyq1wR8W.js} +305 -305
- package/web-dist/assets/{infoDiagram-LFFYTUFH-JQ1DhuIN.js → infoDiagram-LFFYTUFH-C1EleBwJ.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BiQo9puY.js → ishikawaDiagram-PHBUUO56-CY7B0Af8.js} +1 -1
- package/web-dist/assets/{journeyDiagram-4ABVD52K-BWvVCFKb.js → journeyDiagram-4ABVD52K-BEbad9lw.js} +1 -1
- package/web-dist/assets/{kanban-definition-K7BYSVSG-B1pZvgm7.js → kanban-definition-K7BYSVSG-PmiPROs_.js} +1 -1
- package/web-dist/assets/{layout-C_VnOnT4.js → layout-u4nQqZo9.js} +1 -1
- package/web-dist/assets/{linear-BeBoVpvX.js → linear-CYNrNanw.js} +1 -1
- package/web-dist/assets/{mindmap-definition-YRQLILUH-B3U5ZJAw.js → mindmap-definition-YRQLILUH-Ch-jh05Z.js} +1 -1
- package/web-dist/assets/{pieDiagram-SKSYHLDU-B9JMxGDx.js → pieDiagram-SKSYHLDU-ypmvYTXD.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-337W2JSQ-DNAEOevf.js → quadrantDiagram-337W2JSQ-Butg8Ecg.js} +1 -1
- package/web-dist/assets/{requirementDiagram-Z7DCOOCP-Dcgzabvl.js → requirementDiagram-Z7DCOOCP-nj6Myt9w.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-BDcQVCtL.js → sankeyDiagram-WA2Y5GQK-DPAF8v8e.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-2WXFIKYE-5kY7GmoR.js → sequenceDiagram-2WXFIKYE-DVyGYemI.js} +1 -1
- package/web-dist/assets/{stateDiagram-RAJIS63D-BwQlMlEC.js → stateDiagram-RAJIS63D-CstalmXc.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-DidQo5W_.js +1 -0
- package/web-dist/assets/{timeline-definition-YZTLITO2-BE0IDpJe.js → timeline-definition-YZTLITO2-D0D_Mp_k.js} +1 -1
- package/web-dist/assets/{treemap-KZPCXAKY-CHwtWAgO.js → treemap-KZPCXAKY-C9RoKRs9.js} +1 -1
- package/web-dist/assets/{vennDiagram-LZ73GAT5-ByqFK92_.js → vennDiagram-LZ73GAT5-r2eoeYH9.js} +1 -1
- package/web-dist/assets/{xychartDiagram-JWTSCODW-BdCa1f3c.js → xychartDiagram-JWTSCODW-CdE4gaJ1.js} +1 -1
- package/web-dist/index.html +1 -1
- package/web-dist/noVNC/LICENSE.txt +62 -0
- package/web-dist/noVNC/app/error-handler.js +79 -0
- package/web-dist/noVNC/app/images/alt.svg +92 -0
- package/web-dist/noVNC/app/images/clipboard.svg +106 -0
- package/web-dist/noVNC/app/images/connect.svg +96 -0
- package/web-dist/noVNC/app/images/ctrl.svg +96 -0
- package/web-dist/noVNC/app/images/ctrlaltdel.svg +100 -0
- package/web-dist/noVNC/app/images/disconnect.svg +94 -0
- package/web-dist/noVNC/app/images/drag.svg +76 -0
- package/web-dist/noVNC/app/images/error.svg +81 -0
- package/web-dist/noVNC/app/images/esc.svg +92 -0
- package/web-dist/noVNC/app/images/expander.svg +69 -0
- package/web-dist/noVNC/app/images/fullscreen.svg +93 -0
- package/web-dist/noVNC/app/images/handle.svg +82 -0
- package/web-dist/noVNC/app/images/handle_bg.svg +172 -0
- package/web-dist/noVNC/app/images/icons/Makefile +42 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon-sm.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-120.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-152.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-167.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-180.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-40.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-58.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-60.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-80.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-87.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-icon.svg +183 -0
- package/web-dist/noVNC/app/images/icons/novnc.ico +0 -0
- package/web-dist/noVNC/app/images/info.svg +81 -0
- package/web-dist/noVNC/app/images/keyboard.svg +88 -0
- package/web-dist/noVNC/app/images/power.svg +87 -0
- package/web-dist/noVNC/app/images/settings.svg +76 -0
- package/web-dist/noVNC/app/images/tab.svg +86 -0
- package/web-dist/noVNC/app/images/toggleextrakeys.svg +90 -0
- package/web-dist/noVNC/app/images/warning.svg +81 -0
- package/web-dist/noVNC/app/images/windows.svg +65 -0
- package/web-dist/noVNC/app/locale/README +1 -0
- package/web-dist/noVNC/app/locale/cs.json +71 -0
- package/web-dist/noVNC/app/locale/de.json +74 -0
- package/web-dist/noVNC/app/locale/el.json +100 -0
- package/web-dist/noVNC/app/locale/es.json +68 -0
- package/web-dist/noVNC/app/locale/fr.json +82 -0
- package/web-dist/noVNC/app/locale/hu.json +80 -0
- package/web-dist/noVNC/app/locale/it.json +68 -0
- package/web-dist/noVNC/app/locale/ja.json +81 -0
- package/web-dist/noVNC/app/locale/ko.json +70 -0
- package/web-dist/noVNC/app/locale/nl.json +95 -0
- package/web-dist/noVNC/app/locale/pl.json +80 -0
- package/web-dist/noVNC/app/locale/pt_BR.json +72 -0
- package/web-dist/noVNC/app/locale/ru.json +72 -0
- package/web-dist/noVNC/app/locale/sv.json +83 -0
- package/web-dist/noVNC/app/locale/tr.json +69 -0
- package/web-dist/noVNC/app/locale/uk.json +81 -0
- package/web-dist/noVNC/app/locale/zh_CN.json +93 -0
- package/web-dist/noVNC/app/locale/zh_TW.json +69 -0
- package/web-dist/noVNC/app/localization.js +206 -0
- package/web-dist/noVNC/app/sounds/CREDITS +4 -0
- package/web-dist/noVNC/app/sounds/bell.mp3 +0 -0
- package/web-dist/noVNC/app/sounds/bell.oga +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.ttf +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.woff +0 -0
- package/web-dist/noVNC/app/styles/base.css +927 -0
- package/web-dist/noVNC/app/styles/constants.css +30 -0
- package/web-dist/noVNC/app/styles/input.css +628 -0
- package/web-dist/noVNC/app/ui.js +1873 -0
- package/web-dist/noVNC/app/wakelock.js +199 -0
- package/web-dist/noVNC/app/webutil.js +250 -0
- package/web-dist/noVNC/core/base64.js +104 -0
- package/web-dist/noVNC/core/clipboard.js +72 -0
- package/web-dist/noVNC/core/crypto/aes.js +178 -0
- package/web-dist/noVNC/core/crypto/bigint.js +34 -0
- package/web-dist/noVNC/core/crypto/crypto.js +90 -0
- package/web-dist/noVNC/core/crypto/des.js +330 -0
- package/web-dist/noVNC/core/crypto/dh.js +55 -0
- package/web-dist/noVNC/core/crypto/md5.js +82 -0
- package/web-dist/noVNC/core/crypto/rsa.js +132 -0
- package/web-dist/noVNC/core/decoders/copyrect.js +27 -0
- package/web-dist/noVNC/core/decoders/h264.js +321 -0
- package/web-dist/noVNC/core/decoders/hextile.js +181 -0
- package/web-dist/noVNC/core/decoders/jpeg.js +161 -0
- package/web-dist/noVNC/core/decoders/raw.js +59 -0
- package/web-dist/noVNC/core/decoders/rre.js +44 -0
- package/web-dist/noVNC/core/decoders/tight.js +393 -0
- package/web-dist/noVNC/core/decoders/tightpng.js +27 -0
- package/web-dist/noVNC/core/decoders/zlib.js +51 -0
- package/web-dist/noVNC/core/decoders/zrle.js +185 -0
- package/web-dist/noVNC/core/deflator.js +84 -0
- package/web-dist/noVNC/core/display.js +578 -0
- package/web-dist/noVNC/core/encodings.js +54 -0
- package/web-dist/noVNC/core/inflator.js +65 -0
- package/web-dist/noVNC/core/input/domkeytable.js +311 -0
- package/web-dist/noVNC/core/input/fixedkeys.js +129 -0
- package/web-dist/noVNC/core/input/gesturehandler.js +567 -0
- package/web-dist/noVNC/core/input/keyboard.js +294 -0
- package/web-dist/noVNC/core/input/keysym.js +616 -0
- package/web-dist/noVNC/core/input/keysymdef.js +688 -0
- package/web-dist/noVNC/core/input/util.js +191 -0
- package/web-dist/noVNC/core/input/vkeys.js +116 -0
- package/web-dist/noVNC/core/input/xtscancodes.js +173 -0
- package/web-dist/noVNC/core/ra2.js +312 -0
- package/web-dist/noVNC/core/rfb.js +3426 -0
- package/web-dist/noVNC/core/util/browser.js +266 -0
- package/web-dist/noVNC/core/util/cursor.js +249 -0
- package/web-dist/noVNC/core/util/element.js +32 -0
- package/web-dist/noVNC/core/util/events.js +138 -0
- package/web-dist/noVNC/core/util/eventtarget.js +35 -0
- package/web-dist/noVNC/core/util/int.js +15 -0
- package/web-dist/noVNC/core/util/logging.js +56 -0
- package/web-dist/noVNC/core/util/strings.js +28 -0
- package/web-dist/noVNC/core/websock.js +369 -0
- package/web-dist/noVNC/defaults.json +1 -0
- package/web-dist/noVNC/mandatory.json +1 -0
- package/web-dist/noVNC/vendor/pako/LICENSE +21 -0
- package/web-dist/noVNC/vendor/pako/README.md +6 -0
- package/web-dist/noVNC/vendor/pako/lib/utils/common.js +45 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/adler32.js +27 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/constants.js +47 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/crc32.js +36 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/deflate.js +1846 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/gzheader.js +35 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inffast.js +324 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inflate.js +1527 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inftrees.js +322 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/messages.js +11 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/trees.js +1195 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/zstream.js +24 -0
- package/web-dist/noVNC/vnc_lite.html +180 -0
- package/web-dist/assets/channel-DlBBaM6I.js +0 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-DixDm16f.js +0 -1
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-DixDm16f.js +0 -1
- package/web-dist/assets/clone-DEDCKaxV.js +0 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-Bdpt0e9f.js +0 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2019 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*
|
|
8
|
+
* Browser feature support detection
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as Log from './logging.js';
|
|
12
|
+
import Base64 from '../base64.js';
|
|
13
|
+
|
|
14
|
+
// Async clipboard detection
|
|
15
|
+
|
|
16
|
+
/* Evaluates if there is browser support for the async clipboard API and
|
|
17
|
+
* relevant clipboard permissions. Returns 'unsupported' if permission states
|
|
18
|
+
* cannot be resolved. On the other hand, detecting 'granted' or 'prompt'
|
|
19
|
+
* permission states for both read and write indicates full API support with no
|
|
20
|
+
* imposed native browser paste prompt. Conversely, detecting 'denied' indicates
|
|
21
|
+
* the user elected to disable clipboard.
|
|
22
|
+
*/
|
|
23
|
+
export async function browserAsyncClipboardSupport() {
|
|
24
|
+
if (!(navigator?.permissions?.query &&
|
|
25
|
+
navigator?.clipboard?.writeText &&
|
|
26
|
+
navigator?.clipboard?.readText)) {
|
|
27
|
+
return 'unsupported';
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const writePerm = await navigator.permissions.query(
|
|
31
|
+
{name: "clipboard-write", allowWithoutGesture: true});
|
|
32
|
+
const readPerm = await navigator.permissions.query(
|
|
33
|
+
{name: "clipboard-read", allowWithoutGesture: false});
|
|
34
|
+
if (writePerm.state === "denied" || readPerm.state === "denied") {
|
|
35
|
+
return 'denied';
|
|
36
|
+
}
|
|
37
|
+
if ((writePerm.state === "granted" || writePerm.state === "prompt") &&
|
|
38
|
+
(readPerm.state === "granted" || readPerm.state === "prompt")) {
|
|
39
|
+
return 'available';
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
return 'unsupported';
|
|
43
|
+
}
|
|
44
|
+
return 'unsupported';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Touch detection
|
|
48
|
+
export let isTouchDevice = ('ontouchstart' in document.documentElement) ||
|
|
49
|
+
// required for Chrome debugger
|
|
50
|
+
(document.ontouchstart !== undefined) ||
|
|
51
|
+
// required for MS Surface
|
|
52
|
+
(navigator.maxTouchPoints > 0) ||
|
|
53
|
+
(navigator.msMaxTouchPoints > 0);
|
|
54
|
+
window.addEventListener('touchstart', function onFirstTouch() {
|
|
55
|
+
isTouchDevice = true;
|
|
56
|
+
window.removeEventListener('touchstart', onFirstTouch, false);
|
|
57
|
+
}, false);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// The goal is to find a certain physical width, the devicePixelRatio
|
|
61
|
+
// brings us a bit closer but is not optimal.
|
|
62
|
+
export let dragThreshold = 10 * (window.devicePixelRatio || 1);
|
|
63
|
+
|
|
64
|
+
let _supportsCursorURIs = false;
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const target = document.createElement('canvas');
|
|
68
|
+
target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
|
|
69
|
+
|
|
70
|
+
if (target.style.cursor.indexOf("url") === 0) {
|
|
71
|
+
Log.Info("Data URI scheme cursor supported");
|
|
72
|
+
_supportsCursorURIs = true;
|
|
73
|
+
} else {
|
|
74
|
+
Log.Warn("Data URI scheme cursor not supported");
|
|
75
|
+
}
|
|
76
|
+
} catch (exc) {
|
|
77
|
+
Log.Error("Data URI scheme cursor test exception: " + exc);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const supportsCursorURIs = _supportsCursorURIs;
|
|
81
|
+
|
|
82
|
+
let _hasScrollbarGutter = true;
|
|
83
|
+
try {
|
|
84
|
+
// Create invisible container
|
|
85
|
+
const container = document.createElement('div');
|
|
86
|
+
container.style.visibility = 'hidden';
|
|
87
|
+
container.style.overflow = 'scroll'; // forcing scrollbars
|
|
88
|
+
document.body.appendChild(container);
|
|
89
|
+
|
|
90
|
+
// Create a div and place it in the container
|
|
91
|
+
const child = document.createElement('div');
|
|
92
|
+
container.appendChild(child);
|
|
93
|
+
|
|
94
|
+
// Calculate the difference between the container's full width
|
|
95
|
+
// and the child's width - the difference is the scrollbars
|
|
96
|
+
const scrollbarWidth = (container.offsetWidth - child.offsetWidth);
|
|
97
|
+
|
|
98
|
+
// Clean up
|
|
99
|
+
container.parentNode.removeChild(container);
|
|
100
|
+
|
|
101
|
+
_hasScrollbarGutter = scrollbarWidth != 0;
|
|
102
|
+
} catch (exc) {
|
|
103
|
+
Log.Error("Scrollbar test exception: " + exc);
|
|
104
|
+
}
|
|
105
|
+
export const hasScrollbarGutter = _hasScrollbarGutter;
|
|
106
|
+
|
|
107
|
+
export let supportsWebCodecsH264Decode = false;
|
|
108
|
+
|
|
109
|
+
async function _checkWebCodecsH264DecodeSupport() {
|
|
110
|
+
if (!('VideoDecoder' in window)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// We'll need to make do with some placeholders here
|
|
115
|
+
const config = {
|
|
116
|
+
codec: 'avc1.42401f',
|
|
117
|
+
codedWidth: 1920,
|
|
118
|
+
codedHeight: 1080,
|
|
119
|
+
optimizeForLatency: true,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
let support = await VideoDecoder.isConfigSupported(config);
|
|
123
|
+
if (!support.supported) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Firefox incorrectly reports supports for H.264 under some
|
|
128
|
+
// circumstances, so we need to actually test a real frame
|
|
129
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1932392
|
|
130
|
+
|
|
131
|
+
const data = new Uint8Array(Base64.decode(
|
|
132
|
+
'AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4Hc' +
|
|
133
|
+
'Rem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5Zjkg' +
|
|
134
|
+
'LSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIz' +
|
|
135
|
+
'IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9u' +
|
|
136
|
+
'czogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4' +
|
|
137
|
+
'MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4' +
|
|
138
|
+
'ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4' +
|
|
139
|
+
'OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJv' +
|
|
140
|
+
'bWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0x' +
|
|
141
|
+
'IHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9' +
|
|
142
|
+
'MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVz' +
|
|
143
|
+
'PTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNj' +
|
|
144
|
+
'ZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9' +
|
|
145
|
+
'YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAu' +
|
|
146
|
+
'NjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFx' +
|
|
147
|
+
'PTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw=='));
|
|
148
|
+
|
|
149
|
+
let gotframe = false;
|
|
150
|
+
let error = null;
|
|
151
|
+
|
|
152
|
+
let decoder = new VideoDecoder({
|
|
153
|
+
output: (frame) => { gotframe = true; frame.close(); },
|
|
154
|
+
error: (e) => { error = e; },
|
|
155
|
+
});
|
|
156
|
+
let chunk = new EncodedVideoChunk({
|
|
157
|
+
timestamp: 0,
|
|
158
|
+
type: 'key',
|
|
159
|
+
data: data,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
decoder.configure(config);
|
|
163
|
+
decoder.decode(chunk);
|
|
164
|
+
try {
|
|
165
|
+
await decoder.flush();
|
|
166
|
+
} catch (e) {
|
|
167
|
+
// Firefox incorrectly throws an exception here
|
|
168
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1932566
|
|
169
|
+
error = e;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Firefox fails to deliver the error on Windows, so we need to
|
|
173
|
+
// check if we got a frame instead
|
|
174
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1932579
|
|
175
|
+
if (!gotframe) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (error !== null) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
supportsWebCodecsH264Decode = await _checkWebCodecsH264DecodeSupport();
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
* The functions for detection of platforms and browsers below are exported
|
|
189
|
+
* but the use of these should be minimized as much as possible.
|
|
190
|
+
*
|
|
191
|
+
* It's better to use feature detection than platform detection.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
/* OS */
|
|
195
|
+
|
|
196
|
+
export function isMac() {
|
|
197
|
+
return !!(/mac/i).exec(navigator.platform);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function isWindows() {
|
|
201
|
+
return !!(/win/i).exec(navigator.platform);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function isIOS() {
|
|
205
|
+
return (!!(/ipad/i).exec(navigator.platform) ||
|
|
206
|
+
!!(/iphone/i).exec(navigator.platform) ||
|
|
207
|
+
!!(/ipod/i).exec(navigator.platform));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function isAndroid() {
|
|
211
|
+
/* Android sets navigator.platform to Linux :/ */
|
|
212
|
+
return !!navigator.userAgent.match('Android ');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function isChromeOS() {
|
|
216
|
+
/* ChromeOS sets navigator.platform to Linux :/ */
|
|
217
|
+
return !!navigator.userAgent.match(' CrOS ');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Browser */
|
|
221
|
+
|
|
222
|
+
export function isSafari() {
|
|
223
|
+
return !!navigator.userAgent.match('Safari/...') &&
|
|
224
|
+
!navigator.userAgent.match('Chrome/...') &&
|
|
225
|
+
!navigator.userAgent.match('Chromium/...') &&
|
|
226
|
+
!navigator.userAgent.match('Epiphany/...');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function isFirefox() {
|
|
230
|
+
return !!navigator.userAgent.match('Firefox/...') &&
|
|
231
|
+
!navigator.userAgent.match('Seamonkey/...');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function isChrome() {
|
|
235
|
+
return !!navigator.userAgent.match('Chrome/...') &&
|
|
236
|
+
!navigator.userAgent.match('Chromium/...') &&
|
|
237
|
+
!navigator.userAgent.match('Edg/...') &&
|
|
238
|
+
!navigator.userAgent.match('OPR/...');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function isChromium() {
|
|
242
|
+
return !!navigator.userAgent.match('Chromium/...');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function isOpera() {
|
|
246
|
+
return !!navigator.userAgent.match('OPR/...');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function isEdge() {
|
|
250
|
+
return !!navigator.userAgent.match('Edg/...');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* Engine */
|
|
254
|
+
|
|
255
|
+
export function isGecko() {
|
|
256
|
+
return !!navigator.userAgent.match('Gecko/...');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function isWebKit() {
|
|
260
|
+
return !!navigator.userAgent.match('AppleWebKit/...') &&
|
|
261
|
+
!navigator.userAgent.match('Chrome/...');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function isBlink() {
|
|
265
|
+
return !!navigator.userAgent.match('Chrome/...');
|
|
266
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2019 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { supportsCursorURIs, isTouchDevice } from './browser.js';
|
|
8
|
+
|
|
9
|
+
const useFallback = !supportsCursorURIs || isTouchDevice;
|
|
10
|
+
|
|
11
|
+
export default class Cursor {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._target = null;
|
|
14
|
+
|
|
15
|
+
this._canvas = document.createElement('canvas');
|
|
16
|
+
|
|
17
|
+
if (useFallback) {
|
|
18
|
+
this._canvas.style.position = 'fixed';
|
|
19
|
+
this._canvas.style.zIndex = '65535';
|
|
20
|
+
this._canvas.style.pointerEvents = 'none';
|
|
21
|
+
// Safari on iOS can select the cursor image
|
|
22
|
+
// https://bugs.webkit.org/show_bug.cgi?id=249223
|
|
23
|
+
this._canvas.style.userSelect = 'none';
|
|
24
|
+
this._canvas.style.WebkitUserSelect = 'none';
|
|
25
|
+
// Can't use "display" because of Firefox bug #1445997
|
|
26
|
+
this._canvas.style.visibility = 'hidden';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this._position = { x: 0, y: 0 };
|
|
30
|
+
this._hotSpot = { x: 0, y: 0 };
|
|
31
|
+
|
|
32
|
+
this._eventHandlers = {
|
|
33
|
+
'mouseover': this._handleMouseOver.bind(this),
|
|
34
|
+
'mouseleave': this._handleMouseLeave.bind(this),
|
|
35
|
+
'mousemove': this._handleMouseMove.bind(this),
|
|
36
|
+
'mouseup': this._handleMouseUp.bind(this),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
attach(target) {
|
|
41
|
+
if (this._target) {
|
|
42
|
+
this.detach();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this._target = target;
|
|
46
|
+
|
|
47
|
+
if (useFallback) {
|
|
48
|
+
document.body.appendChild(this._canvas);
|
|
49
|
+
|
|
50
|
+
const options = { capture: true, passive: true };
|
|
51
|
+
this._target.addEventListener('mouseover', this._eventHandlers.mouseover, options);
|
|
52
|
+
this._target.addEventListener('mouseleave', this._eventHandlers.mouseleave, options);
|
|
53
|
+
this._target.addEventListener('mousemove', this._eventHandlers.mousemove, options);
|
|
54
|
+
this._target.addEventListener('mouseup', this._eventHandlers.mouseup, options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.clear();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
detach() {
|
|
61
|
+
if (!this._target) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (useFallback) {
|
|
66
|
+
const options = { capture: true, passive: true };
|
|
67
|
+
this._target.removeEventListener('mouseover', this._eventHandlers.mouseover, options);
|
|
68
|
+
this._target.removeEventListener('mouseleave', this._eventHandlers.mouseleave, options);
|
|
69
|
+
this._target.removeEventListener('mousemove', this._eventHandlers.mousemove, options);
|
|
70
|
+
this._target.removeEventListener('mouseup', this._eventHandlers.mouseup, options);
|
|
71
|
+
|
|
72
|
+
if (document.contains(this._canvas)) {
|
|
73
|
+
document.body.removeChild(this._canvas);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this._target = null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
change(rgba, hotx, hoty, w, h) {
|
|
81
|
+
if ((w === 0) || (h === 0)) {
|
|
82
|
+
this.clear();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this._position.x = this._position.x + this._hotSpot.x - hotx;
|
|
87
|
+
this._position.y = this._position.y + this._hotSpot.y - hoty;
|
|
88
|
+
this._hotSpot.x = hotx;
|
|
89
|
+
this._hotSpot.y = hoty;
|
|
90
|
+
|
|
91
|
+
let ctx = this._canvas.getContext('2d');
|
|
92
|
+
|
|
93
|
+
this._canvas.width = w;
|
|
94
|
+
this._canvas.height = h;
|
|
95
|
+
|
|
96
|
+
let img = new ImageData(new Uint8ClampedArray(rgba), w, h);
|
|
97
|
+
ctx.clearRect(0, 0, w, h);
|
|
98
|
+
ctx.putImageData(img, 0, 0);
|
|
99
|
+
|
|
100
|
+
if (useFallback) {
|
|
101
|
+
this._updatePosition();
|
|
102
|
+
} else {
|
|
103
|
+
let url = this._canvas.toDataURL();
|
|
104
|
+
this._target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
clear() {
|
|
109
|
+
this._target.style.cursor = 'none';
|
|
110
|
+
this._canvas.width = 0;
|
|
111
|
+
this._canvas.height = 0;
|
|
112
|
+
this._position.x = this._position.x + this._hotSpot.x;
|
|
113
|
+
this._position.y = this._position.y + this._hotSpot.y;
|
|
114
|
+
this._hotSpot.x = 0;
|
|
115
|
+
this._hotSpot.y = 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Mouse events might be emulated, this allows
|
|
119
|
+
// moving the cursor in such cases
|
|
120
|
+
move(clientX, clientY) {
|
|
121
|
+
if (!useFallback) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// clientX/clientY are relative the _visual viewport_,
|
|
125
|
+
// but our position is relative the _layout viewport_,
|
|
126
|
+
// so try to compensate when we can
|
|
127
|
+
if (window.visualViewport) {
|
|
128
|
+
this._position.x = clientX + window.visualViewport.offsetLeft;
|
|
129
|
+
this._position.y = clientY + window.visualViewport.offsetTop;
|
|
130
|
+
} else {
|
|
131
|
+
this._position.x = clientX;
|
|
132
|
+
this._position.y = clientY;
|
|
133
|
+
}
|
|
134
|
+
this._updatePosition();
|
|
135
|
+
let target = document.elementFromPoint(clientX, clientY);
|
|
136
|
+
this._updateVisibility(target);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_handleMouseOver(event) {
|
|
140
|
+
// This event could be because we're entering the target, or
|
|
141
|
+
// moving around amongst its sub elements. Let the move handler
|
|
142
|
+
// sort things out.
|
|
143
|
+
this._handleMouseMove(event);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_handleMouseLeave(event) {
|
|
147
|
+
// Check if we should show the cursor on the element we are leaving to
|
|
148
|
+
this._updateVisibility(event.relatedTarget);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_handleMouseMove(event) {
|
|
152
|
+
this._updateVisibility(event.target);
|
|
153
|
+
|
|
154
|
+
this._position.x = event.clientX - this._hotSpot.x;
|
|
155
|
+
this._position.y = event.clientY - this._hotSpot.y;
|
|
156
|
+
|
|
157
|
+
this._updatePosition();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_handleMouseUp(event) {
|
|
161
|
+
// We might get this event because of a drag operation that
|
|
162
|
+
// moved outside of the target. Check what's under the cursor
|
|
163
|
+
// now and adjust visibility based on that.
|
|
164
|
+
let target = document.elementFromPoint(event.clientX, event.clientY);
|
|
165
|
+
this._updateVisibility(target);
|
|
166
|
+
|
|
167
|
+
// Captures end with a mouseup but we can't know the event order of
|
|
168
|
+
// mouseup vs releaseCapture.
|
|
169
|
+
//
|
|
170
|
+
// In the cases when releaseCapture comes first, the code above is
|
|
171
|
+
// enough.
|
|
172
|
+
//
|
|
173
|
+
// In the cases when the mouseup comes first, we need wait for the
|
|
174
|
+
// browser to flush all events and then check again if the cursor
|
|
175
|
+
// should be visible.
|
|
176
|
+
if (this._captureIsActive()) {
|
|
177
|
+
window.setTimeout(() => {
|
|
178
|
+
// We might have detached at this point
|
|
179
|
+
if (!this._target) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Refresh the target from elementFromPoint since queued events
|
|
183
|
+
// might have altered the DOM
|
|
184
|
+
target = document.elementFromPoint(event.clientX,
|
|
185
|
+
event.clientY);
|
|
186
|
+
this._updateVisibility(target);
|
|
187
|
+
}, 0);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_showCursor() {
|
|
192
|
+
if (this._canvas.style.visibility === 'hidden') {
|
|
193
|
+
this._canvas.style.visibility = '';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_hideCursor() {
|
|
198
|
+
if (this._canvas.style.visibility !== 'hidden') {
|
|
199
|
+
this._canvas.style.visibility = 'hidden';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Should we currently display the cursor?
|
|
204
|
+
// (i.e. are we over the target, or a child of the target without a
|
|
205
|
+
// different cursor set)
|
|
206
|
+
_shouldShowCursor(target) {
|
|
207
|
+
if (!target) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
// Easy case
|
|
211
|
+
if (target === this._target) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
// Other part of the DOM?
|
|
215
|
+
if (!this._target.contains(target)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
// Has the child its own cursor?
|
|
219
|
+
// FIXME: How can we tell that a sub element has an
|
|
220
|
+
// explicit "cursor: none;"?
|
|
221
|
+
if (window.getComputedStyle(target).cursor !== 'none') {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
_updateVisibility(target) {
|
|
228
|
+
// When the cursor target has capture we want to show the cursor.
|
|
229
|
+
// So, if a capture is active - look at the captured element instead.
|
|
230
|
+
if (this._captureIsActive()) {
|
|
231
|
+
target = document.captureElement;
|
|
232
|
+
}
|
|
233
|
+
if (this._shouldShowCursor(target)) {
|
|
234
|
+
this._showCursor();
|
|
235
|
+
} else {
|
|
236
|
+
this._hideCursor();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_updatePosition() {
|
|
241
|
+
this._canvas.style.left = this._position.x + "px";
|
|
242
|
+
this._canvas.style.top = this._position.y + "px";
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_captureIsActive() {
|
|
246
|
+
return document.captureElement &&
|
|
247
|
+
document.documentElement.contains(document.captureElement);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2020 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* HTML element utility functions
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export function clientToElement(x, y, elem) {
|
|
14
|
+
const bounds = elem.getBoundingClientRect();
|
|
15
|
+
let pos = { x: 0, y: 0 };
|
|
16
|
+
// Clip to target bounds
|
|
17
|
+
if (x < bounds.left) {
|
|
18
|
+
pos.x = 0;
|
|
19
|
+
} else if (x >= bounds.right) {
|
|
20
|
+
pos.x = bounds.width - 1;
|
|
21
|
+
} else {
|
|
22
|
+
pos.x = x - bounds.left;
|
|
23
|
+
}
|
|
24
|
+
if (y < bounds.top) {
|
|
25
|
+
pos.y = 0;
|
|
26
|
+
} else if (y >= bounds.bottom) {
|
|
27
|
+
pos.y = bounds.height - 1;
|
|
28
|
+
} else {
|
|
29
|
+
pos.y = y - bounds.top;
|
|
30
|
+
}
|
|
31
|
+
return pos;
|
|
32
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2018 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Cross-browser event and position routines
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export function getPointerEvent(e) {
|
|
14
|
+
return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function stopEvent(e) {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Emulate Element.setCapture() when not supported
|
|
23
|
+
let _captureRecursion = false;
|
|
24
|
+
let _elementForUnflushedEvents = null;
|
|
25
|
+
document.captureElement = null;
|
|
26
|
+
function _captureProxy(e) {
|
|
27
|
+
// Recursion protection as we'll see our own event
|
|
28
|
+
if (_captureRecursion) return;
|
|
29
|
+
|
|
30
|
+
// Clone the event as we cannot dispatch an already dispatched event
|
|
31
|
+
const newEv = new e.constructor(e.type, e);
|
|
32
|
+
|
|
33
|
+
_captureRecursion = true;
|
|
34
|
+
if (document.captureElement) {
|
|
35
|
+
document.captureElement.dispatchEvent(newEv);
|
|
36
|
+
} else {
|
|
37
|
+
_elementForUnflushedEvents.dispatchEvent(newEv);
|
|
38
|
+
}
|
|
39
|
+
_captureRecursion = false;
|
|
40
|
+
|
|
41
|
+
// Avoid double events
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
|
|
44
|
+
// Respect the wishes of the redirected event handlers
|
|
45
|
+
if (newEv.defaultPrevented) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Implicitly release the capture on button release
|
|
50
|
+
if (e.type === "mouseup") {
|
|
51
|
+
releaseCapture();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Follow cursor style of target element
|
|
56
|
+
function _capturedElemChanged() {
|
|
57
|
+
const proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
58
|
+
proxyElem.style.cursor = window.getComputedStyle(document.captureElement).cursor;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const _captureObserver = new MutationObserver(_capturedElemChanged);
|
|
62
|
+
|
|
63
|
+
export function setCapture(target) {
|
|
64
|
+
if (target.setCapture) {
|
|
65
|
+
|
|
66
|
+
target.setCapture();
|
|
67
|
+
document.captureElement = target;
|
|
68
|
+
} else {
|
|
69
|
+
// Release any existing capture in case this method is
|
|
70
|
+
// called multiple times without coordination
|
|
71
|
+
releaseCapture();
|
|
72
|
+
|
|
73
|
+
let proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
74
|
+
|
|
75
|
+
if (proxyElem === null) {
|
|
76
|
+
proxyElem = document.createElement("div");
|
|
77
|
+
proxyElem.id = "noVNC_mouse_capture_elem";
|
|
78
|
+
proxyElem.style.position = "fixed";
|
|
79
|
+
proxyElem.style.top = "0px";
|
|
80
|
+
proxyElem.style.left = "0px";
|
|
81
|
+
proxyElem.style.width = "100%";
|
|
82
|
+
proxyElem.style.height = "100%";
|
|
83
|
+
proxyElem.style.zIndex = 10000;
|
|
84
|
+
proxyElem.style.display = "none";
|
|
85
|
+
document.body.appendChild(proxyElem);
|
|
86
|
+
|
|
87
|
+
// This is to make sure callers don't get confused by having
|
|
88
|
+
// our blocking element as the target
|
|
89
|
+
proxyElem.addEventListener('contextmenu', _captureProxy);
|
|
90
|
+
|
|
91
|
+
proxyElem.addEventListener('mousemove', _captureProxy);
|
|
92
|
+
proxyElem.addEventListener('mouseup', _captureProxy);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
document.captureElement = target;
|
|
96
|
+
|
|
97
|
+
// Track cursor and get initial cursor
|
|
98
|
+
_captureObserver.observe(target, {attributes: true});
|
|
99
|
+
_capturedElemChanged();
|
|
100
|
+
|
|
101
|
+
proxyElem.style.display = "";
|
|
102
|
+
|
|
103
|
+
// We listen to events on window in order to keep tracking if it
|
|
104
|
+
// happens to leave the viewport
|
|
105
|
+
window.addEventListener('mousemove', _captureProxy);
|
|
106
|
+
window.addEventListener('mouseup', _captureProxy);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function releaseCapture() {
|
|
111
|
+
if (document.releaseCapture) {
|
|
112
|
+
|
|
113
|
+
document.releaseCapture();
|
|
114
|
+
document.captureElement = null;
|
|
115
|
+
|
|
116
|
+
} else {
|
|
117
|
+
if (!document.captureElement) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// There might be events already queued. The event proxy needs
|
|
122
|
+
// access to the captured element for these queued events.
|
|
123
|
+
// E.g. contextmenu (right-click) in Microsoft Edge
|
|
124
|
+
//
|
|
125
|
+
// Before removing the capturedElem pointer we save it to a
|
|
126
|
+
// temporary variable that the unflushed events can use.
|
|
127
|
+
_elementForUnflushedEvents = document.captureElement;
|
|
128
|
+
document.captureElement = null;
|
|
129
|
+
|
|
130
|
+
_captureObserver.disconnect();
|
|
131
|
+
|
|
132
|
+
const proxyElem = document.getElementById("noVNC_mouse_capture_elem");
|
|
133
|
+
proxyElem.style.display = "none";
|
|
134
|
+
|
|
135
|
+
window.removeEventListener('mousemove', _captureProxy);
|
|
136
|
+
window.removeEventListener('mouseup', _captureProxy);
|
|
137
|
+
}
|
|
138
|
+
}
|