Skip to content

Commit 5c46b2e

Browse files
authored
Feature/kasm 6894 remove webpack to reduce vulnerabilities (#128)
* KASM-6894 Remove Webpack to reduce vulnerabilities, update packages
1 parent 46412d2 commit 5c46b2e

File tree

6 files changed

+93
-29788
lines changed

6 files changed

+93
-29788
lines changed

app/ui.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ window.updateSetting = (name, value) => {
2525
}
2626
}
2727

28+
import '@interactjs/pointer-events'
29+
import '@interactjs/actions/drag'
30+
import interact from '@interactjs/interact';
2831
import "core-js/stable";
2932
import "regenerator-runtime/runtime";
3033
import * as Log from '../core/util/logging.js';
@@ -67,6 +70,7 @@ const UI = {
6770
selectedMonitor: null,
6871
refreshRotation: 0,
6972
currentDisplay: null,
73+
displayWindows: ['primary'],
7074

7175
supportsBroadcastChannel: (typeof BroadcastChannel !== "undefined"),
7276

@@ -84,7 +88,13 @@ const UI = {
8488

8589
// Render default UI and initialize settings menu
8690
start() {
87-
//initialize settings then apply quality presents
91+
92+
// If secondary monitor skip init
93+
if (window.location.href.includes("screen.html")) {
94+
return;
95+
}
96+
97+
// Initialize settings then apply quality presents
8898
UI.initSettings();
8999
UI.updateQuality();
90100

@@ -265,6 +275,7 @@ const UI = {
265275
UI.initSetting('prefer_local_cursor', true);
266276
UI.initSetting('toggle_control_panel', false);
267277
UI.initSetting('enable_perf_stats', false);
278+
UI.initSetting('enable_threading', true);
268279
UI.initSetting('virtual_keyboard_visible', false);
269280
UI.initSetting('enable_ime', false);
270281
UI.initSetting('enable_webrtc', false);
@@ -529,6 +540,7 @@ const UI = {
529540
UI.addClickHandle('noVNC_settings_button', UI.toggleSettingsPanel);
530541

531542
document.getElementById("noVNC_setting_enable_perf_stats").addEventListener('click', UI.showStats);
543+
document.getElementById("noVNC_setting_enable_threading").addEventListener('click', UI.threading);
532544
document.getElementById("noVNC_auto_placement").addEventListener('change', UI.setAutoPlacement);
533545

534546
UI.addSettingChangeHandler('encrypt');
@@ -597,6 +609,8 @@ const UI = {
597609
UI.addSettingChangeHandler('enable_webrtc', UI.toggleWebRTC);
598610
UI.addSettingChangeHandler('enable_hidpi');
599611
UI.addSettingChangeHandler('enable_hidpi', UI.enableHiDpi);
612+
UI.addSettingChangeHandler('enable_threading');
613+
UI.addSettingChangeHandler('enable_threading', UI.threading);
600614
},
601615

602616
addFullscreenHandlers() {
@@ -742,6 +756,17 @@ const UI = {
742756

743757
},
744758

759+
threading() {
760+
if (UI.rfb) {
761+
if (UI.getSetting('enable_threading')) {
762+
UI.rfb.threading = true;
763+
} else {
764+
UI.rfb.threading = false;
765+
}
766+
}
767+
UI.saveSetting('enable_threading');
768+
},
769+
745770
showStatus(text, statusType, time, kasm = false) {
746771
// If inside the full Kasm CDI framework, don't show messages unless explicitly told to
747772
if (WebUtil.isInsideKasmVDI() && !kasm) {
@@ -1482,6 +1507,7 @@ const UI = {
14821507
UI.rfb.clipboardBinary = supportsBinaryClipboard() && UI.rfb.clipboardSeamless;
14831508
UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc');
14841509
UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi');
1510+
UI.rfb.threading = UI.getSetting('enable_threading');
14851511
UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper();
14861512
if (UI.rfb.videoQuality === 5) {
14871513
UI.rfb.enableQOI = true;
@@ -1792,6 +1818,10 @@ const UI = {
17921818
case 'control_displays':
17931819
parent.postMessage({ action: 'can_control_displays', value: true}, '*' );
17941820
break;
1821+
case 'enable_threading':
1822+
UI.forceSetting('enable_threading', event.data.value, false);
1823+
UI.threading();
1824+
break;
17951825
case 'terminate':
17961826
//terminate a session, different then disconnect in that it is assumed KasmVNC will be shutdown
17971827
if (UI.rfb) {
@@ -1892,6 +1922,7 @@ const UI = {
18921922
UI.rfb.videoQuality = UI.getSetting('video_quality');
18931923
UI.rfb.enableWebP = UI.getSetting('enable_webp');
18941924
UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi');
1925+
UI.rfb.threading = UI.getSetting('enable_threading');
18951926

18961927
if (UI.rfb.resizeSession) {
18971928
UI.rfb.forcedResolutionX = null;
@@ -1982,8 +2013,9 @@ const UI = {
19822013
const current = UI.increaseCurrentDisplay(details)
19832014
let screen = details.screens[current]
19842015
const options = 'left='+screen.availLeft+',top='+screen.availTop+',width='+screen.availWidth+',height='+screen.availHeight+',fullscreen'
1985-
window.open(new_display_url, '_blank', options);
1986-
return
2016+
let newdisplay = window.open(new_display_url, '_blank', options);
2017+
UI.displayWindows.push(newdisplay);
2018+
return;
19872019
}
19882020
} catch (e) {
19892021
console.log(e)
@@ -1992,7 +2024,8 @@ const UI = {
19922024
}
19932025

19942026
Log.Debug(`Opening a secondary display ${new_display_url}`)
1995-
window.open(new_display_url, '_blank', 'toolbar=0,location=0,menubar=0');
2027+
let newdisplay = window.open(new_display_url, '_blank', 'toolbar=0,location=0,menubar=0');
2028+
UI.displayWindows.push(newdisplay);
19962029
},
19972030

19982031
initMonitors(screenPlan) {
@@ -2545,6 +2578,7 @@ const UI = {
25452578
UI.rfb.videoQuality = parseInt(UI.getSetting('video_quality'));
25462579
UI.rfb.enableQOI = enable_qoi;
25472580
UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi');
2581+
UI.rfb.threading = UI.getSetting('enable_threading');
25482582

25492583
// Gracefully update settings server side
25502584
UI.rfb.updateConnectionSettings();

vnc.html renamed to index.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,9 @@
4747
<link rel="apple-touch-icon" sizes="120x120" type="image/png" href="app/images/icons/368_kasm_logo_only_120x120.png">
4848
<link rel="apple-touch-icon" sizes="152x152" type="image/png" href="app/images/icons/368_kasm_logo_only_152x152.png">
4949

50-
<script src="vendor/interact.min.js"></script>
50+
<link rel="stylesheet" href="app/styles/base.css">
5151

52-
<!-- Stylesheets -->
53-
<!--link rel="stylesheet" href="app/styles/base.css">
54-
55-
<script src="app/error-handler.js"></script>
52+
<script type="module" src="app/error-handler.js"></script>
5653

5754
<script>
5855
let isInsideKasmVDI = false;
@@ -63,7 +60,7 @@
6360
}
6461
</script>
6562

66-
<script type="module" crossorigin="use-credentials" src="app/ui.js"></script-->
63+
<script type="module" crossorigin="use-credentials" src="app/ui.js"></script>
6764
</head>
6865

6966
<body>
@@ -275,6 +272,13 @@ <h1 class="noVNC_logo">
275272
<span class="slider-label">Enable Performance Stats</span>
276273
</label>
277274
</li>
275+
<li>
276+
<label class="switch">
277+
<input id="noVNC_setting_enable_threading" type="checkbox" />
278+
<span class="slider round"></span>
279+
<span class="slider-label">Enable Threaded Decoding</span>
280+
</label>
281+
</li>
278282
<li>
279283
<label class="switch">
280284
<input type="checkbox" id="noVNC_setting_pointer_lock" />

0 commit comments

Comments
 (0)