import asyncio
from playwright.async_api import async_playwright
URL='http://localhost:8090/DOZIKWORKS_OS_v5_locked.dc.html'
async def main():
    async with async_playwright() as p:
        br=await p.chromium.launch(channel='msedge',headless=True)
        pg=await br.new_page(viewport={'width':1200,'height':800})
        msgs=[]
        pg.on('console',lambda m: msgs.append(f"[{m.type}] {m.text}"))
        pg.on('pageerror',lambda e: msgs.append("PAGEERROR: "+str(e)))
        await pg.goto(URL)
        await pg.wait_for_timeout(3500)
        st=await pg.evaluate("()=>({hasDzw:!!window.__dzw, hasParts:!!(window.__dzw&&window.__dzw._torchParts), hasNode:!!(window.__dzw&&window.__dzw._torchNode)})")
        print("STATE:",st)
        print("--- messages ---")
        for m in msgs[-40:]: print(m)
        await br.close()
asyncio.run(main())
