(function () { var errorEl = null; function showGlobalErrorPage() { if (errorEl) { return; } errorEl = document.createElement('div'); errorEl.innerHTML = [ '', '
', '', '
', '

Unsupported Environment

', '

', 'It looks like AFFiNE cannot run in this environment.', "Please ensure you are using a supported browser or update your device's operating system to the latest version.", 'If the issue persists, visit our support page for further assistance.', '

', '
', '
', ].join(''); errorEl.setAttribute( 'style', 'position:absolute;top:0;left:0;height:100vh;width:100vw;display:flex;flex-direction:column;align-items:center;justify-content:center;background:white;z-index:999;' ); document.body.append(errorEl); } /** * @param event {PromiseRejectionEvent|ErrorEvent} */ function handler(event) { var error; if ('error' in event) { error = event.error || (event.message === 'Script error.' ? new SyntaxError(event.message) : new Error(event.message)); } else { error = event.reason; } console.error('unhandled unrecoverable error', error); var shouldCache = // syntax error error && error instanceof SyntaxError; if (!shouldCache) { return; } event.stopImmediatePropagation(); showGlobalErrorPage(); } function registerGlobalErrorHandler() { if (typeof document !== 'undefined') { globalThis.addEventListener('unhandledrejection', handler); globalThis.addEventListener('error', handler); return function () { globalThis.removeEventListener('unhandledrejection', handler); globalThis.removeEventListener('error', handler); }; } return null; } function unregisterRegisterGlobalErrorHandler(fn) { if (typeof fn === 'function') { var app = document.getElementById('app'); if (app) { var ob = new MutationObserver(function () { fn(); ob.disconnect(); ob = null; }); ob.observe(app, { childList: true }); } } } function ensureBasicEnvironment() { var globals = [ 'Promise', 'Map', 'fetch', 'customElements', 'MutationObserver', ]; // eslint-disable-next-line @typescript-eslint/prefer-for-of for (var i = 0; i < globals.length; i++) { if (!(globals[i] in globalThis)) { showGlobalErrorPage(); return; } } } ensureBasicEnvironment(); var goodtogo = registerGlobalErrorHandler(); unregisterRegisterGlobalErrorHandler(goodtogo); })();