Fix VNC connection dropping immediately after connect

- Replace ws_send_frame with ws_send_binary_frame for VNC WebSocket data
- This ensures proper binary frame handling for VNC protocol data
- Fixes immediate disconnection after 'VNC connected' message
parent e4033f9f
# Makefile for wssshd2 - Generated by configure.sh
# Do not edit manually, run ./configure.sh instead
CC = gcc
CFLAGS = -Wall -Wextra -O2 -I. -pthread
LDFLAGS = -lssl -lcrypto -lm -luuid -lsqlite3
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
CONFIGDIR = /etc
# Source files
SRCS = main.c config.c tunnel.c terminal.c vnc.c websocket.c websocket_protocol.c web.c assets.c ssl.c
OBJS = $(SRCS:.c=.o)
# Target
TARGET = wssshd
.PHONY: all clean install uninstall
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Dependencies
main.o: main.c config.h websocket.h web.h
config.o: config.c config.h
tunnel.o: tunnel.c tunnel.h websocket.h
terminal.o: terminal.c terminal.h config.h
vnc.o: vnc.c vnc.h config.h
websocket.o: websocket.c websocket.h websocket_protocol.h config.h
websocket_protocol.o: websocket_protocol.c websocket_protocol.h
web.o: web.c web.h terminal.h vnc.h assets.h websocket.h html_pages/index_page.h html_pages/login_page.h html_pages/terminal_page.h html_pages/vnc_page.h html_pages/users_page.h
assets.o: assets.c assets.h
ssl.o: ssl.c ssl.h
# Asset embedding (run before compilation)
assets.o: image_data.h
image_data.h: embed_assets.sh
./embed_assets.sh
# HTML page generation
html_pages/index_page.h html_pages/login_page.h html_pages/terminal_page.h html_pages/vnc_page.h: embed_assets.sh
./embed_assets.sh
clean:
rm -f $(OBJS) $(TARGET) image_data.h favicon_data.h
install: $(TARGET)
install -d $(DESTDIR)$(BINDIR)
install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/
install -d $(DESTDIR)$(CONFIGDIR)
[ -f $(DESTDIR)$(CONFIGDIR)/wssshd.conf ] || install -m 644 wssshd.conf.example $(DESTDIR)$(CONFIGDIR)/wssshd.conf
install -d $(DESTDIR)$(MANDIR)/man8
install -m 644 wssshd.8 $(DESTDIR)$(MANDIR)/man8/
uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(TARGET)
rm -f $(DESTDIR)$(MANDIR)/man8/wssshd.8
# Development targets
debug: CFLAGS += -g -DDEBUG
debug: clean all
test: $(TARGET)
@echo "Running basic functionality test..."
./$(TARGET) --help || true
distclean: clean
rm -f Makefile
# Help target
help:
@echo "Available targets:"
@echo " all - Build wssshd2 (default)"
@echo " clean - Remove build artifacts"
@echo " install - Install wssshd2 to system"
@echo " uninstall - Remove wssshd2 from system"
@echo " debug - Build with debug symbols"
@echo " test - Run basic tests"
@echo " distclean - Remove all generated files"
@echo " help - Show this help"
...@@ -41,6 +41,7 @@ static void set_default_config(wssshd_config_t *config) { ...@@ -41,6 +41,7 @@ static void set_default_config(wssshd_config_t *config) {
config->debug = false; config->debug = false;
config->debug_web = false; config->debug_web = false;
config->debug_database = false; config->debug_database = false;
config->debug_vnc = false;
} }
static void load_config_file(wssshd_config_t *config, const char *config_file) { static void load_config_file(wssshd_config_t *config, const char *config_file) {
...@@ -156,6 +157,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) { ...@@ -156,6 +157,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) {
{"debug", no_argument, 0, 'D'}, {"debug", no_argument, 0, 'D'},
{"debug-web", no_argument, 0, 'E'}, {"debug-web", no_argument, 0, 'E'},
{"debug-database", no_argument, 0, 'F'}, {"debug-database", no_argument, 0, 'F'},
{"debug-vnc", no_argument, 0, 'G'},
{"help", no_argument, 0, '?'}, {"help", no_argument, 0, '?'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
...@@ -163,7 +165,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) { ...@@ -163,7 +165,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) {
int opt; int opt;
int option_index = 0; int option_index = 0;
while ((opt = getopt_long(argc, argv, "c:h:p:d:P:w:W:stDEF?", long_options, &option_index)) != -1) { while ((opt = getopt_long(argc, argv, "c:h:p:d:P:w:W:stDEFG?", long_options, &option_index)) != -1) {
switch (opt) { switch (opt) {
case 'c': case 'c':
if (config->config_file) free(config->config_file); if (config->config_file) free(config->config_file);
...@@ -206,6 +208,9 @@ wssshd_config_t *load_config(int argc, char *argv[]) { ...@@ -206,6 +208,9 @@ wssshd_config_t *load_config(int argc, char *argv[]) {
case 'F': case 'F':
config->debug_database = true; config->debug_database = true;
break; break;
case 'G':
config->debug_vnc = true;
break;
case '?': case '?':
printf("Usage: %s [OPTIONS]\n", argv[0]); printf("Usage: %s [OPTIONS]\n", argv[0]);
printf("Options:\n"); printf("Options:\n");
...@@ -221,6 +226,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) { ...@@ -221,6 +226,7 @@ wssshd_config_t *load_config(int argc, char *argv[]) {
printf(" --debug Enable debug output\n"); printf(" --debug Enable debug output\n");
printf(" --debug-web Enable comprehensive web interface debug output\n"); printf(" --debug-web Enable comprehensive web interface debug output\n");
printf(" --debug-database Enable database debug output\n"); printf(" --debug-database Enable database debug output\n");
printf(" --debug-vnc Enable VNC debug output\n");
printf(" --help Show this help\n"); printf(" --help Show this help\n");
free_config(config); free_config(config);
exit(0); exit(0);
...@@ -297,4 +303,5 @@ void print_config(const wssshd_config_t *config) { ...@@ -297,4 +303,5 @@ void print_config(const wssshd_config_t *config) {
printf(" Debug: %s\n", config->debug ? "yes" : "no"); printf(" Debug: %s\n", config->debug ? "yes" : "no");
printf(" Debug Web: %s\n", config->debug_web ? "yes" : "no"); printf(" Debug Web: %s\n", config->debug_web ? "yes" : "no");
printf(" Debug Database: %s\n", config->debug_database ? "yes" : "no"); printf(" Debug Database: %s\n", config->debug_database ? "yes" : "no");
printf(" Debug VNC: %s\n", config->debug_vnc ? "yes" : "no");
} }
\ No newline at end of file
...@@ -36,6 +36,7 @@ typedef struct { ...@@ -36,6 +36,7 @@ typedef struct {
bool debug; bool debug;
bool debug_web; bool debug_web;
bool debug_database; bool debug_database;
bool debug_vnc;
} wssshd_config_t; } wssshd_config_t;
// Function declarations // Function declarations
......
#!/bin/bash
# Script to convert noVNC ES6 modules to global scripts
echo "Converting noVNC files from ES6 modules to global scripts..."
# Function to convert a single file
convert_file() {
local file="$1"
echo "Converting $file..."
# Create a backup
cp "$file" "${file}.bak"
# Remove import statements and convert exports
sed -i '
# Remove import statements
/^import.*from/d
/^export function /{
s/export function /function /
}
/^export const /{
s/export const /const /
}
/^export let /{
s/export let /let /
}
/^export default class /{
s/export default class /class /
}
/^export class /{
s/export class /class /
}
/^export default /{
s/export default /window./
}
/^export {/{
s/export {/window./
s/}/ = {/
s/ as /: /
}
' "$file"
# Add global assignments for exported items
if grep -q "^function " "$file" || grep -q "^const " "$file" || grep -q "^let " "$file" || grep -q "^class " "$file"; then
# Find exported functions/variables and add global assignments
grep "^function \|^const \|^let \|^class " "$file" | while read -r line; do
if [[ $line =~ ^(function|const|let|class)[[:space:]]+([a-zA-Z_][a-zA-Z0-9_]*) ]]; then
name="${BASH_REMATCH[2]}"
# Skip if already assigned to window
if ! grep -q "window\.$name" "$file"; then
echo "window.$name = $name;" >> "$file"
fi
fi
done
fi
}
# Convert all JS files
find templates/novnc -name "*.js" | while read -r file; do
convert_file "$file"
done
echo "Conversion complete!"
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/**
* index page HTML template for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INDEX_PAGE_H
#define INDEX_PAGE_H
// index page HTML template
static const char *index_page_html =
"<!DOCTYPE html>\n"
"<html lang=\"en\">\n"
"<head>\n"
" <meta charset=\"UTF-8\">\n"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
" <title>Dashboard - WSSSHD control panel</title>\n"
" <link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\">\n"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\n"
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\" rel=\"stylesheet\">\n"
"</head>\n"
"<body>\n"
"<nav class=\"navbar navbar-expand-lg navbar-dark bg-primary\">\n"
"<div class=\"container\">\n"
"<a class=\"navbar-brand\" href=\"/\">\n"
"<i class=\"fas fa-terminal\"></i> WSSSHD control panel</a>\n"
"<div class=\"navbar-nav ms-auto\">\n"
"<span class=\"navbar-text me-3\">%s</span>\n"
"<a class=\"nav-link\" href=\"/logout\">Logout</a>\n"
"</div></div></nav>\n"
"%s\n"
"<div class=\"container mt-4\">\n"
"<div class=\"row\">\n"
" <div class=\"col-md-8\">\n"
" <div class=\"card\">\n"
" <div class=\"card-header\">\n"
" <h3 class=\"card-title mb-0\">\n"
" <i class=\"fas fa-server\"></i> Registered Clients\n"
" </h3>\n"
" </div>\n"
" <div class=\"card-body\">\n"
" <div id=\"client-list\">%s</div>\n"
" </div>\n"
" </div>\n"
" </div>\n"
"\n"
" <div class=\"col-md-4\">\n"
" <div class=\"card\">\n"
" <div class=\"card-header\">\n"
" <h3 class=\"card-title mb-0\">\n"
" <i class=\"fas fa-cogs\"></i> Quick Actions\n"
" </h3>\n"
" </div>\n"
" <div class=\"card-body\">\n"
" %s\n"
" <button class=\"btn btn-outline-secondary btn-sm w-100\" onclick=\"location.reload()\">\n"
" <i class=\"fas fa-sync\"></i> Refresh Status\n"
" </button>\n"
" </div>\n"
" </div>\n"
"\n"
" <div class=\"card mt-3\">\n"
" <div class=\"card-header\">\n"
" <h3 class=\"card-title mb-0\">\n"
" <i class=\"fas fa-info-circle\"></i> System Info\n"
" </h3>\n"
" </div>\n"
" <div class=\"card-body\">\n"
" <p class=\"mb-1\"><strong>WebSocket Port:</strong> <span id=\"websocket-port\">%d</span></p>\n"
" <p class=\"mb-1\"><strong>Domain:</strong> <span id=\"domain\">%s</span></p>\n"
" <p class=\"mb-0\"><strong>Connected Clients:</strong> <span id=\"client-count\">%d</span></p>\n"
" </div>\n"
" </div>\n"
" </div>\n"
"</div>\n"
"</div>\n"
"<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>\n"
"<script>\n"
"function showNotification(message, type = 'info') {\n"
" const notificationArea = document.getElementById('notification-area');\n"
" const notification = document.createElement('div');\n"
" notification.className = `alert alert-${type} alert-dismissible fade show`;\n"
" notification.innerHTML = `${message}<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\"></button>`;\n"
" notificationArea.appendChild(notification);\n"
" setTimeout(() => {\n"
" if (notification.parentNode) {\n"
" notification.remove();\n"
" }\n"
" }, 5000);\n"
"}\n"
"\n"
"function updateClients() {\n"
" fetch('/api/clients')\n"
" .then(response => response.json())\n"
" .then(data => {\n"
" // Update client count\n"
" document.getElementById('client-count').textContent = data.count;\n"
"\n"
" // Generate HTML for client list\n"
" let clientListHtml = '';\n"
" if (data.count === 0) {\n"
" clientListHtml = '<div class=\"text-center py-5\"><i class=\"fas fa-server fa-4x text-muted mb-3\"></i><h4 class=\"text-muted\">No clients registered</h4><p class=\"text-muted\">Clients will appear here when they register.</p></div>';\n"
" } else {\n"
" for (const [clientId, clientData] of Object.entries(data.clients)) {\n"
" const statusIcon = clientData.status === 'connected' ? 'fa-desktop text-success' : 'fa-server text-warning';\n"
" const statusText = clientData.status === 'connected' ? 'Connected' : 'Registered';\n"
" const services = clientData.services;\n"
" let actionsHtml = '';\n"
" if (services.includes('ssh')) {\n"
" actionsHtml += `<a href=\"/terminal/${clientId}\" class=\"btn btn-primary btn-sm me-1\"><i class=\"fas fa-terminal\"></i> SSH</a>`;\n"
" }\n"
" if (services.includes('vnc')) {\n"
" actionsHtml += `<a href=\"/vnc/${clientId}\" class=\"btn btn-info btn-sm me-1\"><i class=\"fas fa-desktop\"></i> VNC</a>`;\n"
" }\n"
" clientListHtml += `\n"
" <div class=\"col-md-4 mb-3\">\n"
" <div class=\"card client-card h-100\">\n"
" <div class=\"card-body text-center\">\n"
" <i class=\"fas ${statusIcon} fa-3x mb-3\"></i>\n"
" <h5 class=\"card-title\">${clientId}</h5>\n"
" <p class=\"card-text text-muted\">${statusText}</p>\n"
" <p class=\"card-text small\">Services: ${services}</p>\n"
" <div class=\"d-flex justify-content-center\">${actionsHtml}</div>\n"
" </div>\n"
" </div>\n"
" </div>`;\n"
" }\n"
" }\n"
"\n"
" // Update client list only if changed\n"
" const clientListDiv = document.getElementById('client-list');\n"
" if (clientListDiv.innerHTML !== clientListHtml) {\n"
" clientListDiv.innerHTML = clientListHtml;\n"
" }\n"
" })\n"
" .catch(error => {\n"
" console.log('Error fetching client data:', error);\n"
" });\n"
"}\n"
"\n"
"// Update every 5 seconds\n"
"setInterval(updateClients, 5000);\n"
"\n"
"// Initial update after 1 second\n"
"setTimeout(updateClients, 1000);\n"
"</script>\n"
"</body>\n"
"</html>\n";
#endif /* INDEX_PAGE_H */
/**
* login page HTML template for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LOGIN_PAGE_H
#define LOGIN_PAGE_H
// login page HTML template
static const char *login_page_html =
"<!DOCTYPE html>\n"
"<html lang=\"en\">\n"
"<head>\n"
" <meta charset=\"UTF-8\">\n"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
" <title>Login - WSSSHD control panel</title>\n"
" <link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\">\n"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\n"
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\" rel=\"stylesheet\">\n"
"</head>\n"
"<body>\n"
"<nav class=\"navbar navbar-expand-lg navbar-dark bg-primary\">\n"
"<div class=\"container\">\n"
"<a class=\"navbar-brand\" href=\"/\">\n"
"<i class=\"fas fa-terminal\"></i> WSSSHD control panel</a>\n"
"</div></nav>\n"
"<div class=\"container mt-4\">\n"
"<div class=\"row justify-content-center\">\n"
" <div class=\"col-md-6\">\n"
" <div class=\"card\">\n"
" <div class=\"card-header\">\n"
" <h3 class=\"card-title mb-0\"><i class=\"fas fa-sign-in-alt\"></i> Login</h3>\n"
" </div>\n"
" <div class=\"card-body\">\n"
" <form method=\"post\">\n"
" <div class=\"mb-3\">\n"
" <label for=\"username\" class=\"form-label\">Username</label>\n"
" <input type=\"text\" class=\"form-control\" id=\"username\" name=\"username\" required>\n"
" </div>\n"
" <div class=\"mb-3\">\n"
" <label for=\"password\" class=\"form-label\">Password</label>\n"
" <input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\" required>\n"
" </div>\n"
" <button type=\"submit\" class=\"btn btn-primary\">\n"
" <i class=\"fas fa-sign-in-alt\"></i> Login\n"
" </button>\n"
" </form>\n"
" <div class=\"mt-3\">\n"
" <small class=\"text-muted\">\n"
" Default credentials: admin / admin123\n"
" </small>\n"
" </div>\n"
" </div>\n"
" </div>\n"
" </div>\n"
"</div>\n"
"</div>\n"
"<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>\n"
"</body>\n"
"</html>\n";
#endif /* LOGIN_PAGE_H */
#ifndef NOVNC_BASE64_JS_PAGE_H
#define NOVNC_BASE64_JS_PAGE_H
extern const char *novnc_base64_js;
#endif /* NOVNC_BASE64_JS_PAGE_H */
/**
* noVNC CSS for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NOVNC_CSS_PAGE_H
#define NOVNC_CSS_PAGE_H
// noVNC CSS
const char *novnc_css =
"Couldn't find the requested file /lib/rfb.css in @novnc/novnc.\n";
#endif /* NOVNC_CSS_PAGE_H */
#ifndef NOVNC_DECODERS_COPYRECT_JS_PAGE_H
#define NOVNC_DECODERS_COPYRECT_JS_PAGE_H
extern const char *novnc_decoders_copyrect_js;
#endif /* NOVNC_DECODERS_COPYRECT_JS_PAGE_H */
#ifndef NOVNC_DECODERS_HEXTILE_JS_PAGE_H
#define NOVNC_DECODERS_HEXTILE_JS_PAGE_H
extern const char *novnc_decoders_hextile_js;
#endif /* NOVNC_DECODERS_HEXTILE_JS_PAGE_H */
#ifndef NOVNC_DECODERS_JPEG_JS_PAGE_H
#define NOVNC_DECODERS_JPEG_JS_PAGE_H
extern const char *novnc_decoders_jpeg_js;
#endif /* NOVNC_DECODERS_JPEG_JS_PAGE_H */
#ifndef NOVNC_DECODERS_RAW_JS_PAGE_H
#define NOVNC_DECODERS_RAW_JS_PAGE_H
extern const char *novnc_decoders_raw_js;
#endif /* NOVNC_DECODERS_RAW_JS_PAGE_H */
#ifndef NOVNC_DECODERS_RRE_JS_PAGE_H
#define NOVNC_DECODERS_RRE_JS_PAGE_H
extern const char *novnc_decoders_rre_js;
#endif /* NOVNC_DECODERS_RRE_JS_PAGE_H */
#ifndef NOVNC_DECODERS_TIGHT_JS_PAGE_H
#define NOVNC_DECODERS_TIGHT_JS_PAGE_H
extern const char *novnc_decoders_tight_js;
#endif /* NOVNC_DECODERS_TIGHT_JS_PAGE_H */
#ifndef NOVNC_DECODERS_TIGHTPNG_JS_PAGE_H
#define NOVNC_DECODERS_TIGHTPNG_JS_PAGE_H
extern const char *novnc_decoders_tightpng_js;
#endif /* NOVNC_DECODERS_TIGHTPNG_JS_PAGE_H */
#ifndef NOVNC_DECODERS_ZRLE_JS_PAGE_H
#define NOVNC_DECODERS_ZRLE_JS_PAGE_H
extern const char *novnc_decoders_zrle_js;
#endif /* NOVNC_DECODERS_ZRLE_JS_PAGE_H */
#ifndef NOVNC_DEFLATOR_JS_PAGE_H
#define NOVNC_DEFLATOR_JS_PAGE_H
extern const char *novnc_deflator_js;
#endif /* NOVNC_DEFLATOR_JS_PAGE_H */
#ifndef NOVNC_DES_JS_PAGE_H
#define NOVNC_DES_JS_PAGE_H
extern const char *novnc_des_js;
#endif /* NOVNC_DES_JS_PAGE_H */
#ifndef NOVNC_DISPLAY_JS_PAGE_H
#define NOVNC_DISPLAY_JS_PAGE_H
extern const char *novnc_display_js;
#endif /* NOVNC_DISPLAY_JS_PAGE_H */
#ifndef NOVNC_ENCODINGS_JS_PAGE_H
#define NOVNC_ENCODINGS_JS_PAGE_H
extern const char *novnc_encodings_js;
#endif /* NOVNC_ENCODINGS_JS_PAGE_H */
#ifndef NOVNC_INFLATOR_JS_PAGE_H
#define NOVNC_INFLATOR_JS_PAGE_H
extern const char *novnc_inflator_js;
#endif /* NOVNC_INFLATOR_JS_PAGE_H */
#ifndef NOVNC_INPUT_DOMKEYTABLE_JS_PAGE_H
#define NOVNC_INPUT_DOMKEYTABLE_JS_PAGE_H
extern const char *novnc_input_domkeytable_js;
#endif /* NOVNC_INPUT_DOMKEYTABLE_JS_PAGE_H */
#ifndef NOVNC_INPUT_FIXEDKEYS_JS_PAGE_H
#define NOVNC_INPUT_FIXEDKEYS_JS_PAGE_H
extern const char *novnc_input_fixedkeys_js;
#endif /* NOVNC_INPUT_FIXEDKEYS_JS_PAGE_H */
#ifndef NOVNC_INPUT_GESTUREHANDLER_JS_PAGE_H
#define NOVNC_INPUT_GESTUREHANDLER_JS_PAGE_H
extern const char *novnc_input_gesturehandler_js;
#endif /* NOVNC_INPUT_GESTUREHANDLER_JS_PAGE_H */
#ifndef NOVNC_INPUT_KEYBOARD_JS_PAGE_H
#define NOVNC_INPUT_KEYBOARD_JS_PAGE_H
extern const char *novnc_input_keyboard_js;
#endif /* NOVNC_INPUT_KEYBOARD_JS_PAGE_H */
#ifndef NOVNC_INPUT_KEYSYM_JS_PAGE_H
#define NOVNC_INPUT_KEYSYM_JS_PAGE_H
extern const char *novnc_input_keysym_js;
#endif /* NOVNC_INPUT_KEYSYM_JS_PAGE_H */
#ifndef NOVNC_INPUT_KEYSYMDEF_JS_PAGE_H
#define NOVNC_INPUT_KEYSYMDEF_JS_PAGE_H
extern const char *novnc_input_keysymdef_js;
#endif /* NOVNC_INPUT_KEYSYMDEF_JS_PAGE_H */
#ifndef NOVNC_INPUT_UTIL_JS_PAGE_H
#define NOVNC_INPUT_UTIL_JS_PAGE_H
extern const char *novnc_input_util_js;
#endif /* NOVNC_INPUT_UTIL_JS_PAGE_H */
#ifndef NOVNC_INPUT_VKEYS_JS_PAGE_H
#define NOVNC_INPUT_VKEYS_JS_PAGE_H
extern const char *novnc_input_vkeys_js;
#endif /* NOVNC_INPUT_VKEYS_JS_PAGE_H */
#ifndef NOVNC_INPUT_XTSCANCODES_JS_PAGE_H
#define NOVNC_INPUT_XTSCANCODES_JS_PAGE_H
extern const char *novnc_input_xtscancodes_js;
#endif /* NOVNC_INPUT_XTSCANCODES_JS_PAGE_H */
#ifndef NOVNC_RA2_JS_PAGE_H
#define NOVNC_RA2_JS_PAGE_H
extern const char *novnc_ra2_js;
#endif /* NOVNC_RA2_JS_PAGE_H */
#ifndef NOVNC_RFB_JS_PAGE_H
#define NOVNC_RFB_JS_PAGE_H
extern const char *novnc_rfb_js;
#endif /* NOVNC_RFB_JS_PAGE_H */
#ifndef NOVNC_UTIL_BROWSER_JS_PAGE_H
#define NOVNC_UTIL_BROWSER_JS_PAGE_H
extern const char *novnc_util_browser_js;
#endif /* NOVNC_UTIL_BROWSER_JS_PAGE_H */
#ifndef NOVNC_UTIL_CURSOR_JS_PAGE_H
#define NOVNC_UTIL_CURSOR_JS_PAGE_H
extern const char *novnc_util_cursor_js;
#endif /* NOVNC_UTIL_CURSOR_JS_PAGE_H */
#ifndef NOVNC_UTIL_ELEMENT_JS_PAGE_H
#define NOVNC_UTIL_ELEMENT_JS_PAGE_H
extern const char *novnc_util_element_js;
#endif /* NOVNC_UTIL_ELEMENT_JS_PAGE_H */
#ifndef NOVNC_UTIL_EVENTS_JS_PAGE_H
#define NOVNC_UTIL_EVENTS_JS_PAGE_H
extern const char *novnc_util_events_js;
#endif /* NOVNC_UTIL_EVENTS_JS_PAGE_H */
#ifndef NOVNC_UTIL_EVENTTARGET_JS_PAGE_H
#define NOVNC_UTIL_EVENTTARGET_JS_PAGE_H
extern const char *novnc_util_eventtarget_js;
#endif /* NOVNC_UTIL_EVENTTARGET_JS_PAGE_H */
#ifndef NOVNC_UTIL_INT_JS_PAGE_H
#define NOVNC_UTIL_INT_JS_PAGE_H
extern const char *novnc_util_int_js;
#endif /* NOVNC_UTIL_INT_JS_PAGE_H */
#ifndef NOVNC_UTIL_LOGGING_JS_PAGE_H
#define NOVNC_UTIL_LOGGING_JS_PAGE_H
extern const char *novnc_util_logging_js;
#endif /* NOVNC_UTIL_LOGGING_JS_PAGE_H */
#ifndef NOVNC_UTIL_MD5_JS_PAGE_H
#define NOVNC_UTIL_MD5_JS_PAGE_H
extern const char *novnc_util_md5_js;
#endif /* NOVNC_UTIL_MD5_JS_PAGE_H */
#ifndef NOVNC_UTIL_STRINGS_JS_PAGE_H
#define NOVNC_UTIL_STRINGS_JS_PAGE_H
extern const char *novnc_util_strings_js;
#endif /* NOVNC_UTIL_STRINGS_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_ADLER32_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_ADLER32_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_adler32_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_ADLER32_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_CONSTANTS_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_CONSTANTS_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_constants_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_CONSTANTS_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_CRC32_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_CRC32_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_crc32_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_CRC32_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_DEFLATE_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_DEFLATE_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_deflate_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_DEFLATE_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_INFFAST_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_INFFAST_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_inffast_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_INFFAST_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_INFLATE_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_INFLATE_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_inflate_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_INFLATE_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_INFTREES_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_INFTREES_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_inftrees_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_INFTREES_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_MESSAGES_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_MESSAGES_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_messages_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_MESSAGES_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_TREES_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_TREES_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_trees_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_TREES_JS_PAGE_H */
#ifndef NOVNC_VENDOR_PAKO_LIB_ZLIB_ZSTREAM_JS_PAGE_H
#define NOVNC_VENDOR_PAKO_LIB_ZLIB_ZSTREAM_JS_PAGE_H
extern const char *novnc_vendor_pako_lib_zlib_zstream_js;
#endif /* NOVNC_VENDOR_PAKO_LIB_ZLIB_ZSTREAM_JS_PAGE_H */
#ifndef NOVNC_WEBSOCK_JS_PAGE_H
#define NOVNC_WEBSOCK_JS_PAGE_H
extern const char *novnc_websock_js;
#endif /* NOVNC_WEBSOCK_JS_PAGE_H */
This diff is collapsed.
/**
* users page HTML template for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef USERS_PAGE_H
#define USERS_PAGE_H
// users page HTML template
static const char *users_page_html =
"<!DOCTYPE html>\n"
"<html lang=\"en\">\n"
"<head>\n"
" <meta charset=\"UTF-8\">\n"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n"
" <title>Users - WSSSHD control panel</title>\n"
" <link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\">\n"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\n"
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\" rel=\"stylesheet\">\n"
"</head>\n"
"<body>\n"
"<nav class=\"navbar navbar-expand-lg navbar-dark bg-primary\">\n"
"<div class=\"container\">\n"
"<a class=\"navbar-brand\" href=\"/\">\n"
"<i class=\"fas fa-terminal\"></i> WSSSHD control panel</a>\n"
"<div class=\"navbar-nav ms-auto\">\n"
"<span class=\"navbar-text me-3\">%s</span>\n"
"<a class=\"nav-link\" href=\"/logout\">Logout</a>\n"
"</div></div></nav>\n"
"<div class=\"container mt-4\">\n"
" <div class=\"card\">\n"
" <div class=\"card-header d-flex justify-content-between align-items-center\">\n"
" <h3 class=\"card-title mb-0\">\n"
" <i class=\"fas fa-users\"></i> User Management\n"
" </h3>\n"
" <div>\n"
" <a href=\"/\" class=\"btn btn-outline-secondary btn-sm me-2\">\n"
" <i class=\"fas fa-home\"></i> Back to Home\n"
" </a>\n"
" <button class=\"btn btn-primary btn-sm\" data-bs-toggle=\"modal\" data-bs-target=\"#addUserModal\">\n"
" <i class=\"fas fa-plus\"></i> Add User\n"
" </button>\n"
" </div>\n"
" </div>\n"
" <div class=\"card-body\">\n"
" <div class=\"table-responsive\">\n"
" <table class=\"table table-striped\">\n"
" <thead>\n"
" <tr>\n"
" <th>Username</th>\n"
" <th>Role</th>\n"
" <th>Actions</th>\n"
" </tr>\n"
" </thead>\n"
" <tbody>\n"
" %s\n"
" </tbody>\n"
" </table>\n"
" </div>\n"
" </div>\n"
" </div>\n"
"</div>\n"
"\n"
"<!-- Add User Modal -->\n"
"<div class=\"modal fade\" id=\"addUserModal\" tabindex=\"-1\">\n"
" <div class=\"modal-dialog\">\n"
" <div class=\"modal-content\">\n"
" <div class=\"modal-header\">\n"
" <h5 class=\"modal-title\">Add New User</h5>\n"
" <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\"></button>\n"
" </div>\n"
" <form id=\"addUserForm\">\n"
" <div class=\"modal-body\">\n"
" <div class=\"mb-3\">\n"
" <label for=\"addUsername\" class=\"form-label\">Username</label>\n"
" <input type=\"text\" class=\"form-control\" id=\"addUsername\" name=\"username\" required>\n"
" </div>\n"
" <div class=\"mb-3\">\n"
" <label for=\"addPassword\" class=\"form-label\">Password</label>\n"
" <input type=\"password\" class=\"form-control\" id=\"addPassword\" name=\"password\" required>\n"
" </div>\n"
" <div class=\"mb-3 form-check\">\n"
" <input type=\"checkbox\" class=\"form-check-input\" id=\"addIsAdmin\" name=\"is_admin\">\n"
" <label class=\"form-check-label\" for=\"addIsAdmin\">Administrator</label>\n"
" </div>\n"
" </div>\n"
" <div class=\"modal-footer\">\n"
" <button type=\"button\" class=\"btn btn-secondary\" data-bs-dismiss=\"modal\">Cancel</button>\n"
" <button type=\"submit\" class=\"btn btn-primary\">Add User</button>\n"
" </div>\n"
" </form>\n"
" </div>\n"
" </div>\n"
"</div>\n"
"\n"
"<!-- Edit User Modal -->\n"
"<div class=\"modal fade\" id=\"editUserModal\" tabindex=\"-1\">\n"
" <div class=\"modal-dialog\">\n"
" <div class=\"modal-content\">\n"
" <div class=\"modal-header\">\n"
" <h5 class=\"modal-title\">Edit User</h5>\n"
" <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\"></button>\n"
" </div>\n"
" <form id=\"editUserForm\">\n"
" <input type=\"hidden\" id=\"editUserId\" name=\"user_id\">\n"
" <div class=\"modal-body\">\n"
" <div class=\"mb-3\">\n"
" <label for=\"editUsername\" class=\"form-label\">Username</label>\n"
" <input type=\"text\" class=\"form-control\" id=\"editUsername\" name=\"username\" required>\n"
" </div>\n"
" <div class=\"mb-3\">\n"
" <label for=\"editPassword\" class=\"form-label\">New Password (leave empty to keep current)</label>\n"
" <input type=\"password\" class=\"form-control\" id=\"editPassword\" name=\"password\">\n"
" </div>\n"
" <div class=\"mb-3 form-check\">\n"
" <input type=\"checkbox\" class=\"form-check-input\" id=\"editIsAdmin\" name=\"is_admin\">\n"
" <label class=\"form-check-label\" for=\"editIsAdmin\">Administrator</label>\n"
" </div>\n"
" </div>\n"
" <div class=\"modal-footer\">\n"
" <button type=\"button\" class=\"btn btn-secondary\" data-bs-dismiss=\"modal\">Cancel</button>\n"
" <button type=\"submit\" class=\"btn btn-primary\">Update User</button>\n"
" </div>\n"
" </form>\n"
" </div>\n"
" </div>\n"
"</div>\n"
"\n"
"<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>\n"
"<script>\n"
"function editUser(userId, username, isAdmin) {\n"
" document.getElementById('editUserId').value = userId;\n"
" document.getElementById('editUsername').value = username;\n"
" document.getElementById('editPassword').value = '';\n"
" document.getElementById('editIsAdmin').checked = isAdmin;\n"
" new bootstrap.Modal(document.getElementById('editUserModal')).show();\n"
"}\n"
"\n"
"function deleteUser(userId, username) {\n"
" if (confirm(`Are you sure you want to delete user \"${username}\"?`)) {\n"
" fetch(`/delete_user/${userId}`, {\n"
" method: 'POST',\n"
" headers: {'Content-Type': 'application/x-www-form-urlencoded'}\n"
" })\n"
" .then(response => response.json())\n"
" .then(data => {\n"
" if (data.success) location.reload();\n"
" else alert('Error: ' + data.error);\n"
" });\n"
" }\n"
"}\n"
"\n"
"document.getElementById('addUserForm').addEventListener('submit', function(e) {\n"
" e.preventDefault();\n"
" const formData = new FormData(this);\n"
" fetch('/add_user', {method: 'POST', body: formData})\n"
" .then(response => response.json())\n"
" .then(data => {\n"
" if (data.success) {\n"
" bootstrap.Modal.getInstance(document.getElementById('addUserModal')).hide();\n"
" location.reload();\n"
" } else alert('Error: ' + data.error);\n"
" });\n"
"});\n"
"\n"
"document.getElementById('editUserForm').addEventListener('submit', function(e) {\n"
" e.preventDefault();\n"
" const formData = new FormData(this);\n"
" const userId = document.getElementById('editUserId').value;\n"
" fetch(`/edit_user/${userId}`, {method: 'POST', body: formData})\n"
" .then(response => response.json())\n"
" .then(data => {\n"
" if (data.success) {\n"
" bootstrap.Modal.getInstance(document.getElementById('editUserModal')).hide();\n"
" location.reload();\n"
" } else alert('Error: ' + data.error);\n"
" });\n"
"});\n"
"</script>\n"
"</body>\n"
"</html>\n";
#endif /* USERS_PAGE_H */
This diff is collapsed.
/**
* xterm-addon-fit.js library for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef XTERM_ADDON_PAGE_H
#define XTERM_ADDON_PAGE_H
// xterm-addon-fit.js library
const char *xterm_addon_fit_js =
"!function(e,t){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=t():\"function\"==typeof define&&define.amd?define([],t):\"object\"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{\"use strict\";var e={};return(()=>{var t=e;Object.defineProperty(t,\"__esModule\",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue(\"height\")),s=Math.max(0,parseInt(i.getPropertyValue(\"width\"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue(\"padding-top\"))+parseInt(n.getPropertyValue(\"padding-bottom\"))),a=s-(parseInt(n.getPropertyValue(\"padding-right\"))+parseInt(n.getPropertyValue(\"padding-left\")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})()));\n"
"//# sourceMappingURL=xterm-addon-fit.js.map\n";
#endif /* XTERM_ADDON_PAGE_H */
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
File added
This diff is collapsed.
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "html_pages/novnc_input_fixedkeys_js_page.h" #include "html_pages/novnc_input_fixedkeys_js_page.h"
#include "html_pages/novnc_input_gesturehandler_js_page.h" #include "html_pages/novnc_input_gesturehandler_js_page.h"
#include "html_pages/novnc_input_keyboard_js_page.h" #include "html_pages/novnc_input_keyboard_js_page.h"
#include "html_pages/novnc_input_keysymdef_js_page.h"
#include "html_pages/novnc_input_keysym_js_page.h" #include "html_pages/novnc_input_keysym_js_page.h"
#include "html_pages/novnc_input_keysymdef_js_page.h"
#include "html_pages/novnc_input_util_js_page.h" #include "html_pages/novnc_input_util_js_page.h"
#include "html_pages/novnc_input_vkeys_js_page.h" #include "html_pages/novnc_input_vkeys_js_page.h"
#include "html_pages/novnc_input_xtscancodes_js_page.h" #include "html_pages/novnc_input_xtscancodes_js_page.h"
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "html_pages/novnc_vendor_pako_lib_zlib_inffast_js_page.h" #include "html_pages/novnc_vendor_pako_lib_zlib_inffast_js_page.h"
#include "html_pages/novnc_vendor_pako_lib_zlib_inflate_js_page.h" #include "html_pages/novnc_vendor_pako_lib_zlib_inflate_js_page.h"
#include "html_pages/novnc_vendor_pako_lib_zlib_inftrees_js_page.h" #include "html_pages/novnc_vendor_pako_lib_zlib_inftrees_js_page.h"
#include "html_pages/novnc_vendor_pako_lib_zlib_messages_js_page.h"
#include "html_pages/novnc_vendor_pako_lib_zlib_trees_js_page.h" #include "html_pages/novnc_vendor_pako_lib_zlib_trees_js_page.h"
#include "html_pages/novnc_vendor_pako_lib_zlib_zstream_js_page.h" #include "html_pages/novnc_vendor_pako_lib_zlib_zstream_js_page.h"
#include "html_pages/novnc_websock_js_page.h" #include "html_pages/novnc_websock_js_page.h"
......
File added
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
*/ */
export default class CopyRectDecoder { class CopyRectDecoder {
decodeRect(x, y, width, height, sock, display, depth) { decodeRect(x, y, width, height, sock, display, depth) {
if (sock.rQwait("COPYRECT", 4)) { if (sock.rQwait("COPYRECT", 4)) {
return false; return false;
...@@ -25,3 +25,4 @@ export default class CopyRectDecoder { ...@@ -25,3 +25,4 @@ export default class CopyRectDecoder {
return true; return true;
} }
} }
window.CopyRectDecoder = CopyRectDecoder;
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
* *
*/ */
import * as Log from '../util/logging.js';
export default class HextileDecoder { class HextileDecoder {
constructor() { constructor() {
this._tiles = 0; this._tiles = 0;
this._lastsubencoding = 0; this._lastsubencoding = 0;
...@@ -189,3 +188,4 @@ export default class HextileDecoder { ...@@ -189,3 +188,4 @@ export default class HextileDecoder {
this._tileBuffer, 0); this._tileBuffer, 0);
} }
} }
window.HextileDecoder = HextileDecoder;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
*/ */
export default class JPEGDecoder { class JPEGDecoder {
constructor() { constructor() {
// RealVNC will reuse the quantization tables // RealVNC will reuse the quantization tables
// and Huffman tables, so we need to cache them. // and Huffman tables, so we need to cache them.
...@@ -139,3 +139,4 @@ export default class JPEGDecoder { ...@@ -139,3 +139,4 @@ export default class JPEGDecoder {
} }
} }
} }
window.JPEGDecoder = JPEGDecoder;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
*/ */
export default class RawDecoder { class RawDecoder {
constructor() { constructor() {
this._lines = 0; this._lines = 0;
} }
...@@ -64,3 +64,4 @@ export default class RawDecoder { ...@@ -64,3 +64,4 @@ export default class RawDecoder {
return true; return true;
} }
} }
window.RawDecoder = RawDecoder;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
*/ */
export default class RREDecoder { class RREDecoder {
constructor() { constructor() {
this._subrects = 0; this._subrects = 0;
} }
...@@ -42,3 +42,4 @@ export default class RREDecoder { ...@@ -42,3 +42,4 @@ export default class RREDecoder {
return true; return true;
} }
} }
window.RREDecoder = RREDecoder;
...@@ -8,10 +8,8 @@ ...@@ -8,10 +8,8 @@
* *
*/ */
import * as Log from '../util/logging.js';
import Inflator from "../inflator.js";
export default class TightDecoder { class TightDecoder {
constructor() { constructor() {
this._ctl = null; this._ctl = null;
this._filter = null; this._filter = null;
...@@ -21,7 +19,7 @@ export default class TightDecoder { ...@@ -21,7 +19,7 @@ export default class TightDecoder {
this._zlibs = []; this._zlibs = [];
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
this._zlibs[i] = new Inflator(); this._zlibs[i] = new Inflate();
} }
} }
...@@ -329,3 +327,4 @@ export default class TightDecoder { ...@@ -329,3 +327,4 @@ export default class TightDecoder {
return this._scratchBuffer; return this._scratchBuffer;
} }
} }
window.TightDecoder = TightDecoder;
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
* *
*/ */
import TightDecoder from './tight.js';
export default class TightPNGDecoder extends TightDecoder { class TightPNGDecoder extends TightDecoder {
_pngRect(x, y, width, height, sock, display, depth) { _pngRect(x, y, width, height, sock, display, depth) {
let data = this._readData(sock); let data = this._readData(sock);
if (data === null) { if (data === null) {
...@@ -25,3 +24,4 @@ export default class TightPNGDecoder extends TightDecoder { ...@@ -25,3 +24,4 @@ export default class TightPNGDecoder extends TightDecoder {
throw new Error("BasicCompression received in TightPNG rect"); throw new Error("BasicCompression received in TightPNG rect");
} }
} }
window.TightPNGDecoder = TightPNGDecoder;
...@@ -7,12 +7,11 @@ ...@@ -7,12 +7,11 @@
* *
*/ */
import Inflate from "../inflator.js";
const ZRLE_TILE_WIDTH = 64; const ZRLE_TILE_WIDTH = 64;
const ZRLE_TILE_HEIGHT = 64; const ZRLE_TILE_HEIGHT = 64;
export default class ZRLEDecoder { class ZRLEDecoder {
constructor() { constructor() {
this._length = 0; this._length = 0;
this._inflator = new Inflate(); this._inflator = new Inflate();
...@@ -183,3 +182,6 @@ export default class ZRLEDecoder { ...@@ -183,3 +182,6 @@ export default class ZRLEDecoder {
return length + 1; return length + 1;
} }
} }
window.ZRLE_TILE_WIDTH = ZRLE_TILE_WIDTH;
window.ZRLE_TILE_HEIGHT = ZRLE_TILE_HEIGHT;
window.ZRLEDecoder = ZRLEDecoder;
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
import { deflateInit, deflate } from "../vendor/pako/lib/zlib/deflate.js";
import { Z_FULL_FLUSH } from "../vendor/pako/lib/zlib/constants.js";
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
export default class Deflator { class Deflator {
constructor() { constructor() {
this.strm = new ZStream(); this.strm = new ZStream();
this.chunkSize = 1024 * 10 * 10; this.chunkSize = 1024 * 10 * 10;
...@@ -83,3 +80,4 @@ export default class Deflator { ...@@ -83,3 +80,4 @@ export default class Deflator {
} }
} }
window.Deflator = Deflator;
...@@ -128,7 +128,7 @@ const 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, ...@@ -128,7 +128,7 @@ const 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,
/* eslint-enable comma-spacing */ /* eslint-enable comma-spacing */
export default class DES { class DES {
constructor(password) { constructor(password) {
this.keys = []; this.keys = [];
...@@ -264,3 +264,15 @@ export default class DES { ...@@ -264,3 +264,15 @@ export default class DES {
return this.enc8(t.slice(0, 8)).concat(this.enc8(t.slice(8, 16))); return this.enc8(t.slice(0, 8)).concat(this.enc8(t.slice(8, 16)));
} }
} }
window.PC2 = PC2;
window.z = z;
window.a = a;
window.SP1 = SP1;
window.SP2 = SP2;
window.SP3 = SP3;
window.SP4 = SP4;
window.SP5 = SP5;
window.SP6 = SP6;
window.SP7 = SP7;
window.SP8 = SP8;
window.DES = DES;
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
import * as Log from './util/logging.js';
import Base64 from "./base64.js";
import { toSigned32bit } from './util/int.js';
export default class Display { class Display {
constructor(target) { constructor(target) {
this._drawCtx = null; this._drawCtx = null;
...@@ -523,3 +520,4 @@ export default class Display { ...@@ -523,3 +520,4 @@ export default class Display {
} }
} }
} }
window.Display = Display;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
export const encodings = { const encodings = {
encodingRaw: 0, encodingRaw: 0,
encodingCopyRect: 1, encodingCopyRect: 1,
encodingRRE: 2, encodingRRE: 2,
...@@ -33,7 +33,7 @@ export const encodings = { ...@@ -33,7 +33,7 @@ export const encodings = {
pseudoEncodingExtendedClipboard: 0xc0a1e5ce pseudoEncodingExtendedClipboard: 0xc0a1e5ce
}; };
export function encodingName(num) { function encodingName(num) {
switch (num) { switch (num) {
case encodings.encodingRaw: return "Raw"; case encodings.encodingRaw: return "Raw";
case encodings.encodingCopyRect: return "CopyRect"; case encodings.encodingCopyRect: return "CopyRect";
...@@ -46,3 +46,5 @@ export function encodingName(num) { ...@@ -46,3 +46,5 @@ export function encodingName(num) {
default: return "[unknown encoding " + num + "]"; default: return "[unknown encoding " + num + "]";
} }
} }
window.encodings = encodings;
window.encodingName = encodingName;
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
import { inflateInit, inflate, inflateReset } from "../vendor/pako/lib/zlib/inflate.js";
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
export default class Inflate { class Inflate {
constructor() { constructor() {
this.strm = new ZStream(); this.strm = new ZStream();
this.chunkSize = 1024 * 10 * 10; this.chunkSize = 1024 * 10 * 10;
...@@ -64,3 +62,4 @@ export default class Inflate { ...@@ -64,3 +62,4 @@ export default class Inflate {
inflateReset(this.strm); inflateReset(this.strm);
} }
} }
window.Inflate = Inflate;
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
* Licensed under MPL 2.0 or any later version (see LICENSE.txt) * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
*/ */
import KeyTable from "./keysym.js";
/* /*
* Mapping between HTML key values and VNC/X11 keysyms for "special" * Mapping between HTML key values and VNC/X11 keysyms for "special"
...@@ -308,4 +307,7 @@ addNumpad("7", KeyTable.XK_7, KeyTable.XK_KP_7); ...@@ -308,4 +307,7 @@ addNumpad("7", KeyTable.XK_7, KeyTable.XK_KP_7);
addNumpad("8", KeyTable.XK_8, KeyTable.XK_KP_8); addNumpad("8", KeyTable.XK_8, KeyTable.XK_KP_8);
addNumpad("9", KeyTable.XK_9, KeyTable.XK_KP_9); addNumpad("9", KeyTable.XK_9, KeyTable.XK_KP_9);
export default DOMKeyTable; window.DOMKeyTable;
window.addStandard = addStandard;
window.addLeftRight = addLeftRight;
window.addNumpad = addNumpad;
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/* eslint-disable key-spacing */ /* eslint-disable key-spacing */
export default { window.{
// 3.1.1.1. Writing System Keys // 3.1.1.1. Writing System Keys
......
...@@ -33,7 +33,7 @@ const GH_LONGPRESS_TIMEOUT = 1000; ...@@ -33,7 +33,7 @@ const GH_LONGPRESS_TIMEOUT = 1000;
// Timeout when waiting to decide between PINCH and TWODRAG (ms) // Timeout when waiting to decide between PINCH and TWODRAG (ms)
const GH_TWOTOUCH_TIMEOUT = 50; const GH_TWOTOUCH_TIMEOUT = 50;
export default class GestureHandler { class GestureHandler {
constructor() { constructor() {
this._target = null; this._target = null;
...@@ -565,3 +565,19 @@ export default class GestureHandler { ...@@ -565,3 +565,19 @@ export default class GestureHandler {
last: { x: ldx, y: ldy } }; last: { x: ldx, y: ldy } };
} }
} }
window.GH_NOGESTURE = GH_NOGESTURE;
window.GH_ONETAP = GH_ONETAP;
window.GH_TWOTAP = GH_TWOTAP;
window.GH_THREETAP = GH_THREETAP;
window.GH_DRAG = GH_DRAG;
window.GH_LONGPRESS = GH_LONGPRESS;
window.GH_TWODRAG = GH_TWODRAG;
window.GH_PINCH = GH_PINCH;
window.GH_INITSTATE = GH_INITSTATE;
window.GH_MOVE_THRESHOLD = GH_MOVE_THRESHOLD;
window.GH_ANGLE_THRESHOLD = GH_ANGLE_THRESHOLD;
window.GH_MULTITOUCH_TIMEOUT = GH_MULTITOUCH_TIMEOUT;
window.GH_TAP_TIMEOUT = GH_TAP_TIMEOUT;
window.GH_LONGPRESS_TIMEOUT = GH_LONGPRESS_TIMEOUT;
window.GH_TWOTOUCH_TIMEOUT = GH_TWOTOUCH_TIMEOUT;
window.GestureHandler = GestureHandler;
...@@ -4,17 +4,12 @@ ...@@ -4,17 +4,12 @@
* Licensed under MPL 2.0 or any later version (see LICENSE.txt) * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
*/ */
import * as Log from '../util/logging.js';
import { stopEvent } from '../util/events.js';
import * as KeyboardUtil from "./util.js";
import KeyTable from "./keysym.js";
import * as browser from "../util/browser.js";
// //
// Keyboard event handler // Keyboard event handler
// //
export default class Keyboard { class Keyboard {
constructor(target) { constructor(target) {
this._target = target || null; this._target = target || null;
...@@ -281,3 +276,4 @@ export default class Keyboard { ...@@ -281,3 +276,4 @@ export default class Keyboard {
//Log.Debug(">> Keyboard.ungrab"); //Log.Debug(">> Keyboard.ungrab");
} }
} }
window.Keyboard = Keyboard;
/* eslint-disable key-spacing */ /* eslint-disable key-spacing */
export default { window.KeyTable = {
XK_VoidSymbol: 0xffffff, /* Void symbol */ XK_VoidSymbol: 0xffffff, /* Void symbol */
XK_BackSpace: 0xff08, /* Back space, back char */ XK_BackSpace: 0xff08, /* Back space, back char */
......
...@@ -669,20 +669,19 @@ const codepoints = { ...@@ -669,20 +669,19 @@ const codepoints = {
0x30fc: 0x04b0, // XK_prolongedsound 0x30fc: 0x04b0, // XK_prolongedsound
}; };
export default { window.lookup = function(u) {
lookup(u) { // Latin-1 is one-to-one mapping
// Latin-1 is one-to-one mapping if ((u >= 0x20) && (u <= 0xff)) {
if ((u >= 0x20) && (u <= 0xff)) { return u;
return u; }
}
// Lookup table (fairly random) // Lookup table (fairly random)
const keysym = codepoints[u]; const keysym = codepoints[u];
if (keysym !== undefined) { if (keysym !== undefined) {
return keysym; return keysym;
} }
// General mapping as final fallback // General mapping as final fallback
return 0x01000000 | u; return 0x01000000 | u;
},
}; };
window.codepoints = codepoints;
import KeyTable from "./keysym.js";
import keysyms from "./keysymdef.js";
import vkeys from "./vkeys.js";
import fixedkeys from "./fixedkeys.js";
import DOMKeyTable from "./domkeytable.js";
import * as browser from "../util/browser.js";
// Get 'KeyboardEvent.code', handling legacy browsers // Get 'KeyboardEvent.code', handling legacy browsers
export function getKeycode(evt) { function getKeycode(evt) {
// Are we getting proper key identifiers? // Are we getting proper key identifiers?
// (unfortunately Firefox and Chrome are crappy here and gives // (unfortunately Firefox and Chrome are crappy here and gives
// us an empty string on some platforms, rather than leaving it // us an empty string on some platforms, rather than leaving it
...@@ -65,7 +59,7 @@ export function getKeycode(evt) { ...@@ -65,7 +59,7 @@ export function getKeycode(evt) {
} }
// Get 'KeyboardEvent.key', handling legacy browsers // Get 'KeyboardEvent.key', handling legacy browsers
export function getKey(evt) { function getKey(evt) {
// Are we getting a proper key value? // Are we getting a proper key value?
if (evt.key !== undefined) { if (evt.key !== undefined) {
// Mozilla isn't fully in sync with the spec yet // Mozilla isn't fully in sync with the spec yet
...@@ -108,7 +102,7 @@ export function getKey(evt) { ...@@ -108,7 +102,7 @@ export function getKey(evt) {
} }
// Get the most reliable keysym value we can get from a key event // Get the most reliable keysym value we can get from a key event
export function getKeysym(evt) { function getKeysym(evt) {
const key = getKey(evt); const key = getKey(evt);
if (key === 'Unidentified') { if (key === 'Unidentified') {
...@@ -189,3 +183,5 @@ export function getKeysym(evt) { ...@@ -189,3 +183,5 @@ export function getKeysym(evt) {
return null; return null;
} }
window.getKeycode = getKeycode;
window.getKeysym = getKeysym;
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* HTML key codes. * HTML key codes.
*/ */
export default { window.{
0x08: 'Backspace', 0x08: 'Backspace',
0x09: 'Tab', 0x09: 'Tab',
0x0a: 'NumpadClear', 0x0a: 'NumpadClear',
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* To re-generate, run: * To re-generate, run:
* keymap-gen code-map --lang=js keymaps.csv html atset1 * keymap-gen code-map --lang=js keymaps.csv html atset1
*/ */
export default { window.XtScancode = {
"Again": 0xe005, /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */ "Again": 0xe005, /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */
"AltLeft": 0x38, /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */ "AltLeft": 0x38, /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */
"AltRight": 0xe038, /* html:AltRight (AltRight) -> linux:100 (KEY_RIGHTALT) -> atset1:57400 */ "AltRight": 0xe038, /* html:AltRight (AltRight) -> linux:100 (KEY_RIGHTALT) -> atset1:57400 */
......
import Base64 from './base64.js';
import { encodeUTF8 } from './util/strings.js';
import EventTargetMixin from './util/eventtarget.js';
export class AESEAXCipher { class AESEAXCipher {
constructor() { constructor() {
this._rawKey = null; this._rawKey = null;
this._ctrKey = null; this._ctrKey = null;
...@@ -128,7 +125,7 @@ export class AESEAXCipher { ...@@ -128,7 +125,7 @@ export class AESEAXCipher {
} }
} }
export class RA2Cipher { class RA2Cipher {
constructor() { constructor() {
this._cipher = new AESEAXCipher(); this._cipher = new AESEAXCipher();
this._counter = new Uint8Array(16); this._counter = new Uint8Array(16);
...@@ -156,7 +153,7 @@ export class RA2Cipher { ...@@ -156,7 +153,7 @@ export class RA2Cipher {
} }
} }
export class RSACipher { class RSACipher {
constructor(keyLength) { constructor(keyLength) {
this._key = null; this._key = null;
this._keyLength = keyLength; this._keyLength = keyLength;
...@@ -306,7 +303,7 @@ export class RSACipher { ...@@ -306,7 +303,7 @@ export class RSACipher {
} }
} }
export default class RSAAESAuthenticationState extends EventTargetMixin { class RSAAESAuthenticationState extends EventTargetMixin {
constructor(sock, getCredentials) { constructor(sock, getCredentials) {
super(); super();
this._hasStarted = false; this._hasStarted = false;
...@@ -564,4 +561,7 @@ export default class RSAAESAuthenticationState extends EventTargetMixin { ...@@ -564,4 +561,7 @@ export default class RSAAESAuthenticationState extends EventTargetMixin {
set hasStarted(s) { set hasStarted(s) {
this._hasStarted = s; this._hasStarted = s;
} }
} }window.AESEAXCipher = AESEAXCipher;
\ No newline at end of file window.RA2Cipher = RA2Cipher;
window.RSACipher = RSACipher;
window.RSAAESAuthenticationState = RSAAESAuthenticationState;
This diff is collapsed.
...@@ -8,10 +8,9 @@ ...@@ -8,10 +8,9 @@
* Browser feature support detection * Browser feature support detection
*/ */
import * as Log from './logging.js';
// Touch detection // Touch detection
export let isTouchDevice = ('ontouchstart' in document.documentElement) || let isTouchDevice = ('ontouchstart' in document.documentElement) ||
// requried for Chrome debugger // requried for Chrome debugger
(document.ontouchstart !== undefined) || (document.ontouchstart !== undefined) ||
// required for MS Surface // required for MS Surface
...@@ -25,7 +24,7 @@ window.addEventListener('touchstart', function onFirstTouch() { ...@@ -25,7 +24,7 @@ window.addEventListener('touchstart', function onFirstTouch() {
// The goal is to find a certain physical width, the devicePixelRatio // The goal is to find a certain physical width, the devicePixelRatio
// brings us a bit closer but is not optimal. // brings us a bit closer but is not optimal.
export let dragThreshold = 10 * (window.devicePixelRatio || 1); let dragThreshold = 10 * (window.devicePixelRatio || 1);
let _supportsCursorURIs = false; let _supportsCursorURIs = false;
...@@ -43,7 +42,7 @@ try { ...@@ -43,7 +42,7 @@ try {
Log.Error("Data URI scheme cursor test exception: " + exc); Log.Error("Data URI scheme cursor test exception: " + exc);
} }
export const supportsCursorURIs = _supportsCursorURIs; const supportsCursorURIs = _supportsCursorURIs;
let _hasScrollbarGutter = true; let _hasScrollbarGutter = true;
try { try {
...@@ -68,7 +67,7 @@ try { ...@@ -68,7 +67,7 @@ try {
} catch (exc) { } catch (exc) {
Log.Error("Scrollbar test exception: " + exc); Log.Error("Scrollbar test exception: " + exc);
} }
export const hasScrollbarGutter = _hasScrollbarGutter; const hasScrollbarGutter = _hasScrollbarGutter;
/* /*
* The functions for detection of platforms and browsers below are exported * The functions for detection of platforms and browsers below are exported
...@@ -79,74 +78,93 @@ export const hasScrollbarGutter = _hasScrollbarGutter; ...@@ -79,74 +78,93 @@ export const hasScrollbarGutter = _hasScrollbarGutter;
/* OS */ /* OS */
export function isMac() { function isMac() {
return !!(/mac/i).exec(navigator.platform); return !!(/mac/i).exec(navigator.platform);
} }
export function isWindows() { function isWindows() {
return !!(/win/i).exec(navigator.platform); return !!(/win/i).exec(navigator.platform);
} }
export function isIOS() { function isIOS() {
return (!!(/ipad/i).exec(navigator.platform) || return (!!(/ipad/i).exec(navigator.platform) ||
!!(/iphone/i).exec(navigator.platform) || !!(/iphone/i).exec(navigator.platform) ||
!!(/ipod/i).exec(navigator.platform)); !!(/ipod/i).exec(navigator.platform));
} }
export function isAndroid() { function isAndroid() {
/* Android sets navigator.platform to Linux :/ */ /* Android sets navigator.platform to Linux :/ */
return !!navigator.userAgent.match('Android '); return !!navigator.userAgent.match('Android ');
} }
export function isChromeOS() { function isChromeOS() {
/* ChromeOS sets navigator.platform to Linux :/ */ /* ChromeOS sets navigator.platform to Linux :/ */
return !!navigator.userAgent.match(' CrOS '); return !!navigator.userAgent.match(' CrOS ');
} }
/* Browser */ /* Browser */
export function isSafari() { function isSafari() {
return !!navigator.userAgent.match('Safari/...') && return !!navigator.userAgent.match('Safari/...') &&
!navigator.userAgent.match('Chrome/...') && !navigator.userAgent.match('Chrome/...') &&
!navigator.userAgent.match('Chromium/...') && !navigator.userAgent.match('Chromium/...') &&
!navigator.userAgent.match('Epiphany/...'); !navigator.userAgent.match('Epiphany/...');
} }
export function isFirefox() { function isFirefox() {
return !!navigator.userAgent.match('Firefox/...') && return !!navigator.userAgent.match('Firefox/...') &&
!navigator.userAgent.match('Seamonkey/...'); !navigator.userAgent.match('Seamonkey/...');
} }
export function isChrome() { function isChrome() {
return !!navigator.userAgent.match('Chrome/...') && return !!navigator.userAgent.match('Chrome/...') &&
!navigator.userAgent.match('Chromium/...') && !navigator.userAgent.match('Chromium/...') &&
!navigator.userAgent.match('Edg/...') && !navigator.userAgent.match('Edg/...') &&
!navigator.userAgent.match('OPR/...'); !navigator.userAgent.match('OPR/...');
} }
export function isChromium() { function isChromium() {
return !!navigator.userAgent.match('Chromium/...'); return !!navigator.userAgent.match('Chromium/...');
} }
export function isOpera() { function isOpera() {
return !!navigator.userAgent.match('OPR/...'); return !!navigator.userAgent.match('OPR/...');
} }
export function isEdge() { function isEdge() {
return !!navigator.userAgent.match('Edg/...'); return !!navigator.userAgent.match('Edg/...');
} }
/* Engine */ /* Engine */
export function isGecko() { function isGecko() {
return !!navigator.userAgent.match('Gecko/...'); return !!navigator.userAgent.match('Gecko/...');
} }
export function isWebKit() { function isWebKit() {
return !!navigator.userAgent.match('AppleWebKit/...') && return !!navigator.userAgent.match('AppleWebKit/...') &&
!navigator.userAgent.match('Chrome/...'); !navigator.userAgent.match('Chrome/...');
} }
export function isBlink() { function isBlink() {
return !!navigator.userAgent.match('Chrome/...'); return !!navigator.userAgent.match('Chrome/...');
} }
window.isTouchDevice = isTouchDevice;
window.dragThreshold = dragThreshold;
window._supportsCursorURIs = _supportsCursorURIs;
window.supportsCursorURIs = supportsCursorURIs;
window._hasScrollbarGutter = _hasScrollbarGutter;
window.hasScrollbarGutter = hasScrollbarGutter;
window.isMac = isMac;
window.isWindows = isWindows;
window.isIOS = isIOS;
window.isAndroid = isAndroid;
window.isChromeOS = isChromeOS;
window.isSafari = isSafari;
window.isFirefox = isFirefox;
window.isChromium = isChromium;
window.isOpera = isOpera;
window.isEdge = isEdge;
window.isGecko = isGecko;
window.isWebKit = isWebKit;
window.isBlink = isBlink;
...@@ -4,11 +4,10 @@ ...@@ -4,11 +4,10 @@
* Licensed under MPL 2.0 or any later version (see LICENSE.txt) * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
*/ */
import { supportsCursorURIs, isTouchDevice } from './browser.js';
const useFallback = !supportsCursorURIs || isTouchDevice; const useFallback = !supportsCursorURIs || isTouchDevice;
export default class Cursor { class Cursor {
constructor() { constructor() {
this._target = null; this._target = null;
...@@ -245,3 +244,5 @@ export default class Cursor { ...@@ -245,3 +244,5 @@ export default class Cursor {
document.documentElement.contains(document.captureElement); document.documentElement.contains(document.captureElement);
} }
} }
window.useFallback = useFallback;
window.Cursor = Cursor;
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* HTML element utility functions * HTML element utility functions
*/ */
export function clientToElement(x, y, elem) { function clientToElement(x, y, elem) {
const bounds = elem.getBoundingClientRect(); const bounds = elem.getBoundingClientRect();
let pos = { x: 0, y: 0 }; let pos = { x: 0, y: 0 };
// Clip to target bounds // Clip to target bounds
...@@ -30,3 +30,4 @@ export function clientToElement(x, y, elem) { ...@@ -30,3 +30,4 @@ export function clientToElement(x, y, elem) {
} }
return pos; return pos;
} }
window.clientToElement = clientToElement;
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
* Cross-browser event and position routines * Cross-browser event and position routines
*/ */
export function getPointerEvent(e) { function getPointerEvent(e) {
return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e; return e.changedTouches ? e.changedTouches[0] : e.touches ? e.touches[0] : e;
} }
export function stopEvent(e) { function stopEvent(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
} }
...@@ -60,7 +60,7 @@ function _capturedElemChanged() { ...@@ -60,7 +60,7 @@ function _capturedElemChanged() {
const _captureObserver = new MutationObserver(_capturedElemChanged); const _captureObserver = new MutationObserver(_capturedElemChanged);
export function setCapture(target) { function setCapture(target) {
if (target.setCapture) { if (target.setCapture) {
target.setCapture(); target.setCapture();
...@@ -107,7 +107,7 @@ export function setCapture(target) { ...@@ -107,7 +107,7 @@ export function setCapture(target) {
} }
} }
export function releaseCapture() { function releaseCapture() {
if (document.releaseCapture) { if (document.releaseCapture) {
document.releaseCapture(); document.releaseCapture();
...@@ -136,3 +136,12 @@ export function releaseCapture() { ...@@ -136,3 +136,12 @@ export function releaseCapture() {
window.removeEventListener('mouseup', _captureProxy); window.removeEventListener('mouseup', _captureProxy);
} }
} }
window.getPointerEvent = getPointerEvent;
window.stopEvent = stopEvent;
window._captureRecursion = _captureRecursion;
window._elementForUnflushedEvents = _elementForUnflushedEvents;
window._captureProxy = _captureProxy;
window._capturedElemChanged = _capturedElemChanged;
window._captureObserver = _captureObserver;
window.setCapture = setCapture;
window.releaseCapture = releaseCapture;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
export default class EventTargetMixin { class EventTargetMixin {
constructor() { constructor() {
this._listeners = new Map(); this._listeners = new Map();
} }
...@@ -33,3 +33,4 @@ export default class EventTargetMixin { ...@@ -33,3 +33,4 @@ export default class EventTargetMixin {
return !event.defaultPrevented; return !event.defaultPrevented;
} }
} }
window.EventTargetMixin = EventTargetMixin;
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
* See README.md for usage and integration instructions. * See README.md for usage and integration instructions.
*/ */
export function toUnsigned32bit(toConvert) { function toUnsigned32bit(toConvert) {
return toConvert >>> 0; return toConvert >>> 0;
} }
export function toSigned32bit(toConvert) { function toSigned32bit(toConvert) {
return toConvert | 0; return toConvert | 0;
} }
window.toUnsigned32bit = toUnsigned32bit;
window.toSigned32bit = toSigned32bit;
...@@ -17,7 +17,7 @@ let Info = () => {}; ...@@ -17,7 +17,7 @@ let Info = () => {};
let Warn = () => {}; let Warn = () => {};
let Error = () => {}; let Error = () => {};
export function initLogging(level) { function initLogging(level) {
if (typeof level === 'undefined') { if (typeof level === 'undefined') {
level = _logLevel; level = _logLevel;
} else { } else {
...@@ -46,11 +46,18 @@ export function initLogging(level) { ...@@ -46,11 +46,18 @@ export function initLogging(level) {
} }
} }
export function getLogging() { function getLogging() {
return _logLevel; return _logLevel;
} }
export { Debug, Info, Warn, Error }; window.Log = { Debug, Info, Warn, Error };
// Initialize logging level // Initialize logging level
initLogging(); initLogging();
window._logLevel = _logLevel;
window.Debug = Debug;
window.Info = Info;
window.Warn = Warn;
window.Error = Error;
window.initLogging = initLogging;
window.getLogging = getLogging;
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Performs MD5 hashing on a string of binary characters, returns an array of bytes * Performs MD5 hashing on a string of binary characters, returns an array of bytes
*/ */
export function MD5(d) { function MD5(d) {
let r = M(V(Y(X(d), 8 * d.length))); let r = M(V(Y(X(d), 8 * d.length)));
return r; return r;
} }
...@@ -76,4 +76,14 @@ function add(d, g) { ...@@ -76,4 +76,14 @@ function add(d, g) {
function rol(d, g) { function rol(d, g) {
return d << g | d >>> 32 - g; return d << g | d >>> 32 - g;
} }window.MD5 = MD5;
\ No newline at end of file window.X = X;
window.V = V;
window.Y = Y;
window.cmn = cmn;
window.ff = ff;
window.gg = gg;
window.hh = hh;
window.ii = ii;
window.add = add;
window.rol = rol;
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
// Decode from UTF-8 // Decode from UTF-8
export function decodeUTF8(utf8string, allowLatin1=false) { function decodeUTF8(utf8string, allowLatin1=false) {
try { try {
return decodeURIComponent(escape(utf8string)); return decodeURIComponent(escape(utf8string));
} catch (e) { } catch (e) {
...@@ -23,6 +23,8 @@ export function decodeUTF8(utf8string, allowLatin1=false) { ...@@ -23,6 +23,8 @@ export function decodeUTF8(utf8string, allowLatin1=false) {
} }
// Encode to UTF-8 // Encode to UTF-8
export function encodeUTF8(DOMString) { function encodeUTF8(DOMString) {
return unescape(encodeURIComponent(DOMString)); return unescape(encodeURIComponent(DOMString));
} }
window.decodeUTF8 = decodeUTF8;
window.encodeUTF8 = encodeUTF8;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment