()
| 88 | |
| 89 | /** How many pages the app has open right now — a new in-app window bumps this. */ |
| 90 | const pageTargetCount = async (): Promise<number> => { |
| 91 | const targets = (await fetch(`http://127.0.0.1:${cdpPort}/json/list`) |
| 92 | .then((r) => (r.ok ? r.json() : [])) |
| 93 | .catch(() => [])) as ReadonlyArray<{ type: string }>; |
| 94 | return targets.filter((t) => t.type === "page").length; |
| 95 | }; |
| 96 | |
| 97 | const run = async (runDir: string) => { |
| 98 | const cdp = await CdpPage.connect(await pageWsUrl(Number(cdpPort))); |