chore: fix protocol-types-generator to work with new API
Follow-up to a2ab645e63
This commit is contained in:
parent
55b6fe241e
commit
cd68619786
|
|
@ -10,11 +10,13 @@ async function generateChromiunProtocol(revision) {
|
||||||
if (revision.local && fs.existsSync(outputPath))
|
if (revision.local && fs.existsSync(outputPath))
|
||||||
return;
|
return;
|
||||||
const playwright = await require('../../index').chromium;
|
const playwright = await require('../../index').chromium;
|
||||||
const browser = await playwright.launch({ executablePath: revision.executablePath });
|
const browserServer = await playwright.launchServer({ executablePath: revision.executablePath });
|
||||||
|
const origin = browserServer.wsEndpoint().match(/ws:\/\/([0-9A-Za-z:\.]*)\//)[1];
|
||||||
|
const browser = await playwright.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto(`http://${origin}/json/protocol`);
|
await page.goto(`http://${origin}/json/protocol`);
|
||||||
const json = JSON.parse(await page.evaluate(() => document.documentElement.innerText));
|
const json = JSON.parse(await page.evaluate(() => document.documentElement.innerText));
|
||||||
await browser.close();
|
await browserServer.kill();
|
||||||
fs.writeFileSync(outputPath, jsonToTS(json));
|
fs.writeFileSync(outputPath, jsonToTS(json));
|
||||||
console.log(`Wrote protocol.ts to ${path.relative(process.cwd(), outputPath)}`);
|
console.log(`Wrote protocol.ts to ${path.relative(process.cwd(), outputPath)}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue