diff --git a/main.js b/main.js index af7bdf0..1d67e8a 100644 --- a/main.js +++ b/main.js @@ -2,10 +2,12 @@ import "./style.css"; // Vite handles inserting CSS // Common pattern is to put JS source files in src/ import { setupVideo, takePhoto } from "./src/camera.js"; -const button = document.querySelector("#take-photo"); -const canvas = document.querySelector("canvas"); -const video = await setupVideo(); +(async function run() { + const button = document.querySelector("#take-photo"); + const canvas = document.querySelector("canvas"); + const video = await setupVideo(); -button.addEventListener("click", () => { - takePhoto(video, canvas); -}); + button.addEventListener("click", () => { + takePhoto(video, canvas); + }); +})();