5 # include <nlohmann/json.hpp>
6 # include <boost/asio/any_io_executor.hpp>
15 #include <unordered_map>
57 struct CustomSchemeRequest
60 std::function<std::string
const&()> getContent{};
61 std::unordered_multimap<std::string, std::string> headers{};
65 std::optional<Url> parseUrl()
const;
71 struct CustomSchemeResponse
75 std::string reasonPhrase{};
76 std::unordered_multimap<std::string, std::string> headers{};
84 std::vector<std::string> allowedOrigins = {};
86 std::function<CustomSchemeResponse(CustomSchemeRequest
const&)> onRequest = {};
92 bool treatAsSecure =
true;
95 bool hasAuthorityComponent =
false;
101 std::optional<std::string> title = std::nullopt;
107 std::vector<CustomScheme> customSchemes = {};
110 std::optional<std::string> browserArguments = std::nullopt;
113 bool enableTrackingPrevention =
true;
116 std::optional<std::string> language = std::nullopt;
119 std::optional<std::string> folderMappingScheme = std::string{
"assets"};
122 std::function<void(std::string_view)> onRpcError = {};
157 [[deprecated]]
explicit Window(
bool debug);
166 [[deprecated]]
explicit Window(std::string
const& title,
bool debug =
false);
175 [[deprecated]]
explicit Window(
char const* title,
bool debug =
false);
187 void setTitle(std::string
const& title);
205 void setPosition(
int x,
int y,
bool useFrameOrigin =
true);
217 void navigate(
const std::string& url);
232 void navigate(
const std::filesystem::path& file);
255 void bind(std::string
const& name, std::function<
void(nlohmann::json
const&)>
const& callback);
262 void unbind(std::string
const& name);
264 boost::asio::any_io_executor getExecutor()
const;
276 void setVirtualHostNameToFolderMapping(
277 std::string
const& hostName,
278 std::filesystem::path
const& folderPath,
291 void dispatch(std::function<
void()> func);
302 std::string_view html,
310 void setHtmlThroughFilesystem(std::string_view html);
317 void eval(std::string
const& js);
324 void eval(
char const* js);
330 void eval(std::filesystem::path
const& file);
337 void init(std::string
const& js);
343 void init(std::filesystem::path
const& file);
351 void* getNativeWebView();
358 void* getNativeWindow();
363 void setConsoleOutput(
bool active);
369 struct Implementation;
370 struct WindowsImplementation;
371 struct LinuxImplementation;
372 struct MacOsImplementation;
375 std::shared_ptr<Implementation> impl_;
This class encapsulates the webview.
Definition: window.hpp:133
void terminate()
Close the window and exit run.
Definition: window.cpp:479
void openDevTools()
Open the dev tools.
Definition: window.cpp:630
Window & operator=(const Window &)=delete
constexpr static std::string_view windowsServeAuthority
Definition: window.hpp:137
Window & operator=(Window &&)
void setTitle(std::string const &title)
Set the Title of the window.
Definition: window.cpp:281
~Window()
Definition: window.cpp:271
void setSize(int width, int height, WebViewHint hint=WebViewHint::WEBVIEW_HINT_NONE)
Sets the size of the window.
Definition: window.cpp:287
void navigate(const std::string &url)
Navigate to url.
Definition: window.cpp:418
Window(const Window &)=delete
void setPosition(int x, int y, bool useFrameOrigin=true)
Sets the position of the window.
Definition: window.cpp:485
void runInJavascriptThread(std::function< void()> &&func)
Definition: window.cpp:551
Window()
Construct a new Window object.
Definition: window.cpp:182
void centerOnPrimaryDisplay()
Center the window on the primary display.
Definition: window.cpp:509
Definition: file_dialog.hpp:6
HostResourceAccessKind
Definition: window.hpp:29
WebViewHint
Definition: window.hpp:20
emscripten::val bind(F &&f, Args &&... args)
Equivalent of std::bind returning a javascript functor.
Definition: functions.hpp:98
NuiCoreWebView2WebResourceContext
Definition: window.hpp:36
Definition: window.hpp:126