plusui-native 0.2.103 → 0.2.105
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plusui-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.105",
|
|
4
4
|
"description": "PlusUI CLI - Build C++ desktop apps modern UI ",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"semver": "^7.6.0",
|
|
28
28
|
"which": "^4.0.0",
|
|
29
29
|
"execa": "^8.0.1",
|
|
30
|
-
"plusui-native-builder": "^0.1.
|
|
31
|
-
"plusui-native-connect": "^0.1.
|
|
30
|
+
"plusui-native-builder": "^0.1.103",
|
|
31
|
+
"plusui-native-connect": "^0.1.103"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"plusui-native-connect": "^0.1.
|
|
34
|
+
"plusui-native-connect": "^0.1.103"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
#include <iostream>
|
|
3
3
|
#include "generated/assets.h"
|
|
4
4
|
|
|
5
|
+
// Include the auto-generated semantic connect bindings.
|
|
6
|
+
// Run `plusui connect` to generate this file.
|
|
7
|
+
#include "Connections/connections.gen.hpp"
|
|
8
|
+
|
|
5
9
|
using namespace plusui;
|
|
6
10
|
using json = nlohmann::json;
|
|
7
11
|
|
|
@@ -12,8 +16,8 @@ using json = nlohmann::json;
|
|
|
12
16
|
// Built-in features (window, router, clipboard, etc.) work without any extra
|
|
13
17
|
// wiring — just call them from the frontend via `import plusui from 'plusui'`.
|
|
14
18
|
//
|
|
15
|
-
// Custom frontend ↔ backend
|
|
16
|
-
//
|
|
19
|
+
// Custom frontend ↔ backend communication:
|
|
20
|
+
// Use connect::namespace.method syntax anywhere, then run `plusui connect`.
|
|
17
21
|
// ============================================================================
|
|
18
22
|
|
|
19
23
|
struct AppConfig {
|
|
@@ -33,24 +37,34 @@ struct WindowConfig {
|
|
|
33
37
|
bool showInTaskbar = true;
|
|
34
38
|
bool devTools = true;
|
|
35
39
|
bool scrollbars = false;
|
|
36
|
-
bool
|
|
40
|
+
bool fileDrop = true; // Enable file drop from OS to webview
|
|
37
41
|
std::string route = "/"; // Starting route
|
|
38
42
|
int devServerPort = 5173;
|
|
39
43
|
} windowConfig;
|
|
40
44
|
|
|
41
45
|
// ============================================================================
|
|
42
|
-
// CUSTOM
|
|
46
|
+
// CUSTOM COMMUNICATION (optional)
|
|
43
47
|
// ============================================================================
|
|
44
|
-
//
|
|
45
|
-
//
|
|
48
|
+
// Use connect::namespace.method syntax for CUSTOM frontend ↔ backend
|
|
49
|
+
// communication. Built-in features (window, clipboard, app) are accessed
|
|
50
|
+
// directly via their APIs.
|
|
51
|
+
//
|
|
52
|
+
// Example custom patterns (auto-detected by `plusui connect`):
|
|
53
|
+
//
|
|
54
|
+
// // Handle a call from the frontend (Request/Response):
|
|
55
|
+
// connect::user.handleFetch = [](const json& p) -> json {
|
|
56
|
+
// return {{"name", "Dannan"}, {"id", p["id"]}};
|
|
57
|
+
// };
|
|
46
58
|
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// bindConnect(mainWindow, conn);
|
|
50
|
-
// initChannels(conn);
|
|
59
|
+
// // Send an event to the frontend (Fire & Forget):
|
|
60
|
+
// connect::app.notify({{"msg", "Backend ready!"}});
|
|
51
61
|
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
62
|
+
// // Listen for events from the frontend (Event listener):
|
|
63
|
+
// connect::system.onMinimize = [](const json&) {
|
|
64
|
+
// mainWindow.minimize();
|
|
65
|
+
// };
|
|
66
|
+
//
|
|
67
|
+
// Run `plusui connect` after writing your custom communication code.
|
|
54
68
|
// ============================================================================
|
|
55
69
|
|
|
56
70
|
int main() {
|
|
@@ -65,7 +79,7 @@ int main() {
|
|
|
65
79
|
.alwaysOnTop(windowConfig.alwaysOnTop)
|
|
66
80
|
.skipTaskbar(!windowConfig.showInTaskbar)
|
|
67
81
|
.scrollbars(windowConfig.scrollbars)
|
|
68
|
-
.
|
|
82
|
+
.fileDrop(windowConfig.fileDrop)
|
|
69
83
|
.centered(true)
|
|
70
84
|
.build();
|
|
71
85
|
|
|
@@ -79,6 +93,11 @@ int main() {
|
|
|
79
93
|
mainWindow.hide();
|
|
80
94
|
}
|
|
81
95
|
|
|
96
|
+
// Wire up connect system (for custom frontend ↔ backend communication)
|
|
97
|
+
// Run `plusui connect` after adding custom connect methods
|
|
98
|
+
static Connect conn;
|
|
99
|
+
bindConnect(mainWindow, conn);
|
|
100
|
+
|
|
82
101
|
// Load frontend
|
|
83
102
|
#ifdef PLUSUI_DEV_MODE
|
|
84
103
|
mainWindow.navigate("http://localhost:" + std::to_string(windowConfig.devServerPort) + windowConfig.route);
|
|
@@ -86,19 +105,6 @@ int main() {
|
|
|
86
105
|
mainWindow.loadFile("frontend/dist/index.html" + (windowConfig.route == "/" ? "" : "#" + windowConfig.route));
|
|
87
106
|
#endif
|
|
88
107
|
|
|
89
|
-
// File drop — C++ receives dropped files automatically.
|
|
90
|
-
// Frontend receives the event via plusui.fileDrop.onFilesDropped().
|
|
91
|
-
mainWindow.onFileDrop([](const std::string& filesJson) {
|
|
92
|
-
try {
|
|
93
|
-
auto files = json::parse(filesJson);
|
|
94
|
-
std::cout << "[FileDrop] " << files.size() << " file(s) received\n";
|
|
95
|
-
for (const auto& f : files) {
|
|
96
|
-
std::cout << " " << f.value("name", "?")
|
|
97
|
-
<< " (" << f.value("size", 0) << " bytes)\n";
|
|
98
|
-
}
|
|
99
|
-
} catch (...) {}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
108
|
App runtime;
|
|
103
109
|
runtime.run();
|
|
104
110
|
return 0;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
#include <iostream>
|
|
3
3
|
#include "generated/assets.h"
|
|
4
4
|
|
|
5
|
+
// Include the auto-generated semantic connect bindings.
|
|
6
|
+
// Run `plusui connect` to generate this file.
|
|
7
|
+
#include "Connections/connections.gen.hpp"
|
|
8
|
+
|
|
5
9
|
using namespace plusui;
|
|
6
10
|
using json = nlohmann::json;
|
|
7
11
|
|
|
@@ -12,8 +16,8 @@ using json = nlohmann::json;
|
|
|
12
16
|
// Built-in features (window, router, clipboard, etc.) work without any extra
|
|
13
17
|
// wiring — just call them from the frontend via `import plusui from 'plusui'`.
|
|
14
18
|
//
|
|
15
|
-
// Custom frontend ↔ backend
|
|
16
|
-
//
|
|
19
|
+
// Custom frontend ↔ backend communication:
|
|
20
|
+
// Use connect::namespace.method syntax anywhere, then run `plusui connect`.
|
|
17
21
|
// ============================================================================
|
|
18
22
|
|
|
19
23
|
struct AppConfig {
|
|
@@ -33,24 +37,34 @@ struct WindowConfig {
|
|
|
33
37
|
bool showInTaskbar = true;
|
|
34
38
|
bool devTools = true;
|
|
35
39
|
bool scrollbars = false;
|
|
36
|
-
bool
|
|
40
|
+
bool fileDrop = true; // Enable file drop from OS to webview
|
|
37
41
|
std::string route = "/"; // Starting route
|
|
38
42
|
int devServerPort = 5173;
|
|
39
43
|
} windowConfig;
|
|
40
44
|
|
|
41
45
|
// ============================================================================
|
|
42
|
-
// CUSTOM
|
|
46
|
+
// CUSTOM COMMUNICATION (optional)
|
|
43
47
|
// ============================================================================
|
|
44
|
-
//
|
|
45
|
-
//
|
|
48
|
+
// Use connect::namespace.method syntax for CUSTOM frontend ↔ backend
|
|
49
|
+
// communication. Built-in features (window, clipboard, app) are accessed
|
|
50
|
+
// directly via their APIs.
|
|
51
|
+
//
|
|
52
|
+
// Example custom patterns (auto-detected by `plusui connect`):
|
|
53
|
+
//
|
|
54
|
+
// // Handle a call from the frontend (Request/Response):
|
|
55
|
+
// connect::user.handleFetch = [](const json& p) -> json {
|
|
56
|
+
// return {{"name", "Dannan"}, {"id", p["id"]}};
|
|
57
|
+
// };
|
|
46
58
|
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// bindConnect(mainWindow, conn);
|
|
50
|
-
// initChannels(conn);
|
|
59
|
+
// // Send an event to the frontend (Fire & Forget):
|
|
60
|
+
// connect::app.notify({{"msg", "Backend ready!"}});
|
|
51
61
|
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
62
|
+
// // Listen for events from the frontend (Event listener):
|
|
63
|
+
// connect::system.onMinimize = [](const json&) {
|
|
64
|
+
// mainWindow.minimize();
|
|
65
|
+
// };
|
|
66
|
+
//
|
|
67
|
+
// Run `plusui connect` after writing your custom communication code.
|
|
54
68
|
// ============================================================================
|
|
55
69
|
|
|
56
70
|
int main() {
|
|
@@ -65,7 +79,7 @@ int main() {
|
|
|
65
79
|
.alwaysOnTop(windowConfig.alwaysOnTop)
|
|
66
80
|
.skipTaskbar(!windowConfig.showInTaskbar)
|
|
67
81
|
.scrollbars(windowConfig.scrollbars)
|
|
68
|
-
.
|
|
82
|
+
.fileDrop(windowConfig.fileDrop)
|
|
69
83
|
.centered(true)
|
|
70
84
|
.build();
|
|
71
85
|
|
|
@@ -79,6 +93,11 @@ int main() {
|
|
|
79
93
|
mainWindow.hide();
|
|
80
94
|
}
|
|
81
95
|
|
|
96
|
+
// Wire up connect system (for custom frontend ↔ backend communication)
|
|
97
|
+
// Run `plusui connect` after adding custom connect methods
|
|
98
|
+
static Connect conn;
|
|
99
|
+
bindConnect(mainWindow, conn);
|
|
100
|
+
|
|
82
101
|
// Load frontend
|
|
83
102
|
#ifdef PLUSUI_DEV_MODE
|
|
84
103
|
mainWindow.navigate("http://localhost:" + std::to_string(windowConfig.devServerPort) + windowConfig.route);
|
|
@@ -86,19 +105,6 @@ int main() {
|
|
|
86
105
|
mainWindow.loadFile("frontend/dist/index.html" + (windowConfig.route == "/" ? "" : "#" + windowConfig.route));
|
|
87
106
|
#endif
|
|
88
107
|
|
|
89
|
-
// File drop — C++ receives dropped files automatically.
|
|
90
|
-
// Frontend receives the event via plusui.fileDrop.onFilesDropped().
|
|
91
|
-
mainWindow.onFileDrop([](const std::string& filesJson) {
|
|
92
|
-
try {
|
|
93
|
-
auto files = json::parse(filesJson);
|
|
94
|
-
std::cout << "[FileDrop] " << files.size() << " file(s) received\n";
|
|
95
|
-
for (const auto& f : files) {
|
|
96
|
-
std::cout << " " << f.value("name", "?")
|
|
97
|
-
<< " (" << f.value("size", 0) << " bytes)\n";
|
|
98
|
-
}
|
|
99
|
-
} catch (...) {}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
108
|
App runtime;
|
|
103
109
|
runtime.run();
|
|
104
110
|
return 0;
|