diff --git a/tests/HUB_DESIGN.md b/tests/HUB_DESIGN.md
new file mode 100644
index 0000000..bcc372f
--- /dev/null
+++ b/tests/HUB_DESIGN.md
@@ -0,0 +1,59 @@
+# Дизайн панели Hub (локально, v120)
+
+В разделе «Эффекты → Эффекты Hub» ниже переключателей эффектов добавлен
+раздел «Дизайн», одинаковый на ПК и мобильных устройствах:
+
+- Обычный — прежнее оформление.
+- Зимний — синяя палитра, ледяные панели, статичные снежные детали.
+ Падающий снег включается отдельно в эффектах.
+- Для слабых устройств — сплошной фон, без CSS-анимаций, переходов,
+ размытия, теней и canvas-эффектов. Частицы удаляются, буфер canvas
+ уменьшается до 1×1, цикл requestAnimationFrame отменяется.
+
+Выбор хранится в localStorage этого браузера, применяется перед отрисовкой
+страницы и синхронизируется между вкладками. Настройка применяется ко всем
+сгенерированным страницам Hub: к главной панели, авторизации, VPS/SSH-терминалу,
+логам, заметкам и очереди обновления. Ответы проксируемого LuCI намеренно
+остаются без изменений.
+Выбранный эффект Hub также читается на этих страницах из того же значения
+`owrtRemote:seasonEffectMode`: снег, дождь, космос, угли, орбита, призма,
+пульс и лучи имеют отдельную отрисовку. В lite-режиме эффекты отключены.
+На страницах авторизации, терминала и очереди старые фоновые aura-анимации
+отключаются, чтобы они не смешивались с выбранным эффектом Hub.
+При возврате из облегчённого дизайна восстанавливается выбранный ранее эффект.
+
+В лёгком режиме ресурсы VPS обновляются раз в 5 секунд, роутеры — раз в 10.
+В остальных дизайнах сохраняются интервалы 1 и 5 секунд. Скрытые вкладки
+приостанавливают эффекты и автоматические запросы статистики/роутеров.
+Автоматические запросы списка роутеров не перекрываются, имеют тайм-аут 10 с.
+Неизменившийся ответ в лёгком режиме не вызывает пересоздание карточек.
+Уведомления, Heartbeat, Xray, WAN и настройки роутеров не менялись.
+
+Установка на VPS из PowerShell Windows 11:
+
+```powershell
+powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Users\k.zolotarev95\Documents\openwrt overlay\vps\deploy-hub-design.ps1" -Vps "root@138.124.79.58" -Action Install
+```
+
+После установки обновить страницу и открыть «Эффекты → Дизайн».
+Откат — та же команда с `-Action Rollback`. Резервная копия:
+`/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-design-v120`.
+При сбое установки возвращается файл, который был до этой попытки.
+Скрипт подтверждает SHA-256 реально запущенного Hub через health endpoint.
+
+Проверки:
+
+```text
+python -m unittest tests.test_hub_design_deploy tests.test_vps_resources -q
+python -m unittest tests.test_hub_design_global -q
+node tests/test_hub_design_ui.cjs
+node tests/test_hub_design_polling.cjs .test-output/hub-design/dashboard.js
+node tests/test_vps_resources_ui.cjs .test-output/hub-design/dashboard.js
+```
+
+Браузерные проверки используют Playwright/Chrome и локальные ответы API.
+Проверяют ПК, телефон и горизонтальный экран; сохранение после перезагрузки,
+отключение эффектов/буфера в lite, восстановление эффектов, отсутствие
+горизонтального переполнения. Снимки сохраняются в `.test-output/hub-design/`.
+Это функциональные проверки экономии работы браузера, а не замер FPS или
+потребления памяти на физическом слабом устройстве.
diff --git a/tests/test_hub_design_deploy.py b/tests/test_hub_design_deploy.py
new file mode 100644
index 0000000..0f30533
--- /dev/null
+++ b/tests/test_hub_design_deploy.py
@@ -0,0 +1,8 @@
+"""Local design install and rollback use exact running build verification."""
+from tests import test_update_status_ui_deploy as deploy_tests
+
+
+class HubDesignDeployTests(deploy_tests.UpdateStatusDeployTests):
+ deploy_file = 'deploy-hub-design.ps1'
+ backup_name = 'hub.py.bak-before-hub-design-v120'
+ success_marker = 'HUB_DESIGN_V120_Install_OK'
diff --git a/tests/test_hub_design_global.py b/tests/test_hub_design_global.py
new file mode 100644
index 0000000..8ec2a8b
--- /dev/null
+++ b/tests/test_hub_design_global.py
@@ -0,0 +1,63 @@
+import importlib.util
+import json
+import os
+import pathlib
+import sys
+import tempfile
+import unittest
+from unittest import mock
+
+
+ROOT = pathlib.Path(__file__).resolve().parents[1]
+SPEC = importlib.util.spec_from_file_location("owrt_remote_hub_global_design", ROOT / "vps" / "owrt-remote-hub.py")
+hub = importlib.util.module_from_spec(SPEC)
+STATE = tempfile.TemporaryDirectory(prefix="owrt-global-design-")
+sys.modules[SPEC.name] = hub
+with mock.patch.dict(os.environ, {"OWRT_REMOTE_STATE_DIR": STATE.name}):
+ SPEC.loader.exec_module(hub)
+
+
+def preview_pages():
+ router = {"id": "main", "name": "Test router", "permissions": {"manage": True}}
+ with mock.patch.object(hub, "web_push_backend_status", return_value={"ready": False}):
+ pages = {
+ "/": hub.dashboard_html([], "root", auth_bootstrap={"is_owner": True}),
+ "/login": hub.login_html(),
+ "/vps-terminal/": hub.ssh_terminal_html_v2(hub.vps_terminal_row(), "test"),
+ "/router-updates/": hub.router_updates_html("test"),
+ "/router/main/logs": hub.router_logs_html(router),
+ "/router/main/notes": hub.router_notes_html(router),
+ "/ssh/main/": hub.ssh_terminal_html_v2(hub.vps_terminal_row(), "test"),
+ }
+ return {path: hub.inject_hub_appearance(path, page.encode("utf-8"), "text/html").decode("utf-8")
+ for path, page in pages.items()}
+
+
+class GlobalHubDesignTests(unittest.TestCase):
+ def test_generated_pages_receive_the_shared_head(self):
+ pages = {
+ "login": hub.login_html(),
+ "terminal": hub.ssh_terminal_html_v2(hub.vps_terminal_row(), "token"),
+ "updates": hub.router_updates_html("csrf"),
+ }
+ for path, page in pages.items():
+ result = hub.inject_hub_appearance("/" + path, page.encode("utf-8"), "text/html; charset=utf-8")
+ text = result.decode("utf-8")
+ self.assertEqual(text.count("owrt-hub-design-head"), 1, path)
+ self.assertIn("DESIGN_KEY", text, path)
+ for mode in ("snow", "rain", "cosmos", "embers", "orbit", "prism", "pulse", "laser"):
+ self.assertIn("'" + mode + "'", text, path)
+ self.assertIn("#routerSearchToggle", text, path)
+
+ def test_existing_dashboard_and_luci_are_not_double_injected(self):
+ dashboard = hub.dashboard_html([], "root")
+ self.assertEqual(dashboard.count("owrt-hub-design-head"), 1)
+ luci = b"
LuCIrouter"
+ self.assertEqual(hub.inject_hub_appearance("/access/main/", luci, "text/html"), luci)
+
+
+if __name__ == "__main__":
+ if len(sys.argv) == 3 and sys.argv[1] == "--export-preview":
+ pathlib.Path(sys.argv[2]).write_text(json.dumps(preview_pages(), ensure_ascii=False), encoding="utf-8")
+ else:
+ unittest.main()
diff --git a/tests/test_hub_design_polling.cjs b/tests/test_hub_design_polling.cjs
new file mode 100644
index 0000000..bf081ad
--- /dev/null
+++ b/tests/test_hub_design_polling.cjs
@@ -0,0 +1,47 @@
+// Check request frequency and repaint work without relying on real-time sleeps.
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const vm = require('node:vm');
+const source = fs.readFileSync(process.argv[2], 'utf8');
+const start = source.indexOf('async function loadRouters(options = {}) {');
+const end = source.indexOf('\nif (routerGroupFilter)', start);
+assert(start>=0 && end>start);
+let clock = 10000, calls = 0, renders = 0, wol = false, finish;
+const timers = new Map();
+const fixture = {
+ hubDesignMode:'lite', lastAutomaticRouterPoll:0, routerPollInFlight:false,
+ AbortController, Date:{now:()=>clock}, document:{hidden:false}, window:{ROUTERS:[{id:'main',name:'Router'}]},
+ hasOpenWolPanel:()=>wol, renderRouterGroups(){},syncRouterNotesState(){},shouldDeferRouterRender:()=>false,
+ renderRouterView(){renders++;},fillRouterForm(){},refreshDiagnosticPanel(){},
+ setTimeout(fn,delay){timers.set(1,{fn,delay});return 1;},clearTimeout(id){timers.delete(id);},
+ fetch(url,options){calls++;return fixture.respond(url,options);},
+ respond:async()=>({ok:true,json:async()=>({routers:fixture.window.ROUTERS})}),
+};
+vm.createContext(fixture);
+vm.runInContext(source.slice(start,end), fixture);
+(async()=>{
+ await fixture.loadRouters({automatic:true});
+ assert.equal(calls,1);assert.equal(renders,0,'identical lite data does not rebuild cards');
+ clock=15000;await fixture.loadRouters({automatic:true});assert.equal(calls,1);
+ clock=20000;
+ fixture.respond=()=>new Promise(resolve=>{finish=resolve;});
+ const first=fixture.loadRouters({automatic:true});
+ await fixture.loadRouters({automatic:true});assert.equal(calls,2,'no parallel automatic router fetches');
+ finish({ok:true,json:async()=>({routers:[{id:'main',name:'Renamed'}]})});await first;
+ assert.equal(renders,1);assert.equal(timers.size,0);
+ fixture.document.hidden=true;clock=30000;
+ await fixture.loadRouters({automatic:true});assert.equal(calls,2);
+ fixture.document.hidden=false;wol=true;
+ await fixture.loadRouters({automatic:true});assert.equal(calls,2,'preserve open WOL picker');
+ wol=false;
+ fixture.respond=(url,options)=>new Promise((resolve,reject)=>options.signal.addEventListener('abort',()=>reject(new Error('timeout'))));
+ const pending=fixture.loadRouters({automatic:true});
+ assert.equal(timers.get(1).delay,10000);timers.get(1).fn();
+ await assert.rejects(pending,/timeout/);
+ assert.equal(fixture.routerPollInFlight,false,'timeouts release the polling guard');
+ fixture.respond=async()=>({ok:true,json:async()=>({routers:fixture.window.ROUTERS})});
+ fixture.hubDesignMode='winter';clock=35000;
+ await fixture.loadRouters({automatic:true});assert.equal(calls,4,'normal designs retain the 5-second interval');
+ assert.equal(renders,2);
+ console.log('HUB_DESIGN_POLLING_OK: lite 10s, normal 5s, no parallel fetches or idle repaints, timeout recovery, hidden tabs and WOL');
+})().catch(error=>{console.error(error);process.exitCode=1;});
diff --git a/tests/test_hub_design_ui.cjs b/tests/test_hub_design_ui.cjs
new file mode 100644
index 0000000..d9d026c
--- /dev/null
+++ b/tests/test_hub_design_ui.cjs
@@ -0,0 +1,85 @@
+// Local browser checks; all Hub API calls are fixtures, no VPS is contacted.
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const {execFileSync} = require('node:child_process');
+const {chromium} = require('playwright');
+const output = path.resolve('.test-output/hub-design');
+execFileSync(process.env.TEST_PYTHON || 'python', ['tests/test_vps_resources.py', '--export-preview', output],
+ {env:{...process.env,PYTHONIOENCODING:'utf-8'}});
+const template = fs.readFileSync(path.join(output, 'dashboard.html'), 'utf8');
+const routers = Array.from({length:18}, (_, i) => ({id:'node-'+i,name:'Роутер '+(i+1),role:'node',
+ online:i!==2,entry_port:18000+i,ssh_entry_port:19000+i,last_seen:1700000000,
+ permissions:{manage:true,admin:true,ssh:true},status:{model:'Xiaomi Mi Router AX3000T',
+ release:'OpenWrt 24.10.3',xray:'running',ssh:'running',mem_total_kb:239720,mem_available_kb:72000}}));
+const html = template.replace('window.ROUTERS = [];', 'window.ROUTERS = '+JSON.stringify(routers)+';');
+
+(async () => {
+ const browser = await chromium.launch({headless:true,channel:'chrome'});
+ try {
+ for (const [width,height,mobile] of [[1366,960,false],[390,844,true],[844,390,true]]) {
+ const context = await browser.newContext({viewport:{width,height},isMobile:mobile,hasTouch:mobile});
+ const page = await context.newPage(), errors = [];
+ page.on('pageerror', error => errors.push(error.message));
+ await page.route('**/*', async route => {
+ const url = new URL(route.request().url());
+ if (url.pathname === '/') return route.fulfill({contentType:'text/html',body:html});
+ if (url.pathname === '/api/routers') return route.fulfill({json:{routers}});
+ if (url.pathname === '/api/router-groups') return route.fulfill({json:{groups:[]}});
+ if (url.pathname === '/api/notifications/wait') return route.fulfill({status:429,json:{busy:true},headers:{'Retry-After':'5'}});
+ if (url.pathname === '/api/vps/resources') return route.fulfill({json:{ok:true,cpu:{percent:15},memory:{percent:35},disk:{percent:40}}});
+ if (url.pathname === '/api/hub-update') return route.fulfill({json:{ok:true,checked:true,available:false,current_version:'v120'}});
+ if (url.pathname.startsWith('/api/')) return route.fulfill({json:{ok:true,auth:{username:'root',is_owner:true,can_add_router:true}}});
+ return route.abort();
+ });
+ await page.goto('http://127.0.0.1:9999/');
+ await page.waitForFunction(() => typeof setHubDesign === 'function' && document.querySelectorAll('.card').length === 18);
+ const mobileLayout = width<=680 || mobile;
+ const toggle = page.locator(mobileLayout?'#mobileSeasonToggle':'#seasonToggle');
+ const panel = page.locator(mobileLayout?'#mobileSeasonPanel':'#seasonPanel');
+ await toggle.click();
+ await panel.locator('[data-hub-design="winter"]').click();
+ assert.equal(await page.evaluate(() => document.documentElement.dataset.hubDesign), 'winter');
+ assert.equal(await page.locator('body').evaluate(el => getComputedStyle(el).backgroundColor), 'rgb(6, 20, 38)');
+ assert.equal(await page.locator('.card').first().evaluate(el => getComputedStyle(el).backdropFilter), 'none');
+ assert.equal(await panel.locator('[data-hub-design="winter"]').getAttribute('aria-pressed'), 'true');
+ assert.equal(await page.evaluate(() => localStorage.getItem('owrtRemote:hubDesign')), 'winter');
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth<=innerWidth),true);
+ await page.screenshot({path:path.join(output, 'winter-'+width+'.png'),fullPage:false});
+ await panel.locator('[data-season-mode="snow"]').click();
+ await page.waitForFunction(() => seasonalFxFrame>0 && seasonalFxParticles.length>0);
+ // Pausing a hidden tab cancels the animation, returning resumes one loop.
+ await page.evaluate(() => {Object.defineProperty(document,'hidden',{configurable:true,get:()=>true});document.dispatchEvent(new Event('visibilitychange'));});
+ assert.equal(await page.evaluate(() => seasonalFxFrame),0);
+ await page.evaluate(() => {Object.defineProperty(document,'hidden',{configurable:true,get:()=>false});document.dispatchEvent(new Event('visibilitychange'));});
+ await page.waitForFunction(() => seasonalFxFrame>0);
+ await panel.locator('[data-hub-design="lite"]').click();
+ assert.deepEqual(await page.evaluate(() => [seasonalFxFrame,seasonalFxParticles.length,seasonalFxCanvas.width,seasonalFxCanvas.height]), [0,0,1,1]);
+ assert.equal(await panel.locator('[data-season-mode="snow"]').isDisabled(),true);
+ assert.equal(await page.locator('.card').first().evaluate(el => getComputedStyle(el).boxShadow),'none');
+ assert.equal(await page.locator('.card').first().evaluate(el => getComputedStyle(el).backdropFilter),'none');
+ assert.equal(await page.evaluate(() => document.getAnimations().filter(a=>a.playState==='running').length),0);
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth<=innerWidth),true);
+ await page.screenshot({path:path.join(output, 'lite-'+width+'.png'),fullPage:false});
+ // The palette is restored on reload before canvas allocation.
+ await page.reload();
+ await page.waitForFunction(() => hubDesignMode==='lite');
+ assert.deepEqual(await page.evaluate(() => [seasonalFxFrame,seasonalFxParticles.length,seasonalFxCanvas.width]), [0,0,1]);
+ await toggle.click();
+ assert.equal(await panel.locator('[data-hub-design="lite"]').getAttribute('aria-pressed'),'true');
+ await panel.locator('[data-hub-design="default"]').click();
+ await page.waitForFunction(() => seasonalFxFrame>0);
+ assert.equal(await page.evaluate(() => seasonEffectMode),'snow','restore the saved effect after leaving lite mode');
+ await page.evaluate(() => setSeasonEffectMode('off'));
+ await page.evaluate(() => {localStorage.setItem('owrtRemote:hubDesign','lite');});
+ await page.reload();
+ await page.waitForFunction(() => hubDesignMode==='lite');
+ // Storage unavailable: changing designs still works in the current tab.
+ await page.evaluate(() => {Storage.prototype.setItem=()=>{throw new Error('disabled');};setHubDesign('winter');});
+ assert.equal(await page.evaluate(() => hubDesignMode),'winter');
+ assert.deepEqual(errors,[]);
+ await context.close();
+ }
+ console.log('HUB_DESIGN_UI_OK: desktop/mobile/landscape, persistence, no overflow, lite has no animations or canvas, hidden tab pause/resume');
+ } finally { await browser.close(); }
+})().catch(error => {console.error(error);process.exitCode=1;});
diff --git a/tests/test_hub_effects_shared.cjs b/tests/test_hub_effects_shared.cjs
new file mode 100644
index 0000000..08b3a6d
--- /dev/null
+++ b/tests/test_hub_effects_shared.cjs
@@ -0,0 +1,112 @@
+// Compare actual canvas output and pointer physics across Hub pages. All APIs
+// are local fixtures; no router, terminal session, or VPS is contacted.
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const {execFileSync} = require('node:child_process');
+const {chromium} = require('playwright');
+const output = path.resolve('.test-output/hub-design');
+fs.mkdirSync(output, {recursive:true});
+const preview = path.join(output, 'shared-pages.json');
+execFileSync(process.env.TEST_PYTHON || 'python', ['tests/test_hub_design_global.py','--export-preview',preview],
+ {env:{...process.env,PYTHONIOENCODING:'utf-8'}});
+const pages = JSON.parse(fs.readFileSync(preview, 'utf8'));
+const modes = ['snow','rain','cosmos','embers','orbit','prism','pulse','laser'];
+
+async function renderSample(page, mode, usePointer) {
+ return page.evaluate(({mode,usePointer}) => {
+ seasonFxStop();
+ const random = Math.random, now = Date.now;
+ let seed = 12345;
+ Math.random = () => ((seed = Math.imul(1664525,seed)+1013904223>>>0)/4294967296);
+ Date.now = () => 1000;
+ try {
+ Object.assign(seasonalFxPointer,{x:0,y:0,lastX:0,lastY:0,targetWind:0,wind:0,lastMoveTs:0,active:false});
+ setSeasonEffectMode(mode,{persist:false});
+ if (usePointer) {
+ window.dispatchEvent(new PointerEvent('pointermove',{clientX:90,clientY:110}));
+ window.dispatchEvent(new PointerEvent('pointermove',{clientX:140,clientY:120}));
+ }
+ for (let i=1;i<=12;i++) window.testFrame(i*16);
+ const bytes=seasonalFxCtx.getImageData(0,0,seasonalFxCanvas.width,seasonalFxCanvas.height).data;
+ let digest=2166136261, visible=0;
+ for(let i=0;i>>0;if(i%4===3&&bytes[i])visible++;}
+ return {digest,visible,count:seasonalFxParticles.length,
+ pointer:JSON.parse(JSON.stringify(seasonalFxPointer)),
+ size:seasonalFxSize,pending:window.testFrames.size,
+ particles:JSON.parse(JSON.stringify(seasonalFxParticles.slice(0,3)))};
+ } finally {Math.random=random;Date.now=now;seasonFxStop();}
+ }, {mode,usePointer});
+}
+
+(async()=>{
+ const browser=await chromium.launch({headless:true,channel:'chrome'});
+ try {
+ const context=await browser.newContext({viewport:{width:900,height:700},deviceScaleFactor:1});
+ await context.addInitScript(()=>{
+ window.testFrames=new Map();let frameId=0;
+ window.requestAnimationFrame=callback=>{window.testFrames.set(++frameId,callback);return frameId;};
+ window.cancelAnimationFrame=id=>window.testFrames.delete(id);
+ window.testFrame=ts=>{const callbacks=[...window.testFrames.values()];window.testFrames.clear();callbacks.forEach(fn=>fn(ts));};
+ Object.defineProperty(document,'hidden',{configurable:true,get:()=>false});
+ });
+ await context.route('**/*',route=>{
+ const url=new URL(route.request().url());
+ if(pages[url.pathname])return route.fulfill({contentType:'text/html',body:pages[url.pathname]});
+ if(url.pathname==='/api/routers')return route.fulfill({json:{routers:[]}});
+ if(url.pathname==='/api/router-groups')return route.fulfill({json:{groups:[]}});
+ if(url.pathname==='/api/notifications/wait')return route.fulfill({status:429,headers:{'Retry-After':'5'},json:{busy:true}});
+ if(url.pathname.startsWith('/api/'))return route.fulfill({json:{ok:true,routers:[],auth:{username:'root',is_owner:true}}});
+ return route.abort();
+ });
+ const all=[],errors=[];
+ const baseline={};
+ for(const route of Object.keys(pages)){
+ const page=await context.newPage();all.push(page);
+ page.on('pageerror',error=>errors.push(route+': '+error.message));
+ await page.goto('http://hub.test'+route);
+ await page.waitForFunction(()=>hubAppearanceInitialized&&seasonEffectsInitialized,null,{polling:50,timeout:10000});
+ await page.evaluate(()=>setHubDesign('winter',{persist:false}));
+ assert.equal(await page.locator('canvas.seasonalFx').count(),1,route+' has one canvas');
+ for(const mode of modes){
+ const pointed=await renderSample(page,mode,true);
+ const neutral=await renderSample(page,mode,false);
+ assert.equal(pointed.pointer.x,140,route+' '+mode+' pointer X');
+ assert.equal(pointed.pointer.y,120,route+' '+mode+' pointer Y');
+ assert.equal(pointed.pointer.active,true);
+ assert.equal(pointed.pending,1,'one animation loop');
+ assert(pointed.visible>0,route+' '+mode+' actually draws pixels');
+ assert.notEqual(pointed.digest,neutral.digest,route+' '+mode+' responds to pointer');
+ if(route==='/')baseline[mode]=pointed;
+ else assert.deepEqual(pointed,baseline[mode],route+' '+mode+' matches dashboard pixels and physics');
+ }
+ // Repeated initialization must not add a second pointer handler or loop.
+ await page.evaluate(()=>{initHubAppearance();initSeasonEffects();setSeasonEffectMode('prism',{persist:false});});
+ assert.equal(await page.evaluate(()=>testFrames.size),1,route+' repeated initialization');
+ }
+ // Changes from the dashboard reach already-open login, terminal, queue,
+ // logs and notes tabs, including lite suppression and effect restoration.
+ const main=all[0];
+ for(const mode of modes){
+ await main.evaluate(mode=>setSeasonEffectMode(mode),mode);
+ for(const page of all.slice(1))await page.waitForFunction(mode=>seasonEffectMode===mode,mode,{polling:50,timeout:10000});
+ }
+ await main.evaluate(()=>setHubDesign('lite'));
+ for(const page of all){
+ await page.waitForFunction(()=>hubDesignMode==='lite',null,{polling:50,timeout:10000});
+ assert.deepEqual(await page.evaluate(()=>[seasonalFxFrame,seasonalFxParticles.length,seasonalFxCanvas.width,seasonalFxCanvas.height]),[0,0,1,1]);
+ }
+ await main.evaluate(()=>setHubDesign('winter'));
+ for(const page of all){
+ await page.waitForFunction(()=>hubDesignMode==='winter'&&seasonalFxFrame>0,null,{polling:50,timeout:10000});
+ assert.equal(await page.evaluate(()=>seasonEffectMode),'laser');
+ await page.evaluate(()=>{window.dispatchEvent(new PointerEvent('pointermove',{clientX:280,clientY:210}));});
+ assert.deepEqual(await page.evaluate(()=>[seasonalFxPointer.x,seasonalFxPointer.y,seasonalFxPointer.active]),[280,210,true]);
+ await page.evaluate(()=>window.dispatchEvent(new Event('blur')));
+ assert.deepEqual(await page.evaluate(()=>[seasonalFxPointer.active,seasonalFxPointer.targetWind]),[false,0]);
+ }
+ assert.deepEqual(errors,[]);
+ await context.close();
+ console.log('HUB_SHARED_EFFECTS_OK: 8 effects, 7 pages, identical canvas pixels and cursor physics, single loop, cross-tab design/effect sync, lite pause/restore');
+ } finally {await browser.close();}
+})().catch(error=>{console.error(error);process.exitCode=1;});
diff --git a/tests/test_vps_resources_ui.cjs b/tests/test_vps_resources_ui.cjs
index ca98f0d..8cb1082 100644
--- a/tests/test_vps_resources_ui.cjs
+++ b/tests/test_vps_resources_ui.cjs
@@ -20,7 +20,7 @@ function fixture(initialPending = false) {
const metrics = {ok: true, cpu: {percent: 25, cores: 2}, memory: {percent: 40, used_bytes: 1024, total_bytes: 2048}, disk: {percent: 60, used_bytes: 2048, total_bytes: 4096}};
const context = {
Intl, AbortController,
- document: {hidden: false, querySelectorAll() { return widgets; }, addEventListener(key, fn) { documentEvents[key] = fn; }},
+ document: {hidden: false, documentElement:{dataset:{hubDesign:'default'}}, querySelectorAll() { return widgets; }, addEventListener(key, fn) { documentEvents[key] = fn; }},
window: {addEventListener(key, fn) { windowEvents[key] = fn; }},
setInterval(fn, ms) { const id = nextId++; timers.set(id, {fn, ms, interval: true}); return id; },
setTimeout(fn, ms) { const id = nextId++; timers.set(id, {fn, ms}); return id; },
@@ -92,6 +92,17 @@ function fixture(initialPending = false) {
f.documentEvents.visibilitychange(); await flush();
assert.equal(f.calls.length, count);
+ const lite = fixture(); await flush();
+ lite.context.document.documentElement.dataset.hubDesign = 'lite';
+ lite.windowEvents.hubdesignchange(); await flush();
+ assert.equal(lite.intervals().length, 1, 'changing design must not duplicate widget timers');
+ assert.equal(lite.intervals()[0].ms, 5000, 'lite mode polls resources every 5 seconds');
+ lite.context.document.documentElement.dataset.hubDesign = 'winter';
+ lite.windowEvents.hubdesignchange(); await flush();
+ assert.equal(lite.intervals().length, 1);
+ assert.equal(lite.intervals()[0].ms, 1000, 'winter restores the regular update interval');
+ lite.windowEvents.pagehide();
+
const g = fixture(); await flush();
g.context.respond = (url, options) => new Promise((resolve, reject) => options.signal.addEventListener('abort', () => reject(new Error('timeout'))));
g.tick();
diff --git a/vps/deploy-hub-design.ps1 b/vps/deploy-hub-design.ps1
new file mode 100644
index 0000000..5ac1879
--- /dev/null
+++ b/vps/deploy-hub-design.ps1
@@ -0,0 +1,177 @@
+param(
+ [Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Vps,
+ [ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
+ [switch]$PrepareOnly
+)
+
+$ErrorActionPreference = 'Stop'
+$RepoRoot = Split-Path -Parent $PSScriptRoot
+$UploadName = 'owrt-hub-design-' + [guid]::NewGuid().ToString('N')
+$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
+$Utf8 = [System.Text.UTF8Encoding]::new($false)
+
+$RemoteScript = @'
+#!/bin/sh
+set -eu
+stage=/tmp/__UPLOAD_NAME__
+target=/opt/owrt-remote/owrt-remote-hub.py
+backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-hub-design-v120
+candidate=$target.new-__UPLOAD_NAME__
+changed=0
+
+show_failure() {
+ echo '--- owrt-remote status ---' >&2
+ systemctl --no-pager -l status owrt-remote >&2 || true
+ echo '--- owrt-remote journal ---' >&2
+ journalctl -u owrt-remote -n 80 --no-pager -l >&2 || true
+}
+
+cleanup() {
+ code=$?
+ trap - EXIT
+ if [ "$code" -ne 0 ]; then
+ echo "Remote step failed with rc=$code" >&2
+ show_failure
+ fi
+ if [ "$code" -ne 0 ] && [ "$changed" = 1 ] && [ -s "$stage/previous.py" ]; then
+ echo 'Restoring the previous Hub file...' >&2
+ cp -p "$stage/previous.py" "$candidate"
+ mv -f "$candidate" "$target"
+ systemctl restart owrt-remote || true
+ fi
+ rm -f "$candidate"
+ rm -rf "$stage"
+ exit "$code"
+}
+trap cleanup EXIT
+
+test -s "$target"
+python_bin=/opt/owrt-remote/venv/bin/python
+[ -x "$python_bin" ] || python_bin=python3
+
+if [ '__ACTION__' = Install ]; then
+ test -s "$stage/hub.py"
+ echo 'Validating candidate...'
+ "$python_bin" -m py_compile "$stage/hub.py"
+ "$python_bin" - "$stage/hub.py" <<'PY'
+from pathlib import Path
+import sys
+source = Path(sys.argv[1]).read_text(encoding='utf-8')
+required = ('def hub_design_controls_html():', 'def hub_design_head():',
+ 'function setHubDesign(', 'function initHubDesign()',
+ 'def hub_design_runtime_script():', 'function initHubAppearance()',
+ 'function seasonFxHandlePointerMove(',
+ 'hubdesignchange', "hubDesignMode === 'lite'", 'data-hub-design="winter"')
+for marker in required:
+ if marker not in source:
+ raise SystemExit('Candidate is missing: ' + marker)
+print('Candidate validation OK')
+PY
+ if [ ! -e "$backup" ]; then
+ cp -p "$target" "$backup"
+ fi
+ source_file="$stage/hub.py"
+else
+ test -s "$backup"
+ "$python_bin" -m py_compile "$backup"
+ source_file="$backup"
+fi
+
+expected_revision=$("$python_bin" - "$source_file" <<'PY'
+import hashlib
+from pathlib import Path
+import sys
+print(hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest())
+PY
+)
+
+cp -p "$target" "$stage/previous.py"
+cp "$source_file" "$candidate"
+chmod 0755 "$candidate"
+changed=1
+mv -f "$candidate" "$target"
+echo 'Restarting owrt-remote...'
+if ! systemctl restart owrt-remote; then
+ show_failure
+ exit 1
+fi
+
+healthy=0
+for attempt in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
+ if systemctl is-active --quiet owrt-remote && "$python_bin" - "$expected_revision" > "$stage/health-check" 2>&1 <<'PY'
+import json
+import sys
+import urllib.request
+
+try:
+ opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
+ with opener.open('http://127.0.0.1:8088/health?panel-update=1', timeout=3) as response:
+ data = json.loads(response.read(4096))
+ revision = data.get('revision', '')
+ if not data.get('ok') or revision != sys.argv[1]:
+ raise RuntimeError('Running Hub revision does not match the uploaded file: '
+ + (revision or '(not reported)') + '; expected ' + sys.argv[1])
+ print('Running Hub revision verified: ' + revision)
+except Exception as error:
+ print('Health verification failed: ' + str(error), file=sys.stderr)
+ raise SystemExit(1)
+PY
+ then
+ healthy=1
+ break
+ fi
+ sleep 2
+done
+if [ "$healthy" -ne 1 ]; then
+ echo 'The uploaded Hub build did not become ready; installation was not confirmed.' >&2
+ cat "$stage/health-check" >&2 2>/dev/null || true
+ show_failure
+ exit 1
+fi
+cat "$stage/health-check"
+cmp "$source_file" "$target"
+printf '\nBackup: %s\nHUB_DESIGN_V120_%s_OK\n' "$backup" '__ACTION__'
+if [ '__ACTION__' = Install ]; then
+ echo 'Refresh the Hub page and open Effects to choose the panel design.'
+ echo 'This fix is LOCAL. The panel update button can replace it with the published repository build.'
+fi
+'@
+
+$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
+
+try {
+ [System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
+ [System.IO.File]::WriteAllText(
+ (Join-Path $StageRoot 'run.sh'),
+ $RemoteScript.Replace("`r`n", "`n") + "`n",
+ $Utf8
+ )
+
+ if ($Action -eq 'Install') {
+ $Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'vps\owrt-remote-hub.py')).Replace("`r`n", "`n")
+ [System.IO.File]::WriteAllText((Join-Path $StageRoot 'hub.py'), $Content, $Utf8)
+ }
+
+ if ($PrepareOnly) {
+ Write-Host "Prepared only: $StageRoot"
+ return
+ }
+
+ & scp -O -r -- $StageRoot "${Vps}:/tmp/"
+ if ($LASTEXITCODE -ne 0) { throw 'Upload failed. VPS was not changed.' }
+ & ssh -T -o ConnectTimeout=10 $Vps "sh /tmp/$UploadName/run.sh"
+ if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
+ Write-Host "Hub design $Action finished successfully."
+}
+finally {
+ if (-not $PrepareOnly) {
+ $Resolved = [System.IO.Path]::GetFullPath($StageRoot)
+ $Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
+ if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) {
+ throw 'Unsafe staging cleanup path.'
+ }
+ if (Test-Path -LiteralPath $Resolved) {
+ Remove-Item -LiteralPath $Resolved -Recurse -Force
+ }
+ }
+}
diff --git a/vps/owrt-remote-hub.py b/vps/owrt-remote-hub.py
index 209336d..e22bf2f 100644
--- a/vps/owrt-remote-hub.py
+++ b/vps/owrt-remote-hub.py
@@ -5044,6 +5044,1106 @@ def vps_resource_widgets_html(mobile=False, resources=None):
+def hub_design_controls_html():
+ return '''
+
Дизайн
+
+
+
+
+
+
Выбор сохраняется в этом браузере.
+
'''
+
+
+def hub_design_head():
+ # Apply the saved palette before the body is painted, including lite mode.
+ return '''''' + hub_design_runtime_script()
+
+
+def hub_design_runtime_script():
+ """The dashboard renderer and pointer physics shared by every Hub page."""
+ return r''''''
+
+
+def inject_hub_appearance(path, body, content_type):
+ """Add the shared design head to Hub-owned HTML responses.
+
+ Router/LuCI proxy responses deliberately stay untouched; their own CSS and
+ JavaScript must not inherit the Hub palette.
+ """
+ if "text/html" not in (content_type or "").lower():
+ return body
+ request_path = str(path or "").split("?", 1)[0]
+ if request_path.startswith(("/access/", "/api/", "/cgi-bin/")):
+ return body
+ try:
+ text = body.decode("utf-8")
+ except (AttributeError, UnicodeDecodeError):
+ return body
+ if "owrt-hub-design-head" in text or "" not in text.lower():
+ return body
+ marker = hub_design_head()
+ index = text.lower().find("")
+ text = text[:index] + marker + text[index:]
+ return text.encode("utf-8")
+
+
def dashboard_html(routers, username, sessions=None, notifications=None, auth_bootstrap=None, vps_resources=None):
routers_json = json.dumps(routers, ensure_ascii=False)
sessions_json = json.dumps(sessions or [], ensure_ascii=False)
@@ -5174,6 +6274,7 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
.hubUpdateConfirmActions button{{min-height:44px;padding:9px 8px;font-size:12px}}
}}
+{hub_design_head()}
@@ -5236,6 +6337,7 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
+ {hub_design_controls_html()}
@@ -5557,6 +6659,7 @@ input,select{{min-width:0;border:1px solid var(--line);border-radius:8px;padding
+ {hub_design_controls_html()}
@@ -5685,9 +6788,6 @@ const seasonPanel = document.getElementById('seasonPanel');
const mobileSeasonDock = document.getElementById('mobileSeasonDock');
const mobileSeasonToggle = document.getElementById('mobileSeasonToggle');
const mobileSeasonPanel = document.getElementById('mobileSeasonPanel');
-const seasonalFxCanvas = document.getElementById('seasonalFx');
-const seasonButtons = Array.from(document.querySelectorAll('[data-season-mode]')).filter(Boolean);
-const seasonSwitches = Array.from(document.querySelectorAll('.seasonSwitch')).filter(Boolean);
const routerIdInput = routerForm && routerForm.elements ? routerForm.elements.namedItem('id') : null;
const routerNameInput = routerForm && routerForm.elements ? routerForm.elements.namedItem('name') : null;
const routerRoleInput = routerForm && routerForm.elements ? routerForm.elements.namedItem('role') : null;
@@ -5723,16 +6823,8 @@ let routerGroups = [];
const openRouterGroups = new Set(['__ungrouped__']);
let routerGroupsPanelOpen = false;
let lastRouterSearchTrigger = null;
-const SEASON_EFFECT_KEY = 'owrtRemote:seasonEffectMode';
-const SEASON_EFFECT_MODES = new Set(['off', 'snow', 'rain', 'cosmos', 'embers', 'orbit', 'prism', 'pulse', 'laser']);
-let seasonEffectMode = 'off';
-let seasonalFxCtx = null;
-let seasonalFxFrame = 0;
-let seasonalFxResizeTimer = 0;
-let seasonalFxLastTs = 0;
-let seasonalFxParticles = [];
-let seasonalFxSize = {{width: 0, height: 0, dpr: 1}};
-let seasonalFxPointer = {{x: 0, y: 0, lastX: 0, lastY: 0, targetWind: 0, wind: 0, lastMoveTs: 0, active: false}};
+let lastAutomaticRouterPoll = 0;
+let routerPollInFlight = false;
let seasonPanelOpen = false;
const routerSearchToggles = [routerSearchToggle, mobileRouterSearchToggle].filter(Boolean);
@@ -6323,29 +7415,6 @@ async function loadRouterGroups() {{
renderRouterView();
}}
-function loadSeasonEffectMode() {{
- try {{
- const value = localStorage.getItem(SEASON_EFFECT_KEY);
- return SEASON_EFFECT_MODES.has(value) ? value : 'off';
- }} catch (e) {{
- return 'off';
- }}
-}}
-
-function saveSeasonEffectMode(mode) {{
- try {{
- localStorage.setItem(SEASON_EFFECT_KEY, mode);
- }} catch (e) {{}}
-}}
-
-function syncSeasonButtons() {{
- seasonButtons.forEach((button) => {{
- const active = button.dataset.seasonMode === seasonEffectMode;
- button.dataset.active = active ? 'true' : 'false';
- button.setAttribute('aria-pressed', active ? 'true' : 'false');
- }});
-}}
-
function syncSeasonPanelToggleState() {{
seasonToggles.forEach((toggle) => {{
const open = seasonPanelOpen;
@@ -6365,850 +7434,6 @@ function setSeasonPanelOpen(nextOpen) {{
syncSeasonPanelToggleState();
}}
-function seasonFxResetCanvas() {{
- if (!seasonalFxCanvas) return;
- seasonalFxCtx = seasonalFxCanvas.getContext('2d');
- if (!seasonalFxCtx) return;
- const rect = seasonalFxCanvas.getBoundingClientRect();
- const dpr = Math.min(window.devicePixelRatio || 1, 2);
- const width = Math.max(1, Math.round(rect.width || window.innerWidth || 1));
- const height = Math.max(1, Math.round(rect.height || window.innerHeight || 1));
- seasonalFxCanvas.width = Math.max(1, Math.round(width * dpr));
- seasonalFxCanvas.height = Math.max(1, Math.round(height * dpr));
- seasonalFxCtx.setTransform(dpr, 0, 0, dpr, 0, 0);
- seasonalFxSize = {{width, height, dpr}};
- if (!seasonalFxPointer.active) {{
- seasonalFxPointer.x = width * .5;
- seasonalFxPointer.y = height * .44;
- seasonalFxPointer.lastX = seasonalFxPointer.x;
- seasonalFxPointer.lastY = seasonalFxPointer.y;
- }}
-}}
-
-function seasonFxSpawn(mode, randomY = false) {{
- const width = seasonalFxSize.width || window.innerWidth || 1;
- const height = seasonalFxSize.height || window.innerHeight || 1;
- if (mode === 'snow') {{
- return {{
- x: Math.random() * width,
- y: randomY ? Math.random() * height : -Math.random() * height,
- r: .8 + Math.random() * 1.1,
- vy: .014 + Math.random() * .022,
- vx: (Math.random() - .5) * .02,
- drift: Math.random() * Math.PI * 2,
- driftSpeed: .00045 + Math.random() * .0009,
- alpha: .52 + Math.random() * .26
- }};
- }}
- if (mode === 'cosmos') {{
- const angle = Math.random() * Math.PI * 2;
- const distance = 20 + Math.random() * Math.max(width, height) * .28;
- const speed = .10 + Math.random() * .18;
- return {{
- x: width * .5 + Math.cos(angle) * distance,
- y: height * .5 + Math.sin(angle) * distance,
- vx: Math.cos(angle) * speed,
- vy: Math.sin(angle) * speed,
- size: .7 + Math.random() * 1.8,
- tail: 10 + Math.random() * 18,
- twinkle: Math.random() * Math.PI * 2,
- twinkleSpeed: .006 + Math.random() * .01,
- alpha: .45 + Math.random() * .42
- }};
- }}
- if (mode === 'embers') {{
- return {{
- x: Math.random() * width,
- y: randomY ? Math.random() * height : height + Math.random() * height * .18,
- vx: (Math.random() - .5) * .045,
- vy: -(.022 + Math.random() * .05),
- size: 1.1 + Math.random() * 2.4,
- hue: 18 + Math.random() * 26,
- alpha: .22 + Math.random() * .26,
- sway: Math.random() * Math.PI * 2,
- swaySpeed: .0015 + Math.random() * .0024
- }};
- }}
- if (mode === 'orbit') {{
- const centerX = width * .5;
- const centerY = height * .42;
- return {{
- angle: Math.random() * Math.PI * 2,
- radius: 20 + Math.random() * Math.min(width, height) * .22,
- radiusSwing: 6 + Math.random() * 16,
- radiusDrift: Math.random() * Math.PI * 2,
- radiusSpeed: .0014 + Math.random() * .0022,
- speed: (Math.random() > .5 ? 1 : -1) * (.0012 + Math.random() * .0024),
- size: .9 + Math.random() * 2.2,
- alpha: .22 + Math.random() * .34,
- hue: 182 + Math.random() * 110,
- lane: .72 + Math.random() * .7,
- x: centerX,
- y: centerY
- }};
- }}
- if (mode === 'prism') {{
- return {{
- x: Math.random() * width,
- y: randomY ? Math.random() * height : (Math.random() * height * .2),
- vx: (Math.random() - .5) * .075,
- vy: (Math.random() - .5) * .075,
- size: 3.8 + Math.random() * 8.8,
- rot: Math.random() * Math.PI * 2,
- rotSpeed: (Math.random() - .5) * .006,
- hue: Math.random() * 360,
- alpha: .26 + Math.random() * .28
- }};
- }}
- if (mode === 'pulse') {{
- return {{
- angle: Math.random() * Math.PI * 2,
- radius: Math.random() * 26,
- radiusSpeed: .035 + Math.random() * .065,
- orbit: Math.random() * Math.PI * 2,
- orbitSpeed: (Math.random() - .5) * .0034,
- size: 4 + Math.random() * 16,
- hue: 182 + Math.random() * 150,
- alpha: .18 + Math.random() * .26,
- phase: Math.random() * Math.PI * 2,
- phaseSpeed: .003 + Math.random() * .0045
- }};
- }}
- if (mode === 'laser') {{
- const side = Math.random() > .5 ? 1 : -1;
- return {{
- x: side > 0 ? -40 - Math.random() * width * .18 : width + 40 + Math.random() * width * .18,
- y: Math.random() * height,
- vx: side > 0 ? (.24 + Math.random() * .26) : -(.24 + Math.random() * .26),
- vy: (Math.random() - .5) * .065,
- len: 20 + Math.random() * 42,
- width: .8 + Math.random() * 1.5,
- hue: 190 + Math.random() * 140,
- alpha: .16 + Math.random() * .26,
- pulse: Math.random() * Math.PI * 2,
- pulseSpeed: .003 + Math.random() * .004
- }};
- }}
- if (mode === 'aurora') {{
- return {{
- x: Math.random() * width,
- y: height * (.08 + Math.random() * .34),
- phase: Math.random() * Math.PI * 2,
- phaseSpeed: .0008 + Math.random() * .0016,
- wave: 24 + Math.random() * 88,
- waveSpeed: .0002 + Math.random() * .0005,
- sway: Math.random() * Math.PI * 2,
- swaySpeed: .0004 + Math.random() * .001,
- thickness: 10 + Math.random() * 18,
- hue: 155 + Math.random() * 70,
- alpha: .12 + Math.random() * .14,
- vx: (Math.random() - .5) * .02,
- vy: (Math.random() - .5) * .01
- }};
- }}
- if (mode === 'matrix') {{
- const columns = Math.max(2, Math.floor(width / 16));
- const column = Math.floor(Math.random() * columns);
- const columnWidth = width / columns;
- return {{
- x: column * columnWidth + columnWidth * .5,
- y: randomY ? Math.random() * height : -Math.random() * height,
- vy: 4.6 + Math.random() * 6.8,
- size: 11 + Math.random() * 9,
- alpha: .38 + Math.random() * .42,
- glyph: seasonFxRandomGlyph(),
- glyphSpeed: .003 + Math.random() * .006,
- trail: 18 + Math.random() * 30,
- trailAlpha: .06 + Math.random() * .08,
- hue: 120 + Math.random() * 40
- }};
- }}
- if (mode === 'nebula') {{
- const angle = Math.random() * Math.PI * 2;
- const distance = Math.random() * Math.min(width, height) * .34;
- return {{
- x: width * .5 + Math.cos(angle) * distance,
- y: height * .5 + Math.sin(angle) * distance * .72,
- vx: (Math.random() - .5) * .075,
- vy: (Math.random() - .5) * .065,
- size: 70 + Math.random() * 130,
- hue: 225 + Math.random() * 90,
- alpha: .06 + Math.random() * .08,
- drift: Math.random() * Math.PI * 2,
- driftSpeed: .0003 + Math.random() * .0008,
- pulse: Math.random() * Math.PI * 2
- }};
- }}
- if (mode === 'fireworks') {{
- const fromLeft = Math.random() > .5;
- const startX = fromLeft ? -60 - Math.random() * width * .2 : width + 60 + Math.random() * width * .2;
- const startY = Math.random() * height * .82;
- const speed = 1.8 + Math.random() * 3.4;
- const angle = fromLeft ? (-.26 + Math.random() * .38) : (Math.PI - .26 + Math.random() * .38);
- return {{
- x: startX,
- y: startY,
- vx: Math.cos(angle) * speed,
- vy: Math.sin(angle) * speed,
- gravity: .022 + Math.random() * .028,
- drag: .985 + Math.random() * .009,
- life: .4 + Math.random() * 1.2,
- size: 1.1 + Math.random() * 2.4,
- hue: Math.random() * 360,
- alpha: .34 + Math.random() * .42,
- sparkle: Math.random() * Math.PI * 2,
- sparkleSpeed: .03 + Math.random() * .06,
- trail: 8 + Math.random() * 18
- }};
- }}
- if (mode === 'vortex') {{
- const angle = Math.random() * Math.PI * 2;
- return {{
- x: width * .5,
- y: height * .5,
- angle,
- radius: 18 + Math.random() * Math.min(width, height) * .42,
- radiusSpeed: .012 + Math.random() * .018,
- spin: (Math.random() > .5 ? 1 : -1) * (.002 + Math.random() * .0035),
- wobble: Math.random() * Math.PI * 2,
- wobbleSpeed: .002 + Math.random() * .004,
- lane: .38 + Math.random() * .76,
- size: 1.2 + Math.random() * 3.4,
- hue: 190 + Math.random() * 130,
- alpha: .22 + Math.random() * .28
- }};
- }}
- if (mode === 'comet') {{
- const fromLeft = Math.random() > .5;
- const startX = fromLeft ? -60 - Math.random() * width * .2 : width + 60 + Math.random() * width * .2;
- const startY = Math.random() * height * .82;
- const speed = 1.5 + Math.random() * 2.6;
- const angle = fromLeft ? (-.25 + Math.random() * .35) : (Math.PI - .25 + Math.random() * .35);
- return {{
- x: startX,
- y: startY,
- vx: Math.cos(angle) * speed,
- vy: Math.sin(angle) * speed,
- len: 44 + Math.random() * 88,
- width: 1 + Math.random() * 2.8,
- hue: 190 + Math.random() * 120,
- alpha: .2 + Math.random() * .24,
- wobble: Math.random() * Math.PI * 2,
- wobbleSpeed: .006 + Math.random() * .01
- }};
- }}
- return {{
- x: Math.random() * width,
- y: randomY ? Math.random() * height : -Math.random() * height,
- len: 8 + Math.random() * 10,
- vy: .12 + Math.random() * .12,
- vx: -(0.028 + Math.random() * .055),
- width: .55 + Math.random() * .55,
- alpha: .14 + Math.random() * .16
- }};
-}}
-
-function seasonFxRandomGlyph() {{
- const glyphs = '01<>[]{{}}#@*+=%$';
- return glyphs[Math.floor(Math.random() * glyphs.length)];
-}}
-
-function seasonFxParticleCountForMode(mode, area, width, height) {{
- if (mode === 'snow') return Math.min(560, Math.max(180, Math.round(area / 2100)));
- if (mode === 'cosmos') return Math.min(420, Math.max(160, Math.round(area / 2600)));
- if (mode === 'embers') return Math.min(280, Math.max(90, Math.round(area / 6200)));
- if (mode === 'orbit') return Math.min(160, Math.max(54, Math.round(area / 10800)));
- if (mode === 'prism') return Math.min(240, Math.max(84, Math.round(area / 7200)));
- if (mode === 'pulse') return Math.min(110, Math.max(36, Math.round(area / 16000)));
- if (mode === 'laser') return Math.min(180, Math.max(68, Math.round(area / 9200)));
- if (mode === 'aurora') return Math.min(12, Math.max(6, Math.round(width / 180)));
- if (mode === 'matrix') return Math.min(96, Math.max(54, Math.round(width / 18)));
- if (mode === 'nebula') return Math.min(24, Math.max(14, Math.round(area / 120000)));
- if (mode === 'fireworks') return Math.min(220, Math.max(120, Math.round(area / 5200)));
- if (mode === 'vortex') return Math.min(180, Math.max(80, Math.round(area / 9000)));
- if (mode === 'comet') return Math.min(150, Math.max(54, Math.round(area / 11000)));
- return Math.min(360, Math.max(140, Math.round(area / 3200)));
-}}
-
-function seasonFxBuildParticles() {{
- if (seasonEffectMode === 'off') {{
- seasonalFxParticles = [];
- return;
- }}
- const width = seasonalFxSize.width || window.innerWidth || 1;
- const height = seasonalFxSize.height || window.innerHeight || 1;
- const area = Math.max(1, width * height);
- const count = seasonFxParticleCountForMode(seasonEffectMode, area, width, height);
- seasonalFxParticles = Array.from({{length: count}}, () => seasonFxSpawn(seasonEffectMode, true));
-}}
-
-function seasonFxStop() {{
- if (seasonalFxFrame) {{
- cancelAnimationFrame(seasonalFxFrame);
- seasonalFxFrame = 0;
- }}
- seasonalFxLastTs = 0;
- seasonalFxPointer.targetWind = 0;
- seasonalFxPointer.wind = 0;
- if (seasonalFxCtx && seasonalFxCanvas) {{
- seasonalFxCtx.clearRect(0, 0, seasonalFxSize.width, seasonalFxSize.height);
- }}
-}}
-
-function seasonFxHandlePointerMove(ev) {{
- if (!seasonalFxCanvas) return;
- const width = seasonalFxSize.width || window.innerWidth || 1;
- const height = seasonalFxSize.height || window.innerHeight || 1;
- const x = Math.max(0, Math.min(width, Number(ev.clientX) || 0));
- const y = Math.max(0, Math.min(height, Number(ev.clientY) || 0));
- const deltaX = seasonalFxPointer.lastMoveTs ? (x - seasonalFxPointer.lastX) : 0;
- const centerBias = ((x / width) - .5) * .03;
- const motionBias = Math.max(-.05, Math.min(.05, deltaX * .0016));
- seasonalFxPointer.x = x;
- seasonalFxPointer.y = y;
- seasonalFxPointer.lastX = x;
- seasonalFxPointer.lastY = y;
- seasonalFxPointer.lastMoveTs = Date.now();
- seasonalFxPointer.active = true;
- seasonalFxPointer.targetWind = centerBias + motionBias;
-}}
-
-function seasonFxHandlePointerLeave() {{
- seasonalFxPointer.active = false;
- seasonalFxPointer.targetWind = 0;
-}}
-
-function seasonFxStep(ts) {{
- if (!seasonalFxCanvas || !seasonalFxCtx || seasonEffectMode === 'off') return;
- if (!seasonalFxLastTs) seasonalFxLastTs = ts;
- const dt = Math.min(40, Math.max(1, ts - seasonalFxLastTs));
- seasonalFxLastTs = ts;
- const {{width, height}} = seasonalFxSize;
- if (!seasonalFxPointer.active || (Date.now() - seasonalFxPointer.lastMoveTs) > 160) {{
- seasonalFxPointer.targetWind *= .92;
- if (Math.abs(seasonalFxPointer.targetWind) < .0008) seasonalFxPointer.targetWind = 0;
- }}
- seasonalFxPointer.wind += (seasonalFxPointer.targetWind - seasonalFxPointer.wind) * Math.min(.18, dt / 140);
- seasonalFxCtx.clearRect(0, 0, width, height);
- seasonalFxCtx.globalCompositeOperation = 'source-over';
- seasonalFxCtx.shadowBlur = 0;
- seasonalFxCtx.shadowColor = 'rgba(0,0,0,0)';
- if (seasonEffectMode === 'snow') {{
- seasonalFxCtx.fillStyle = 'rgba(255,255,255,.8)';
- for (const p of seasonalFxParticles) {{
- p.drift += p.driftSpeed * dt;
- p.y += p.vy * dt;
- p.x += (p.vx + seasonalFxPointer.wind * (.75 + p.r * .22)) * dt + Math.sin(p.drift) * .013 * dt;
- if (p.y > height + 14) {{
- Object.assign(p, seasonFxSpawn('snow'));
- p.y = -12 - Math.random() * 40;
- }}
- if (p.x < -20) p.x = width + 20;
- if (p.x > width + 20) p.x = -20;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.fillStyle = `rgba(255,255,255,${{p.alpha}})`;
- seasonalFxCtx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'rain') {{
- seasonalFxCtx.lineCap = 'round';
- for (const p of seasonalFxParticles) {{
- p.y += p.vy * dt;
- const rainWind = seasonalFxPointer.wind * .42;
- p.x += (p.vx + rainWind) * dt;
- if (p.y > height + p.len + 20) {{
- Object.assign(p, seasonFxSpawn('rain'));
- p.y = -20 - Math.random() * height * .2;
- }}
- if (p.x < -40) p.x = width + 40;
- if (p.x > width + 40) p.x = -40;
- seasonalFxCtx.strokeStyle = `rgba(191,229,255,${{p.alpha}})`;
- seasonalFxCtx.lineWidth = p.width;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(p.x, p.y);
- seasonalFxCtx.lineTo(p.x + (p.vx + rainWind * .7) * 18, p.y + p.len);
- seasonalFxCtx.stroke();
- }}
- }} else if (seasonEffectMode === 'cosmos') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- seasonalFxCtx.fillStyle = 'rgba(255,255,255,.9)';
- const centerX = width * .5;
- const centerY = height * .5;
- for (const p of seasonalFxParticles) {{
- p.twinkle += p.twinkleSpeed * dt;
- const driftX = seasonalFxPointer.wind * (18 + p.size * 6);
- const driftY = Math.sin(p.twinkle) * .15;
- p.x += (p.vx + driftX) * dt;
- p.y += (p.vy + driftY) * dt;
- const dx = p.x - centerX;
- const dy = p.y - centerY;
- const dist = Math.hypot(dx, dy);
- if (dist > Math.max(width, height) * .8) {{
- Object.assign(p, seasonFxSpawn('cosmos'));
- }}
- const alpha = Math.max(.12, Math.min(.95, p.alpha + Math.sin(p.twinkle) * .12));
- seasonalFxCtx.strokeStyle = `rgba(171,205,255,${{alpha * .34}})`;
- seasonalFxCtx.lineWidth = Math.max(.4, p.size * .55);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(p.x, p.y);
- seasonalFxCtx.lineTo(p.x - (p.vx * p.tail + seasonalFxPointer.wind * 4), p.y - (p.vy * p.tail));
- seasonalFxCtx.stroke();
- seasonalFxCtx.beginPath();
- seasonalFxCtx.fillStyle = `rgba(255,255,255,${{alpha}})`;
- seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'embers') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
- const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .74;
- const influenceRadius = Math.min(width, height) * .34 + 70;
- for (const p of seasonalFxParticles) {{
- const prevX = p.x;
- const prevY = p.y;
- p.sway += p.swaySpeed * dt;
- if (seasonalFxPointer.active) {{
- const dx = focusX - p.x;
- const dy = focusY - p.y;
- const dist = Math.max(1, Math.hypot(dx, dy));
- const pull = Math.max(0, 1 - dist / influenceRadius);
- p.vx += ((dx / dist) * pull * .0058 + seasonalFxPointer.wind * .04) * dt;
- p.vy += ((dy / dist) * pull * .0041 - .0002) * dt;
- }} else {{
- p.vx += seasonalFxPointer.wind * .015 * dt;
- p.vy -= .00038 * dt;
- }}
- p.vx *= .988;
- p.vy *= .988;
- p.x += (p.vx + Math.sin(p.sway) * .018) * dt;
- p.y += p.vy * dt;
- if (p.y < -34 || p.x < -80 || p.x > width + 80 || p.y > height + 80) {{
- Object.assign(p, seasonFxSpawn('embers'));
- p.y = height + Math.random() * 30;
- p.x = seasonalFxPointer.active ? focusX + (Math.random() - .5) * 120 : Math.random() * width;
- }}
- const glow = seasonalFxPointer.active
- ? Math.max(0, 1 - Math.hypot(focusX - p.x, focusY - p.y) / 150)
- : 0;
- const alpha = Math.min(.96, p.alpha + glow * .4 + Math.abs(Math.sin(p.sway)) * .08);
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .56}})`;
- seasonalFxCtx.lineWidth = Math.max(.7, p.size * .58);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 8}},100%,66%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'orbit') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const centerX = (seasonalFxPointer.active ? seasonalFxPointer.x : width * .5) + seasonalFxPointer.wind * width * .06;
- const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .42;
- const core = seasonalFxCtx.createRadialGradient(centerX, centerY, 0, centerX, centerY, Math.min(width, height) * .16);
- core.addColorStop(0, 'rgba(34,211,238,.14)');
- core.addColorStop(.45, 'rgba(168,85,247,.08)');
- core.addColorStop(1, 'rgba(15,23,42,0)');
- seasonalFxCtx.fillStyle = core;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(centerX, centerY, Math.min(width, height) * .16, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- for (const p of seasonalFxParticles) {{
- const prevX = p.x || centerX;
- const prevY = p.y || centerY;
- p.radiusDrift += p.radiusSpeed * dt;
- p.angle += p.speed * dt * (1 + Math.min(.8, Math.abs(seasonalFxPointer.wind) * 10));
- const radius = p.radius + Math.sin(p.radiusDrift) * p.radiusSwing;
- p.x = centerX + Math.cos(p.angle) * radius;
- p.y = centerY + Math.sin(p.angle * p.lane) * radius * (.42 + p.lane * .22);
- const alpha = Math.max(.14, Math.min(.92, p.alpha + Math.sin(p.radiusDrift) * .1));
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .42}})`;
- seasonalFxCtx.lineWidth = Math.max(.6, p.size * .52);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- if (p.size > 1.7) {{
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 18}},100%,74%,${{alpha * .18}})`;
- seasonalFxCtx.lineWidth = .55;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(centerX, centerY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- }}
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 12}},100%,76%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'prism') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
- const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .46;
- const pullRadius = Math.min(width, height) * .38 + 90;
- for (const p of seasonalFxParticles) {{
- const prevX = p.x;
- const prevY = p.y;
- p.rot += p.rotSpeed * dt;
- if (seasonalFxPointer.active) {{
- const dx = focusX - p.x;
- const dy = focusY - p.y;
- const dist = Math.max(1, Math.hypot(dx, dy));
- const pull = Math.max(0, 1 - dist / pullRadius);
- p.vx += ((dx / dist) * pull * .0052 + seasonalFxPointer.wind * .022) * dt;
- p.vy += ((dy / dist) * pull * .0044) * dt;
- }} else {{
- p.vx += seasonalFxPointer.wind * .01 * dt;
- p.vy += Math.sin(p.rot) * .0009 * dt;
- }}
- p.vx *= .992;
- p.vy *= .992;
- p.x += p.vx * dt;
- p.y += p.vy * dt;
- if (p.x < -90 || p.x > width + 90 || p.y < -90 || p.y > height + 90) {{
- Object.assign(p, seasonFxSpawn('prism', true));
- if (seasonalFxPointer.active) {{
- p.x = focusX + (Math.random() - .5) * 140;
- p.y = focusY + (Math.random() - .5) * 140;
- }}
- }}
- const alpha = Math.min(.96, p.alpha + Math.abs(Math.sin(p.rot * 1.6)) * .16);
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,76%,${{alpha * .34}})`;
- seasonalFxCtx.lineWidth = Math.max(.7, p.size * .16);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.save();
- seasonalFxCtx.translate(p.x, p.y);
- seasonalFxCtx.rotate(p.rot);
- seasonalFxCtx.fillStyle = `hsla(${{p.hue}},100%,64%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(0, -p.size);
- seasonalFxCtx.lineTo(p.size * .8, 0);
- seasonalFxCtx.lineTo(0, p.size);
- seasonalFxCtx.lineTo(-p.size * .8, 0);
- seasonalFxCtx.closePath();
- seasonalFxCtx.fill();
- seasonalFxCtx.restore();
- }}
- }} else if (seasonEffectMode === 'pulse') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const centerX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
- const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .48;
- const maxRadius = Math.min(width, height) * .34 + 50;
- for (const p of seasonalFxParticles) {{
- p.phase += p.phaseSpeed * dt;
- p.orbit += p.orbitSpeed * dt * (1 + Math.min(1.2, Math.abs(seasonalFxPointer.wind) * 12));
- p.radius += p.radiusSpeed * dt;
- if (p.radius > maxRadius) {{
- Object.assign(p, seasonFxSpawn('pulse', true));
- p.radius = Math.random() * 18;
- }}
- const offsetX = Math.cos(p.orbit) * p.radius;
- const offsetY = Math.sin(p.orbit * 1.18) * p.radius * .7;
- const x = centerX + offsetX;
- const y = centerY + offsetY;
- const life = 1 - Math.min(1, p.radius / maxRadius);
- const pulse = .45 + .55 * Math.abs(Math.sin(p.phase));
- const alpha = Math.max(.05, Math.min(.92, p.alpha * life + pulse * .08));
- const ring = Math.max(2, p.size * (.45 + (1 - life) * 1.6));
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,74%,${{alpha * .82}})`;
- seasonalFxCtx.lineWidth = Math.max(.7, 1.1 + (1 - life) * 2.2);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(x, y, ring, 0, Math.PI * 2);
- seasonalFxCtx.stroke();
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 24}},100%,76%,${{alpha * .72}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(x, y, Math.max(.8, ring * .18), 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'aurora') {{
- seasonalFxCtx.globalCompositeOperation = 'screen';
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const baseY = height * .16;
- for (let i = 0; i < seasonalFxParticles.length; i++) {{
- const p = seasonalFxParticles[i];
- p.phase += p.phaseSpeed * dt;
- p.sway += p.swaySpeed * dt;
- p.x += seasonalFxPointer.wind * dt * 36 + p.vx * dt * 10;
- p.y += p.vy * dt * 10;
- p.wave += p.waveSpeed * dt;
- if (p.x < -160) p.x = width + 160;
- if (p.x > width + 160) p.x = -160;
- const amp = p.wave * (1 + Math.sin(p.sway) * .3);
- const yBase = baseY + (i % 3) * height * .09 + Math.sin(p.phase * .7 + i * .42) * amp * .12;
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,70%,${{p.alpha * .28}})`;
- seasonalFxCtx.lineWidth = p.thickness * 3.2;
- seasonalFxCtx.beginPath();
- for (let s = 0; s <= 16; s++) {{
- const x = width * s / 16;
- const y = yBase + Math.sin(p.phase + s * .58 + p.sway) * amp + Math.cos(p.phase * .6 + s * .2) * amp * .18;
- if (s === 0) seasonalFxCtx.moveTo(x, y);
- else seasonalFxCtx.lineTo(x, y);
- }}
- seasonalFxCtx.stroke();
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 18}},100%,82%,${{p.alpha * .66}})`;
- seasonalFxCtx.lineWidth = Math.max(1, p.thickness * .52);
- seasonalFxCtx.beginPath();
- for (let s = 0; s <= 16; s++) {{
- const x = width * s / 16;
- const y = yBase + Math.sin(p.phase + s * .58 + p.sway) * amp + Math.cos(p.phase * .6 + s * .2) * amp * .18;
- if (s === 0) seasonalFxCtx.moveTo(x, y);
- else seasonalFxCtx.lineTo(x, y);
- }}
- seasonalFxCtx.stroke();
- }}
- }} else if (seasonEffectMode === 'matrix') {{
- seasonalFxCtx.globalCompositeOperation = 'lighter';
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.shadowColor = 'rgba(80,255,120,.55)';
- seasonalFxCtx.shadowBlur = 10;
- seasonalFxCtx.textAlign = 'center';
- seasonalFxCtx.textBaseline = 'middle';
- for (const p of seasonalFxParticles) {{
- if (Math.random() < .08) p.glyph = seasonFxRandomGlyph();
- p.y += p.vy * dt;
- p.x += seasonalFxPointer.wind * dt * 8;
- if (p.y > height + p.trail) {{
- Object.assign(p, seasonFxSpawn('matrix'));
- p.y = -Math.random() * height * .34;
- }}
- if (p.x < -40) p.x = width + 40;
- if (p.x > width + 40) p.x = -40;
- seasonalFxCtx.fillStyle = `rgba(70,255,130,${{p.trailAlpha}})`;
- seasonalFxCtx.fillRect(p.x - .8, p.y - p.trail, 1.6, p.trail + 6);
- seasonalFxCtx.font = `900 ${{Math.max(12, Math.round(p.size))}}px ui-monospace, SFMono-Regular, Consolas, monospace`;
- seasonalFxCtx.fillStyle = `rgba(170,255,190,${{p.alpha}})`;
- seasonalFxCtx.fillText(p.glyph, p.x, p.y);
- }}
- }} else if (seasonEffectMode === 'nebula') {{
- seasonalFxCtx.globalCompositeOperation = 'screen';
- for (const p of seasonalFxParticles) {{
- p.drift += p.driftSpeed * dt;
- p.pulse += .0006 * dt;
- p.x += (p.vx + seasonalFxPointer.wind * .024) * dt;
- p.y += p.vy * dt;
- if (p.x < -p.size) p.x = width + p.size;
- if (p.x > width + p.size) p.x = -p.size;
- if (p.y < -p.size) p.y = height + p.size;
- if (p.y > height + p.size) p.y = -p.size;
- const alpha = Math.min(.22, p.alpha + Math.sin(p.drift) * .03 + Math.abs(Math.sin(p.pulse)) * .02);
- const glow = seasonalFxCtx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.size);
- glow.addColorStop(0, `hsla(${{p.hue}},100%,72%,${{alpha}})`);
- glow.addColorStop(.35, `hsla(${{p.hue + 18}},100%,60%,${{alpha * .44}})`);
- glow.addColorStop(1, 'rgba(0,0,0,0)');
- seasonalFxCtx.fillStyle = glow;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'fireworks') {{
- seasonalFxCtx.globalCompositeOperation = 'lighter';
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- for (const p of seasonalFxParticles) {{
- const prevX = p.x;
- const prevY = p.y;
- p.sparkle += p.sparkleSpeed * dt;
- p.vx *= Math.pow(p.drag, dt / 16);
- p.vy = p.vy * Math.pow(p.drag, dt / 16) + p.gravity * dt;
- p.x += p.vx * dt;
- p.y += p.vy * dt;
- p.life -= dt / 1200;
- if (p.life <= 0 || p.x < -80 || p.x > width + 80 || p.y > height + 120) {{
- Object.assign(p, seasonFxSpawn('fireworks'));
- continue;
- }}
- const spark = .5 + .5 * Math.sin(p.sparkle);
- const alpha = Math.min(.96, p.alpha * Math.max(.2, p.life) + Math.abs(spark) * .18);
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .84}})`;
- seasonalFxCtx.lineWidth = Math.max(.6, p.size * .6);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 22}},100%,86%,${{alpha * .34}})`;
- seasonalFxCtx.lineWidth = Math.max(1.2, p.size * 2.8);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 14}},100%,88%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, Math.max(.8, p.size * .95), 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'vortex') {{
- seasonalFxCtx.globalCompositeOperation = 'lighter';
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const centerX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
- const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .5;
- for (const p of seasonalFxParticles) {{
- const prevX = p.x || centerX;
- const prevY = p.y || centerY;
- p.radius += p.radiusSpeed * dt;
- p.angle += p.spin * dt * (1 + Math.min(1.4, Math.abs(seasonalFxPointer.wind) * 10));
- p.wobble += p.wobbleSpeed * dt;
- const radius = p.radius + Math.sin(p.wobble) * 20;
- p.x = centerX + Math.cos(p.angle) * radius;
- p.y = centerY + Math.sin(p.angle * p.lane) * radius * .84;
- if (radius > Math.max(width, height) * .6) {{
- Object.assign(p, seasonFxSpawn('vortex'));
- }}
- const alpha = Math.min(.92, p.alpha + Math.abs(Math.sin(p.wobble)) * .14);
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .22}})`;
- seasonalFxCtx.lineWidth = Math.max(.7, p.size * .74);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 22}},100%,84%,${{alpha * .14}})`;
- seasonalFxCtx.lineWidth = Math.max(1.4, p.size * 2.8);
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(centerX, centerY);
- seasonalFxCtx.lineTo(p.x, p.y);
- seasonalFxCtx.stroke();
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 12}},100%,86%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, Math.max(.8, p.size), 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'comet') {{
- seasonalFxCtx.globalCompositeOperation = 'lighter';
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- for (const p of seasonalFxParticles) {{
- const prevX = p.x;
- const prevY = p.y;
- p.wobble += p.wobbleSpeed * dt;
- p.x += (p.vx + seasonalFxPointer.wind * .03) * dt;
- p.y += (p.vy + Math.sin(p.wobble) * .012) * dt;
- if (p.x < -width * .4 || p.x > width * 1.4 || p.y < -120 || p.y > height + 120) {{
- Object.assign(p, seasonFxSpawn('comet'));
- continue;
- }}
- const tailX = p.x - p.vx * p.len * .62;
- const tailY = p.y - p.vy * p.len * .62;
- const alpha = Math.min(.95, p.alpha + Math.abs(Math.sin(p.wobble)) * .14);
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .84}})`;
- seasonalFxCtx.lineWidth = p.width;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(p.x, p.y);
- seasonalFxCtx.lineTo(tailX, tailY);
- seasonalFxCtx.stroke();
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 18}},100%,86%,${{alpha * .22}})`;
- seasonalFxCtx.lineWidth = p.width * 3.6;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(prevX, prevY);
- seasonalFxCtx.lineTo(tailX, tailY);
- seasonalFxCtx.stroke();
- seasonalFxCtx.fillStyle = `hsla(${{p.hue + 12}},100%,88%,${{alpha}})`;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.arc(p.x, p.y, Math.max(1, p.width * 1.2), 0, Math.PI * 2);
- seasonalFxCtx.fill();
- }}
- }} else if (seasonEffectMode === 'laser') {{
- seasonalFxCtx.lineCap = 'round';
- seasonalFxCtx.lineJoin = 'round';
- const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
- const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .52;
- const influence = Math.min(width, height) * .42 + 120;
- for (const p of seasonalFxParticles) {{
- p.pulse += p.pulseSpeed * dt;
- if (seasonalFxPointer.active) {{
- const dx = focusX - p.x;
- const dy = focusY - p.y;
- const dist = Math.max(1, Math.hypot(dx, dy));
- const pull = Math.max(0, 1 - dist / influence);
- p.vx += (dx / dist) * pull * .008 * dt;
- p.vy += (dy / dist) * pull * .006 * dt;
- }} else {{
- p.vx += seasonalFxPointer.wind * .02 * dt;
- }}
- p.vx *= .996;
- p.vy *= .995;
- p.x += p.vx * dt;
- p.y += p.vy * dt;
- if (p.x < -width * .35 || p.x > width * 1.35 || p.y < -120 || p.y > height + 120) {{
- Object.assign(p, seasonFxSpawn('laser', true));
- }}
- const alpha = Math.min(.94, p.alpha + Math.abs(Math.sin(p.pulse)) * .18);
- const tailX = p.x - p.vx * p.len * .55;
- const tailY = p.y - p.vy * p.len * .55;
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue}},100%,72%,${{alpha * .9}})`;
- seasonalFxCtx.lineWidth = p.width;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(p.x, p.y);
- seasonalFxCtx.lineTo(tailX, tailY);
- seasonalFxCtx.stroke();
- seasonalFxCtx.strokeStyle = `hsla(${{p.hue + 28}},100%,86%,${{alpha * .34}})`;
- seasonalFxCtx.lineWidth = p.width * 3.2;
- seasonalFxCtx.beginPath();
- seasonalFxCtx.moveTo(p.x, p.y);
- seasonalFxCtx.lineTo(tailX, tailY);
- seasonalFxCtx.stroke();
- }}
- }}
- seasonalFxFrame = requestAnimationFrame(seasonFxStep);
-}}
-
-function seasonFxStart() {{
- if (!seasonalFxCanvas || seasonEffectMode === 'off') return;
- seasonalFxCanvas.hidden = false;
- seasonFxResetCanvas();
- seasonFxBuildParticles();
- seasonFxStop();
- seasonalFxFrame = requestAnimationFrame(seasonFxStep);
-}}
-
-function setSeasonEffectMode(nextMode, options = {{}}) {{
- const mode = SEASON_EFFECT_MODES.has(nextMode) ? nextMode : 'off';
- seasonEffectMode = mode;
- if (options.persist !== false) saveSeasonEffectMode(mode);
- syncSeasonButtons();
- if (!seasonalFxCanvas) return;
- if (mode === 'off') {{
- seasonalFxCanvas.hidden = true;
- seasonFxStop();
- return;
- }}
- seasonalFxCanvas.hidden = false;
- seasonFxStart();
-}}
-
-function initSeasonEffects() {{
- if (!seasonalFxCanvas) return;
- seasonSwitches.forEach((el) => {{
- const columns = Math.min(3, Math.max(2, el.querySelectorAll('[data-season-mode]').length));
- el.style.gridTemplateColumns = `repeat(${{columns}},minmax(0,1fr))`;
- }});
- window.addEventListener('resize', () => {{
- clearTimeout(seasonalFxResizeTimer);
- seasonalFxResizeTimer = setTimeout(() => {{
- seasonalFxResizeTimer = 0;
- if (seasonEffectMode === 'off') return;
- seasonFxResetCanvas();
- seasonFxBuildParticles();
- }}, 120);
- }});
- window.addEventListener('pointermove', seasonFxHandlePointerMove, {{passive: true}});
- window.addEventListener('pointerleave', seasonFxHandlePointerLeave);
- window.addEventListener('blur', seasonFxHandlePointerLeave);
- seasonEffectMode = loadSeasonEffectMode();
- syncSeasonButtons();
- setSeasonPanelOpen(false);
- setSeasonEffectMode(seasonEffectMode, {{persist: false}});
-}}
-
function numericMetric(value) {{
const match = String(value ?? '').replace(',', '.').match(/-?\\d+(?:\\.\\d+)?/);
return match ? Number(match[0]) : NaN;
@@ -8742,11 +8967,6 @@ routerSearchToggles.forEach((toggle) => {{
setRouterSearchOpen(panel ? panel.hidden : true, {{preferredInput: input}});
}});
}});
-seasonButtons.forEach((button) => {{
- button.addEventListener('click', () => {{
- setSeasonEffectMode(button.dataset.seasonMode || 'off');
- }});
-}});
seasonToggles.forEach((toggle) => {{
toggle.addEventListener('click', (ev) => {{
ev.stopPropagation();
@@ -8857,18 +9077,33 @@ if (mobileXrayReload) mobileXrayReload.addEventListener('click', handleXrayReloa
if (mobileXrayRestart) mobileXrayRestart.addEventListener('click', handleXrayRestart);
async function loadRouters(options = {{}}) {{
- if (options && options.automatic && hasOpenWolPanel()) return;
- const res = await fetch('/api/routers', {{cache: 'no-store'}});
- if (res.ok) {{
- const data = await res.json();
- if (options && options.automatic && hasOpenWolPanel()) return;
- window.ROUTERS = data.routers;
- renderRouterGroups();
- syncRouterNotesState(window.ROUTERS);
- if (shouldDeferRouterRender()) pendingRouterRender = true;
- else renderRouterView();
- fillRouterForm(false);
- refreshDiagnosticPanel();
+ const automatic = Boolean(options && options.automatic);
+ if (automatic) {{
+ if (document.hidden || hasOpenWolPanel() || routerPollInFlight) return;
+ const now = Date.now();
+ if (hubDesignMode === 'lite' && now - lastAutomaticRouterPoll < 10000) return;
+ lastAutomaticRouterPoll = now;
+ routerPollInFlight = true;
+ }}
+ const controller = new AbortController();
+ const timeout = setTimeout(() => controller.abort(), 10000);
+ try {{
+ const res = await fetch('/api/routers', {{cache: 'no-store', signal: controller.signal}});
+ if (res.ok) {{
+ const data = await res.json();
+ if (automatic && (document.hidden || hasOpenWolPanel())) return;
+ if (automatic && hubDesignMode === 'lite' && JSON.stringify(data.routers) === JSON.stringify(window.ROUTERS)) return;
+ window.ROUTERS = data.routers;
+ renderRouterGroups();
+ syncRouterNotesState(window.ROUTERS);
+ if (shouldDeferRouterRender()) pendingRouterRender = true;
+ else renderRouterView();
+ fillRouterForm(false);
+ refreshDiagnosticPanel();
+ }}
+ }} finally {{
+ clearTimeout(timeout);
+ if (automatic) routerPollInFlight = false;
}}
}}
@@ -11880,7 +12115,8 @@ if (!clientVersionRedirecting) {{
loadPushStatus({{silent: true}});
warmPushEnvironment({{silent: true}});
}}
-initSeasonEffects();
+initHubAppearance();
+setSeasonPanelOpen(false);
syncRouterSearchToggleState();
requestRouterRender();
fillRouterForm(true);
@@ -12062,9 +12298,10 @@ function initVpsResourceWidgets() {{
clearInterval(timer); timer = null;
if (stopped || document.hidden) {{ pause(); return; }}
load();
- timer = setInterval(load, 1000);
+ timer = setInterval(load, document.documentElement?.dataset.hubDesign === 'lite' ? 5000 : 1000);
}};
document.addEventListener('visibilitychange', resume);
+ window.addEventListener('hubdesignchange', resume);
window.addEventListener('pagehide', pause);
window.addEventListener('pageshow', resume);
resume();
@@ -13168,7 +13405,8 @@ async function pollHttpTerminal(){if(!httpSid||httpPollInFlight||httpRecovering)
async function startHttpTerminal(reason){if(httpSid||httpPollInFlight)return;terminalMode='http';httpRecovering=reason==='reconnect'||reason==='read-failed'||reason==='read-error';clearHttpTimers();try{if(ws&&(ws.readyState===WebSocket.OPEN||ws.readyState===WebSocket.CONNECTING))ws.close();}catch(e){}if(reason==='direct')notice('Подключаю HTTP-terminal...','36');else if(reason==='mobile')notice('HTTP-terminal подключается...','36');else if(httpRecovering)notice(IS_VPS_TERMINAL?'Пробую поднять новую VPS terminal сессию...':'Пробую поднять новую SSH-сессию...','36');else notice(reason+'. Включаю запасной HTTP-terminal...','36');try{const res=await fetch(appendQuery(SESSION_PATH,{cols:term.cols||80,rows:term.rows||24}),{cache:'no-store'});let data={};try{data=await res.json();}catch(e){}if(!res.ok||!data.ok){httpPollFailures=Math.max(1,httpPollFailures+1);const delay=Math.min(8000,Math.max(1200,900*httpPollFailures));notice('HTTP-terminal пока не стартовал: '+(data.error||res.status||'hub недоступен')+'. Повторю автоматически...','33');httpReconnectTimer=setTimeout(()=>{httpReconnectTimer=0;startHttpTerminal('reconnect');},delay);return;}httpSid=data.sid;const wasRecovering=httpRecovering;httpRecovering=false;httpPollFailures=0;if(wasRecovering&&httpRecoveryNoticeShown)notice(httpRecoveredMessage(),'32');else notice(READY_LABEL || (isMobileTerminal?'HTTP-terminal подключен. Вводи через поле снизу или клавиатуру.':'HTTP-terminal подключен. Кликни в терминал, Ctrl+V вставляет.'),'32');httpRecoveryNoticeShown=false;if(pendingHubRestartActive())pendingHubRestartAt=0;sendResize();scheduleHttpPoll(80);}catch(e){httpPollFailures=Math.max(1,httpPollFailures+1);const delay=Math.min(8000,Math.max(1200,900*httpPollFailures));notice('HTTP-terminal не стартовал: '+e+'. Повторю автоматически...','31');httpReconnectTimer=setTimeout(()=>{httpReconnectTimer=0;startHttpTerminal('reconnect');},delay);}}
async function explainTerminalError(source){if(diagnosticStarted)return;diagnosticStarted=true;try{const res=await fetch(CHECK_PATH,{cache:'no-store'});const data=await res.json();if(data.tcp_ok)await startHttpTerminal(source);else{notice('SSH-туннель на VPS не отвечает: '+(data.error||'порт закрыт'),'31');notice('В Hub нажми: Обновить Xray CFG, потом Рестарт Xray VPS, и проверь heartbeat роутера.','33');}}catch(e){notice('Не смог проверить SSH-туннель. Проверь firewall VPS и доступ к Hub.','31');}}
function connect(){wsOpened=false;receivedTerminalData=false;diagnosticStarted=false;httpPollFailures=0;httpPollInFlight=false;httpRecovering=false;httpRecoveryNoticeShown=false;terminalMode='ws';httpSid='';clearHttpTimers();inputQueue='';passwordPromptActive=false;passwordBuffer='';autoPasswordUsed=false;if(inputFlushTimer){clearTimeout(inputFlushTimer);inputFlushTimer=0;}if(term){term.reset();notice('Подключение к '+CONNECT_LABEL+'...','36');}if(FORCE_HTTP_ONLY||isMobileTerminal){startHttpTerminal(FORCE_HTTP_ONLY?'direct':'mobile');return;}const proto=location.protocol==='https:'?'wss://':'ws://';ws=new WebSocket(proto+location.host+WS_PATH);ws.binaryType='arraybuffer';ws.onopen=()=>{wsOpened=true;sendResize();};ws.onmessage=async(ev)=>{if(terminalMode==='http')return;let text='';if(typeof ev.data==='string')text=ev.data;else if(ev.data instanceof Blob)text=await ev.data.text();else text=decoder.decode(ev.data);if(!receivedTerminalData)term.clear();receivedTerminalData=true;term.write(text);maybeAutoSendPassword(text);};ws.onerror=()=>explainTerminalError('ошибка web-terminal');ws.onclose=()=>{if(terminalMode==='http')return;if(wsOpened)notice(CLOSED_LABEL,'33');else explainTerminalError(CLOSED_LABEL);};setTimeout(()=>{if(!receivedTerminalData&&!httpSid)startHttpTerminal(SILENT_LABEL);},3000);}
-function initTerminal(){if(!window.Terminal){terminalEl.classList.remove('loading');terminalEl.textContent='xterm.js не загрузился. Проверь доступ браузера к cdn.jsdelivr.net.';return;}terminalEl.classList.remove('loading');terminalEl.textContent='';term=new Terminal({cursorBlink:!isMobileTerminal,convertEol:false,scrollback:isMobileTerminal?200:5000,scrollSensitivity:isMobileTerminal?8:1,fastScrollSensitivity:isMobileTerminal?14:5,smoothScrollDuration:0,fontFamily:'"Cascadia Mono","Consolas","Liberation Mono",monospace',fontSize:isMobileTerminal?12:14,lineHeight:1.14,theme:{background:'#0b0714',foreground:'#f7f2ff',cursor:'#fbbf24',selectionBackground:'#334155',black:'#0b0714',red:'#fb7185',green:'#86efac',yellow:'#fde68a',blue:'#93c5fd',magenta:'#c084fc',cyan:'#67e8f9',white:'#f7f2ff'}});if(window.FitAddon&&FitAddon.FitAddon){fitAddon=new FitAddon.FitAddon();term.loadAddon(fitAddon);}term.open(terminalEl);term.onData(sendData);term.onResize(sendResize);term.attachCustomKeyEventHandler((ev)=>{const key=String(ev.key||'').toLowerCase();if((ev.ctrlKey||ev.metaKey)&&key==='c'&&term.hasSelection&&term.hasSelection()){copySelection();return false;}return true;});terminalEl.addEventListener('click',()=>term.focus());fitTerminal(true);connect();setTimeout(()=>{fitTerminal(true);term.focus();},120);}
+function terminalTheme(){const winter=document.documentElement.dataset.hubDesign==='winter';const lite=document.documentElement.dataset.hubDesign==='lite';return winter?{background:'#071827',foreground:'#ecf9ff',cursor:'#7dd3fc',selectionBackground:'#24445b',black:'#071827',red:'#fb7185',green:'#86efac',yellow:'#fde68a',blue:'#93c5fd',magenta:'#c084fc',cyan:'#67e8f9',white:'#ecf9ff'}:lite?{background:'#101827',foreground:'#f1f5f9',cursor:'#93c5fd',selectionBackground:'#334155',black:'#101827',red:'#fb7185',green:'#86efac',yellow:'#fde68a',blue:'#93c5fd',magenta:'#c4b5fd',cyan:'#7dd3fc',white:'#f1f5f9'}:{background:'#0b0714',foreground:'#f7f2ff',cursor:'#fbbf24',selectionBackground:'#334155',black:'#0b0714',red:'#fb7185',green:'#86efac',yellow:'#fde68a',blue:'#93c5fd',magenta:'#c084fc',cyan:'#67e8f9',white:'#f7f2ff'};}
+function initTerminal(){if(!window.Terminal){terminalEl.classList.remove('loading');terminalEl.textContent='xterm.js не загрузился. Проверь доступ браузера к cdn.jsdelivr.net.';return;}terminalEl.classList.remove('loading');terminalEl.textContent='';term=new Terminal({cursorBlink:!isMobileTerminal,convertEol:false,scrollback:isMobileTerminal?200:5000,scrollSensitivity:isMobileTerminal?8:1,fastScrollSensitivity:isMobileTerminal?14:5,smoothScrollDuration:0,fontFamily:'"Cascadia Mono","Consolas","Liberation Mono",monospace',fontSize:isMobileTerminal?12:14,lineHeight:1.14,theme:terminalTheme()});if(window.FitAddon&&FitAddon.FitAddon){fitAddon=new FitAddon.FitAddon();term.loadAddon(fitAddon);}term.open(terminalEl);window.addEventListener('hubdesignchange',()=>{if(term)term.options.theme=terminalTheme();});term.onData(sendData);term.onResize(sendResize);term.attachCustomKeyEventHandler((ev)=>{const key=String(ev.key||'').toLowerCase();if((ev.ctrlKey||ev.metaKey)&&key==='c'&&term.hasSelection&&term.hasSelection()){copySelection();return false;}return true;});terminalEl.addEventListener('click',()=>term.focus());fitTerminal(true);connect();setTimeout(()=>{fitTerminal(true);term.focus();},120);}
document.addEventListener('paste',(ev)=>{if(isEditableTarget(ev.target))return;if(!terminalFocused())return;handlePaste(ev);});
window.addEventListener('beforeunload',()=>{clearHttpTimers();if(httpSid)navigator.sendBeacon('/api/ssh-session/'+encodeURIComponent(httpSid)+'/close');});
let resizeTimer=0;window.addEventListener('resize',()=>{clearTimeout(resizeTimer);resizeTimer=setTimeout(()=>fitTerminal(false),160);});
@@ -16003,6 +16241,7 @@ class Handler(BaseHTTPRequestHandler):
return False
def send_bytes(self, status, body, content_type="text/plain; charset=utf-8", extra_headers=None):
+ body = inject_hub_appearance(getattr(self, "path", ""), body, content_type)
self.close_connection = True
self.send_response(status)
self.send_header("Content-Type", content_type)