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:
2026-04-15 00:00:00 +01:00
parent f950be0e48
commit e6bdbef26c
12 changed files with 46 additions and 2 deletions
+13 -2
View File
@@ -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', () => {
const app = new App();
app.init().catch((err) => console.error('App initialisation failed:', err));
try {
const app = new App();
app.init().catch((err) => {
console.error('App initialisation failed:', err);
});
} catch (err) {
console.error('App constructor failed:', err);
}
});
})();