import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs'; import { GLOBAL_LOG_A_LOT, APP_CONFIG } from './constants.mjs'; import { initIbGibStorage, initIbGibGlobalThis, dynamicallyLoadBootstrapScript, } from './helpers.web.mjs'; import { initDevTools } from './dev-tools.mjs'; initIbGibGlobalThis(APP_CONFIG); const logalot = GLOBAL_LOG_A_LOT; /** * hmm * Initiates startup without blocking DOMContentLoaded. * * Sequence: * 1. Init IndexedDB storage * 2. Dynamically import bootstrap.mts — the heavy ibgib graph loads here */ async function spinOffStartup(): Promise { const lc = `[${spinOffStartup.name}]`; try { if (logalot) { console.log(`${lc} starting... (I: 3d893846d02c4ff49181f9b8e586eb74)`); } console.time(lc); document.addEventListener('DOMContentLoaded', async () => { try { console.timeLog(lc, 'DOMContentLoaded fired'); await initIbGibStorage(APP_CONFIG); console.timeLog(lc, 'initIbGibStorage complete'); await dynamicallyLoadBootstrapScript('./bootstrap.mjs'); console.timeLog(lc, 'dynamicallyLoadBootstrapScript complete'); initDevTools(); console.timeLog(lc, 'initDevTools complete'); console.timeEnd(lc); } catch (error) { console.error(`${lc} ${extractErrorMsg(error)}`); throw error; } }); } catch (error) { console.timeEnd(lc); debugger; // error in index.mts — investigate immediately console.error(`${lc} ${extractErrorMsg(error)}`); throw error; } finally { if (logalot) { console.log(`${lc} complete.`); } } } spinOffStartup();