plusui-native 0.2.103 → 0.2.104

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.103",
3
+ "version": "0.2.104",
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.101",
31
- "plusui-native-connect": "^0.1.101"
30
+ "plusui-native-builder": "^0.1.102",
31
+ "plusui-native-connect": "^0.1.102"
32
32
  },
33
33
  "peerDependencies": {
34
- "plusui-native-connect": "^0.1.101"
34
+ "plusui-native-connect": "^0.1.102"
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 channels:
16
- // Run `plusui connect` to generate typed channels for your own events.
19
+ // Custom frontend ↔ backend communication:
20
+ // Use connect::namespace.method syntax anywhere, then run `plusui connect`.
17
21
  // ============================================================================
18
22
 
19
23
  struct AppConfig {
@@ -39,18 +43,28 @@ struct WindowConfig {
39
43
  } windowConfig;
40
44
 
41
45
  // ============================================================================
42
- // CUSTOM CHANNELS (optional)
46
+ // CUSTOM COMMUNICATION (optional)
43
47
  // ============================================================================
44
- // If you need your own frontend ↔ backend events beyond the built-in features,
45
- // use `plusui connect`. Add a Connect subclass here and bind it:
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
- // #include "Connections/connections.gen.hpp"
48
- // static Connect conn;
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
- // Then in C++: myChannel.emit({{"key", "value"}});
53
- // And frontend: myChannel.on((data) => { ... });
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() {
@@ -79,6 +93,11 @@ int main() {
79
93
  mainWindow.hide();
80
94
  }
81
95
 
96
+ // Wire up custom connect channels
97
+ static Connect conn;
98
+ bindConnect(mainWindow, conn);
99
+ initConnect(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);
@@ -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 channels:
16
- // Run `plusui connect` to generate typed channels for your own events.
19
+ // Custom frontend ↔ backend communication:
20
+ // Use connect::namespace.method syntax anywhere, then run `plusui connect`.
17
21
  // ============================================================================
18
22
 
19
23
  struct AppConfig {
@@ -39,18 +43,28 @@ struct WindowConfig {
39
43
  } windowConfig;
40
44
 
41
45
  // ============================================================================
42
- // CUSTOM CHANNELS (optional)
46
+ // CUSTOM COMMUNICATION (optional)
43
47
  // ============================================================================
44
- // If you need your own frontend ↔ backend events beyond the built-in features,
45
- // use `plusui connect`. Add a Connect subclass here and bind it:
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
- // #include "Connections/connections.gen.hpp"
48
- // static Connect conn;
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
- // Then in C++: myChannel.emit({{"key", "value"}});
53
- // And frontend: myChannel.on((data) => { ... });
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() {
@@ -79,6 +93,11 @@ int main() {
79
93
  mainWindow.hide();
80
94
  }
81
95
 
96
+ // Wire up custom connect channels
97
+ static Connect conn;
98
+ bindConnect(mainWindow, conn);
99
+ initConnect(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);