bf1efb2099
- Migration 007: repo_url on apps table + analysis table with FTS5 - Analysis struct, parser, CRUD, validation, hash computation - Selective purge: remote-only apps/analysis preserved across fn index - CLI: fn app list/clone/pull, fn analysis list/clone/pull - search/show/list now include analysis results - Apps removed from git tracking (content lives in Gitea repos) - .gitkeep for apps/ and analysis/ dirs - Bash functions: jupyter analysis pipeline, shell utilities - Browser domain: CDP functions moved from infra to browser Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
930 B
Go
36 lines
930 B
Go
package browser
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// CdpWaitLoad espera a que la página actual termine de cargar completamente.
|
|
// Hace polling de document.readyState via Runtime.evaluate cada 200ms hasta
|
|
// que sea "complete", o hasta que se agote el timeout.
|
|
// Retorna error si el timeout se agota o si CdpEvaluate falla (conexion rota).
|
|
func CdpWaitLoad(c *CDPConn, timeout time.Duration) error {
|
|
if c == nil {
|
|
return fmt.Errorf("cdp wait load: conexion nula")
|
|
}
|
|
if timeout <= 0 {
|
|
timeout = 30 * time.Second
|
|
}
|
|
|
|
deadline := time.Now().Add(timeout)
|
|
interval := 200 * time.Millisecond
|
|
|
|
for time.Now().Before(deadline) {
|
|
result, err := CdpEvaluate(c, "document.readyState")
|
|
if err != nil {
|
|
return fmt.Errorf("cdp wait load: error evaluando readyState: %w", err)
|
|
}
|
|
if result == "complete" {
|
|
return nil
|
|
}
|
|
time.Sleep(interval)
|
|
}
|
|
|
|
return fmt.Errorf("cdp wait load: pagina no cargo despues de %s", timeout)
|
|
}
|