plusui-native-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Core/CMakeLists.txt +34 -0
- package/Core/README.md +29 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj +185 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj.filters +8 -0
- package/Core/build/win32/x64/CMakeCache.txt +335 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/INSTALL_force.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/generate.stamp.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeCXXCompiler.cmake +104 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeRCCompiler.cmake +6 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeSystem.cmake +15 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.vcxproj +72 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +4 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/Cl.items.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +22 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.secondary.1.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.txt +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.vcxproj +31 -0
- package/Core/build/win32/x64/CMakeFiles/CMakeConfigureLog.yaml +2698 -0
- package/Core/build/win32/x64/CMakeFiles/InstallScripts.json +7 -0
- package/Core/build/win32/x64/CMakeFiles/TargetDirectories.txt +4 -0
- package/Core/build/win32/x64/CMakeFiles/cmake.check_cache +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.depend +34 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.list +1 -0
- package/Core/build/win32/x64/Capsule.sln +67 -0
- package/Core/build/win32/x64/INSTALL.vcxproj +209 -0
- package/Core/build/win32/x64/INSTALL.vcxproj.filters +13 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj +179 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj.filters +13 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.read.1.tlog +33 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/capsule.lastbuildstate +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/unsuccessfulbuild +0 -0
- package/Core/build/win32/x64/capsule.vcxproj +332 -0
- package/Core/build/win32/x64/capsule.vcxproj.filters +25 -0
- package/Core/build/win32/x64/cmake_install.cmake +72 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +11 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +34 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +2 -0
- package/Core/include/app.hpp +121 -0
- package/Core/include/display.hpp +90 -0
- package/Core/include/keyboard.hpp +135 -0
- package/Core/include/menu.hpp +79 -0
- package/Core/include/tray.hpp +81 -0
- package/Core/include/window.hpp +106 -0
- package/Core/src/app.cpp +311 -0
- package/Core/src/display.cpp +424 -0
- package/Core/src/tray.cpp +275 -0
- package/Core/src/window.cpp +528 -0
- package/Core/vendor/webview.h +551 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +198 -0
- package/package.json +19 -0
- package/src/index.ts +574 -0
package/Core/src/app.cpp
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#include "app.hpp"
|
|
2
|
+
#include "webview.h"
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <mutex>
|
|
5
|
+
#include <iostream>
|
|
6
|
+
|
|
7
|
+
namespace plusui {
|
|
8
|
+
|
|
9
|
+
struct App::Impl {
|
|
10
|
+
webview_t wv = nullptr;
|
|
11
|
+
bool running = false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
App::App() : pImpl(std::make_unique<Impl>()) {}
|
|
15
|
+
App::~App() {
|
|
16
|
+
if (pImpl->wv) {
|
|
17
|
+
webview_destroy(pImpl->wv);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void App::run() {
|
|
22
|
+
if (pImpl->wv) {
|
|
23
|
+
pImpl->running = true;
|
|
24
|
+
webview_run(pImpl->wv);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void App::quit() {
|
|
29
|
+
if (pImpl->wv) {
|
|
30
|
+
webview_terminate(pImpl->wv);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
App::Builder& App::Builder::title(const std::string& t) { config.title = t; return *this; }
|
|
35
|
+
App::Builder& App::Builder::width(int w) { config.width = w; return *this; }
|
|
36
|
+
App::Builder& App::Builder::height(int h) { config.height = h; return *this; }
|
|
37
|
+
App::Builder& App::Builder::resizable(bool r) { config.resizable = r; return *this; }
|
|
38
|
+
App::Builder& App::Builder::devtools(bool d) { config.devtools = d; return *this; }
|
|
39
|
+
App::Builder& App::Builder::trayIcon(const std::string& icon) { config.trayIconPath = icon; return *this; }
|
|
40
|
+
App::Builder& App::Builder::trayTooltip(const std::string& tooltip) { config.trayTooltip = tooltip; return *this; }
|
|
41
|
+
App::Builder& App::Builder::alwaysOnTop(bool top) { config.alwaysOnTop = top; return *this; }
|
|
42
|
+
App::Builder& App::Builder::centered(bool center) { config.centered = center; return *this; }
|
|
43
|
+
App::Builder& App::Builder::transparent(bool transparent) { config.transparent = transparent; return *this; }
|
|
44
|
+
App::Builder& App::Builder::decorations(bool decorations) { config.decorations = decorations; return *this; }
|
|
45
|
+
App::Builder& App::Builder::skipTaskbar(bool skip) { config.skipTaskbar = skip; return *this; }
|
|
46
|
+
|
|
47
|
+
struct WebView::Impl {
|
|
48
|
+
webview_t wv;
|
|
49
|
+
std::unique_ptr<TrayManager> trayManager;
|
|
50
|
+
std::unique_ptr<WindowManager> windowManager;
|
|
51
|
+
std::map<std::string, std::function<void(const std::string&)>> events;
|
|
52
|
+
std::mutex events_mutex;
|
|
53
|
+
std::map<std::string, std::function<std::string(const std::string&)>> bindings;
|
|
54
|
+
std::mutex bindings_mutex;
|
|
55
|
+
|
|
56
|
+
static void binding_callback(const char* seq, const char* req, void* arg) {
|
|
57
|
+
auto self = static_cast<Impl*>(arg);
|
|
58
|
+
std::string req_str(req);
|
|
59
|
+
|
|
60
|
+
size_t id_start = req_str.find("\"id\":");
|
|
61
|
+
size_t method_start = req_str.find("\"method\":");
|
|
62
|
+
size_t params_start = req_str.find("\"params\":");
|
|
63
|
+
|
|
64
|
+
if (id_start != std::string::npos && method_start != std::string::npos) {
|
|
65
|
+
size_t method_start_q = req_str.find("\"", method_start + 8);
|
|
66
|
+
size_t method_end_q = req_str.find("\"", method_start + 9);
|
|
67
|
+
std::string method = req_str.substr(method_start + 9, method_end_q - method_start - 9);
|
|
68
|
+
|
|
69
|
+
size_t id_start_v = req_str.find(":", id_start);
|
|
70
|
+
size_t id_end = req_str.find_first_of(",}", id_start_v + 1);
|
|
71
|
+
std::string id_str = req_str.substr(id_start_v + 1, id_end - id_start_v - 1);
|
|
72
|
+
|
|
73
|
+
std::string params = "[]";
|
|
74
|
+
if (params_start != std::string::npos) {
|
|
75
|
+
size_t params_start_b = req_str.find("[", params_start);
|
|
76
|
+
size_t params_end = req_str.find("]", params_start);
|
|
77
|
+
if (params_start_b != std::string::npos && params_end != std::string::npos) {
|
|
78
|
+
params = req_str.substr(params_start_b, params_end - params_start_b + 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
std::lock_guard lock(self->bindings_mutex);
|
|
83
|
+
auto it = self->bindings.find(method);
|
|
84
|
+
if (it != self->bindings.end()) {
|
|
85
|
+
std::string result = it->second(params);
|
|
86
|
+
webview_return(self->wv, id_str.c_str(), 0, result.c_str());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
WebView::WebView(const App::Builder::Config& config) : pImpl(std::make_unique<Impl>()) {
|
|
93
|
+
pImpl->wv = webview_create(config.devtools ? 1 : 0, nullptr);
|
|
94
|
+
|
|
95
|
+
if (pImpl->wv) {
|
|
96
|
+
webview_set_title(pImpl->wv, config.title.c_str());
|
|
97
|
+
webview_set_size(pImpl->wv, config.width, config.height,
|
|
98
|
+
config.resizable ? WEBVIEW_HINT_NONE : WEBVIEW_HINT_FIXED);
|
|
99
|
+
|
|
100
|
+
void* nativeWin = webview_get_window(pImpl->wv);
|
|
101
|
+
pImpl->windowManager = std::make_unique<WindowManager>(nativeWin);
|
|
102
|
+
pImpl->trayManager = std::make_unique<TrayManager>();
|
|
103
|
+
|
|
104
|
+
if (config.alwaysOnTop) {
|
|
105
|
+
pImpl->windowManager->setAlwaysOnTop(true);
|
|
106
|
+
}
|
|
107
|
+
if (config.centered) {
|
|
108
|
+
pImpl->windowManager->setCenter();
|
|
109
|
+
}
|
|
110
|
+
if (!config.decorations) {
|
|
111
|
+
pImpl->windowManager->setDecorations(false);
|
|
112
|
+
}
|
|
113
|
+
if (config.skipTaskbar) {
|
|
114
|
+
pImpl->windowManager->setSkipTaskbar(true);
|
|
115
|
+
}
|
|
116
|
+
if (config.transparent) {
|
|
117
|
+
pImpl->windowManager->setTransparency(0.0);
|
|
118
|
+
}
|
|
119
|
+
if (!config.trayIconPath.empty()) {
|
|
120
|
+
pImpl->trayManager->setIcon(config.trayIconPath);
|
|
121
|
+
pImpl->trayManager->setVisible(true);
|
|
122
|
+
}
|
|
123
|
+
if (!config.trayTooltip.empty()) {
|
|
124
|
+
pImpl->trayManager->setTooltip(config.trayTooltip);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
pImpl->bindings["window.setSize"] = [this](const std::string& params) {
|
|
128
|
+
int w = 800, h = 600;
|
|
129
|
+
sscanf(params.c_str(), "[%d,%d]", &w, &h);
|
|
130
|
+
pImpl->windowManager->setSize(w, h);
|
|
131
|
+
return "true";
|
|
132
|
+
};
|
|
133
|
+
pImpl->bindings["window.setPosition"] = [this](const std::string& params) {
|
|
134
|
+
int x = 0, y = 0;
|
|
135
|
+
sscanf(params.c_str(), "[%d,%d]", &x, &y);
|
|
136
|
+
pImpl->windowManager->setPosition(x, y);
|
|
137
|
+
return "true";
|
|
138
|
+
};
|
|
139
|
+
pImpl->bindings["window.setTitle"] = [this](const std::string& params) {
|
|
140
|
+
std::string title = params.substr(1, params.length() - 2);
|
|
141
|
+
pImpl->windowManager->setTitle(title);
|
|
142
|
+
return "true";
|
|
143
|
+
};
|
|
144
|
+
pImpl->bindings["window.setFullscreen"] = [this](const std::string& params) {
|
|
145
|
+
bool fs = params == "[true]";
|
|
146
|
+
pImpl->windowManager->setFullscreen(fs);
|
|
147
|
+
return "true";
|
|
148
|
+
};
|
|
149
|
+
pImpl->bindings["window.setAlwaysOnTop"] = [this](const std::string& params) {
|
|
150
|
+
bool top = params == "[true]";
|
|
151
|
+
pImpl->windowManager->setAlwaysOnTop(top);
|
|
152
|
+
return "true";
|
|
153
|
+
};
|
|
154
|
+
pImpl->bindings["window.setResizable"] = [this](const std::string& params) {
|
|
155
|
+
bool r = params == "[true]";
|
|
156
|
+
pImpl->windowManager->setResizable(r);
|
|
157
|
+
return "true";
|
|
158
|
+
};
|
|
159
|
+
pImpl->bindings["window.setTransparency"] = [this](const std::string& params) {
|
|
160
|
+
double alpha = 1.0;
|
|
161
|
+
sscanf(params.c_str(), "[%lf]", &alpha);
|
|
162
|
+
pImpl->windowManager->setTransparency(alpha);
|
|
163
|
+
return "true";
|
|
164
|
+
};
|
|
165
|
+
pImpl->bindings["window.minimize"] = [this](const std::string&) {
|
|
166
|
+
pImpl->windowManager->minimize();
|
|
167
|
+
return "true";
|
|
168
|
+
};
|
|
169
|
+
pImpl->bindings["window.maximize"] = [this](const std::string&) {
|
|
170
|
+
pImpl->windowManager->maximize();
|
|
171
|
+
return "true";
|
|
172
|
+
};
|
|
173
|
+
pImpl->bindings["window.restore"] = [this](const std::string&) {
|
|
174
|
+
pImpl->windowManager->restore();
|
|
175
|
+
return "true";
|
|
176
|
+
};
|
|
177
|
+
pImpl->bindings["window.show"] = [this](const std::string&) {
|
|
178
|
+
pImpl->windowManager->show();
|
|
179
|
+
return "true";
|
|
180
|
+
};
|
|
181
|
+
pImpl->bindings["window.hide"] = [this](const std::string&) {
|
|
182
|
+
pImpl->windowManager->hide();
|
|
183
|
+
return "true";
|
|
184
|
+
};
|
|
185
|
+
pImpl->bindings["window.close"] = [this](const std::string&) {
|
|
186
|
+
pImpl->windowManager->close();
|
|
187
|
+
return "true";
|
|
188
|
+
};
|
|
189
|
+
pImpl->bindings["window.isMaximized"] = [this](const std::string&) {
|
|
190
|
+
return pImpl->windowManager->isMaximized() ? "true" : "false";
|
|
191
|
+
};
|
|
192
|
+
pImpl->bindings["window.isMinimized"] = [this](const std::string&) {
|
|
193
|
+
return pImpl->windowManager->isMinimized() ? "true" : "false";
|
|
194
|
+
};
|
|
195
|
+
pImpl->bindings["window.isVisible"] = [this](const std::string&) {
|
|
196
|
+
return pImpl->windowManager->isVisible() ? "true" : "false";
|
|
197
|
+
};
|
|
198
|
+
pImpl->bindings["window.getSize"] = [this](const std::string&) {
|
|
199
|
+
auto size = pImpl->windowManager->getSize();
|
|
200
|
+
return "{\"width\":" + std::to_string(size.width) + ",\"height\":" + std::to_string(size.height) + "}";
|
|
201
|
+
};
|
|
202
|
+
pImpl->bindings["window.getPosition"] = [this](const std::string&) {
|
|
203
|
+
auto pos = pImpl->windowManager->getPosition();
|
|
204
|
+
return "{\"x\":" + std::to_string(pos.x) + ",\"y\":" + std::to_string(pos.y) + "}";
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
pImpl->bindings["tray.setIcon"] = [this](const std::string& params) {
|
|
208
|
+
std::string path = params.substr(1, params.length() - 2);
|
|
209
|
+
pImpl->trayManager->setIcon(path);
|
|
210
|
+
return "true";
|
|
211
|
+
};
|
|
212
|
+
pImpl->bindings["tray.setTooltip"] = [this](const std::string& params) {
|
|
213
|
+
std::string tooltip = params.substr(1, params.length() - 2);
|
|
214
|
+
pImpl->trayManager->setTooltip(tooltip);
|
|
215
|
+
return "true";
|
|
216
|
+
};
|
|
217
|
+
pImpl->bindings["tray.setVisible"] = [this](const std::string& params) {
|
|
218
|
+
bool visible = params == "[true]";
|
|
219
|
+
pImpl->trayManager->setVisible(visible);
|
|
220
|
+
return "true";
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
webview_bind(pImpl->wv, "plusui_invoke", [](const char* seq, const char* req, void* arg) {
|
|
224
|
+
auto self = static_cast<Impl*>(arg);
|
|
225
|
+
std::string req_str(req);
|
|
226
|
+
|
|
227
|
+
size_t id_start = req_str.find("\"id\":");
|
|
228
|
+
size_t method_start = req_str.find("\"method\":");
|
|
229
|
+
size_t params_start = req_str.find("\"params\":");
|
|
230
|
+
|
|
231
|
+
if (id_start != std::string::npos && method_start != std::string::npos) {
|
|
232
|
+
size_t method_start_q = req_str.find("\"", method_start + 8);
|
|
233
|
+
size_t method_end_q = req_str.find("\"", method_start + 9);
|
|
234
|
+
std::string method = req_str.substr(method_start + 9, method_end_q - method_start - 9);
|
|
235
|
+
|
|
236
|
+
size_t id_start_v = req_str.find(":", id_start);
|
|
237
|
+
size_t id_end = req_str.find_first_of(",}", id_start_v + 1);
|
|
238
|
+
std::string id_str = req_str.substr(id_start_v + 1, id_end - id_start_v - 1);
|
|
239
|
+
|
|
240
|
+
std::string params = "[]";
|
|
241
|
+
if (params_start != std::string::npos) {
|
|
242
|
+
size_t params_start_b = req_str.find("[", params_start);
|
|
243
|
+
size_t params_end = req_str.find("]", params_start);
|
|
244
|
+
if (params_start_b != std::string::npos && params_end != std::string::npos) {
|
|
245
|
+
params = req_str.substr(params_start_b, params_end - params_start_b + 1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
std::lock_guard lock(self->bindings_mutex);
|
|
250
|
+
auto it = self->bindings.find(method);
|
|
251
|
+
if (it != self->bindings.end()) {
|
|
252
|
+
std::string result = it->second(params);
|
|
253
|
+
webview_return(self->wv, id_str.c_str(), 0, result.c_str());
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}, pImpl.get());
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
WebView::~WebView() = default;
|
|
261
|
+
|
|
262
|
+
void WebView::navigate(const std::string& url) {
|
|
263
|
+
if (pImpl->wv) {
|
|
264
|
+
webview_navigate(pImpl->wv, url.c_str());
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
void WebView::loadHTML(const std::string& html) {
|
|
269
|
+
navigate("data:text/html," + html);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
void WebView::loadFile(const std::string& path) {
|
|
273
|
+
navigate("file://" + path);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
void WebView::eval(const std::string& js) {
|
|
277
|
+
if (pImpl->wv) {
|
|
278
|
+
webview_eval(pImpl->wv, js.c_str());
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
void WebView::on(const std::string& event, std::function<void(const std::string&)> callback) {
|
|
283
|
+
std::lock_guard lock(pImpl->events_mutex);
|
|
284
|
+
pImpl->events[event] = callback;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
void WebView::emit(const std::string& event, const std::string& data) {
|
|
288
|
+
std::string js = "window.dispatchEvent(new CustomEvent('" + event + "', {detail: " + data + "}))";
|
|
289
|
+
eval(js);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
void* WebView::nativeWindow() {
|
|
293
|
+
if (pImpl->wv) {
|
|
294
|
+
return webview_get_window(pImpl->wv);
|
|
295
|
+
}
|
|
296
|
+
return nullptr;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
TrayManager& WebView::tray() {
|
|
300
|
+
return *pImpl->trayManager;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
WindowManager& WebView::window() {
|
|
304
|
+
return *pImpl->windowManager;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
App::Builder createApp() {
|
|
308
|
+
return App::Builder();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
}
|