plusui-native-core 0.1.105 → 0.1.107

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 (77) hide show
  1. package/Core/.cache/clangd/index/api.hpp.016B34C8046EF490.idx +0 -0
  2. package/Core/.cache/clangd/index/app.cpp.1E6FAF043D496421.idx +0 -0
  3. package/Core/.cache/clangd/index/app.hpp.FA0E5D412C4E6148.idx +0 -0
  4. package/Core/.cache/clangd/index/browser.cpp.9461A2CAF129F1D9.idx +0 -0
  5. package/Core/.cache/clangd/index/browser.hpp.BE40AE80881B3107.idx +0 -0
  6. package/Core/.cache/clangd/index/clipboard.cpp.2399913537B2A7AD.idx +0 -0
  7. package/Core/.cache/clangd/index/clipboard.hpp.C1095DDACD7149E9.idx +0 -0
  8. package/Core/.cache/clangd/index/connect.cpp.518C66C7C28B30A9.idx +0 -0
  9. package/Core/.cache/clangd/index/connect.hpp.08E2F7CD13B78601.idx +0 -0
  10. package/Core/.cache/clangd/index/connection.hpp.849FAEF1523BF2C3.idx +0 -0
  11. package/Core/.cache/clangd/index/display.cpp.F6F6D932BF9F8D8E.idx +0 -0
  12. package/Core/.cache/clangd/index/display.hpp.0C1A9CAD11EE4404.idx +0 -0
  13. package/Core/.cache/clangd/index/filedrop.cpp.669B524B3C501C52.idx +0 -0
  14. package/Core/.cache/clangd/index/filedrop.hpp.48460099C3F35F2D.idx +0 -0
  15. package/Core/.cache/clangd/index/keyboard.cpp.DC6D34E4A4F798DD.idx +0 -0
  16. package/Core/.cache/clangd/index/keyboard.hpp.F016CB68D7DE5A46.idx +0 -0
  17. package/Core/.cache/clangd/index/keyboard_linux.cpp.B403FDCEA7A6CA53.idx +0 -0
  18. package/Core/.cache/clangd/index/menu.cpp.3059F08D8D2DF265.idx +0 -0
  19. package/Core/.cache/clangd/index/menu.hpp.8716DCCC573910D4.idx +0 -0
  20. package/Core/.cache/clangd/index/plusui.hpp.8CFCDFDC2E3F41DD.idx +0 -0
  21. package/Core/.cache/clangd/index/router.cpp.EAC9EAD34C59E573.idx +0 -0
  22. package/Core/.cache/clangd/index/router.hpp.2B06E2EE9998468D.idx +0 -0
  23. package/Core/.cache/clangd/index/stb_image.h.E26CF48FE089A0D3.idx +0 -0
  24. package/Core/.cache/clangd/index/tray.cpp.92F244E7E1D7F0EC.idx +0 -0
  25. package/Core/.cache/clangd/index/tray.hpp.0D881B0601BBBD25.idx +0 -0
  26. package/Core/.cache/clangd/index/webgpu.cpp.FC656FA8BE10FE15.idx +0 -0
  27. package/Core/.cache/clangd/index/webgpu.hpp.5AF1A5E9DF9E5AE0.idx +0 -0
  28. package/Core/.cache/clangd/index/window.cpp.191D8C9ADF874B22.idx +0 -0
  29. package/Core/.cache/clangd/index/window.hpp.B9811B43AA295697.idx +0 -0
  30. package/Core/.claude/settings.local.json +7 -0
  31. package/Core/CMakeLists.txt +1 -1
  32. package/Core/Features/API/app-api.ts +28 -28
  33. package/Core/Features/API/browser-api.ts +38 -38
  34. package/Core/Features/API/clipboard-api.ts +21 -21
  35. package/Core/Features/API/display-api.ts +33 -33
  36. package/Core/Features/API/keyboard-api.ts +33 -33
  37. package/Core/Features/API/menu-api.ts +39 -39
  38. package/Core/Features/API/router-api.ts +23 -23
  39. package/Core/Features/API/tray-api.ts +22 -22
  40. package/Core/Features/API/webgpu-api.ts +55 -55
  41. package/Core/Features/App/app.cpp +135 -102
  42. package/Core/Features/Browser/browser.cpp +227 -227
  43. package/Core/Features/Browser/browser.ts +161 -161
  44. package/Core/Features/Clipboard/clipboard.cpp +235 -235
  45. package/Core/Features/Display/display.cpp +212 -212
  46. package/Core/Features/FileDrop/filedrop.cpp +448 -324
  47. package/Core/Features/FileDrop/filedrop.css +421 -421
  48. package/Core/Features/FileDrop/filedrop.ts +0 -7
  49. package/Core/Features/Keyboard/keyboard_linux.cpp +4 -0
  50. package/Core/Features/Router/router.cpp +62 -62
  51. package/Core/Features/Router/router.ts +113 -113
  52. package/Core/Features/Tray/tray.cpp +437 -324
  53. package/Core/Features/WebGPU/webgpu.cpp +948 -948
  54. package/Core/Features/Window/webview.cpp +1009 -1009
  55. package/Core/Features/Window/webview.ts +516 -516
  56. package/Core/Features/Window/window.cpp +2240 -1986
  57. package/Core/include/plusui/api.hpp +237 -237
  58. package/Core/include/plusui/app.hpp +36 -34
  59. package/Core/include/plusui/browser.hpp +67 -67
  60. package/Core/include/plusui/clipboard.hpp +41 -41
  61. package/Core/include/plusui/connect.hpp +340 -340
  62. package/Core/include/plusui/connection.hpp +3 -3
  63. package/Core/include/plusui/display.hpp +90 -90
  64. package/Core/include/plusui/filedrop.hpp +92 -77
  65. package/Core/include/plusui/keyboard.hpp +112 -112
  66. package/Core/include/plusui/menu.hpp +153 -153
  67. package/Core/include/plusui/plusui +18 -18
  68. package/Core/include/plusui/router.hpp +42 -42
  69. package/Core/include/plusui/tray.hpp +94 -94
  70. package/Core/include/plusui/webgpu.hpp +434 -434
  71. package/Core/include/plusui/window.hpp +180 -177
  72. package/Core/scripts/generate-umbrella-header.mjs +77 -77
  73. package/Core/vendor/WebView2EnvironmentOptions.h +406 -406
  74. package/Core/vendor/webview.h +487 -487
  75. package/Core/vendor/webview2.h +52079 -52079
  76. package/README.md +19 -19
  77. 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