Fix JS execution: wrap all scripts in IIFEs to avoid WebKit global scope conflicts
WebKit's WKWebView rejects top-level const/let declarations that shadow global function names. Since utils.js defines functions like stateLabel() at the global scope (non-module scripts), and later files destructure the same names from window.NexusTerminal using const, WebKit throws: SyntaxError: Can't create duplicate variable that shadows a global property Fix: wrap every JS file in an IIFE so all declarations are function-scoped. Also remove temporary diagnostic instrumentation.
This commit is contained in:
+12
-1
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — main application entry point.
|
||||
* Initialises the application shell, loads profiles, and sets up event listeners.
|
||||
@@ -281,6 +282,7 @@ class App {
|
||||
* Binds click handlers to static UI elements.
|
||||
*/
|
||||
setupUI() {
|
||||
var btnEl = document.getElementById('btn-new-connection');
|
||||
this._bindClick('btn-new-connection', () => this.profileEditor.openNew());
|
||||
this._bindClick('btn-settings', () => this.settings.open());
|
||||
this._bindClick('btn-import', () => this.importProfiles());
|
||||
@@ -509,7 +511,16 @@ class App {
|
||||
|
||||
// ── Bootstrap ────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
try {
|
||||
const app = new App();
|
||||
app.init().catch((err) => console.error('App initialisation failed:', err));
|
||||
app.init().catch((err) => {
|
||||
console.error('App initialisation failed:', err);
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('App constructor failed:', err);
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — command palette (Ctrl+K).
|
||||
* Provides a searchable overlay for quick access to application commands,
|
||||
@@ -382,3 +383,5 @@ class CommandPalette {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.CommandPalette = CommandPalette;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — toast notification system.
|
||||
* Provides non-blocking, auto-dismissing notifications that stack
|
||||
@@ -125,3 +126,5 @@ class Notifications {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.Notifications = Notifications;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — connection profile editor.
|
||||
* Renders a slide-out drawer for creating and editing connection profiles.
|
||||
@@ -889,3 +890,5 @@ class ProfileEditor {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.ProfileEditor = ProfileEditor;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — RAW TCP data viewer.
|
||||
* Provides text, hex, and split display modes for raw socket data,
|
||||
@@ -565,3 +566,5 @@ class RawViewer {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.RawViewer = RawViewer;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — secret/passphrase prompt dialogs.
|
||||
* Provides modal prompts for collecting passwords, master-vault passphrases,
|
||||
@@ -301,3 +302,5 @@ class SecretPrompt {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.SecretPrompt = SecretPrompt;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — settings modal.
|
||||
* Renders a tabbed settings dialog for application-wide preferences,
|
||||
@@ -464,3 +465,5 @@ class Settings {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.Settings = Settings;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — sidebar module.
|
||||
* Renders the profile list with search, sections (favourites, recent, all),
|
||||
@@ -336,3 +337,5 @@ class Sidebar {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.Sidebar = Sidebar;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — application state management.
|
||||
* Provides a centralised store for profiles, sessions, and preferences,
|
||||
@@ -226,3 +227,5 @@ class State {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.State = State;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — tab management.
|
||||
* Handles the tab bar: adding, removing, reordering, renaming,
|
||||
@@ -550,3 +551,5 @@ class TabManager {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.TabManager = TabManager;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — xterm.js terminal manager.
|
||||
* Creates, manages, and destroys xterm.js instances for SSH and Telnet sessions.
|
||||
@@ -287,3 +288,5 @@ class TerminalManager {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
window.NexusTerminal.TerminalManager = TerminalManager;
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
(function() {
|
||||
/**
|
||||
* Nexus Terminal — utility functions.
|
||||
* General-purpose helpers used throughout the application.
|
||||
@@ -230,3 +231,5 @@ function stateLabel(state) {
|
||||
|
||||
window.NexusTerminal = window.NexusTerminal || {};
|
||||
Object.assign(window.NexusTerminal, { $, $$, createElement, escapeHtml, formatTimestamp, debounce, fuzzyMatch, base64Encode, base64Decode, generateId, formatBytes, truncate, dismissContextMenus, protocolColour, stateLabel });
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user