plusui-native-core 0.1.105 → 0.1.106

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.
Files changed (48) hide show
  1. package/Core/.claude/settings.local.json +7 -0
  2. package/Core/CMakeLists.txt +1 -1
  3. package/Core/Features/API/app-api.ts +28 -28
  4. package/Core/Features/API/browser-api.ts +38 -38
  5. package/Core/Features/API/clipboard-api.ts +21 -21
  6. package/Core/Features/API/display-api.ts +33 -33
  7. package/Core/Features/API/keyboard-api.ts +33 -33
  8. package/Core/Features/API/menu-api.ts +39 -39
  9. package/Core/Features/API/router-api.ts +23 -23
  10. package/Core/Features/API/tray-api.ts +22 -22
  11. package/Core/Features/API/webgpu-api.ts +55 -55
  12. package/Core/Features/App/app.cpp +128 -102
  13. package/Core/Features/Browser/browser.cpp +227 -227
  14. package/Core/Features/Browser/browser.ts +161 -161
  15. package/Core/Features/Clipboard/clipboard.cpp +235 -235
  16. package/Core/Features/Display/display.cpp +212 -212
  17. package/Core/Features/FileDrop/filedrop.cpp +448 -324
  18. package/Core/Features/FileDrop/filedrop.css +421 -421
  19. package/Core/Features/FileDrop/filedrop.ts +0 -7
  20. package/Core/Features/Keyboard/keyboard_linux.cpp +4 -0
  21. package/Core/Features/Router/router.cpp +62 -62
  22. package/Core/Features/Router/router.ts +113 -113
  23. package/Core/Features/Tray/tray.cpp +328 -324
  24. package/Core/Features/WebGPU/webgpu.cpp +948 -948
  25. package/Core/Features/Window/webview.cpp +1009 -1009
  26. package/Core/Features/Window/webview.ts +516 -516
  27. package/Core/Features/Window/window.cpp +2240 -1986
  28. package/Core/include/plusui/api.hpp +237 -237
  29. package/Core/include/plusui/app.hpp +33 -33
  30. package/Core/include/plusui/browser.hpp +67 -67
  31. package/Core/include/plusui/clipboard.hpp +41 -41
  32. package/Core/include/plusui/connect.hpp +340 -340
  33. package/Core/include/plusui/connection.hpp +3 -3
  34. package/Core/include/plusui/display.hpp +90 -90
  35. package/Core/include/plusui/filedrop.hpp +92 -77
  36. package/Core/include/plusui/keyboard.hpp +112 -112
  37. package/Core/include/plusui/menu.hpp +153 -153
  38. package/Core/include/plusui/plusui +18 -18
  39. package/Core/include/plusui/router.hpp +42 -42
  40. package/Core/include/plusui/tray.hpp +94 -94
  41. package/Core/include/plusui/webgpu.hpp +434 -434
  42. package/Core/include/plusui/window.hpp +180 -177
  43. package/Core/scripts/generate-umbrella-header.mjs +77 -77
  44. package/Core/vendor/WebView2EnvironmentOptions.h +406 -406
  45. package/Core/vendor/webview.h +487 -487
  46. package/Core/vendor/webview2.h +52079 -52079
  47. package/README.md +19 -19
  48. package/package.json +1 -1
@@ -1,228 +1,228 @@
1
- #include <algorithm>
2
- #include <iostream>
3
- #include <plusui/browser.hpp>
4
- #include <plusui/window.hpp>
5
- #include <vector>
6
-
7
-
8
- #ifdef _WIN32
9
- #define WIN32_LEAN_AND_MEAN
10
- #include <windows.h>
11
- #include <shellapi.h>
12
-
13
- #endif
14
-
15
- namespace plusui {
16
-
17
- // Keep secondary windows alive
18
- static std::vector<std::shared_ptr<Window>> g_windows;
19
- static std::vector<std::shared_ptr<Window>> g_webviews;
20
-
21
- struct Browser::Impl {
22
- Window *window = nullptr;
23
- std::map<std::string, std::string> routes;
24
- std::string currentRoute;
25
- BrowserState state;
26
-
27
- std::vector<NavigateCallback> navigateCallbacks;
28
- std::vector<StateCallback> stateCallbacks;
29
- std::vector<LoadCallback> loadStartCallbacks;
30
- std::vector<LoadCallback> loadEndCallbacks;
31
- std::vector<std::function<void(const std::string &)>> loadErrorCallbacks;
32
-
33
- void updateState() {
34
- if (window) {
35
- state.url = window->getURL();
36
- state.title = window->getTitle();
37
- state.canGoBack = window->canGoBack();
38
- state.canGoForward = window->canGoForward();
39
- state.isLoading = window->isLoading();
40
-
41
- for (auto &cb : stateCallbacks) {
42
- cb(state);
43
- }
44
- }
45
- }
46
-
47
- void notifyNavigate(const std::string &url) {
48
- state.url = url;
49
- for (auto &cb : navigateCallbacks) {
50
- cb(url);
51
- }
52
- updateState();
53
- }
54
- };
55
-
56
- Browser::Browser() : pImpl(std::make_shared<Impl>()) {}
57
-
58
- Browser::~Browser() = default;
59
-
60
- Browser Browser::create(Window *window) {
61
- Browser browser;
62
- browser.pImpl->window = window;
63
-
64
- if (window) {
65
- window->onNavigationStart([impl = browser.pImpl](const std::string &url) {
66
- impl->notifyNavigate(url);
67
- return true;
68
- });
69
-
70
- window->onLoadStart([impl = browser.pImpl]() {
71
- impl->state.isLoading = true;
72
- for (auto &cb : impl->loadStartCallbacks) {
73
- cb();
74
- }
75
- });
76
-
77
- window->onLoadEnd([impl = browser.pImpl]() {
78
- impl->state.isLoading = false;
79
- impl->updateState();
80
- for (auto &cb : impl->loadEndCallbacks) {
81
- cb();
82
- }
83
- });
84
-
85
- window->onLoadError(
86
- [impl = browser.pImpl](const std::string &error, int code) {
87
- (void)code; // Suppress unused warning
88
- impl->state.isLoading = false;
89
- for (auto &cb : impl->loadErrorCallbacks) {
90
- cb(error);
91
- }
92
- });
93
- }
94
-
95
- return browser;
96
- }
97
-
98
- void Browser::navigate(const std::string &url) {
99
- if (pImpl->window) {
100
- pImpl->window->navigate(url);
101
- pImpl->notifyNavigate(url);
102
- }
103
- }
104
-
105
- void Browser::goBack() {
106
- if (pImpl->window && pImpl->window->canGoBack()) {
107
- pImpl->window->goBack();
108
- pImpl->updateState();
109
- }
110
- }
111
-
112
- void Browser::goForward() {
113
- if (pImpl->window && pImpl->window->canGoForward()) {
114
- pImpl->window->goForward();
115
- pImpl->updateState();
116
- }
117
- }
118
-
119
- void Browser::reload() {
120
- if (pImpl->window) {
121
- pImpl->window->reload();
122
- }
123
- }
124
-
125
- void Browser::stop() {
126
- if (pImpl->window) {
127
- pImpl->window->stop();
128
- }
129
- }
130
-
131
- void Browser::openExternal(const std::string &url) {
132
- #ifdef _WIN32
133
- ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
134
- #elif __APPLE__
135
- std::string command = "open \"" + url + "\"";
136
- system(command.c_str());
137
- #else
138
- std::string command = "xdg-open \"" + url + "\"";
139
- system(command.c_str());
140
- #endif
141
- }
142
-
143
- void Browser::openNewWindow(const std::string &url) {
144
- WindowConfig winConfig;
145
- winConfig.title = "New Window";
146
-
147
- auto win = std::make_shared<Window>(Window::create(winConfig));
148
- win->show();
149
- g_windows.push_back(win);
150
-
151
- WindowConfig webConfig;
152
- auto wv = std::make_shared<Window>(
153
- Window::create(win->nativeHandle(), webConfig));
154
- wv->setWindow(win);
155
- wv->navigate(url);
156
- g_webviews.push_back(wv);
157
-
158
- win->onClose([win, wv]() {
159
- auto itW = std::find(g_windows.begin(), g_windows.end(), win);
160
- if (itW != g_windows.end())
161
- g_windows.erase(itW);
162
-
163
- auto itV = std::find(g_webviews.begin(), g_webviews.end(), wv);
164
- if (itV != g_webviews.end())
165
- g_webviews.erase(itV);
166
- });
167
- }
168
-
169
- std::string Browser::getURL() const {
170
- return pImpl->window ? pImpl->window->getURL() : "";
171
- }
172
-
173
- std::string Browser::getTitle() const {
174
- return pImpl->window ? pImpl->window->getTitle() : "";
175
- }
176
-
177
- BrowserState Browser::getState() const { return pImpl->state; }
178
-
179
- bool Browser::canGoBack() const {
180
- return pImpl->window ? pImpl->window->canGoBack() : false;
181
- }
182
-
183
- bool Browser::canGoForward() const {
184
- return pImpl->window ? pImpl->window->canGoForward() : false;
185
- }
186
-
187
- bool Browser::isLoading() const { return pImpl->state.isLoading; }
188
-
189
- void Browser::onNavigate(NavigateCallback callback) {
190
- pImpl->navigateCallbacks.push_back(callback);
191
- }
192
-
193
- void Browser::onStateChange(StateCallback callback) {
194
- pImpl->stateCallbacks.push_back(callback);
195
- }
196
-
197
- void Browser::onLoadStart(LoadCallback callback) {
198
- pImpl->loadStartCallbacks.push_back(callback);
199
- }
200
-
201
- void Browser::onLoadEnd(LoadCallback callback) {
202
- pImpl->loadEndCallbacks.push_back(callback);
203
- }
204
-
205
- void Browser::onLoadError(
206
- std::function<void(const std::string &error)> callback) {
207
- pImpl->loadErrorCallbacks.push_back(callback);
208
- }
209
-
210
- void Browser::setRoutes(const std::map<std::string, std::string> &routes) {
211
- pImpl->routes = routes;
212
- }
213
-
214
- void Browser::push(const std::string &route) {
215
- pImpl->currentRoute = route;
216
- auto it = pImpl->routes.find(route);
217
- if (it != pImpl->routes.end()) {
218
- navigate(it->second);
219
- } else {
220
- navigate(route);
221
- }
222
- }
223
-
224
- void Browser::replace(const std::string &route) { push(route); }
225
-
226
- std::string Browser::getCurrentRoute() const { return pImpl->currentRoute; }
227
-
1
+ #include <algorithm>
2
+ #include <iostream>
3
+ #include <plusui/browser.hpp>
4
+ #include <plusui/window.hpp>
5
+ #include <vector>
6
+
7
+
8
+ #ifdef _WIN32
9
+ #define WIN32_LEAN_AND_MEAN
10
+ #include <windows.h>
11
+ #include <shellapi.h>
12
+
13
+ #endif
14
+
15
+ namespace plusui {
16
+
17
+ // Keep secondary windows alive
18
+ static std::vector<std::shared_ptr<Window>> g_windows;
19
+ static std::vector<std::shared_ptr<Window>> g_webviews;
20
+
21
+ struct Browser::Impl {
22
+ Window *window = nullptr;
23
+ std::map<std::string, std::string> routes;
24
+ std::string currentRoute;
25
+ BrowserState state;
26
+
27
+ std::vector<NavigateCallback> navigateCallbacks;
28
+ std::vector<StateCallback> stateCallbacks;
29
+ std::vector<LoadCallback> loadStartCallbacks;
30
+ std::vector<LoadCallback> loadEndCallbacks;
31
+ std::vector<std::function<void(const std::string &)>> loadErrorCallbacks;
32
+
33
+ void updateState() {
34
+ if (window) {
35
+ state.url = window->getURL();
36
+ state.title = window->getTitle();
37
+ state.canGoBack = window->canGoBack();
38
+ state.canGoForward = window->canGoForward();
39
+ state.isLoading = window->isLoading();
40
+
41
+ for (auto &cb : stateCallbacks) {
42
+ cb(state);
43
+ }
44
+ }
45
+ }
46
+
47
+ void notifyNavigate(const std::string &url) {
48
+ state.url = url;
49
+ for (auto &cb : navigateCallbacks) {
50
+ cb(url);
51
+ }
52
+ updateState();
53
+ }
54
+ };
55
+
56
+ Browser::Browser() : pImpl(std::make_shared<Impl>()) {}
57
+
58
+ Browser::~Browser() = default;
59
+
60
+ Browser Browser::create(Window *window) {
61
+ Browser browser;
62
+ browser.pImpl->window = window;
63
+
64
+ if (window) {
65
+ window->onNavigationStart([impl = browser.pImpl](const std::string &url) {
66
+ impl->notifyNavigate(url);
67
+ return true;
68
+ });
69
+
70
+ window->onLoadStart([impl = browser.pImpl]() {
71
+ impl->state.isLoading = true;
72
+ for (auto &cb : impl->loadStartCallbacks) {
73
+ cb();
74
+ }
75
+ });
76
+
77
+ window->onLoadEnd([impl = browser.pImpl]() {
78
+ impl->state.isLoading = false;
79
+ impl->updateState();
80
+ for (auto &cb : impl->loadEndCallbacks) {
81
+ cb();
82
+ }
83
+ });
84
+
85
+ window->onLoadError(
86
+ [impl = browser.pImpl](const std::string &error, int code) {
87
+ (void)code; // Suppress unused warning
88
+ impl->state.isLoading = false;
89
+ for (auto &cb : impl->loadErrorCallbacks) {
90
+ cb(error);
91
+ }
92
+ });
93
+ }
94
+
95
+ return browser;
96
+ }
97
+
98
+ void Browser::navigate(const std::string &url) {
99
+ if (pImpl->window) {
100
+ pImpl->window->navigate(url);
101
+ pImpl->notifyNavigate(url);
102
+ }
103
+ }
104
+
105
+ void Browser::goBack() {
106
+ if (pImpl->window && pImpl->window->canGoBack()) {
107
+ pImpl->window->goBack();
108
+ pImpl->updateState();
109
+ }
110
+ }
111
+
112
+ void Browser::goForward() {
113
+ if (pImpl->window && pImpl->window->canGoForward()) {
114
+ pImpl->window->goForward();
115
+ pImpl->updateState();
116
+ }
117
+ }
118
+
119
+ void Browser::reload() {
120
+ if (pImpl->window) {
121
+ pImpl->window->reload();
122
+ }
123
+ }
124
+
125
+ void Browser::stop() {
126
+ if (pImpl->window) {
127
+ pImpl->window->stop();
128
+ }
129
+ }
130
+
131
+ void Browser::openExternal(const std::string &url) {
132
+ #ifdef _WIN32
133
+ ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
134
+ #elif __APPLE__
135
+ std::string command = "open \"" + url + "\"";
136
+ system(command.c_str());
137
+ #else
138
+ std::string command = "xdg-open \"" + url + "\"";
139
+ system(command.c_str());
140
+ #endif
141
+ }
142
+
143
+ void Browser::openNewWindow(const std::string &url) {
144
+ WindowConfig winConfig;
145
+ winConfig.title = "New Window";
146
+
147
+ auto win = std::make_shared<Window>(Window::create(winConfig));
148
+ win->show();
149
+ g_windows.push_back(win);
150
+
151
+ WindowConfig webConfig;
152
+ auto wv = std::make_shared<Window>(
153
+ Window::create(win->nativeHandle(), webConfig));
154
+ wv->setWindow(win);
155
+ wv->navigate(url);
156
+ g_webviews.push_back(wv);
157
+
158
+ win->onClose([win, wv]() {
159
+ auto itW = std::find(g_windows.begin(), g_windows.end(), win);
160
+ if (itW != g_windows.end())
161
+ g_windows.erase(itW);
162
+
163
+ auto itV = std::find(g_webviews.begin(), g_webviews.end(), wv);
164
+ if (itV != g_webviews.end())
165
+ g_webviews.erase(itV);
166
+ });
167
+ }
168
+
169
+ std::string Browser::getURL() const {
170
+ return pImpl->window ? pImpl->window->getURL() : "";
171
+ }
172
+
173
+ std::string Browser::getTitle() const {
174
+ return pImpl->window ? pImpl->window->getTitle() : "";
175
+ }
176
+
177
+ BrowserState Browser::getState() const { return pImpl->state; }
178
+
179
+ bool Browser::canGoBack() const {
180
+ return pImpl->window ? pImpl->window->canGoBack() : false;
181
+ }
182
+
183
+ bool Browser::canGoForward() const {
184
+ return pImpl->window ? pImpl->window->canGoForward() : false;
185
+ }
186
+
187
+ bool Browser::isLoading() const { return pImpl->state.isLoading; }
188
+
189
+ void Browser::onNavigate(NavigateCallback callback) {
190
+ pImpl->navigateCallbacks.push_back(callback);
191
+ }
192
+
193
+ void Browser::onStateChange(StateCallback callback) {
194
+ pImpl->stateCallbacks.push_back(callback);
195
+ }
196
+
197
+ void Browser::onLoadStart(LoadCallback callback) {
198
+ pImpl->loadStartCallbacks.push_back(callback);
199
+ }
200
+
201
+ void Browser::onLoadEnd(LoadCallback callback) {
202
+ pImpl->loadEndCallbacks.push_back(callback);
203
+ }
204
+
205
+ void Browser::onLoadError(
206
+ std::function<void(const std::string &error)> callback) {
207
+ pImpl->loadErrorCallbacks.push_back(callback);
208
+ }
209
+
210
+ void Browser::setRoutes(const std::map<std::string, std::string> &routes) {
211
+ pImpl->routes = routes;
212
+ }
213
+
214
+ void Browser::push(const std::string &route) {
215
+ pImpl->currentRoute = route;
216
+ auto it = pImpl->routes.find(route);
217
+ if (it != pImpl->routes.end()) {
218
+ navigate(it->second);
219
+ } else {
220
+ navigate(route);
221
+ }
222
+ }
223
+
224
+ void Browser::replace(const std::string &route) { push(route); }
225
+
226
+ std::string Browser::getCurrentRoute() const { return pImpl->currentRoute; }
227
+
228
228
  } // namespace plusui