feat: externalize apps/analysis to Gitea repos, add analysis table
- 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>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package browser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CdpWaitElement espera hasta que un selector CSS exista en el DOM.
|
||||
// Hace polling con Runtime.evaluate hasta que el elemento aparezca o se agote el timeout.
|
||||
// Retorna error si el timeout se agota sin encontrar el elemento.
|
||||
func CdpWaitElement(c *CDPConn, selector string, timeout time.Duration) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("cdp wait element: conexion nula")
|
||||
}
|
||||
if timeout <= 0 {
|
||||
timeout = 10 * time.Second
|
||||
}
|
||||
|
||||
deadline := time.Now().Add(timeout)
|
||||
interval := 200 * time.Millisecond
|
||||
|
||||
js := fmt.Sprintf(`document.querySelector(%q) !== null`, selector)
|
||||
|
||||
for time.Now().Before(deadline) {
|
||||
result, err := CdpEvaluate(c, js)
|
||||
if err != nil {
|
||||
// Error en evaluate — puede que la pagina aun no este lista
|
||||
time.Sleep(interval)
|
||||
continue
|
||||
}
|
||||
if result == "true" {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(interval)
|
||||
}
|
||||
|
||||
return fmt.Errorf("cdp wait element: selector %q no encontrado despues de %s", selector, timeout)
|
||||
}
|
||||
Reference in New Issue
Block a user