46#include <choc/containers/choc_Value.h>
89 using Handler = std::function<std::string(
const choc::value::ValueView& payload)>;
133 const choc::
value::ValueView& payload) const noexcept;
146 std::string_view payload_json) const noexcept;
182 std::string_view handler_name);
184 std::string_view handler_name);
195 float dflt) noexcept;
198 std::
size_t dflt) noexcept;
200 const
char* key) noexcept;
216 std::unique_ptr<Impl> impl_;
EditorBridge & operator=(const EditorBridge &)=delete
void add_handler(std::string_view type, Handler fn)
Register a handler for the given message type.
static std::size_t get_uint(const choc::value::ValueView &v, const char *key, std::size_t dflt) noexcept
void attach_webview(WebViewPanel &panel)
Hook this bridge up to a WebViewPanel's structured message channel.
void attach_native_runtime(JsRuntime &runtime, std::string_view handler_name)
Hook this bridge up to a native JS runtime's postMessage source.
EditorBridge & operator=(EditorBridge &&)=delete
EditorBridge(EditorBridge &&)=delete
EditorBridge(const EditorBridge &)=delete
std::function< std::string(const choc::value::ValueView &payload)> Handler
Handler signature.
Definition editor_bridge.hpp:89
static std::string get_string(const choc::value::ValueView &v, const char *key) noexcept
std::string dispatch_webview_message(std::string_view type, std::string_view payload_json) const noexcept
Convenience: dispatch a WebViewPanel message that has already been split into type + payload_json by ...
void detach_native_runtime(ScriptedUiSession &session, std::string_view handler_name)
void remove_handler(std::string_view type)
Remove a handler. No-op if no handler was registered.
static std::string err_response(std::string_view msg) noexcept
{"ok":false,"error":"<msg>"}.
std::string dispatch_json(std::string_view json) const noexcept
Parse a JSON envelope and dispatch.
bool has_handler(std::string_view type) const noexcept
True if a handler is registered for type.
std::string dispatch(std::string_view type, const choc::value::ValueView &payload) const noexcept
Dispatch an already-parsed envelope.
std::size_t handler_count() const noexcept
Number of registered handlers.
static float get_float(const choc::value::ValueView &v, const char *key, float dflt) noexcept
static std::string ok_response() noexcept
{"ok":true}.
std::vector< std::string > handlers() const
Return the registered message types in canonical lexicographic order.
void detach_webview(WebViewPanel &panel)
Clear the message handler installed by attach_webview().
Definition script_engine.hpp:22
Definition scripted_ui.hpp:125
Definition web_view.hpp:167
Definition generated_event_source.hpp:33
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ type
Built-in / common type name (e.g. int, Number).
Definition code_editor_tokenizer.hpp:39
std::string render_claude_bridge_scaffold(const std::string &generated_js_path)
Build the starter bridge_handlers.cpp text the CLI emits next to the generated JS view when --from cl...
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ v
Definition input_events.hpp:41