8357774b86
- CMakeLists.txt - app.md - main.cpp - panels.cpp - appicon.ico - autoextract_panel.cpp - picker_state.cpp - picker_state.h - py_subprocess.cpp - py_subprocess.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#pragma once
|
|
|
|
// picker_state — Pick element: inyecta JS via CDP Runtime.evaluate, escucha
|
|
// `Runtime.consoleAPICalled` filtrando args[0].value == "__fn_picked__", y
|
|
// publica el ultimo elemento elegido para que Tab Detail panel lo renderice.
|
|
//
|
|
// Decisiones:
|
|
// - WS propio (CdpWs) por panel; no comparte el de NetworkSession para
|
|
// no entrelazar Runtime.* con Network.*.
|
|
// - El JS payload se lee de ${FN_REGISTRY_ROOT}/functions/browser/cdp_pick_element_js.js
|
|
// (path por env, fallback hardcoded relativo al exe).
|
|
// - Estado global thread-safe.
|
|
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
namespace navegator {
|
|
|
|
struct PickedElement {
|
|
std::string selector;
|
|
std::string xpath;
|
|
std::string tag;
|
|
std::string text;
|
|
std::string rect_str; // "x,y,w,h" formato libre
|
|
bool valid = false;
|
|
};
|
|
|
|
class CdpWs; // fwd
|
|
|
|
// Inicia modo pick para el tab dado. Si ya esta activo, reactiva.
|
|
// Carga el JS desde el path de funciones del registry. Devuelve "" si OK,
|
|
// error en caso contrario.
|
|
std::string picker_start(int port, const std::string& tab_id, const std::string& ws_url);
|
|
|
|
// Para el modo pick (cierra WS).
|
|
void picker_stop();
|
|
|
|
bool picker_is_active();
|
|
|
|
// Snapshot atomico del ultimo elemento capturado.
|
|
PickedElement picker_last();
|
|
|
|
// Limpia el ultimo capturado.
|
|
void picker_clear_last();
|
|
|
|
// Loader del payload JS. Devuelve "" si no se pudo leer.
|
|
std::string picker_load_js();
|
|
|
|
} // namespace navegator
|