plusui-native 0.2.85 → 0.2.87
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.87",
|
|
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.85",
|
|
31
|
+
"plusui-native-connect": "^0.1.85"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"plusui-native-connect": "^0.1.
|
|
34
|
+
"plusui-native-connect": "^0.1.85"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import plusui from 'plusui';
|
|
3
|
-
//
|
|
4
|
-
import { customFileDrop } from '../../Connections/connections.gen';
|
|
3
|
+
// Built-in features are exposed directly on the plusui object
|
|
5
4
|
|
|
6
5
|
function App() {
|
|
7
6
|
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });
|
|
@@ -10,7 +9,7 @@ function App() {
|
|
|
10
9
|
const [canGoBack, setCanGoBack] = useState(false);
|
|
11
10
|
const [canGoForward, setCanGoForward] = useState(false);
|
|
12
11
|
|
|
13
|
-
//
|
|
12
|
+
// Native FileDrop state
|
|
14
13
|
const [isDragging, setIsDragging] = useState(false);
|
|
15
14
|
const [droppedFiles, setDroppedFiles] = useState<{ name: string; size: number; type: string }[]>([]);
|
|
16
15
|
const [backendMsg, setBackendMsg] = useState<string | null>(null);
|
|
@@ -27,25 +26,31 @@ function App() {
|
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
// Listen for navigation changes
|
|
30
|
-
const
|
|
29
|
+
const unsubNav = plusui.browser.onNavigate((url) => {
|
|
31
30
|
setCurrentUrl(url);
|
|
32
31
|
plusui.browser.canGoBack().then(setCanGoBack);
|
|
33
32
|
plusui.browser.canGoForward().then(setCanGoForward);
|
|
34
33
|
});
|
|
35
34
|
|
|
36
|
-
// Listen for responses emitted from C++ via ch.customFileDrop.emit(...) in main.cpp
|
|
37
|
-
const unsubChannel = customFileDrop.on((data: any) => {
|
|
38
|
-
setBackendMsg(data?.message ?? JSON.stringify(data));
|
|
39
|
-
});
|
|
40
|
-
|
|
41
35
|
// Get initial state
|
|
42
36
|
plusui.browser.getUrl().then(setCurrentUrl);
|
|
43
37
|
plusui.browser.canGoBack().then(setCanGoBack);
|
|
44
38
|
plusui.browser.canGoForward().then(setCanGoForward);
|
|
45
39
|
|
|
40
|
+
// Listen for native file drops
|
|
41
|
+
const unsubFileDrop = plusui.fileDrop.onFilesDropped((files: any[]) => {
|
|
42
|
+
setDroppedFiles(files);
|
|
43
|
+
setBackendMsg(`Native FileDrop: Received ${files.length} file(s)`);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const unsubDragEnter = plusui.fileDrop.onDragEnter(() => setIsDragging(true));
|
|
47
|
+
const unsubDragLeave = plusui.fileDrop.onDragLeave(() => setIsDragging(false));
|
|
48
|
+
|
|
46
49
|
return () => {
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
unsubNav();
|
|
51
|
+
unsubFileDrop();
|
|
52
|
+
unsubDragEnter();
|
|
53
|
+
unsubDragLeave();
|
|
49
54
|
};
|
|
50
55
|
}, []);
|
|
51
56
|
|
|
@@ -69,26 +74,14 @@ function App() {
|
|
|
69
74
|
// App control
|
|
70
75
|
const handleQuit = async () => await plusui.app.quit();
|
|
71
76
|
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const handleDragLeave = (e: React.DragEvent) => { e.preventDefault(); setIsDragging(false); };
|
|
76
|
-
const handleDrop = (e: React.DragEvent) => {
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
setIsDragging(false);
|
|
79
|
-
const items = Array.from(e.dataTransfer.files).map(f => ({
|
|
80
|
-
name: f.name, size: f.size, type: f.type || 'unknown',
|
|
81
|
-
}));
|
|
82
|
-
setDroppedFiles(items);
|
|
83
|
-
setBackendMsg(null);
|
|
84
|
-
// Emit to C++ — ch.customFileDrop.on() in main.cpp receives this
|
|
85
|
-
customFileDrop.emit({ files: items });
|
|
86
|
-
};
|
|
77
|
+
// Native FileDrop handlers
|
|
78
|
+
// The C++ native window automatically detects elements with class 'filedrop-zone'.
|
|
79
|
+
// We do not need HTML5 drag events, the C++ backend emits events directly.
|
|
87
80
|
|
|
88
81
|
return (
|
|
89
82
|
<div className="app">
|
|
90
83
|
<header className="app-header">
|
|
91
|
-
<h1>{{ PROJECT_NAME }}</h1>
|
|
84
|
+
<h1>{'{{ PROJECT_NAME }}'}</h1>
|
|
92
85
|
<p>Built with PlusUI Framework</p>
|
|
93
86
|
</header>
|
|
94
87
|
|
|
@@ -138,20 +131,16 @@ function App() {
|
|
|
138
131
|
</div>
|
|
139
132
|
|
|
140
133
|
<div className="card">
|
|
141
|
-
<h2>
|
|
134
|
+
<h2>Native FileDrop API</h2>
|
|
142
135
|
<p style={{ fontSize: '0.85em', color: '#aaa', marginBottom: '1rem' }}>
|
|
143
|
-
Drop files below. The
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<code>plusui connect</code> to regenerate the channel bindings from both sides.
|
|
136
|
+
Drop files below. The <code>plusui.fileDrop</code> API is handled natively in C++
|
|
137
|
+
which overrides standard browser drag-and-drop. It automatically detects elements
|
|
138
|
+
with the <code>.filedrop-zone</code> class or <code>data-dropzone="true"</code>.
|
|
147
139
|
</p>
|
|
148
140
|
|
|
149
141
|
<div
|
|
150
142
|
className={`filedrop-zone ${isDragging ? 'filedrop-active' : ''}`}
|
|
151
|
-
|
|
152
|
-
onDragEnter={handleDragOver}
|
|
153
|
-
onDragLeave={handleDragLeave}
|
|
154
|
-
onDrop={handleDrop}
|
|
143
|
+
data-dropzone="true"
|
|
155
144
|
>
|
|
156
145
|
<div className="filedrop-content">
|
|
157
146
|
<svg className="filedrop-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
@@ -200,25 +200,22 @@ int main() {
|
|
|
200
200
|
initChannels(conn);
|
|
201
201
|
|
|
202
202
|
// ========================================
|
|
203
|
-
//
|
|
203
|
+
// NATIVE FILE DROP
|
|
204
204
|
// ========================================
|
|
205
|
-
//
|
|
206
|
-
// Frontend
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
// The PlusUI native file drop feature is enabled in WindowConfig.
|
|
206
|
+
// Frontend dropped files are automatically passed to C++ as JSON.
|
|
207
|
+
// Frontend also receives the 'plusui:fileDrop.filesDropped' event automatically.
|
|
208
|
+
mainWindow.onFileDrop([](const std::string& filesJson) {
|
|
209
|
+
try {
|
|
210
|
+
auto files = json::parse(filesJson);
|
|
211
|
+
int count = static_cast<int>(files.size());
|
|
212
|
+
std::cout << "Native FileDrop: received " << count << " file(s)" << std::endl;
|
|
213
|
+
for (const auto& f : files) {
|
|
214
|
+
std::cout << " - " << f.value("name", "?") << " (" << f.value("size", 0) << " bytes)" << std::endl;
|
|
215
|
+
}
|
|
216
|
+
} catch (const std::exception& e) {
|
|
217
|
+
std::cout << "Native FileDrop Error: " << e.what() << std::endl;
|
|
215
218
|
}
|
|
216
|
-
// Reply back to frontend — received by customFileDrop.on() in App.tsx
|
|
217
|
-
customFileDrop.emit({
|
|
218
|
-
{"processed", true},
|
|
219
|
-
{"count", count},
|
|
220
|
-
{"message", "C++ received " + std::to_string(count) + " file(s)"}
|
|
221
|
-
});
|
|
222
219
|
});
|
|
223
220
|
|
|
224
221
|
// ========================================
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createSignal, onMount, onCleanup, Show, For } from 'solid-js';
|
|
2
2
|
import plusui from 'plusui';
|
|
3
|
-
//
|
|
4
|
-
import { customFileDrop } from '../../Connections/connections.gen';
|
|
3
|
+
// Built-in features are exposed directly on the plusui object
|
|
5
4
|
|
|
6
5
|
function App() {
|
|
7
6
|
const [windowSize, setWindowSize] = createSignal({ width: 0, height: 0 });
|
|
@@ -10,7 +9,7 @@ function App() {
|
|
|
10
9
|
const [canGoBack, setCanGoBack] = createSignal(false);
|
|
11
10
|
const [canGoForward, setCanGoForward] = createSignal(false);
|
|
12
11
|
|
|
13
|
-
//
|
|
12
|
+
// Native FileDrop state
|
|
14
13
|
const [isDragging, setIsDragging] = createSignal(false);
|
|
15
14
|
const [droppedFiles, setDroppedFiles] = createSignal<{ name: string; size: number; type: string }[]>([]);
|
|
16
15
|
const [backendMsg, setBackendMsg] = createSignal<string | null>(null);
|
|
@@ -23,7 +22,7 @@ function App() {
|
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
// Listen for navigation changes
|
|
26
|
-
plusui.browser.onNavigate((url) => {
|
|
25
|
+
const unsubNav = plusui.browser.onNavigate((url) => {
|
|
27
26
|
setCurrentUrl(url);
|
|
28
27
|
plusui.browser.canGoBack().then(setCanGoBack);
|
|
29
28
|
plusui.browser.canGoForward().then(setCanGoForward);
|
|
@@ -34,11 +33,21 @@ function App() {
|
|
|
34
33
|
plusui.browser.canGoBack().then(setCanGoBack);
|
|
35
34
|
plusui.browser.canGoForward().then(setCanGoForward);
|
|
36
35
|
|
|
37
|
-
// Listen for
|
|
38
|
-
const
|
|
39
|
-
|
|
36
|
+
// Listen for native file drops
|
|
37
|
+
const unsubFileDrop = plusui.fileDrop.onFilesDropped((files: any[]) => {
|
|
38
|
+
setDroppedFiles(files);
|
|
39
|
+
setBackendMsg(`Native FileDrop: Received ${files.length} file(s)`);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const unsubDragEnter = plusui.fileDrop.onDragEnter(() => setIsDragging(true));
|
|
43
|
+
const unsubDragLeave = plusui.fileDrop.onDragLeave(() => setIsDragging(false));
|
|
44
|
+
|
|
45
|
+
onCleanup(() => {
|
|
46
|
+
unsubNav();
|
|
47
|
+
unsubFileDrop();
|
|
48
|
+
unsubDragEnter();
|
|
49
|
+
unsubDragLeave();
|
|
40
50
|
});
|
|
41
|
-
onCleanup(() => unsub());
|
|
42
51
|
});
|
|
43
52
|
|
|
44
53
|
const handleMinimize = async () => await plusui.win.minimize();
|
|
@@ -61,26 +70,14 @@ function App() {
|
|
|
61
70
|
// App control
|
|
62
71
|
const handleQuit = async () => await plusui.app.quit();
|
|
63
72
|
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
const handleDragLeave = (e: DragEvent) => { e.preventDefault(); setIsDragging(false); };
|
|
68
|
-
const handleDrop = (e: DragEvent) => {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
setIsDragging(false);
|
|
71
|
-
const items = Array.from(e.dataTransfer?.files ?? []).map(f => ({
|
|
72
|
-
name: f.name, size: f.size, type: f.type || 'unknown',
|
|
73
|
-
}));
|
|
74
|
-
setDroppedFiles(items);
|
|
75
|
-
setBackendMsg(null);
|
|
76
|
-
// Emit to C++ — ch.customFileDrop.on() in main.cpp receives this
|
|
77
|
-
customFileDrop.emit({ files: items });
|
|
78
|
-
};
|
|
73
|
+
// Native FileDrop handlers
|
|
74
|
+
// The C++ native window automatically detects elements with class 'filedrop-zone'.
|
|
75
|
+
// We do not need HTML5 drag events, the C++ backend emits events directly.
|
|
79
76
|
|
|
80
77
|
return (
|
|
81
78
|
<div class="app">
|
|
82
79
|
<header class="app-header">
|
|
83
|
-
<h1>{{ PROJECT_NAME }} App</h1>
|
|
80
|
+
<h1>{'{{ PROJECT_NAME }}'} App</h1>
|
|
84
81
|
<p>Built with PlusUI Framework</p>
|
|
85
82
|
</header>
|
|
86
83
|
|
|
@@ -130,20 +127,16 @@ function App() {
|
|
|
130
127
|
</div>
|
|
131
128
|
|
|
132
129
|
<div class="card">
|
|
133
|
-
<h2>
|
|
130
|
+
<h2>Native FileDrop API</h2>
|
|
134
131
|
<p style={{ 'font-size': '0.85em', color: '#aaa', 'margin-bottom': '1rem' }}>
|
|
135
|
-
Drop files below. The
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<code>plusui connect</code> to regenerate the channel bindings from both sides.
|
|
132
|
+
Drop files below. The <code>plusui.fileDrop</code> API is handled natively in C++
|
|
133
|
+
which overrides standard browser drag-and-drop. It automatically detects elements
|
|
134
|
+
with the <code>.filedrop-zone</code> class or <code>data-dropzone="true"</code>.
|
|
139
135
|
</p>
|
|
140
136
|
|
|
141
137
|
<div
|
|
142
138
|
class={`filedrop-zone ${isDragging() ? 'filedrop-active' : ''}`}
|
|
143
|
-
|
|
144
|
-
onDragEnter={handleDragOver}
|
|
145
|
-
onDragLeave={handleDragLeave}
|
|
146
|
-
onDrop={handleDrop}
|
|
139
|
+
data-dropzone="true"
|
|
147
140
|
>
|
|
148
141
|
<div class="filedrop-content">
|
|
149
142
|
<svg class="filedrop-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
@@ -194,25 +194,22 @@ int main() {
|
|
|
194
194
|
initChannels(conn);
|
|
195
195
|
|
|
196
196
|
// ========================================
|
|
197
|
-
//
|
|
197
|
+
// NATIVE FILE DROP
|
|
198
198
|
// ========================================
|
|
199
|
-
//
|
|
200
|
-
// Frontend
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
// The PlusUI native file drop feature is enabled in WindowConfig.
|
|
200
|
+
// Frontend dropped files are automatically passed to C++ as JSON.
|
|
201
|
+
// Frontend also receives the 'plusui:fileDrop.filesDropped' event automatically.
|
|
202
|
+
mainWindow.onFileDrop([](const std::string& filesJson) {
|
|
203
|
+
try {
|
|
204
|
+
auto files = json::parse(filesJson);
|
|
205
|
+
int count = static_cast<int>(files.size());
|
|
206
|
+
std::cout << "Native FileDrop: received " << count << " file(s)" << std::endl;
|
|
207
|
+
for (const auto& f : files) {
|
|
208
|
+
std::cout << " - " << f.value("name", "?") << " (" << f.value("size", 0) << " bytes)" << std::endl;
|
|
209
|
+
}
|
|
210
|
+
} catch (const std::exception& e) {
|
|
211
|
+
std::cout << "Native FileDrop Error: " << e.what() << std::endl;
|
|
209
212
|
}
|
|
210
|
-
// Reply back to frontend — received by customFileDrop.on() in App.tsx
|
|
211
|
-
customFileDrop.emit({
|
|
212
|
-
{"processed", true},
|
|
213
|
-
{"count", count},
|
|
214
|
-
{"message", "C++ received " + std::to_string(count) + " file(s)"}
|
|
215
|
-
});
|
|
216
213
|
});
|
|
217
214
|
|
|
218
215
|
// ========================================
|