plusui-native-core 0.1.8 → 0.1.9
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 +2 -1
- package/Core/Features/Bindings/ARCHITECTURE.md +328 -0
- package/Core/Features/Bindings/CustomBindings/custom_bindings.cpp +53 -0
- package/Core/Features/Bindings/CustomBindings/custom_bindings.ts +35 -0
- package/Core/Features/Bindings/EXAMPLE_USAGE.hpp +143 -0
- package/Core/Features/Bindings/EXAMPLE_USAGE.tsx +210 -0
- package/Core/Features/Bindings/IPC_GUIDE.md +325 -0
- package/Core/Features/Bindings/NativeBindings/native_bindings.cpp +30 -0
- package/Core/Features/Bindings/NativeBindings/native_bindings.ts +29 -0
- package/Core/Features/Bindings/UNIFIED_SYSTEM.md +351 -0
- package/Core/Features/FileDrop/filedrop.cpp +316 -0
- package/Core/Features/FileDrop/filedrop.css +421 -0
- package/Core/Features/FileDrop/filedrop.ts +269 -0
- package/Core/include/plusui/bindings.hpp +65 -0
- package/Core/include/plusui/custom_bindings.hpp +17 -0
- package/Core/include/plusui/filedrop.hpp +77 -0
- package/Core/include/plusui/native_bindings.hpp +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlusUI Unified Binding System
|
|
3
|
+
*
|
|
4
|
+
* Single macro for all frontend ↔ backend communication
|
|
5
|
+
* Generates type-safe bindings at compile time
|
|
6
|
+
* Simple, bidirectional, type-safe
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <functional>
|
|
12
|
+
#include <nlohmann/json.hpp>
|
|
13
|
+
|
|
14
|
+
namespace plusui {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* PLUSUI_BIND - Unified binding macro
|
|
18
|
+
*
|
|
19
|
+
* Usage in C++ headers:
|
|
20
|
+
* PLUSUI_BIND(methodName, ReturnType, ParamType1, ParamType2, ...)
|
|
21
|
+
*
|
|
22
|
+
* Examples:
|
|
23
|
+
* PLUSUI_BIND(getUserName, string, void)
|
|
24
|
+
* PLUSUI_BIND(setTheme, void, string)
|
|
25
|
+
* PLUSUI_BIND(calculate, int, int, int)
|
|
26
|
+
* PLUSUI_BIND(onFileChanged, void, json)
|
|
27
|
+
*
|
|
28
|
+
* Direction is auto-detected:
|
|
29
|
+
* - Methods with return values: Frontend → Backend
|
|
30
|
+
* - Methods starting with "on": Backend → Frontend (events)
|
|
31
|
+
* - Explicitly bidirectional when needed
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// Macro for binding definitions (parsed by bindgen)
|
|
35
|
+
#define PLUSUI_BIND(name, returnType, ...) \
|
|
36
|
+
/* Marker for code generation - actual impl in user code */
|
|
37
|
+
|
|
38
|
+
namespace bindings {
|
|
39
|
+
|
|
40
|
+
using json = nlohmann::json;
|
|
41
|
+
|
|
42
|
+
// Invoke handler type - backend methods callable from frontend
|
|
43
|
+
using InvokeHandler = std::function<json(const json& params)>;
|
|
44
|
+
|
|
45
|
+
// Event handler type - frontend methods callable from backend
|
|
46
|
+
using EventHandler = std::function<void(const json& data)>;
|
|
47
|
+
|
|
48
|
+
// Register a backend method (frontend can call this)
|
|
49
|
+
void registerMethod(const std::string& name, InvokeHandler handler);
|
|
50
|
+
|
|
51
|
+
// Register an event listener (backend can emit to this)
|
|
52
|
+
void registerEvent(const std::string& name, EventHandler handler);
|
|
53
|
+
|
|
54
|
+
// Call frontend from backend (emit event)
|
|
55
|
+
void emitToFrontend(const std::string& name, const json& data);
|
|
56
|
+
|
|
57
|
+
// Call backend from frontend (invoke method) - handled by webview bridge
|
|
58
|
+
json invokeFromFrontend(const std::string& name, const json& params);
|
|
59
|
+
|
|
60
|
+
// Get all registered bindings (for diagnostics)
|
|
61
|
+
std::vector<std::string> getRegisteredMethods();
|
|
62
|
+
std::vector<std::string> getRegisteredEvents();
|
|
63
|
+
|
|
64
|
+
} // namespace bindings
|
|
65
|
+
} // namespace plusui
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <functional>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
namespace plusui {
|
|
8
|
+
|
|
9
|
+
using CustomBindingCallback = std::function<void(const std::string &payload)>;
|
|
10
|
+
|
|
11
|
+
class CustomBindings {
|
|
12
|
+
public:
|
|
13
|
+
static void registerBinding(const std::string &name,
|
|
14
|
+
CustomBindingCallback callback);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace plusui
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <vector>
|
|
5
|
+
#include <functional>
|
|
6
|
+
|
|
7
|
+
namespace PlusUI {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* FileInfo - Represents a dropped file
|
|
11
|
+
*/
|
|
12
|
+
struct FileInfo {
|
|
13
|
+
std::string path; // Full path to the file
|
|
14
|
+
std::string name; // File name with extension
|
|
15
|
+
std::string type; // MIME type (e.g., "image/png", "text/plain")
|
|
16
|
+
std::uint64_t size; // File size in bytes
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* FileDrop - Cross-platform drag & drop file handling
|
|
21
|
+
*
|
|
22
|
+
* Enables dragging files into the webview window and from the window to the desktop.
|
|
23
|
+
* Supports all file types cross-platform (Windows, macOS, Linux).
|
|
24
|
+
*/
|
|
25
|
+
class FileDrop {
|
|
26
|
+
public:
|
|
27
|
+
FileDrop();
|
|
28
|
+
~FileDrop();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Enable or disable file drop into window
|
|
32
|
+
* @param enabled - true to allow files to be dropped into the window
|
|
33
|
+
*/
|
|
34
|
+
void setEnabled(bool enabled);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if file drop is currently enabled
|
|
38
|
+
* @return true if file drop is enabled
|
|
39
|
+
*/
|
|
40
|
+
bool isEnabled() const;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set callback for when files are dropped into the window
|
|
44
|
+
* @param callback - Function called with array of dropped files
|
|
45
|
+
*/
|
|
46
|
+
void onFilesDropped(std::function<void(const std::vector<FileInfo>&)> callback);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set callback for when a drag operation enters the window
|
|
50
|
+
* @param callback - Function called when drag enters
|
|
51
|
+
*/
|
|
52
|
+
void onDragEnter(std::function<void()> callback);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set callback for when a drag operation leaves the window
|
|
56
|
+
* @param callback - Function called when drag leaves
|
|
57
|
+
*/
|
|
58
|
+
void onDragLeave(std::function<void()> callback);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Start a drag operation to drag files out of the window
|
|
62
|
+
* @param filePaths - Paths to files to be dragged
|
|
63
|
+
* @return true if drag operation started successfully
|
|
64
|
+
*/
|
|
65
|
+
bool startDrag(const std::vector<std::string>& filePaths);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Clear all callbacks
|
|
69
|
+
*/
|
|
70
|
+
void clearCallbacks();
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
struct Impl;
|
|
74
|
+
Impl* pImpl;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace PlusUI
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
namespace plusui {
|
|
7
|
+
|
|
8
|
+
struct BindingEntry {
|
|
9
|
+
const char *source;
|
|
10
|
+
const char *feature;
|
|
11
|
+
const char *method;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
class NativeBindings {
|
|
15
|
+
public:
|
|
16
|
+
static const std::vector<BindingEntry> &getEntries();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace plusui
|