diff --git a/public/pausio/capture.css b/public/pausio/capture.css new file mode 100644 index 00000000..08db02f5 --- /dev/null +++ b/public/pausio/capture.css @@ -0,0 +1,14 @@ +:root{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Arial,sans-serif;color:#edf1f5;background:#0c131c;font-synthesis:none} +*{box-sizing:border-box}html{min-width:320px}body{margin:0}body,button,select,textarea,input{font-family:inherit}button,a{-webkit-tap-highlight-color:transparent}button{cursor:pointer}button:disabled{opacity:.5;cursor:not-allowed}[hidden]{display:none!important} +.shell{max-width:1240px;margin:auto;padding:0 26px}.topbar{height:70px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #27313e;gap:12px}.brand{font-size:23px;font-weight:800;letter-spacing:-1.2px}.brand-mark{font-size:21px;color:#f5ac78;margin-right:7px}.dot{color:#f5ac78}.brand-page{font-size:13px;letter-spacing:0;color:#a5b3c2;font-weight:500}.privacy{color:#b5c6b8;font-size:12px;white-space:nowrap}.privacy-dot{display:inline-block;width:7px;height:7px;background:#7ccaaa;border-radius:50%;margin-right:6px} +.layout{display:grid;grid-template-columns:minmax(0,1.08fr) minmax(300px,.82fr);align-items:start;gap:54px;padding:35px 0}.heading{display:flex;justify-content:space-between;align-items:start;gap:10px;margin-bottom:20px}.eyebrow{color:#f5ac78;font-size:10px;letter-spacing:2px;font-weight:750;margin:0 0 10px}h1{font-size:clamp(28px,3vw,39px);line-height:1.14;letter-spacing:-1.4px;margin:0}h1 em{font-style:normal;color:#f3aa78}.state-chip{font-size:10px;letter-spacing:1px;padding:8px 10px;border:1px solid #344456;border-radius:20px;color:#bcc8d5;white-space:nowrap} +.camera{position:relative;width:min(100%,430px);aspect-ratio:9/16;background:linear-gradient(140deg,#1f2a38,#101822);border-radius:17px;overflow:hidden;border:1px solid #354454;box-shadow:0 20px 70px rgba(0,0,0,.28)} +.camera video{width:100%;height:100%;object-fit:cover;position:absolute;inset:0;background:#101822}.camera video.mirrored{transform:scaleX(-1)}.camera-placeholder{height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:38px;gap:14px;color:#d1dbe3}.camera-placeholder .camera-glyph{font-size:65px;color:#65788d}.camera-placeholder strong{font-size:19px;line-height:1.25}.camera-placeholder p{margin:0;color:#9babbc;font-size:13px;line-height:1.6} +.prompter{position:absolute;z-index:2;left:7%;right:7%;top:5.5%;padding:10px 12px 12px;border-radius:14px;background:rgba(10,17,25,.74);border:1px solid rgba(234,241,247,.15);pointer-events:none;box-shadow:0 10px 28px rgba(0,0,0,.32)}.prompter.middle{top:37%}.lens-hint{text-align:center;text-transform:uppercase;font-size:9px;letter-spacing:1.25px;color:#f4b88f;margin:0 0 9px}.lens-dot{display:inline-block;width:6px;height:6px;border:1px solid #f4b88f;border-radius:50%;margin-right:5px}.prompter-scroll{height:calc(var(--font-size,26px) * 4.2);overflow:hidden;scrollbar-width:none}.prompter-scroll::-webkit-scrollbar{display:none}.prompter-scroll>div{font-size:var(--font-size,26px);font-weight:680;line-height:1.4;color:#fff;white-space:pre-wrap;overflow-wrap:anywhere;padding-bottom:90px;text-align:center} +.camera-hud{position:absolute;z-index:3;left:14px;right:14px;bottom:14px;display:flex;justify-content:space-between;gap:6px;align-items:center}.timer,.format-pill{background:rgba(8,16,24,.78);backdrop-filter:blur(6px);border-radius:20px;padding:8px 12px;font-size:11px;color:#e0e8ef;font-variant-numeric:tabular-nums}.timer{display:flex;align-items:center;gap:7px;font-size:12px}.record-dot{background:#6a7581;border-radius:50%;width:9px;height:9px}.timer.live .record-dot{background:#fd5b5b;box-shadow:0 0 0 4px rgba(253,91,91,.2)}.countdown{position:absolute;inset:0;z-index:5;display:grid;place-items:center;color:#fff;font-size:96px;font-weight:750;background:rgba(7,12,18,.42)} +.transport{display:flex;gap:10px;flex-wrap:wrap;width:min(100%,430px);margin-top:15px}.button{border-radius:10px;border:1px solid #46576a;padding:13px 17px;min-height:48px;font-weight:700;font-size:13px;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;line-height:1.2;text-align:center;transition:background .14s}.button.primary{background:#f2ac79;border-color:#f2ac79;color:#111921}.button.primary:hover{background:#ffc195}.button.secondary{background:#1c2835;color:#edf1f5}.button.secondary:hover{background:#27384a}.button.recording{background:#e95859;border-color:#e95859;color:#fff}.button.danger{background:#e95859;border-color:#e95859;color:#fff}.button.compact{width:48px;padding:0;font-size:21px}.transport>.button:not(.compact){flex:1}.button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #9dd4f5;outline-offset:3px} +.download-panel{margin-top:20px;padding:20px;border-radius:14px;background:#162b29;border:1px solid #375e54;width:min(100%,560px)}.download-panel h2{margin:0 0 8px;font-size:19px;letter-spacing:-.4px}.download-panel .small{margin:0 0 14px}.download-actions{display:flex;gap:9px;flex-wrap:wrap}.download-actions>*{flex:1}.hint,.small{color:#a9b8c8;font-size:12px;line-height:1.6}.hint{margin:14px 0 0}.status{width:min(100%,560px);padding:12px 0;color:#a8bbca;font-size:12px;line-height:1.6;margin:8px 0 0}.status.error{color:#ffadad} +.settings{background:#141e29;border:1px solid #2d3d4f;border-radius:18px;padding:25px;margin-top:5px}.settings-head h2{font-size:24px;letter-spacing:-.5px;margin:0 0 7px}.settings-head p:not(.eyebrow){color:#aab9c9;font-size:13px;line-height:1.5;margin:0 0 22px}.field{display:grid;gap:8px;font-size:12px;font-weight:650;color:#dde7ef;margin:0 0 19px}.field textarea,.field select{width:100%;background:#0f1823;color:#eef2f6;border:1px solid #405064;border-radius:10px;font-size:14px;padding:13px;outline-offset:2px}.field textarea{resize:vertical;min-height:160px;line-height:1.65}.field select{height:45px}.slider-line{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:14px 0 7px;font-size:12px}.slider-line strong{color:#f3b385;font-size:12px}input[type=range]{width:100%;accent-color:#f5ac78;min-height:34px}.checkbox-line{display:flex;gap:10px;align-items:start;font-size:12px;color:#dae4ed;line-height:1.5;margin-top:18px}.checkbox-line input{accent-color:#f5ac78;width:18px;height:18px;margin:0}.info{background:#1c2b39;border-left:2px solid #f5ac78;border-radius:8px;margin-top:22px;padding:13px 15px}.info strong{font-size:12px}.info p{font-size:12px;color:#aebdcc;line-height:1.6;margin:7px 0 0}.settings>.small{margin:17px 0 0}footer{color:#76899b;border-top:1px solid #283542;padding:23px 0 35px;font-size:10px;letter-spacing:1.3px;display:flex;justify-content:space-between;gap:10px} +@media(max-width:850px){.layout{grid-template-columns:1fr;gap:20px}.camera{margin:auto}.transport{margin-left:auto;margin-right:auto}.settings{margin-top:5px}.heading{max-width:540px;margin-left:auto;margin-right:auto}.capture-column{max-width:640px;margin:auto;width:100%}} +@media(max-width:440px){.shell{padding:0 14px}.topbar{height:59px}.brand{font-size:19px}.brand-page{font-size:11px}.privacy{font-size:10px}.layout{padding:23px 0}.heading{margin-bottom:14px}.heading h1{font-size:27px}.state-chip{padding:6px 8px;font-size:9px}.camera{max-height:min(67svh,690px);width:auto;max-width:100%;margin:auto;aspect-ratio:9/16}.transport{width:100%}.settings{padding:17px}.download-panel{padding:16px}.format-pill{font-size:9px}.prompter{left:5%;right:5%;top:4%}.prompter-scroll{height:calc(var(--font-size,26px) * 3.2)}footer span{display:none}} +@media(prefers-reduced-motion:reduce){*{transition:none!important}} diff --git a/public/pausio/capture.js b/public/pausio/capture.js new file mode 100644 index 00000000..c6a3de85 --- /dev/null +++ b/public/pausio/capture.js @@ -0,0 +1,282 @@ +/* Pausio Mobile Capture. No backend, analytics or external services. */ +(() => { + "use strict"; + const $ = id => document.getElementById(id); + const els = { + live: $("camera-video"), playback: $("result-video"), placeholder: $("camera-placeholder"), + frame: $("camera-frame"), prompter: $("prompter"), scroll: $("prompter-scroll"), + text: $("prompter-text"), status: $("status"), state: $("capture-state"), + timer: $("timer"), clock: $("timer-text"), format: $("format-pill"), + camera: $("activate-camera"), start: $("record-start"), stop: $("record-stop"), + next: $("new-take"), flip: $("switch-camera"), pause: $("toggle-scroll"), + countdown: $("countdown"), panel: $("download-panel"), download: $("download-video"), + share: $("share-video"), details: $("file-details"), script: $("script-input"), + speed: $("speed"), font: $("font-size"), position: $("prompter-position"), + autoplay: $("auto-scroll") + }; + const STORE_KEY = "pausio-mobile-capture-v1"; + let stream = null, recorder = null, chunks = [], output = null, blobUrl = null; + let outputName = "", mode = "idle", facing = "user", raf = 0, lastFrame = 0; + let startedAt = 0, pausedScroll = false, countdownId = 0; + let savedAfterRecording = false, recordedMime = ""; + + function notice(message, error = false) { + els.status.textContent = message; + els.status.classList.toggle("error", error); + } + function setMode(next) { + mode = next; + els.camera.hidden = next !== "idle" && next !== "error"; + els.start.hidden = next !== "preview"; + els.stop.hidden = next !== "recording"; + els.next.hidden = next !== "finished"; + els.flip.hidden = next !== "preview"; + els.pause.hidden = next !== "preview" && next !== "recording"; + els.panel.hidden = next !== "finished"; + els.placeholder.hidden = next !== "idle" && next !== "error"; + els.live.hidden = next === "finished" || next === "idle" || next === "error"; + els.playback.hidden = next !== "finished"; + els.prompter.hidden = next === "finished" || next === "idle" || next === "error"; + els.timer.classList.toggle("live", next === "recording"); + els.state.textContent = {idle:"PRONTO", error:"ERRORE", preview:"CAMERA ATTIVA", + countdown:"PREPARATI", recording:"REC", stopping:"SALVATAGGIO", finished:"TAKE PRONTO"}[next] || "PRONTO"; + const locked = ["countdown","recording","stopping"].includes(next); + for (const el of [els.script,els.speed,els.font,els.position,els.autoplay]) el.disabled = locked; + els.pause.textContent = pausedScroll ? "▶" : "Ⅱ"; + els.pause.setAttribute("aria-label", pausedScroll ? "Riprendi scorrimento" : "Pausa scorrimento"); + } + function prefs() { + try { + const data = JSON.parse(localStorage.getItem(STORE_KEY) || "null"); + if (!data || data.version !== 1) return; + if (typeof data.script === "string") els.script.value = data.script.slice(0, 15000); + if (Number.isFinite(data.speed)) els.speed.value = Math.max(50, Math.min(220, data.speed)); + if (Number.isFinite(data.font)) els.font.value = Math.max(20, Math.min(44, data.font)); + if (["top","middle"].includes(data.position)) els.position.value = data.position; + if (typeof data.autoplay === "boolean") els.autoplay.checked = data.autoplay; + } catch (_) { /* Storage unavailable in private browsing. */ } + } + function remember() { + try { + localStorage.setItem(STORE_KEY, JSON.stringify({version:1, + script:els.script.value.slice(0,15000), speed:+els.speed.value, font:+els.font.value, + position:els.position.value, autoplay:els.autoplay.checked})); + } catch (_) { /* Capture and downloads do not require localStorage. */ } + } + function refreshPrompter() { + els.text.textContent = els.script.value.trim() || "Scrivi uno script nelle impostazioni."; + els.prompter.style.setProperty("--font-size", els.font.value + "px"); + els.prompter.classList.toggle("middle", els.position.value === "middle"); + $("speed-value").textContent = els.speed.value + " parole/min"; + $("font-value").textContent = els.font.value + " px"; + } + function stopAnimation() { cancelAnimationFrame(raf); raf = 0; lastFrame = 0; } + function tick(now) { + if (mode !== "recording" && mode !== "preview") { stopAnimation(); return; } + if (mode === "recording") { + const elapsed = Math.max(0, Math.floor((now - startedAt) / 1000)); + els.clock.textContent = String(Math.floor(elapsed / 60)).padStart(2, "0") + + ":" + String(elapsed % 60).padStart(2, "0"); + } + if (lastFrame && !pausedScroll && els.autoplay.checked && mode === "recording") { + const fontPx = +els.font.value; + const charsPerLine = Math.max(10, els.scroll.clientWidth / (fontPx * .54)); + const wordsPerLine = Math.max(1.6, charsPerLine / 6); + const pxPerSecond = ((+els.speed.value / 60) / wordsPerLine) * fontPx * 1.4; + els.scroll.scrollTop += Math.min((now - lastFrame) / 1000, .15) * pxPerSecond; + } + lastFrame = now; + raf = requestAnimationFrame(tick); + } + function resetScroll() { + stopAnimation(); els.scroll.scrollTop = 0; pausedScroll = false; els.clock.textContent = "00:00"; + } + function supportedMime() { + if (!window.MediaRecorder) return ""; + const candidates = [ + 'video/mp4;codecs="avc1.42E01E,mp4a.40.2"', "video/mp4", + "video/webm;codecs=vp9,opus", "video/webm;codecs=vp8,opus", "video/webm" + ]; + return candidates.find(type => MediaRecorder.isTypeSupported(type)) || ""; + } + async function releaseCamera() { + if (stream) for (const track of stream.getTracks()) track.stop(); + stream = null; + els.live.pause(); + els.live.srcObject = null; + } + async function activateCamera() { + if (!navigator.mediaDevices?.getUserMedia || !window.MediaRecorder) { + setMode("error"); + notice("Questo browser non supporta la registrazione diretta. Usa Safari aggiornato su iPhone o Chrome aggiornato su Android, tramite HTTPS.", true); + return; + } + try { + els.camera.disabled = true; + els.flip.disabled = true; + await releaseCamera(); + const candidate = await navigator.mediaDevices.getUserMedia({ + video: {facingMode: {ideal:facing}, width:{ideal:1080}, height:{ideal:1920}, + aspectRatio:{ideal:9/16}, frameRate:{ideal:30}}, + audio: true + }); + stream = candidate; + els.live.srcObject = stream; + els.live.classList.toggle("mirrored", facing === "user"); + await els.live.play(); + resetScroll(); + refreshPrompter(); + setMode("preview"); + const dimensions = candidate.getVideoTracks()[0]?.getSettings?.() || {}; + const width = dimensions.width, height = dimensions.height; + els.format.textContent = width && height ? width + "×" + height + " · originale" : "Formato automatico"; + if (width && height && width >= height) { + notice("La fotocamera registra in orizzontale (" + width + "×" + height + "). Ruota il telefono in verticale e riattiva la fotocamera prima del take.", true); + } else { + notice("Controlla l'inquadratura, poi tocca Registra. Il gobbo sarà visibile solo sullo schermo."); + } + } catch (error) { + await releaseCamera(); + setMode("error"); + const denied = ["NotAllowedError","PermissionDeniedError","SecurityError"].includes(error?.name); + notice(denied ? "Fotocamera o microfono non autorizzati. Abilita entrambi nei permessi del browser e riprova." : + "Non riesco ad aprire fotocamera e microfono. Chiudi altre app che li usano e riprova (" + (error?.name || "errore") + ").", true); + } finally { + els.camera.disabled = false; + els.flip.disabled = false; + } + } + function cancelCountdown() { + countdownId++; + els.countdown.hidden = true; + } + async function startRecording() { + if (mode !== "preview" || !stream || !els.script.value.trim()) { + notice("Inserisci uno script e attiva la fotocamera prima di registrare.", true); + return; + } + resetScroll(); + els.countdown.hidden = false; + setMode("countdown"); + const seq = ++countdownId; + for (const number of [3,2,1]) { + if (seq !== countdownId) return; + els.countdown.textContent = String(number); + await new Promise(resolve => setTimeout(resolve, 750)); + } + if (seq !== countdownId || !stream || mode !== "countdown") return; + els.countdown.hidden = true; + try { + const mimeType = supportedMime(); + recorder = new MediaRecorder(stream, mimeType ? {mimeType} : undefined); + recordedMime = recorder.mimeType || mimeType || "video/webm"; + chunks = []; + recorder.ondataavailable = event => { if (event.data && event.data.size) chunks.push(event.data); }; + recorder.onerror = () => { notice("Registrazione interrotta. Prova a salvare il take, se disponibile.", true); }; + recorder.onstop = finishRecording; + recorder.start(1000); + startedAt = performance.now(); + setMode("recording"); + notice("Registrazione in corso. Non bloccare lo schermo e non uscire dal browser."); + raf = requestAnimationFrame(tick); + } catch (error) { + recorder = null; + setMode("preview"); + notice("Impossibile avviare la registrazione su questo browser (" + (error?.name || "formato non supportato") + ").", true); + } + } + function stopRecording() { + if (mode !== "recording") return; + stopAnimation(); + setMode("stopping"); + notice("Sto preparando il video per il download. Tieni aperta questa pagina."); + try { + if (recorder && recorder.state !== "inactive") { + recorder.requestData(); + recorder.stop(); + } else { finishRecording(); } + } catch (_) { finishRecording(); } + } + async function finishRecording() { + if (mode !== "stopping" && mode !== "recording") return; + stopAnimation(); + await releaseCamera(); + const type = recordedMime.includes("mp4") ? "video/mp4" : "video/webm"; + output = new Blob(chunks, {type}); + chunks = []; + recorder = null; + if (!output.size) { + output = null; + setMode("error"); + notice("Il browser non ha restituito dati video. Non chiudere altre registrazioni senza averne verificato l'anteprima.", true); + return; + } + if (blobUrl) URL.revokeObjectURL(blobUrl); + blobUrl = URL.createObjectURL(output); + outputName = "pausio-take-" + new Date().toISOString().replace(/[:.]/g,"-") + + (type === "video/mp4" ? ".mp4" : ".webm"); + els.playback.src = blobUrl; + els.download.href = blobUrl; + els.download.download = outputName; + const seconds = Math.round((performance.now() - startedAt) / 1000); + els.details.textContent = outputName.split(".").pop().toUpperCase() + " · " + + (output.size / (1024 * 1024)).toFixed(1) + " MB · " + seconds + " s · senza gobbo"; + savedAfterRecording = false; + const file = new File([output], outputName, {type}); + els.share.hidden = !(navigator.canShare && navigator.canShare({files:[file]})); + setMode("finished"); + notice("Take pronto. Tocca Scarica video oppure Condividi / Salva su File. Verifica il file prima di abbandonare la pagina."); + } + async function shareRecording() { + if (!output || !navigator.share) return; + try { + const file = new File([output], outputName, {type:output.type}); + if (!navigator.canShare?.({files:[file]})) throw Error("Share non disponibile"); + await navigator.share({files:[file],title:"Pausio · Video registrato"}); + savedAfterRecording = true; + notice("Condivisione avviata. Controlla nell'app scelta che il video sia stato salvato."); + } catch (error) { + if (error?.name !== "AbortError") notice("Condivisione non disponibile: usa Scarica video oppure apri il file nel browser.", true); + } + } + async function newTake() { + if (mode !== "finished") return; + if (!savedAfterRecording && !window.confirm("Hai salvato il video sul telefono? Iniziando un nuovo take perderai l'anteprima attuale.")) return; + els.playback.pause(); + els.playback.removeAttribute("src"); + els.playback.load(); + if (blobUrl) URL.revokeObjectURL(blobUrl); + blobUrl = null; output = null; outputName = ""; + setMode("idle"); + notice("Pronto per un altro take. Il copione e le impostazioni restano disponibili."); + await activateCamera(); + } + els.camera.addEventListener("click", activateCamera); + els.flip.addEventListener("click", async () => { if (mode !== "preview") return; facing = facing === "user" ? "environment" : "user"; await activateCamera(); }); + els.start.addEventListener("click", startRecording); + els.stop.addEventListener("click", stopRecording); + els.next.addEventListener("click", newTake); + els.pause.addEventListener("click", () => { pausedScroll = !pausedScroll; els.pause.textContent = pausedScroll ? "▶" : "Ⅱ"; els.pause.setAttribute("aria-label",pausedScroll ? "Riprendi scorrimento" : "Pausa scorrimento"); }); + els.download.addEventListener("click", () => { savedAfterRecording = true; notice("Download richiesto. Verifica che il file sia realmente presente in Download o File prima di uscire."); }); + els.share.addEventListener("click", shareRecording); + for (const el of [els.script,els.speed,els.font,els.position,els.autoplay]) { + el.addEventListener(el === els.script ? "input" : "change", () => { refreshPrompter(); remember(); }); + if (el === els.speed || el === els.font) el.addEventListener("input", () => { refreshPrompter(); remember(); }); + } + document.addEventListener("visibilitychange", () => { + if (document.hidden && (mode === "recording" || mode === "countdown")) { + notice("Non bloccare lo schermo: il browser può interrompere fotocamera e registrazione.", true); + } + }); + window.addEventListener("pagehide", () => { cancelCountdown(); stopAnimation(); releaseCamera(); }); + window.addEventListener("beforeunload", event => { + if (mode === "recording" || mode === "stopping" || (mode === "finished" && !savedAfterRecording)) { + event.preventDefault(); event.returnValue = ""; + } + }); + prefs(); refreshPrompter(); setMode("idle"); + if (!window.isSecureContext && !["localhost","127.0.0.1"].includes(location.hostname)) { + els.camera.disabled = true; + notice("La fotocamera da browser richiede HTTPS. Apri questa pagina da un sito HTTPS.", true); + } +})(); diff --git a/public/pausio/index.html b/public/pausio/index.html new file mode 100644 index 00000000..77f85ab0 --- /dev/null +++ b/public/pausio/index.html @@ -0,0 +1,87 @@ + + + + + + + + + Registra · Pausio + + + + +
+
+
pausio. / Registra
+
Sul tuo telefono
+
+
+
+
+

MOBILE STUDIO / 01

La tua voce.
Senza perdere il filo.

+ PRONTO +
+
+ + +
+ + Pronto per il tuo prossimo take. +

Attiva fotocamera e microfono per vedere il gobbo sopra l'anteprima.

+
+ +
+ 00:00 + 9:16 · formato automatico +
+ +
+
+ + + + + + +
+ +

Il video resta nel browser finché non lo scarichi. Non viene inviato a Pausio o a servizi esterni.

+
+ +
+ +
+ + diff --git a/tests/smoke.js b/tests/smoke.js index e37b8b55..9e731467 100644 --- a/tests/smoke.js +++ b/tests/smoke.js @@ -397,6 +397,40 @@ for (const { from, target } of expectedRedirects) { } } +console.log('\n🔍 8. Verifying standalone Pausio mobile capture...'); +const captureArtifacts = [ + 'pausio/index.html', + 'pausio/capture.css', + 'pausio/capture.js', +]; +for (const asset of captureArtifacts) { + const target = path.join(distDir, asset); + if (!fs.existsSync(target) || fs.statSync(target).size === 0) { + console.error(`❌ Pausio mobile artifact missing or empty: ${asset}`); + errors++; + } else { + console.log(` ✓ Pausio capture asset verified: ${asset}`); + } +} +const captureIndex = path.join(distDir, 'pausio/index.html'); +const captureScript = path.join(distDir, 'pausio/capture.js'); +if (fs.existsSync(captureIndex) && fs.existsSync(captureScript)) { + const html = fs.readFileSync(captureIndex, 'utf-8'); + const js = fs.readFileSync(captureScript, 'utf-8'); + const contracts = [ + [html.includes('id="record-start"'), 'Record button'], + [html.includes('id="download-video"'), 'On-device download button'], + [html.includes('./capture.css') && html.includes('./capture.js'), 'Relative URLs under /pausio/'], + [js.includes('new MediaRecorder(stream'), 'Browser video recorder'], + [js.includes('URL.createObjectURL(output)'), 'Offline blob video download'], + [js.includes('els.download.download = outputName'), 'Downloaded file name'], + [!js.includes('fetch(') && !js.includes('XMLHttpRequest'), 'No automatic remote uploads'], + ]; + for (const [passes, label] of contracts) { + if (!passes) { console.error(`❌ Pausio capture contract failed: ${label}`); errors++; } + } +} + if (errors > 0) { console.error(`\n❌ Verification completed with ${errors} error(s).`); process.exit(1);