earshelf / source /scripts /trace.mjs
WilburDev's picture
Deploy 2026-11-19T12:25Z
4a58e48 verified
Raw History Blame Contribute Delete
1.36 kB
import { chromium } from '@playwright/test';
const dtype = process.argv[2];
const b = await chromium.launch({ channel: 'chrome' });
const ctx = await b.newContext();
await ctx.route(/huggingface\.co/, (r) => { console.log('BLOCKED', r.request().url()); r.abort(); });
const p = await ctx.newPage();
p.on('requestfailed', (r) => console.log('FAILED', r.url()));
ctx.on('request', (r) => { if (/models|onnx|\.bin/.test(r.url())) console.log('REQ', r.url().replace('http://localhost:4175/', '')); });
await p.goto('http://localhost:4175/');
const workerUrl = await p.evaluate(async () => {
const idx = performance.getEntriesByType('resource').map((r) => r.name).find((n) => /assets\/index-.*\.js$/.test(n));
const src = await (await fetch(idx)).text();
return new URL('assets/' + src.match(/tts-worker-[\w-]+\.js/)[0], location.href).href;
});
const r = await p.evaluate(async ({ workerUrl, dtype }) => {
const w = new Worker(workerUrl, { type: 'module' });
return await new Promise((resolve) => {
w.onmessage = (e) => { if (['ready', 'loadError'].includes(e.data.type)) resolve(e.data); };
w.postMessage({ type: 'load', device: 'wasm', dtype, threads: 4, ortBase: new URL('ort/', location.href).href, modelBase: new URL('models/kokoro/', location.href).href });
});
}, { workerUrl, dtype });
console.log(JSON.stringify(r));
await b.close();