| 78 | } |
| 79 | |
| 80 | function buildHostHtml(fixtureName: string, width: number, height: number): string { |
| 81 | const playerSrc = "/player/hyperframes-player.global.js"; |
| 82 | const fixtureSrc = `/fixtures/${fixtureName}/index.html`; |
| 83 | return `<!doctype html> |
| 84 | <html lang="en"> |
| 85 | <head> |
| 86 | <meta charset="utf-8" /> |
| 87 | <title>player perf host: ${fixtureName}</title> |
| 88 | <style> |
| 89 | html, body { margin: 0; padding: 0; background: #000; } |
| 90 | hyperframes-player { display: block; } |
| 91 | </style> |
| 92 | </head> |
| 93 | <body> |
| 94 | <hyperframes-player |
| 95 | id="player" |
| 96 | src="${fixtureSrc}" |
| 97 | width="${width}" |
| 98 | height="${height}" |
| 99 | muted |
| 100 | ></hyperframes-player> |
| 101 | <script> |
| 102 | window.__playerReady = false; |
| 103 | window.__playerReadyAt = null; |
| 104 | window.__playerNavStart = performance.timeOrigin + performance.now(); |
| 105 | const player = document.getElementById("player"); |
| 106 | player.addEventListener("ready", function (event) { |
| 107 | window.__playerReady = true; |
| 108 | window.__playerReadyAt = performance.timeOrigin + performance.now(); |
| 109 | window.__playerDuration = (event.detail && event.detail.duration) || 0; |
| 110 | }); |
| 111 | player.addEventListener("error", function (event) { |
| 112 | window.__playerError = (event.detail && event.detail.message) || "unknown"; |
| 113 | }); |
| 114 | </script> |
| 115 | <script src="${playerSrc}"></script> |
| 116 | </body> |
| 117 | </html>`; |
| 118 | } |
| 119 | |
| 120 | async function readBunFile(path: string): Promise<Response> { |
| 121 | if (!existsSync(path)) { |