import { chromium } from "playwright";
import fs from "node:fs";
const outDir = "pw-out";
fs.mkdirSync(outDir, { recursive: true });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const cursorOverlayScript = `
(() => {
const style = document.createElement('style');
style.textContent = \`
#__pw_cursor {
position: fixed;
top: 0; left: 0;
width: 18px; height: 18px;
transform: translate(-100px, -100px);
z-index: 2147483647;
pointer-events: none;
}
#__pw_cursor svg { width: 18px; height: 18px; }
#__pw_cursor .dot {
fill: rgba(255,255,255,0.9);
stroke: rgba(0,0,0,0.85);
stroke-width: 2;
}
#__pw_click {
position: fixed;
width: 8px; height: 8px;
border-radius: 50%;
transform: translate(-100px, -100px);
z-index: 2147483646;
pointer-events: none;
opacity: 0;
border: 2px solid rgba(0,0,0,0.6);
}
\`;
document.documentElement.appendChild(style);
const cursor = document.createElement('div');
cursor.id = '__pw_cursor';
cursor.innerHTML = \`
\`;
document.documentElement.appendChild(cursor);
const click = document.createElement('div');
click.id = '__pw_click';
document.documentElement.appendChild(click);
let x = -100, y = -100;
const move = (nx, ny) => {
x = nx; y = ny;
cursor.style.transform = \`translate(\${x}px, \${y}px)\`;
click.style.transform = \`translate(\${x}px, \${y}px)\`;
};
window.addEventListener('pointermove', (e) => move(e.clientX, e.clientY), { passive: true });
window.addEventListener('mousemove', (e) => move(e.clientX, e.clientY), { passive: true });
window.addEventListener('pointerdown', () => {
click.style.transition = 'none';
click.style.opacity = '0.9';
click.style.width = '8px';
click.style.height = '8px';
requestAnimationFrame(() => {
click.style.transition = 'all 250ms ease-out';
click.style.opacity = '0';
click.style.width = '28px';
click.style.height = '28px';
});
}, { passive: true });
})();
`;
// Converts native