76 const std::string& js_source);
83 const std::vector<uint8_t>& bytes);
91 const std::vector<WebViewEmbeddedAsset>& assets);
95 const std::string& html_embedded_name,
96 const std::vector<WebViewEmbeddedAsset>& assets);
100 const std::string&
path,
101 const std::string& html_embedded_name,
102 const std::vector<WebViewEmbeddedAsset>& assets);
107 std::string html_embedded_name,
108 std::vector<WebViewEmbeddedAsset> assets);
114 const std::string&
path,
115 const std::filesystem::path& root_directory,
116 std::string index_filename =
"index.html");
122 std::filesystem::path root_directory,
123 std::string index_filename =
"index.html");
169 using JsCallback = std::function<std::string(
const std::string& args_json)>;
170 using EvalCallback = std::function<void(
const std::string& result_json,
171 const std::string&
error)>;
Definition web_view.hpp:167
std::function< void(const std::string &result_json, const std::string &error)> EvalCallback
Definition web_view.hpp:170
virtual void set_ready_handler(ReadyHandler handler)=0
std::function< void()> ReadyHandler
Definition web_view.hpp:173
virtual void evaluate_js(const std::string &js, EvalCallback callback)=0
virtual std::vector< uint8_t > snapshot_png()
Definition web_view.hpp:198
std::function< std::string(const std::string &args_json)> JsCallback
Definition web_view.hpp:169
virtual void set_html(const std::string &html)=0
static std::unique_ptr< WebViewPanel > create(const WebViewOptions &options={})
virtual void bind(const std::string &name, JsCallback callback)=0
virtual void set_message_handler(MessageHandler handler)=0
virtual bool is_ready() const =0
virtual void navigate(const std::string &url)=0
virtual void post_message(const WebViewMessage &message)=0
std::function< std::string(const WebViewMessage &message)> MessageHandler
Definition web_view.hpp:172
virtual void set_size(uint32_t width, uint32_t height)=0
virtual ~WebViewPanel()=default
virtual void evaluate_js(const std::string &js)=0
virtual NativeViewHandle native_handle()=0
Definition accessibility_provider.hpp:65
const WebViewBackendProvider * set_webview_backend_provider(const WebViewBackendProvider *provider)
Install an override provider (for tests), or with nullptr remove it so the linked provider answers ag...
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ path
Definition anchor_strategy.hpp:42
bool decode_webview_message_json(const std::string &json, WebViewMessage &message)
Decode a structured WebView message from JSON.
std::string guess_webview_mime_type(const std::string &path)
Best-effort MIME type guess for an HTML-linked asset path.
std::string encode_webview_message_json(const WebViewMessage &message)
Encode a structured WebView message to canonical JSON.
std::string make_webview_offline_html(const std::string &html, const std::vector< WebViewEmbeddedAsset > &assets)
Rewrite simple src/href references in HTML to offline data: URIs backed by embedded assets.
std::string load_webview_embedded_text(const std::string &embedded_name)
Load a UTF-8 text asset previously registered with AssetManager.
WebViewOptions::FetchResource make_webview_directory_resource_fetcher(std::filesystem::path root_directory, std::string index_filename="index.html")
Create a resource callback that serves files from a directory through CHOC's fetchResource/customSche...
std::string make_webview_data_uri(const std::string &mime_type, const std::vector< uint8_t > &bytes)
Create a data: URI for an embedded WebView asset.
std::string make_webview_bridge_bootstrap_script()
JavaScript helper that installs a small window.pulp bridge on a page.
@ html
Definition design_ir.hpp:46
std::string make_webview_offline_html_from_embedded(const std::string &html_embedded_name, const std::vector< WebViewEmbeddedAsset > &assets)
Load embedded HTML and rewrite its referenced assets for offline use.
std::string make_webview_eval_script(const std::string &request_id, const std::string &js_source)
JavaScript wrapper that evaluates user code asynchronously and reports the result back through the in...
std::optional< WebViewOptions::Resource > fetch_webview_directory_resource(const std::string &path, const std::filesystem::path &root_directory, std::string index_filename="index.html")
Fetch a single file-system resource for a WebView custom resource server.
@ height
Definition css_animation.hpp:128
@ width
Definition css_animation.hpp:127
bool webview_backend_available()
Returns true if the host process has a usable WebView backend.
WebViewOptions::FetchResource make_webview_embedded_resource_fetcher(std::string html_embedded_name, std::vector< WebViewEmbeddedAsset > assets)
Create a resource callback that serves embedded HTML/assets through CHOC's fetchResource/customScheme...
std::optional< WebViewOptions::Resource > fetch_webview_embedded_resource(const std::string &path, const std::string &html_embedded_name, const std::vector< WebViewEmbeddedAsset > &assets)
Fetch a single embedded resource for a WebView custom resource server.
@ error
Definition design_ir.hpp:697
std::string detect_webview_backend()
Identifies the live WebView backend on this platform / build.
void * NativeViewHandle
Definition native_view_host.hpp:19
Definition web_view.hpp:54
std::string mime_type
Definition web_view.hpp:57
std::string reference_path
Definition web_view.hpp:55
std::string embedded_name
Definition web_view.hpp:56
Definition web_view.hpp:45
std::string payload_json
Definition web_view.hpp:47
std::string id
Definition web_view.hpp:48
std::string type
Definition web_view.hpp:46
Definition web_view.hpp:27
std::vector< uint8_t > data
Definition web_view.hpp:28
std::string mime_type
Definition web_view.hpp:29
Definition web_view.hpp:26
std::string custom_user_agent
Override User-Agent string.
Definition web_view.hpp:38
std::string initial_html
Optional placeholder HTML shown before navigate()/set_html().
Definition web_view.hpp:37
bool transparent_background
Definition web_view.hpp:35
bool enable_debug
Enable DevTools / Web Inspector.
Definition web_view.hpp:33
bool enable_debug_inspector
Request a separate inspector window when supported.
Definition web_view.hpp:34
FetchResource fetch_resource
Optional custom resource server.
Definition web_view.hpp:39
std::function< std::optional< Resource >(const std::string &path)> FetchResource
Definition web_view.hpp:31
std::string custom_scheme_uri
Optional home URI for fetch_resource, e.g. pulp://app.
Definition web_view.hpp:40
bool accept_first_click
macOS: first click on unfocused view is input
Definition web_view.hpp:36
The answer behind detect_webview_backend() and webview_backend_available().
Definition web_view.hpp:149
bool(* available)()
Definition web_view.hpp:151
std::string(* detect)()
Definition web_view.hpp:150