SHA256
667 lines
35 KiB
HTML
667 lines
35 KiB
HTML
<!doctype html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta
|
||
name="viewport"
|
||
content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-visual"
|
||
/>
|
||
<meta name="theme-color" content="#121419" />
|
||
<base href="/" />
|
||
<link rel="manifest" href="./manifest.webmanifest" />
|
||
<link rel="icon" type="image/jpeg" href="./img/logo.jpg" />
|
||
<link rel="apple-touch-icon" href="./img/logo.jpg" />
|
||
<title>СИЯНИЕ</title>
|
||
<script id="shine-stage0-startup-diagnostics">
|
||
// Stage 0: пассивные метки только при включённых инструментах разработчика.
|
||
(function initializeStartupDiagnostics() {
|
||
let debugEnabled = false;
|
||
try {
|
||
const flag = localStorage.getItem('shine-feature-developer-tools-v1');
|
||
debugEnabled = flag === '1' || flag === 'true';
|
||
} catch {}
|
||
if (!debugEnabled || !window.performance || typeof performance.mark !== 'function') return;
|
||
|
||
const allowed = new Set([
|
||
'bootstrap', 'dom_ready', 'css_start', 'css_ok', 'css_error', 'css_complete', 'css_revealed',
|
||
'main_js_requested', 'main_js_start', 'first_dom_render', 'splash_leave', 'splash_removed',
|
||
'ws_attempt', 'ws_open', 'ws_error', 'ws_close',
|
||
'session_restore_start', 'session_restore_ok', 'session_restore_failed',
|
||
'reconnect_restore_start', 'reconnect_restore_ok', 'reconnect_restore_failed',
|
||
'health_invoked', 'health_skipped_inflight', 'health_local_demo',
|
||
'status_connected', 'splash_finish_called', 'splash_transition_start',
|
||
'splash_removed_via_transition', 'splash_removed_via_timeout',
|
||
]);
|
||
const single = new Set([
|
||
'bootstrap', 'dom_ready', 'css_start', 'css_complete', 'css_revealed',
|
||
'main_js_requested', 'main_js_start', 'first_dom_render', 'splash_leave', 'splash_removed',
|
||
'session_restore_start', 'session_restore_ok', 'session_restore_failed',
|
||
'splash_transition_start', 'splash_removed_via_transition', 'splash_removed_via_timeout',
|
||
]);
|
||
const operationsAllowed = new Set([
|
||
'connection_health', 'monitor_start', 'ping', 'pwa_first_ping_update', 'ui_version_ping',
|
||
'ui_version_periodic', 'ui_version_fetch', 'sw_refresh',
|
||
'sw_get_registrations', 'sw_registration_update', 'sw_skip_waiting',
|
||
]);
|
||
const operationContexts = new Set([
|
||
'first_ping', 'reload', 'bootstrap', 'session_runtime', 'session_reset',
|
||
'periodic', 'visibility', 'retry_countdown', 'manual_retry', 'unspecified',
|
||
]);
|
||
const safeErrorNames = new Set([
|
||
'AbortError', 'TimeoutError', 'NetworkError', 'SecurityError', 'InvalidStateError',
|
||
'NotAllowedError', 'NotFoundError', 'TypeError', 'SyntaxError', 'RangeError', 'Error',
|
||
'HttpResponseNotOk',
|
||
]);
|
||
const operations = [];
|
||
const pendingOperations = new Map();
|
||
let operationsDropped = 0;
|
||
let nextOperationId = 0;
|
||
const events = [];
|
||
const counts = Object.create(null);
|
||
const first = Object.create(null);
|
||
const maxEvents = 256;
|
||
const round = (value) => Math.round(value * 10) / 10;
|
||
function mark(stage) {
|
||
try {
|
||
if (!allowed.has(stage)) return;
|
||
if (single.has(stage) && Object.hasOwn(first, stage)) return;
|
||
if (stage === 'session_restore_failed' && Object.hasOwn(first, 'session_restore_ok')) return;
|
||
const atMs = round(performance.now());
|
||
counts[stage] = (counts[stage] || 0) + 1;
|
||
if (!Object.hasOwn(first, stage)) first[stage] = atMs;
|
||
if (events.length < maxEvents) {
|
||
performance.mark('shine-stage0:' + stage);
|
||
events.push({ stage, atMs });
|
||
}
|
||
} catch {
|
||
// Измерение никогда не должно прерывать запуск приложения.
|
||
}
|
||
}
|
||
// Only fixed stage/operation names and fixed error classes can enter the export.
|
||
// Numeric ids are local measurement sequence numbers, never request/session ids.
|
||
function begin(operation, context = null) {
|
||
try {
|
||
if (!operationsAllowed.has(operation)) return null;
|
||
if (operations.length >= 256) { operationsDropped += 1; return null; }
|
||
const id = ++nextOperationId;
|
||
const item = { id, operation, startMs: round(performance.now()), endMs: null,
|
||
durationMs: null, outcome: 'pending' };
|
||
if (operationContexts.has(context)) item.context = context;
|
||
operations.push(item);
|
||
pendingOperations.set(id, item);
|
||
performance.mark('shine-stage0:' + operation + ':start');
|
||
return id;
|
||
} catch { return null; }
|
||
}
|
||
function finish(id, outcome = 'ok', error = null) {
|
||
try {
|
||
const item = pendingOperations.get(id);
|
||
if (!item) return;
|
||
pendingOperations.delete(id);
|
||
const endMs = round(performance.now());
|
||
item.endMs = endMs;
|
||
item.durationMs = round(endMs - item.startMs);
|
||
item.outcome = outcome === 'error' ? 'error'
|
||
: outcome === 'restore-unavailable' ? 'restore-unavailable'
|
||
: outcome === 'deduplicated' ? 'deduplicated' : 'ok';
|
||
if (item.outcome === 'error') {
|
||
let name;
|
||
try { name = error?.name; } catch {}
|
||
item.errorType = safeErrorNames.has(name) ? name : 'UnknownError';
|
||
}
|
||
performance.mark('shine-stage0:' + item.operation + ':end');
|
||
} catch {
|
||
// A diagnostic failure must never affect a network or UI operation.
|
||
}
|
||
}
|
||
function exportJson() {
|
||
const timing = Object.create(null);
|
||
for (const stage of allowed) {
|
||
if (Object.hasOwn(first, stage)) timing[stage] = first[stage];
|
||
}
|
||
const interval = (a, b) => a in first && b in first ? round(first[b] - first[a]) : null;
|
||
let domContentLoadedMs = null;
|
||
let firstContentfulPaintMs = null;
|
||
try {
|
||
const navigation = performance.getEntriesByType('navigation')[0];
|
||
if (navigation && Number.isFinite(navigation.domContentLoadedEventEnd)) {
|
||
domContentLoadedMs = round(navigation.domContentLoadedEventEnd);
|
||
}
|
||
const paint = performance.getEntriesByType('paint').find((item) => item.name === 'first-contentful-paint');
|
||
if (paint) firstContentfulPaintMs = round(paint.startTime);
|
||
} catch {}
|
||
return JSON.stringify({
|
||
schema: 'shine-stage0-v1',
|
||
units: 'milliseconds_since_navigation_start',
|
||
timing,
|
||
durations: {
|
||
cssAllSettledMs: interval('css_start', 'css_complete'),
|
||
cssRevealMs: interval('css_start', 'css_revealed'),
|
||
moduleLoadAndEvaluationMs: interval('main_js_requested', 'main_js_start'),
|
||
sessionRestoreMs: interval('session_restore_start',
|
||
'session_restore_ok' in first ? 'session_restore_ok' : 'session_restore_failed'),
|
||
splashRemovalMs: interval('bootstrap', 'splash_removed'),
|
||
renderToSplashLeaveMs: interval('first_dom_render', 'splash_leave'),
|
||
connectedToSplashLeaveMs: interval('status_connected', 'splash_leave'),
|
||
splashTransitionToRemovalMs: interval('splash_transition_start', 'splash_removed'),
|
||
},
|
||
browser: { domContentLoadedMs, firstContentfulPaintMs },
|
||
counters: {
|
||
cssLoaded: counts.css_ok || 0,
|
||
cssFailed: counts.css_error || 0,
|
||
wsAttempts: counts.ws_attempt || 0,
|
||
wsAttemptsAfterFirst: Math.max(0, (counts.ws_attempt || 0) - 1),
|
||
wsOpened: counts.ws_open || 0,
|
||
wsOpenErrors: counts.ws_error || 0,
|
||
wsClosed: counts.ws_close || 0,
|
||
sessionRestoreFailures: counts.session_restore_failed || 0,
|
||
reconnectRestoreFailures: counts.reconnect_restore_failed || 0,
|
||
eventsDropped: Object.values(counts).reduce((sum, n) => sum + n, 0) - events.length,
|
||
pingStarted: operations.filter((op) => op.operation === 'ping').length,
|
||
pingCompleted: operations.filter((op) => op.operation === 'ping' && op.endMs !== null).length,
|
||
connectedAssignments: counts.status_connected || 0,
|
||
splashFinishCalls: counts.splash_finish_called || 0,
|
||
operationsDropped,
|
||
},
|
||
events: events.slice(),
|
||
splashTrace: {
|
||
// No record means the operation was never observed. A pending record has
|
||
// endMs/durationMs null; it must not be confused with a zero-duration call.
|
||
operations: operations.map((item) => ({ ...item })),
|
||
},
|
||
}, null, 2);
|
||
}
|
||
Object.defineProperty(window, '__SHINE_STAGE0__', {
|
||
value: Object.freeze({ mark, begin, finish }), configurable: false, writable: false,
|
||
});
|
||
Object.defineProperty(window, '__SHINE_STAGE0_EXPORT__', {
|
||
value: exportJson, configurable: false, writable: false,
|
||
});
|
||
mark('bootstrap');
|
||
document.addEventListener('DOMContentLoaded', () => mark('dom_ready'), { once: true });
|
||
}());
|
||
</script>
|
||
<script>
|
||
(function applySavedThemeBeforePaint() {
|
||
let mode = 'system';
|
||
try {
|
||
const saved = localStorage.getItem('shine-ui-theme-mode-v1');
|
||
if (saved === 'light' || saved === 'dark' || saved === 'system') mode = saved;
|
||
} catch {}
|
||
const resolved = mode === 'system'
|
||
? (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark')
|
||
: mode;
|
||
document.documentElement.dataset.themeMode = mode;
|
||
document.documentElement.dataset.theme = resolved;
|
||
document.documentElement.style.colorScheme = resolved;
|
||
// Своя палитра (см. js/services/theme-service.js) применяется до отрисовки, без вспышки.
|
||
try {
|
||
const applied = JSON.parse(localStorage.getItem('shine-ui-palette-applied-v1') || 'null');
|
||
const colors = applied && applied[resolved];
|
||
if (colors) {
|
||
Object.keys(colors).forEach(function (role) {
|
||
if (/^#[0-9a-f]{6}$/i.test(colors[role])) document.documentElement.style.setProperty('--' + role, colors[role]);
|
||
});
|
||
if (colors.accent) document.documentElement.style.setProperty('--focus-ring', colors.accent);
|
||
}
|
||
} catch {}
|
||
}());
|
||
</script>
|
||
<script>
|
||
window.__SHINE_BUILD_HASH__ = '20261015230000';
|
||
window.__SHINE_CLIENT_VERSION__ = '1.2.10';
|
||
</script>
|
||
<script>
|
||
(function attachStylesWithBuildHash() {
|
||
const v = encodeURIComponent(window.__SHINE_BUILD_HASH__ || 'dev');
|
||
const cssFiles = ['./styles/main.css', './styles/layout.css', './styles/app-shell.css', './styles/buttons-white.css', './styles/components/topbar.css', './styles/components/dropdown-menu.css', './styles/components/primitives.css', './styles/components/feedback.css', './styles/components/tabs.css', './styles/components/chips.css', './styles/components/nav-list.css', './styles/components/palette-editor.css', './styles/components/avatar.css', './styles/components/modal.css', './styles/components/person-note.css', './styles/components/person-row.css', './styles/components/compose.css', './styles/components/attachments.css', './styles/components/media-viewer.css', './styles/components/channel-editor.css', './styles/components/emoji-picker.css', './styles/components/call-ui.css', './styles/components/scroll-to-bottom.css', './styles/components/overflow-dots.css', './styles/components/toolbar.css', './styles/features/preauth.css', './styles/features/messages.css', './styles/features/chat.css', './styles/features/channels-common.css', './styles/features/channels-list.css', './styles/features/channel.css', './styles/features/channel-thread.css', './styles/features/notifications.css', './styles/features/network.css', './styles/features/profile.css', './styles/features/profile-page.css', './styles/features/settings.css', './styles/features/devices.css', './styles/features/developer-tools.css', './styles/network-graph.css', './styles/network-legacy.css'];
|
||
// Стили, добавленные скриптом, браузер не ждёт перед первой отрисовкой: без этого
|
||
// на долю секунды виден экран без CSS (логотип 640×640), а потом он «прыгает» на место.
|
||
const root = document.documentElement;
|
||
let pending = cssFiles.length;
|
||
const reveal = () => { root.classList.add('shine-styles-ready'); window.__SHINE_STAGE0__?.mark('css_revealed'); };
|
||
const settle = (event) => {
|
||
window.__SHINE_STAGE0__?.mark(event?.type === 'error' ? 'css_error' : 'css_ok');
|
||
pending -= 1;
|
||
if (pending <= 0) { window.__SHINE_STAGE0__?.mark('css_complete'); reveal(); }
|
||
};
|
||
window.__SHINE_STAGE0__?.mark('css_start');
|
||
cssFiles.forEach((file) => {
|
||
const link = document.createElement('link');
|
||
link.rel = 'stylesheet';
|
||
link.href = `${file}?v=${v}`;
|
||
link.onload = settle;
|
||
link.onerror = settle;
|
||
document.head.appendChild(link);
|
||
});
|
||
setTimeout(reveal, 4000);
|
||
}());
|
||
</script>
|
||
<style>
|
||
html { background: var(--background, #121419); }
|
||
html[data-theme='light'] { background: var(--background, #f3f2f7); }
|
||
html:not(.shine-styles-ready) body { visibility: hidden; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<!-- Заставка повторяет верх экрана входа (те же классы и раскладка): смена на него незаметна. -->
|
||
<div id="initial-splash" class="initial-splash">
|
||
<div class="initial-splash__frame">
|
||
<section class="auth-screen auth-screen--welcome">
|
||
<div class="auth-logo-wrap">
|
||
<img class="auth-logo" src="./img/shine-logo-transparent-final.png" alt="Логотип Сияние" />
|
||
</div>
|
||
<div class="stack auth-brand-block">
|
||
<h1 class="auth-brand"><svg class="shine-wordmark" viewBox="52 -722 7294 744" role="img" aria-label="Сияние"><path fill="currentColor" d="M721 -129Q619 -33 479 -33Q401 -33 341 -60Q281 -87 241 -132Q201 -177 180.5 -236Q160 -295 160 -359Q160 -427 181.5 -483.5Q203 -540 242 -581Q281 -622 334.5 -645Q388 -668 451 -668Q494 -668 529.5 -658Q565 -648 592.5 -632Q620 -616 637.5 -595.5Q655 -575 662 -554H736Q721 -588 697.5 -617Q674 -646 639 -667Q604 -688 557 -700Q510 -712 450 -712Q363 -712 291.5 -687Q220 -662 169 -615.5Q118 -569 90 -503.5Q62 -438 62 -357Q62 -287 84.5 -220.5Q107 -154 154 -102.5Q201 -51 274 -19.5Q347 12 448 12Q512 12 562.5 0Q613 -12 650.5 -29.5Q688 -47 713 -67Q738 -87 751 -102ZM1542 -82V-700H1451V0H1542L1957 -625V0H2048V-700H1957ZM3316 -700V0H3225V-309H3181Q3153 -309 3134.5 -304Q3116 -299 3101 -287Q3086 -275 3073 -256Q3060 -237 3042 -209L2963 -92Q2948 -69 2933.5 -50Q2919 -31 2902 -17.5Q2885 -4 2863.5 4Q2842 12 2812 12Q2790 12 2776 10Q2762 8 2748 0V-37Q2753 -36 2758 -35.5Q2763 -35 2768 -35Q2789 -35 2805 -41Q2821 -47 2835 -58.5Q2849 -70 2862 -86.5Q2875 -103 2889 -124Q2931 -185 2954 -221.5Q2977 -258 2990.5 -278Q3004 -298 3012.5 -307Q3021 -316 3033 -322L3043 -327V-331Q2995 -334 2960.5 -352Q2926 -370 2904 -397Q2882 -424 2872 -455.5Q2862 -487 2862 -517Q2862 -544 2872.5 -576Q2883 -608 2908.5 -635.5Q2934 -663 2978 -681.5Q3022 -700 3089 -700ZM3225 -656H3124Q3086 -656 3055.5 -645Q3025 -634 3003 -614.5Q2981 -595 2969.5 -568Q2958 -541 2958 -509Q2958 -482 2968.5 -454.5Q2979 -427 3000 -404.5Q3021 -382 3051.5 -368Q3082 -354 3122 -354H3225ZM4197 -348H4616V0H4707V-700H4616V-394H4197V-700H4106V0H4197ZM5588 -82V-700H5497V0H5588L6003 -625V0H6094V-700H6003ZM6884 -700V0H7336V-55H6975V-346H7285V-394H6975V-645H7336V-700Z"/></svg></h1>
|
||
<p class="meta-muted auth-site-name" id="initial-splash-host"></p>
|
||
</div>
|
||
<div class="auth-actions shine-actions initial-splash__actions" aria-hidden="true">
|
||
<span class="shine-btn"></span>
|
||
<span class="secondary-btn shine-btn--register"></span>
|
||
<span class="text-btn start-language-link"></span>
|
||
<span class="text-btn start-settings-link"></span>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<script>
|
||
document.getElementById('initial-splash-host').textContent = window.location.host || 'shineup.me';
|
||
</script>
|
||
</div>
|
||
<div class="app-shell">
|
||
<div id="topbar-slot" class="topbar-slot" hidden></div>
|
||
<main id="app-screen" class="screen-content"></main>
|
||
<div id="composer-slot" class="composer-slot" hidden></div>
|
||
<div id="toolbar-slot" class="toolbar-slot" hidden></div>
|
||
<div class="app-shell-fade app-shell-fade--top" aria-hidden="true"></div>
|
||
<div class="app-shell-fade app-shell-fade--bottom" aria-hidden="true"></div>
|
||
</div>
|
||
<div id="modal-root"></div>
|
||
<script>
|
||
// Public VAPID key for Web Push (Base64URL)
|
||
window.__SHINE_WEBPUSH_VAPID_PUBLIC_KEY__ = 'BOdoWZndZRaNe9kyUFsJ5-xEfFABXNKennAKg15Z7ycAwUIQ7yDV_sIWWYJCwJriN4g9oU-CyJPrn1U6lfxuDbI';
|
||
</script>
|
||
<script>
|
||
(function attachBootErrorOverlay() {
|
||
const stateKey = '__SHINE_BOOT_ERROR_STATE__';
|
||
const menuId = 'boot-error-action-sheet';
|
||
const escapeText = (value) => String(value == null ? '' : value)
|
||
.replace(/&/g, '&')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>')
|
||
.replace(/"/g, '"');
|
||
const safeString = (value, maxLen = 1000) => {
|
||
const text = String(value == null ? '' : value).trim();
|
||
if (text.length <= maxLen) return text;
|
||
return `${text.slice(0, Math.max(0, maxLen - 3))}...`;
|
||
};
|
||
const setState = (next) => {
|
||
try {
|
||
window[stateKey] = next;
|
||
} catch {}
|
||
};
|
||
const getState = () => {
|
||
try {
|
||
return window[stateKey] || null;
|
||
} catch {
|
||
return null;
|
||
}
|
||
};
|
||
const getKnownClientError = () => {
|
||
try {
|
||
return typeof window.__SHINE_GET_LAST_CLIENT_ERROR__ === 'function'
|
||
? window.__SHINE_GET_LAST_CLIENT_ERROR__()
|
||
: null;
|
||
} catch {
|
||
return null;
|
||
}
|
||
};
|
||
const showFeedback = (message, kind = 'success') => {
|
||
try {
|
||
if (typeof window.__SHINE_SHOW_TOAST__ === 'function') {
|
||
window.__SHINE_SHOW_TOAST__(message, kind);
|
||
} else {
|
||
console.info(message);
|
||
}
|
||
} catch {}
|
||
};
|
||
const buildReport = () => {
|
||
const state = getState() || {};
|
||
const known = getKnownClientError();
|
||
const viewport = {
|
||
width: Math.round(window.innerWidth || 0),
|
||
height: Math.round(window.innerHeight || 0),
|
||
dpr: Number(window.devicePixelRatio || 1),
|
||
visualWidth: Math.round(window.visualViewport?.width || 0),
|
||
visualHeight: Math.round(window.visualViewport?.height || 0),
|
||
visualScale: Number(window.visualViewport?.scale || 1),
|
||
};
|
||
const screenInfo = window.screen ? {
|
||
width: Math.round(window.screen.width || 0),
|
||
height: Math.round(window.screen.height || 0),
|
||
availWidth: Math.round(window.screen.availWidth || 0),
|
||
availHeight: Math.round(window.screen.availHeight || 0),
|
||
pixelDepth: Number(window.screen.pixelDepth || 0),
|
||
} : null;
|
||
return {
|
||
kind: safeString(state.kind || 'boot_error', 64),
|
||
title: safeString(state.title || 'BOOT ERROR', 128),
|
||
message: safeString(state.message || '', 500),
|
||
stack: safeString(state.stack || '', 8000),
|
||
sourceUrl: safeString(state.sourceUrl || '', 240),
|
||
lineNumber: Number.isFinite(state.lineNumber) ? state.lineNumber : null,
|
||
columnNumber: Number.isFinite(state.columnNumber) ? state.columnNumber : null,
|
||
reasonType: safeString(state.reasonType || '', 64),
|
||
route: safeString(window.location.hash || window.location.pathname || '', 200),
|
||
href: safeString(window.location.href || '', 240),
|
||
pageTitle: safeString(document.title || '', 200),
|
||
pageVisibility: safeString(document.visibilityState || '', 32),
|
||
userAgent: safeString(navigator.userAgent || '', 240),
|
||
locale: safeString(navigator.language || '', 32),
|
||
clientTs: Number.isFinite(state.clientTs) ? state.clientTs : Date.now(),
|
||
viewport,
|
||
screenInfo,
|
||
lastKnownClientError: known || null,
|
||
contextJson: safeString(JSON.stringify({
|
||
bootState: state,
|
||
currentRoute: window.location.hash || window.location.pathname || '',
|
||
hasClientErrorSender: typeof window.__SHINE_SEND_CLIENT_ERROR__ === 'function',
|
||
}), 2000),
|
||
};
|
||
};
|
||
const buildSendPayload = (report) => {
|
||
const payload = {
|
||
kind: safeString(report?.kind || 'boot_error', 64),
|
||
message: safeString(report?.message || report?.title || 'Неизвестная ошибка', 500),
|
||
stack: safeString(report?.stack || '', 8000),
|
||
sourceUrl: safeString(report?.sourceUrl || '', 240),
|
||
lineNumber: Number.isFinite(report?.lineNumber) ? report.lineNumber : null,
|
||
columnNumber: Number.isFinite(report?.columnNumber) ? report.columnNumber : null,
|
||
route: safeString(report?.route || '', 200),
|
||
href: safeString(report?.href || '', 240),
|
||
userAgent: safeString(report?.userAgent || '', 240),
|
||
clientTs: Number.isFinite(report?.clientTs) ? report.clientTs : Date.now(),
|
||
requestOp: '',
|
||
requestIdRef: '',
|
||
contextJson: safeString(JSON.stringify({
|
||
...report,
|
||
contextJson: undefined,
|
||
}), 2000),
|
||
};
|
||
return payload;
|
||
};
|
||
const shareErrorText = async (report) => {
|
||
const text = formatReportText(report);
|
||
if (!text) throw new Error('Текст ошибки пуст');
|
||
if (!navigator.share) {
|
||
throw new Error('Отправка через системное меню недоступна в этом браузере');
|
||
}
|
||
try {
|
||
await navigator.share({
|
||
title: report?.title || 'Описание ошибки',
|
||
text,
|
||
});
|
||
} catch (error) {
|
||
if (error?.name === 'AbortError') return false;
|
||
throw error;
|
||
}
|
||
return true;
|
||
};
|
||
const formatReportText = (report) => {
|
||
const lines = [
|
||
`Ошибка: ${report.title || report.kind || 'unknown'}`,
|
||
`Описание: ${report.message || '–'}`,
|
||
`Окно: ${report.pageTitle || '–'}`,
|
||
`Маршрут: ${report.route || '–'}`,
|
||
`URL: ${report.href || '–'}`,
|
||
`Видимость: ${report.pageVisibility || '–'}`,
|
||
`Время: ${new Date(Number(report.clientTs || Date.now())).toISOString()}`,
|
||
`UA: ${report.userAgent || '–'}`,
|
||
`Экран: ${report.viewport ? `${report.viewport.width}x${report.viewport.height} @${report.viewport.dpr || 1}x` : '–'}`,
|
||
`Монитор: ${report.screenInfo ? `${report.screenInfo.width}x${report.screenInfo.height}` : '–'}`,
|
||
`Источник: ${report.sourceUrl || '–'}`,
|
||
`Строка: ${Number.isFinite(report.lineNumber) ? report.lineNumber : '–'}`,
|
||
`Колонка: ${Number.isFinite(report.columnNumber) ? report.columnNumber : '–'}`,
|
||
`Тип причины: ${report.reasonType || '–'}`,
|
||
];
|
||
if (report.stack) {
|
||
lines.push('Stack:', report.stack);
|
||
}
|
||
if (report.lastKnownClientError) {
|
||
lines.push('Последняя известная ошибка:', JSON.stringify(report.lastKnownClientError, null, 2));
|
||
}
|
||
if (report.contextJson) {
|
||
lines.push('Контекст:', report.contextJson);
|
||
}
|
||
return lines.join('\n');
|
||
};
|
||
const copyText = async (text) => {
|
||
const value = String(text || '');
|
||
if (!value) return false;
|
||
if (navigator.clipboard?.writeText) {
|
||
await navigator.clipboard.writeText(value);
|
||
return true;
|
||
}
|
||
const ta = document.createElement('textarea');
|
||
ta.value = value;
|
||
ta.setAttribute('readonly', 'readonly');
|
||
ta.style.position = 'fixed';
|
||
ta.style.opacity = '0';
|
||
ta.style.pointerEvents = 'none';
|
||
document.body.append(ta);
|
||
ta.focus();
|
||
ta.select();
|
||
const ok = document.execCommand('copy');
|
||
ta.remove();
|
||
return !!ok;
|
||
};
|
||
const removeMenu = () => {
|
||
try {
|
||
document.getElementById(menuId)?.remove();
|
||
} catch {}
|
||
};
|
||
const dismissError = () => {
|
||
removeMenu();
|
||
try {
|
||
document.getElementById('boot-error-overlay')?.remove();
|
||
setState(null);
|
||
} catch {}
|
||
};
|
||
const openMenu = () => {
|
||
try {
|
||
removeMenu();
|
||
document.dispatchEvent(new CustomEvent('shine:dropdown-open', { detail: { owner: 'boot-error' } }));
|
||
const report = buildReport();
|
||
const root = document.getElementById('modal-root') || document.body;
|
||
const shell = document.createElement('div');
|
||
shell.id = menuId;
|
||
shell.className = 'modal-shell boot-error-menu-shell';
|
||
// Красная строка BOOT ERROR имеет z-index 999999. Меню ошибки должно
|
||
// всегда находиться поверх неё, не меняя слои остальных модальных окон.
|
||
shell.style.zIndex = '1000000';
|
||
shell.innerHTML = `
|
||
<div class="modal-backdrop" data-action="close"></div>
|
||
<div class="modal-dialog boot-error-menu-dialog" role="dialog" aria-modal="true" aria-labelledby="boot-error-menu-title" tabindex="-1">
|
||
<div class="modal-card stack boot-error-menu-card">
|
||
<strong class="modal-title" id="boot-error-menu-title">Описание ошибки</strong>
|
||
<p class="meta-muted boot-error-menu-message">${escapeText(report.message || report.title || 'Ошибка')}</p>
|
||
<button type="button" class="secondary-btn" data-action="copy">Скопировать текст ошибки</button>
|
||
<button type="button" class="secondary-btn" data-action="share">Отправить текст ошибки</button>
|
||
<button type="button" class="secondary-btn" data-action="send"${typeof window.__SHINE_SEND_CLIENT_ERROR_TO_SERVER__ === 'function' ? '' : ' disabled'}>Отправить в лог на сервере</button>
|
||
<button type="button" class="secondary-btn" data-action="dismiss">Закрыть</button>
|
||
</div>
|
||
</div>
|
||
`;
|
||
root.append(shell);
|
||
|
||
const dialog = shell.querySelector('.modal-dialog');
|
||
const close = () => {
|
||
window.removeEventListener('keydown', onKeyDown);
|
||
shell.remove();
|
||
};
|
||
const onKeyDown = (event) => {
|
||
if (event.key === 'Escape') {
|
||
event.preventDefault();
|
||
close();
|
||
}
|
||
};
|
||
|
||
shell.addEventListener('click', (event) => {
|
||
if (event.target === shell || event.target?.dataset?.action === 'close') {
|
||
close();
|
||
}
|
||
});
|
||
|
||
shell.querySelector('[data-action="copy"]')?.addEventListener('click', async () => {
|
||
try {
|
||
await copyText(formatReportText(report));
|
||
showFeedback('Описание ошибки скопировано');
|
||
} catch {
|
||
showFeedback('Не удалось скопировать описание ошибки', 'error');
|
||
}
|
||
close();
|
||
});
|
||
|
||
shell.querySelector('[data-action="share"]')?.addEventListener('click', async () => {
|
||
try {
|
||
const shared = await shareErrorText(report);
|
||
if (shared === false) return close();
|
||
showFeedback('Текст ошибки открыт для отправки');
|
||
} catch (error) {
|
||
showFeedback(error?.message || 'Не удалось открыть системное меню отправки', 'error');
|
||
}
|
||
close();
|
||
});
|
||
|
||
shell.querySelector('[data-action="send"]')?.addEventListener('click', async () => {
|
||
try {
|
||
const sender = window.__SHINE_SEND_CLIENT_ERROR_TO_SERVER__;
|
||
if (typeof sender !== 'function') {
|
||
throw new Error('Отправка в лог на сервере недоступна');
|
||
}
|
||
const ok = await sender(buildSendPayload(report));
|
||
if (!ok) {
|
||
throw new Error('Не удалось отправить ошибку в лог на сервере');
|
||
}
|
||
showFeedback('Ошибка отправлена в лог на сервере');
|
||
} catch (error) {
|
||
showFeedback(error?.message || 'Не удалось отправить ошибку в лог на сервере', 'error');
|
||
}
|
||
close();
|
||
});
|
||
|
||
shell.querySelector('[data-action="dismiss"]')?.addEventListener('click', () => {
|
||
close();
|
||
try {
|
||
document.getElementById('boot-error-overlay')?.remove();
|
||
setState(null);
|
||
} catch {}
|
||
});
|
||
const onPeerDropdownOpen = (event) => {
|
||
if (event?.detail?.owner === 'boot-error') return;
|
||
close();
|
||
};
|
||
document.addEventListener('shine:dropdown-open', onPeerDropdownOpen, { once: true });
|
||
dialog?.focus?.();
|
||
window.addEventListener('keydown', onKeyDown);
|
||
} catch (error) {
|
||
console.warn('boot error menu failed', error);
|
||
}
|
||
};
|
||
const show = (title, text, extra = {}) => {
|
||
try {
|
||
const reportState = {
|
||
kind: safeString(extra.kind || title || 'boot_error', 64),
|
||
title: safeString(title || 'BOOT ERROR', 128),
|
||
message: safeString(extra.message || text || '', 500),
|
||
stack: safeString(extra.stack || '', 8000),
|
||
sourceUrl: safeString(extra.sourceUrl || extra.filename || '', 240),
|
||
lineNumber: Number.isFinite(extra.lineNumber) ? extra.lineNumber : (Number.isFinite(extra.lineno) ? extra.lineno : null),
|
||
columnNumber: Number.isFinite(extra.columnNumber) ? extra.columnNumber : (Number.isFinite(extra.colno) ? extra.colno : null),
|
||
reasonType: safeString(extra.reasonType || '', 64),
|
||
clientTs: Number.isFinite(extra.clientTs) ? extra.clientTs : Date.now(),
|
||
};
|
||
setState(reportState);
|
||
|
||
let el = document.getElementById('boot-error-overlay');
|
||
if (!el) {
|
||
el = document.createElement('pre');
|
||
el.id = 'boot-error-overlay';
|
||
el.style.position = 'fixed';
|
||
el.style.left = '8px';
|
||
el.style.right = '8px';
|
||
el.style.bottom = '8px';
|
||
el.style.maxHeight = '40vh';
|
||
el.style.overflow = 'auto';
|
||
el.style.padding = '10px';
|
||
el.style.margin = '0';
|
||
el.style.background = 'rgba(120, 0, 0, 0.92)';
|
||
el.style.color = '#fff';
|
||
el.style.fontSize = '12px';
|
||
el.style.lineHeight = '1.4';
|
||
el.style.zIndex = '999999';
|
||
el.style.whiteSpace = 'pre-wrap';
|
||
el.style.cursor = 'pointer';
|
||
el.style.userSelect = 'none';
|
||
el.style.webkitUserSelect = 'none';
|
||
el.style.touchAction = 'manipulation';
|
||
el.setAttribute('role', 'button');
|
||
el.setAttribute('tabindex', '0');
|
||
el.setAttribute('aria-haspopup', 'dialog');
|
||
document.body.appendChild(el);
|
||
el.addEventListener('click', openMenu);
|
||
el.addEventListener('keydown', (event) => {
|
||
if (event.key === 'Enter' || event.key === ' ') {
|
||
event.preventDefault();
|
||
openMenu();
|
||
}
|
||
});
|
||
}
|
||
el.textContent = `[BOOT ERROR] ${title}\n${String(text || '')}`;
|
||
el.setAttribute('aria-label', `${title}. Нажмите, чтобы открыть меню действий.`);
|
||
el.title = 'Нажмите, чтобы открыть меню действий';
|
||
} catch {}
|
||
};
|
||
window.addEventListener('error', (e) => {
|
||
// Предупреждение браузера о переносе замеров ResizeObserver на следующий кадр – не ошибка
|
||
if (/^ResizeObserver loop/.test(String(e?.message || ''))) return;
|
||
show('window.error', `${e?.message || ''}\n${e?.filename || ''}:${e?.lineno || ''}:${e?.colno || ''}`, {
|
||
kind: 'window_error',
|
||
message: e?.message || '',
|
||
stack: e?.error?.stack || '',
|
||
sourceUrl: e?.filename || '',
|
||
lineNumber: e?.lineno,
|
||
columnNumber: e?.colno,
|
||
reasonType: e?.error?.constructor?.name || e?.constructor?.name || 'ErrorEvent',
|
||
});
|
||
});
|
||
window.addEventListener('unhandledrejection', (e) => {
|
||
const reason = e?.reason;
|
||
show('unhandledrejection', reason?.stack || reason?.message || String(reason || 'unknown'), {
|
||
kind: 'unhandled_rejection',
|
||
message: reason?.message || String(reason || 'Unhandled promise rejection'),
|
||
stack: reason?.stack || '',
|
||
reasonType: reason?.constructor?.name || typeof reason,
|
||
});
|
||
});
|
||
}());
|
||
</script>
|
||
<script>
|
||
(async function attachAppWithBuildHash() {
|
||
const isLocalPreview = ['localhost', '127.0.0.1', '::1'].includes(String(window.location.hostname || '').toLowerCase());
|
||
if (isLocalPreview && 'serviceWorker' in navigator) {
|
||
try {
|
||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||
await Promise.all(registrations.map((registration) => registration.unregister()));
|
||
} catch {}
|
||
}
|
||
const v = encodeURIComponent(window.__SHINE_BUILD_HASH__ || 'dev');
|
||
const script = document.createElement('script');
|
||
script.type = 'module';
|
||
script.src = isLocalPreview ? `./js/app.js?v=${v}&local=${Date.now()}` : `./js/app.js?v=${v}`;
|
||
window.__SHINE_STAGE0__?.mark('main_js_requested');
|
||
document.body.appendChild(script);
|
||
}());
|
||
</script>
|
||
</body>
|
||
</html>
|