fix(frontend): unbreak dashboard — bundle order, IIFE close, dup const

Three merge-fallout bugs that combined to leave the services grid empty
and most UI inert:

1. error-handler.js was bundled into onboarding.js (loaded 3rd), but
   globals.js in core.js (loaded 1st) does `const errorHandler = new
   ErrorHandler()` at top level. ErrorHandler was undefined when core.js
   ran -> ReferenceError -> globals.js stopped, so window.APPS,
   _showTotpOverlay, loadServices, etc. were never set, and init.js
   blew up on every call into core's exports.

   Moved error-handler.js to the start of the core.js bundle so the
   class is on window before any other script touches it.

2. setup-wizard.js also declared `const errorHandler = new ErrorHandler()`
   at top level. Classic scripts share the document's top-level lexical
   environment, so this collided with globals.js's declaration ->
   redeclaration SyntaxError in features.js. Removed setup-wizard.js's
   copy; it picks up the global one.

3. tooltip-definitions.js closed its `(function(window){...})(window);`
   IIFE at line ~171 ("Validation module loaded"), then the TOOLTIP_
   DEFINITIONS array, getter helpers, window.TooltipDefinitions export,
   and final `debug(...)` log all sat at top level — outside the IIFE,
   where `debug` was no longer in scope. Removed the early close and
   added one at EOF so the whole file is in one IIFE.
This commit is contained in:
Sami
2026-05-17 02:03:31 -07:00
parent f9dad0abb4
commit bab5105e48
7 changed files with 148 additions and 138 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
// Shared timezone utility — used by setup wizard and settings modal
const errorHandler = new ErrorHandler();
// errorHandler is declared globally in globals.js (core.js bundle); reusing it
// here so we don't get "redeclaration of const errorHandler" at script scope.
window.populateTimezoneSelect = function(selectEl, selectedTz) {
const timezones = Intl.supportedValuesOf('timeZone');
+6 -2
View File
@@ -168,8 +168,10 @@
debug('[TooltipDefinitions] Validation module loaded');
})(window);
// (IIFE close moved to EOF — the TOOLTIP_DEFINITIONS array and getter
// helpers below must stay inside this IIFE so they have access to `debug`
// and `errorHandler`. The early `})(window);` here used to fall out of
// scope, leaving the later `debug(...)` call referencing an undefined name.)
/**
* Tooltip Definitions Array
@@ -542,3 +544,5 @@ window.TooltipDefinitions = {
debug('[TooltipDefinitions] Definitions loaded:', TOOLTIP_DEFINITIONS.length, 'tooltips');
})(window);