Files
90-RED 3474927aee v1.3.0 — Web Worker routing, profiler disk export, stretch extraction
- Web Worker routing — A* search runs in a background Worker thread,
  keeping the UI responsive during large batch routes
- Worker watchdog — auto-falls back to main-thread routing on any failure
- Worker held-pause — drag-pause re-routes also run in worker
- stretch.js — extracted sticky-path logic, shared by main thread and worker
- Profiler disk export — POST /linkrouter/write_log endpoint saves reports
- Chunked worker processing — 8ms macrotask slices for cancel responsiveness
- New settings: Background worker routing, Held-pause in worker
2026-07-19 06:36:24 +08:00

48 lines
1.5 KiB
Python

import json
import os
from datetime import datetime
from aiohttp import web
from server import PromptServer
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
WEB_DIRECTORY = "./web"
# The frontend profiler POSTs each finished report here — browser JS cannot
# write to disk directly. Files land in custom_nodes/.disabled/LinkRouter_log.
_LOG_DIR = os.path.normpath(
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
os.pardir,
".disabled",
"LinkRouter_log",
)
)
@PromptServer.instance.routes.post("/linkrouter/write_log")
async def _linkrouter_write_log(request):
try:
payload = await request.json()
except Exception:
return web.json_response({"ok": False, "error": "invalid json"}, status=400)
try:
os.makedirs(_LOG_DIR, exist_ok=True)
stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
name = f"LinkRouter_{stamp}.json"
path = os.path.join(_LOG_DIR, name)
n = 1
while os.path.exists(path):
name = f"LinkRouter_{stamp}_{n}.json"
path = os.path.join(_LOG_DIR, name)
n += 1
with open(path, "w", encoding="utf-8") as f:
json.dump(payload, f, ensure_ascii=False, indent=2)
return web.json_response({"ok": True, "file": name})
except Exception as exc:
return web.json_response({"ok": False, "error": str(exc)}, status=500)
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]