plusui-native-core 0.1.86 → 0.1.89
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 +1 -0
- package/Core/{API → Features/API}/Connect_API.ts +1 -1
- package/Core/Features/API/app-api.ts +28 -0
- package/Core/Features/API/browser-api.ts +40 -0
- package/Core/Features/API/clipboard-api.ts +21 -0
- package/Core/Features/API/display-api.ts +33 -0
- package/Core/Features/API/filedrop-api.ts +43 -0
- package/Core/{API → Features/API}/index.ts +50 -51
- package/Core/Features/API/keyboard-api.ts +33 -0
- package/Core/Features/API/menu-api.ts +39 -0
- package/Core/Features/API/router-api.ts +23 -0
- package/Core/Features/API/tray-api.ts +22 -0
- package/Core/Features/API/webgpu-api.ts +55 -0
- package/Core/Features/API/window-api.ts +52 -0
- package/Core/Features/App/app.cpp +1 -3
- package/Core/Features/App/app.ts +2 -13
- package/Core/Features/Browser/browser.ts +3 -2
- package/Core/Features/Router/router.cpp +62 -0
- package/Core/Features/Router/router.ts +2 -1
- package/Core/include/plusui/api.hpp +237 -0
- package/Core/include/plusui/plusui.hpp +2 -0
- package/Core/include/plusui/router.hpp +42 -0
- package/package.json +1 -1
package/Core/CMakeLists.txt
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App API
|
|
3
|
+
*
|
|
4
|
+
* Application lifecycle management: version, paths, badge, and lifecycle events.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* app.invoke(name, args) - Call a named native method directly
|
|
8
|
+
* app.quit() - Quit the application
|
|
9
|
+
* app.getVersion() - Get the application version string
|
|
10
|
+
* app.getName() - Get the application name
|
|
11
|
+
* app.getPath(name) - Get a well-known path (home, appData, temp, etc.)
|
|
12
|
+
* app.setBadge(count) - Set the taskbar/dock badge count
|
|
13
|
+
* app.getBadge() - Get the current badge count
|
|
14
|
+
* app.emit(event, payload) - Dispatch a custom application event
|
|
15
|
+
*
|
|
16
|
+
* Events:
|
|
17
|
+
* app.onReady(cb) - Fires when the app is fully initialized
|
|
18
|
+
* app.onQuit(cb) - Fires when the app is about to quit
|
|
19
|
+
* app.onActivate(cb) - Fires when the app is re-activated (macOS dock click)
|
|
20
|
+
* app.onWindowAllClosed(cb) - Fires when all windows are closed
|
|
21
|
+
* app.onSecondInstance(cb) - Fires when a second instance is launched
|
|
22
|
+
* app.on(event, cb) - Listen for any custom app event
|
|
23
|
+
* app.once(event, cb) - Listen for a custom app event only once
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type { AppConfig } from '../App/app';
|
|
27
|
+
|
|
28
|
+
export { app } from '../App/app';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser API
|
|
3
|
+
*
|
|
4
|
+
* Control in-app browser navigation and receive page lifecycle events.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* browser.navigate(url) - Navigate to a URL
|
|
8
|
+
* browser.open(url) - Alias for navigate()
|
|
9
|
+
* browser.openExternal(url) - Open a URL in the system default browser
|
|
10
|
+
* browser.openNewWindow(url) - Open a URL in a new application window
|
|
11
|
+
* browser.goBack() - Go back in navigation history
|
|
12
|
+
* browser.goForward() - Go forward in navigation history
|
|
13
|
+
* browser.reload() - Reload the current page
|
|
14
|
+
* browser.stop() - Stop the current page load
|
|
15
|
+
* browser.getUrl() - Get the current URL
|
|
16
|
+
* browser.getTitle() - Get the current page title
|
|
17
|
+
* browser.getState() - Get the full current browser state snapshot
|
|
18
|
+
* browser.canGoBack() - Check if back navigation is possible
|
|
19
|
+
* browser.canGoForward() - Check if forward navigation is possible
|
|
20
|
+
* browser.isLoading() - Check if a page is currently loading
|
|
21
|
+
* browser.emit(name, payload) - Send a message on a browser feature channel
|
|
22
|
+
* browser.on(name, cb) - Listen on a browser feature channel
|
|
23
|
+
*
|
|
24
|
+
* Events:
|
|
25
|
+
* browser.onNavigate(cb) - Fires when navigation occurs (URL change)
|
|
26
|
+
* browser.onStateChange(cb) - Fires when any browser state changes
|
|
27
|
+
* browser.onLoadStart(cb) - Fires when a page begins loading
|
|
28
|
+
* browser.onLoadEnd(cb) - Fires when a page finishes loading
|
|
29
|
+
* browser.onLoadError(cb) - Fires when a page load fails
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export type {
|
|
33
|
+
BrowserState,
|
|
34
|
+
NavigateCallback,
|
|
35
|
+
StateCallback,
|
|
36
|
+
LoadCallback,
|
|
37
|
+
ErrorCallback,
|
|
38
|
+
} from '../Browser/browser';
|
|
39
|
+
|
|
40
|
+
export { browser } from '../Browser/browser';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard API
|
|
3
|
+
*
|
|
4
|
+
* Read from and write to the system clipboard. Supports text and images.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* clipboard.getText() - Read text from clipboard
|
|
8
|
+
* clipboard.setText(text) - Write text to clipboard
|
|
9
|
+
* clipboard.hasText() - Check if clipboard has text
|
|
10
|
+
* clipboard.getImage() - Read image as base64 data URL
|
|
11
|
+
* clipboard.setImage(b64) - Write image from base64 data URL
|
|
12
|
+
* clipboard.hasImage() - Check if clipboard has an image
|
|
13
|
+
* clipboard.clear() - Clear the clipboard
|
|
14
|
+
*
|
|
15
|
+
* Events:
|
|
16
|
+
* clipboard.onChange(cb) - Fires when clipboard content changes
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type { ClipboardAPI } from '../Clipboard/clipboard';
|
|
20
|
+
|
|
21
|
+
export { clipboard } from '../Clipboard/clipboard';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display API
|
|
3
|
+
*
|
|
4
|
+
* Query and control connected monitors/screens.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* display.getAllDisplays() - Get all connected displays
|
|
8
|
+
* display.getPrimaryDisplay() - Get the primary display
|
|
9
|
+
* display.getDisplayAt(x, y) - Get the display at a screen coordinate
|
|
10
|
+
* display.getDisplayAtCursor() - Get the display under the cursor
|
|
11
|
+
* display.getDisplayById(id) - Get a display by its ID
|
|
12
|
+
* display.setDisplayMode(id, mode) - Change resolution/refresh rate
|
|
13
|
+
* display.setPosition(id, x, y) - Reposition a display
|
|
14
|
+
* display.turnOff(id) - Turn off a display
|
|
15
|
+
* display.getScreenWidth() - Get primary screen width in pixels
|
|
16
|
+
* display.getScreenHeight() - Get primary screen height in pixels
|
|
17
|
+
* display.getScaleFactor() - Get DPI scale factor
|
|
18
|
+
* display.getRefreshRate() - Get refresh rate in Hz
|
|
19
|
+
*
|
|
20
|
+
* Events:
|
|
21
|
+
* display.onConnected(cb) - Fires when a display is connected
|
|
22
|
+
* display.onDisconnected(cb) - Fires when a display is disconnected
|
|
23
|
+
* display.onChanged(cb) - Fires when a display configuration changes
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
Display,
|
|
28
|
+
DisplayMode,
|
|
29
|
+
DisplayBounds,
|
|
30
|
+
DisplayResolution,
|
|
31
|
+
} from '../Display/display';
|
|
32
|
+
|
|
33
|
+
export { display } from '../Display/display';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileDrop API
|
|
3
|
+
*
|
|
4
|
+
* Handle files dragged and dropped onto the application window.
|
|
5
|
+
* Also supports initiating drag operations from the app.
|
|
6
|
+
*
|
|
7
|
+
* Actions:
|
|
8
|
+
* fileDrop.setEnabled(enabled) - Enable or disable file drop
|
|
9
|
+
* fileDrop.isEnabled() - Check if file drop is enabled
|
|
10
|
+
* fileDrop.startDrag(filePaths) - Start a drag operation with the given files
|
|
11
|
+
* fileDrop.clearCallbacks() - Remove all registered drop callbacks
|
|
12
|
+
*
|
|
13
|
+
* Events:
|
|
14
|
+
* fileDrop.onFilesDropped(cb) - Fires when files are dropped onto the window
|
|
15
|
+
* fileDrop.onDragEnter(cb) - Fires when a drag enters the window
|
|
16
|
+
* fileDrop.onDragLeave(cb) - Fires when a drag leaves the window
|
|
17
|
+
*
|
|
18
|
+
* Helpers (pure functions):
|
|
19
|
+
* readFileAsText(path) - Read a file path as a text string
|
|
20
|
+
* readFileAsDataUrl(path) - Read a file path as a base64 data URL
|
|
21
|
+
* filterFilesByExtension(files, ext) - Filter FileInfo[] by extension(s)
|
|
22
|
+
* filterFilesByMimeType(files, mime) - Filter FileInfo[] by MIME type(s)
|
|
23
|
+
* isImageFile(file) - Check if FileInfo is an image
|
|
24
|
+
* isVideoFile(file) - Check if FileInfo is a video
|
|
25
|
+
* isAudioFile(file) - Check if FileInfo is audio
|
|
26
|
+
* isTextFile(file) - Check if FileInfo is a text file
|
|
27
|
+
* formatFileSize(bytes) - Format byte count as a human-readable string
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export type { FileInfo, DragEvent, FileDropAPI } from '../FileDrop/filedrop';
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
fileDrop,
|
|
34
|
+
readFileAsText,
|
|
35
|
+
readFileAsDataUrl,
|
|
36
|
+
filterFilesByExtension,
|
|
37
|
+
filterFilesByMimeType,
|
|
38
|
+
isImageFile,
|
|
39
|
+
isVideoFile,
|
|
40
|
+
isAudioFile,
|
|
41
|
+
isTextFile,
|
|
42
|
+
formatFileSize,
|
|
43
|
+
} from '../FileDrop/filedrop';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PlusUI API - Unified Entry Point
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* TWO DISTINCT PATTERNS:
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* 1. BUILT-IN FEATURES - Direct methods only (NO .on/.emit)
|
|
7
7
|
* window.setTitle('My App');
|
|
8
8
|
* window.minimize();
|
|
9
9
|
* clipboard.setText('hello');
|
|
10
10
|
* window.onResize((size) => { ... });
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* 2. CUSTOM CHANNELS - Use .on() and .emit()
|
|
13
13
|
* const search = createChannel('search');
|
|
14
14
|
* search.emit({ query: 'test' });
|
|
15
15
|
* search.on((result) => { ... });
|
|
16
|
-
*
|
|
16
|
+
*
|
|
17
17
|
* The `plusui connect` CLI scans your codebase for name.on() and name.emit()
|
|
18
18
|
* and generates typed channel objects for both frontend and backend.
|
|
19
19
|
*/
|
|
@@ -67,19 +67,20 @@ if (typeof window !== 'undefined') {
|
|
|
67
67
|
|
|
68
68
|
// ============================================================
|
|
69
69
|
// BUILT-IN FEATURES - Direct methods only (NO .on/.emit)
|
|
70
|
+
// Each feature has its own dedicated API file in this directory.
|
|
70
71
|
// ============================================================
|
|
71
72
|
|
|
72
|
-
export { window } from '
|
|
73
|
-
export { clipboard } from '
|
|
74
|
-
export { keyboard } from '
|
|
75
|
-
export { tray } from '
|
|
76
|
-
export { display } from '
|
|
77
|
-
export { fileDrop } from '
|
|
78
|
-
export { menu } from '
|
|
79
|
-
export { app } from '
|
|
80
|
-
export { gpu } from '
|
|
81
|
-
export { browser } from '
|
|
82
|
-
export { router } from '
|
|
73
|
+
export { window } from './window-api';
|
|
74
|
+
export { clipboard } from './clipboard-api';
|
|
75
|
+
export { keyboard, KeyCode, KeyMod } from './keyboard-api';
|
|
76
|
+
export { tray } from './tray-api';
|
|
77
|
+
export { display } from './display-api';
|
|
78
|
+
export { fileDrop } from './filedrop-api';
|
|
79
|
+
export { menu } from './menu-api';
|
|
80
|
+
export { app } from './app-api';
|
|
81
|
+
export { gpu, GPUBufferUsage, GPUTextureUsage, GPUMapMode, GPUShaderStage, GPUColorWrite } from './webgpu-api';
|
|
82
|
+
export { browser } from './browser-api';
|
|
83
|
+
export { router } from './router-api';
|
|
83
84
|
|
|
84
85
|
// ============================================================
|
|
85
86
|
// CUSTOM CHANNELS - For user-defined events (uses .on/.emit)
|
|
@@ -93,7 +94,7 @@ export {
|
|
|
93
94
|
} from './Connect_API';
|
|
94
95
|
|
|
95
96
|
// Internal export for connection generator
|
|
96
|
-
export { _client } from '../
|
|
97
|
+
export { _client } from '../Connection/connect';
|
|
97
98
|
|
|
98
99
|
// ============================================================
|
|
99
100
|
// TYPES - Re-exported for convenience
|
|
@@ -105,38 +106,27 @@ export type {
|
|
|
105
106
|
WindowRect,
|
|
106
107
|
WindowState,
|
|
107
108
|
WindowId
|
|
108
|
-
} from '
|
|
109
|
+
} from './window-api';
|
|
109
110
|
|
|
110
|
-
export type {
|
|
111
|
-
ClipboardAPI
|
|
112
|
-
} from '../Features/Clipboard/clipboard';
|
|
111
|
+
export type { ClipboardAPI } from './clipboard-api';
|
|
113
112
|
|
|
114
113
|
export type {
|
|
115
114
|
KeyEvent,
|
|
116
115
|
Shortcut,
|
|
117
116
|
KeyEventCallback,
|
|
118
117
|
ShortcutCallback,
|
|
119
|
-
|
|
120
|
-
KeyMod
|
|
121
|
-
} from '../Features/Keyboard/keyboard';
|
|
118
|
+
} from './keyboard-api';
|
|
122
119
|
|
|
123
|
-
export type {
|
|
124
|
-
TrayMenuItem,
|
|
125
|
-
TrayIconData
|
|
126
|
-
} from '../Features/Tray/tray';
|
|
120
|
+
export type { TrayMenuItem, TrayIconData } from './tray-api';
|
|
127
121
|
|
|
128
122
|
export type {
|
|
129
123
|
Display,
|
|
130
124
|
DisplayMode,
|
|
131
125
|
DisplayBounds,
|
|
132
126
|
DisplayResolution
|
|
133
|
-
} from '
|
|
127
|
+
} from './display-api';
|
|
134
128
|
|
|
135
|
-
export type {
|
|
136
|
-
FileInfo,
|
|
137
|
-
DragEvent,
|
|
138
|
-
FileDropAPI
|
|
139
|
-
} from '../Features/FileDrop/filedrop';
|
|
129
|
+
export type { FileInfo, DragEvent, FileDropAPI } from './filedrop-api';
|
|
140
130
|
|
|
141
131
|
export type {
|
|
142
132
|
MenuItem,
|
|
@@ -144,11 +134,9 @@ export type {
|
|
|
144
134
|
MenuBarData,
|
|
145
135
|
ContextMenuOptions,
|
|
146
136
|
ContextInfo
|
|
147
|
-
} from '
|
|
137
|
+
} from './menu-api';
|
|
148
138
|
|
|
149
|
-
export type {
|
|
150
|
-
AppConfig
|
|
151
|
-
} from '../Features/App/app';
|
|
139
|
+
export type { AppConfig } from './app-api';
|
|
152
140
|
|
|
153
141
|
export type {
|
|
154
142
|
GPUAdapter,
|
|
@@ -160,7 +148,17 @@ export type {
|
|
|
160
148
|
GPUComputePipeline,
|
|
161
149
|
GPUQueue,
|
|
162
150
|
GPUCommandEncoder
|
|
163
|
-
} from '
|
|
151
|
+
} from './webgpu-api';
|
|
152
|
+
|
|
153
|
+
export type {
|
|
154
|
+
BrowserState,
|
|
155
|
+
NavigateCallback,
|
|
156
|
+
StateCallback,
|
|
157
|
+
LoadCallback,
|
|
158
|
+
ErrorCallback,
|
|
159
|
+
} from './browser-api';
|
|
160
|
+
|
|
161
|
+
export type { RouteMap, RouteChangeCallback, RouteConfig } from './router-api';
|
|
164
162
|
|
|
165
163
|
// ============================================================
|
|
166
164
|
// HELPER FUNCTIONS
|
|
@@ -176,28 +174,28 @@ export {
|
|
|
176
174
|
isAudioFile,
|
|
177
175
|
isTextFile,
|
|
178
176
|
formatFileSize
|
|
179
|
-
} from '
|
|
177
|
+
} from './filedrop-api';
|
|
180
178
|
|
|
181
179
|
// ============================================================
|
|
182
180
|
// DEFAULT EXPORT - For `import plusui from 'plusui'` convenience
|
|
183
181
|
// ============================================================
|
|
184
182
|
|
|
185
|
-
import { window } from '
|
|
186
|
-
import { clipboard } from '
|
|
187
|
-
import { keyboard } from '
|
|
188
|
-
import { tray } from '
|
|
189
|
-
import { display } from '
|
|
190
|
-
import { fileDrop, formatFileSize } from '
|
|
191
|
-
import { menu } from '
|
|
192
|
-
import { app } from '
|
|
193
|
-
import { gpu } from '
|
|
194
|
-
import { browser } from '
|
|
195
|
-
import { router } from '
|
|
183
|
+
import { window } from './window-api';
|
|
184
|
+
import { clipboard } from './clipboard-api';
|
|
185
|
+
import { keyboard } from './keyboard-api';
|
|
186
|
+
import { tray } from './tray-api';
|
|
187
|
+
import { display } from './display-api';
|
|
188
|
+
import { fileDrop, formatFileSize } from './filedrop-api';
|
|
189
|
+
import { menu } from './menu-api';
|
|
190
|
+
import { app } from './app-api';
|
|
191
|
+
import { gpu } from './webgpu-api';
|
|
192
|
+
import { browser } from './browser-api';
|
|
193
|
+
import { router } from './router-api';
|
|
196
194
|
import { connect, createChannel, createFeatureConnect } from './Connect_API';
|
|
197
195
|
|
|
198
196
|
const plusui = {
|
|
199
197
|
window,
|
|
200
|
-
win: window, // Alias for backward compatibility
|
|
198
|
+
win: window, // Alias for backward compatibility
|
|
201
199
|
clipboard,
|
|
202
200
|
keyboard,
|
|
203
201
|
tray,
|
|
@@ -205,6 +203,7 @@ const plusui = {
|
|
|
205
203
|
fileDrop,
|
|
206
204
|
menu,
|
|
207
205
|
app,
|
|
206
|
+
api: app,
|
|
208
207
|
gpu,
|
|
209
208
|
browser,
|
|
210
209
|
router,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard API
|
|
3
|
+
*
|
|
4
|
+
* Listen for key events and register global shortcuts.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* keyboard.isKeyPressed(key) - Check if a key is currently held down
|
|
8
|
+
* keyboard.setAutoRepeat(enabled) - Enable/disable key auto-repeat
|
|
9
|
+
* keyboard.getAutoRepeat() - Get auto-repeat state
|
|
10
|
+
* keyboard.registerShortcut(id, shortcut, cb) - Register a global keyboard shortcut
|
|
11
|
+
* keyboard.unregisterShortcut(id) - Remove a registered shortcut
|
|
12
|
+
* keyboard.clearShortcuts() - Remove all registered shortcuts
|
|
13
|
+
* keyboard.parseShortcut('Ctrl+S') - Parse a shortcut string into a Shortcut object
|
|
14
|
+
* keyboard.keyNameToCode('enter') - Convert a key name string to a KeyCode
|
|
15
|
+
*
|
|
16
|
+
* Events:
|
|
17
|
+
* keyboard.onKeyDown(cb) - Fires when any key is pressed
|
|
18
|
+
* keyboard.onKeyUp(cb) - Fires when any key is released
|
|
19
|
+
* keyboard.onShortcut(cb) - Fires when a registered shortcut is triggered
|
|
20
|
+
*
|
|
21
|
+
* Enums:
|
|
22
|
+
* KeyCode - Key codes (e.g. KeyCode.Enter, KeyCode.F5)
|
|
23
|
+
* KeyMod - Modifier flags (e.g. KeyMod.Control, KeyMod.Shift)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
KeyEvent,
|
|
28
|
+
Shortcut,
|
|
29
|
+
KeyEventCallback,
|
|
30
|
+
ShortcutCallback,
|
|
31
|
+
} from '../Keyboard/keyboard';
|
|
32
|
+
|
|
33
|
+
export { KeyCode, KeyMod, keyboard } from '../Keyboard/keyboard';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu API
|
|
3
|
+
*
|
|
4
|
+
* Build and control native context menus and application menu bars.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* menu.create(items) - Create a menu and return its ID
|
|
8
|
+
* menu.popup(id, x, y) - Show a menu at a screen position
|
|
9
|
+
* menu.popupAtCursor(id) - Show a menu at the current cursor position
|
|
10
|
+
* menu.close(id) - Close an open menu
|
|
11
|
+
* menu.destroy(id) - Destroy a menu and free resources
|
|
12
|
+
* menu.setApplicationMenu(items) - Set the application-level menu bar
|
|
13
|
+
* menu.getApplicationMenu() - Get the current application menu items
|
|
14
|
+
* menu.appendToMenuBar(item) - Append an item to the menu bar
|
|
15
|
+
* menu.showContextMenu(items, options) - Create and show a context menu in one call
|
|
16
|
+
* menu.dispose() - Clear all internal click handlers
|
|
17
|
+
*
|
|
18
|
+
* Builder helpers (return pre-built MenuItem trees):
|
|
19
|
+
* menu.createFileMenu(handlers) - Standard File menu (New, Open, Save, Exit)
|
|
20
|
+
* menu.createEditMenu(handlers) - Standard Edit menu (Undo, Cut, Copy, Paste)
|
|
21
|
+
* menu.createViewMenu(handlers) - Standard View menu (Zoom, Fullscreen, DevTools)
|
|
22
|
+
* menu.createTextContextMenu() - Right-click menu for text fields
|
|
23
|
+
* menu.createImageContextMenu() - Right-click menu for images
|
|
24
|
+
* menu.createLinkContextMenu() - Right-click menu for links
|
|
25
|
+
*
|
|
26
|
+
* Events:
|
|
27
|
+
* menu.onItemClick(cb) - Fires when any menu item is clicked
|
|
28
|
+
* menu.onContextOpen(cb) - Fires when a context menu is about to open
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
MenuItem,
|
|
33
|
+
MenuItemType,
|
|
34
|
+
MenuBarData,
|
|
35
|
+
ContextMenuOptions,
|
|
36
|
+
ContextInfo,
|
|
37
|
+
} from '../Menu/menu';
|
|
38
|
+
|
|
39
|
+
export { menu } from '../Menu/menu';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router API
|
|
3
|
+
*
|
|
4
|
+
* Map route paths to frontend URLs and navigate between them across windows.
|
|
5
|
+
* Works with any frontend router (React Router, TanStack Router, Solid Router, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Actions:
|
|
8
|
+
* router.setRoutes(routes) - Define the route map ({ '/settings': 'http://...' })
|
|
9
|
+
* router.getRoutes() - Get the current route map
|
|
10
|
+
* router.push(route, windowId?) - Navigate to a route (adds to history)
|
|
11
|
+
* router.replace(route, windowId?) - Navigate to a route (replaces history entry)
|
|
12
|
+
* router.getCurrentRoute(windowId?) - Get the current route for a window
|
|
13
|
+
* router.setInitialRoute(route) - Set the route loaded on app startup
|
|
14
|
+
* router.emit(name, payload) - Send a message on a router feature channel
|
|
15
|
+
* router.on(name, cb) - Listen on a router feature channel
|
|
16
|
+
*
|
|
17
|
+
* Events:
|
|
18
|
+
* router.onRouteChange(cb) - Fires when the route changes (from backend or other windows)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export type { RouteMap, RouteChangeCallback, RouteConfig } from '../Router/router';
|
|
22
|
+
|
|
23
|
+
export { router } from '../Router/router';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tray API
|
|
3
|
+
*
|
|
4
|
+
* Manage the system tray icon: icon, tooltip, visibility, and context menu.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* tray.setIcon(path) - Set the tray icon image
|
|
8
|
+
* tray.setTooltip(text) - Set the hover tooltip text
|
|
9
|
+
* tray.setVisible(visible) - Show or hide the tray icon
|
|
10
|
+
* tray.setMenu(items) - Set the full tray menu
|
|
11
|
+
* tray.setContextMenu(items) - Set the right-click context menu
|
|
12
|
+
*
|
|
13
|
+
* Events:
|
|
14
|
+
* tray.onClick(cb) - Fires on left click
|
|
15
|
+
* tray.onDoubleClick(cb) - Fires on double click
|
|
16
|
+
* tray.onRightClick(cb) - Fires on right click
|
|
17
|
+
* tray.onMenuItemClick(cb) - Fires when a menu item is selected
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type { TrayMenuItem, TrayIconData } from '../Tray/tray';
|
|
21
|
+
|
|
22
|
+
export { tray } from '../Tray/tray';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGPU API
|
|
3
|
+
*
|
|
4
|
+
* GPU-accelerated rendering and compute via the WebGPU standard.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* gpu.requestAdapter(options?) - Request a GPU adapter (entry point for WebGPU)
|
|
8
|
+
* gpu.getPreferredCanvasFormat() - Get the preferred swap-chain texture format
|
|
9
|
+
*
|
|
10
|
+
* Events:
|
|
11
|
+
* gpu.onAdapterLost(cb) - Fires when the GPU adapter is lost
|
|
12
|
+
* gpu.onDeviceLost(cb) - Fires when the GPU device is lost
|
|
13
|
+
* gpu.onError(cb) - Fires on GPU errors
|
|
14
|
+
*
|
|
15
|
+
* Core types (mirrors the WebGPU spec):
|
|
16
|
+
* GPUAdapter, GPUDevice, GPUBuffer, GPUTexture, GPUTextureView
|
|
17
|
+
* GPUSampler, GPUShaderModule, GPURenderPipeline, GPUComputePipeline
|
|
18
|
+
* GPUBindGroup, GPUBindGroupLayout, GPUCommandEncoder
|
|
19
|
+
* GPURenderPassEncoder, GPUComputePassEncoder, GPUQueue, GPUCommandBuffer
|
|
20
|
+
*
|
|
21
|
+
* Usage flags / constants:
|
|
22
|
+
* GPUBufferUsage, GPUTextureUsage, GPUMapMode, GPUShaderStage, GPUColorWrite
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export type {
|
|
26
|
+
GPUAdapter,
|
|
27
|
+
GPUAdapterInfo,
|
|
28
|
+
GPUDevice,
|
|
29
|
+
GPUDeviceLostInfo,
|
|
30
|
+
GPUBuffer,
|
|
31
|
+
GPUTexture,
|
|
32
|
+
GPUTextureView,
|
|
33
|
+
GPUSampler,
|
|
34
|
+
GPUShaderModule,
|
|
35
|
+
GPURenderPipeline,
|
|
36
|
+
GPUComputePipeline,
|
|
37
|
+
GPUBindGroupLayout,
|
|
38
|
+
GPUBindGroup,
|
|
39
|
+
GPUCommandEncoder,
|
|
40
|
+
GPURenderPassEncoder,
|
|
41
|
+
GPUComputePassEncoder,
|
|
42
|
+
GPUQueue,
|
|
43
|
+
GPUCommandBuffer,
|
|
44
|
+
GPURequestAdapterOptions,
|
|
45
|
+
GPUDeviceDescriptor,
|
|
46
|
+
} from '../WebGPU/webgpu';
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
gpu,
|
|
50
|
+
GPUBufferUsage,
|
|
51
|
+
GPUTextureUsage,
|
|
52
|
+
GPUMapMode,
|
|
53
|
+
GPUShaderStage,
|
|
54
|
+
GPUColorWrite,
|
|
55
|
+
} from '../WebGPU/webgpu';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Window API
|
|
3
|
+
*
|
|
4
|
+
* Controls native window behavior: visibility, size, position, decorations, and events.
|
|
5
|
+
*
|
|
6
|
+
* Actions:
|
|
7
|
+
* window.show() - Make the window visible
|
|
8
|
+
* window.hide() - Hide the window
|
|
9
|
+
* window.minimize() - Minimize to taskbar
|
|
10
|
+
* window.maximize() - Maximize to screen
|
|
11
|
+
* window.restore() - Restore from minimized/maximized
|
|
12
|
+
* window.close() - Close the window
|
|
13
|
+
* window.center() - Center on screen
|
|
14
|
+
* window.focus() - Bring to front and focus
|
|
15
|
+
* window.setTitle(title) - Set the title bar text
|
|
16
|
+
* window.setSize(w, h) - Resize the window
|
|
17
|
+
* window.setPosition(x,y) - Move the window
|
|
18
|
+
* window.setFullscreen(b) - Enter/exit fullscreen
|
|
19
|
+
* window.setAlwaysOnTop(b)- Pin above other windows
|
|
20
|
+
* window.setResizable(b) - Allow/disallow resizing
|
|
21
|
+
* window.setDecorations(b)- Show/hide title bar and borders
|
|
22
|
+
* window.setTransparency(a)- Set window opacity (0–1)
|
|
23
|
+
* window.setIcon(path) - Set the window icon
|
|
24
|
+
* window.getSize() - Get current size
|
|
25
|
+
* window.getPosition() - Get current position
|
|
26
|
+
* window.getRect() - Get position + size together
|
|
27
|
+
* window.getState() - Get full window state
|
|
28
|
+
* window.isMaximized() - Check if maximized
|
|
29
|
+
* window.isMinimized() - Check if minimized
|
|
30
|
+
* window.isVisible() - Check if visible
|
|
31
|
+
*
|
|
32
|
+
* Events:
|
|
33
|
+
* window.onResize(cb) - Fires when window is resized
|
|
34
|
+
* window.onMove(cb) - Fires when window is moved
|
|
35
|
+
* window.onClose(cb) - Fires when window is closed
|
|
36
|
+
* window.onFocus(cb) - Fires when focus changes
|
|
37
|
+
* window.onStateChange(cb)- Fires on any state change
|
|
38
|
+
* window.onMinimize(cb) - Fires when minimized
|
|
39
|
+
* window.onMaximize(cb) - Fires when maximized
|
|
40
|
+
* window.onRestore(cb) - Fires when restored
|
|
41
|
+
* window.onFileDrop(cb) - Fires when files are dropped onto window
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
export type {
|
|
45
|
+
WindowSize,
|
|
46
|
+
WindowPosition,
|
|
47
|
+
WindowRect,
|
|
48
|
+
WindowState,
|
|
49
|
+
WindowId,
|
|
50
|
+
} from '../Window/window';
|
|
51
|
+
|
|
52
|
+
export { window } from '../Window/window';
|
package/Core/Features/App/app.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* App API - Application lifecycle
|
|
3
|
-
*
|
|
4
|
-
* Direct method calls - no .on/.emit
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* import { app } from '@plusui/api';
|
|
8
|
-
*
|
|
9
|
-
* app.quit();
|
|
10
|
-
* app.onReady(() => { ... });
|
|
11
|
-
* app.onQuit(() => { ... });
|
|
12
|
-
*/
|
|
1
|
+
import { plusui } from "@plusui";
|
|
13
2
|
|
|
14
3
|
export interface AppConfig {
|
|
15
4
|
title?: string;
|
|
@@ -91,7 +80,7 @@ async function invoke<T = unknown>(name: string, args?: unknown[], options: Invo
|
|
|
91
80
|
|
|
92
81
|
function eventHandler(event: string, callback: (...args: unknown[]) => void): () => void {
|
|
93
82
|
init();
|
|
94
|
-
|
|
83
|
+
|
|
95
84
|
if (!_event) {
|
|
96
85
|
if (typeof window !== 'undefined' && (window as any).__on__) {
|
|
97
86
|
_event = (window as any).__on__;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { plusui } from "@plusui";
|
|
2
2
|
|
|
3
3
|
export interface BrowserState {
|
|
4
4
|
url: string;
|
|
@@ -24,7 +24,8 @@ async function invoke(method: string, args?: unknown[]): Promise<unknown> {
|
|
|
24
24
|
if (typeof window !== 'undefined' && (window as any).__invoke__) {
|
|
25
25
|
_invoke = (window as any).__invoke__;
|
|
26
26
|
} else {
|
|
27
|
-
|
|
27
|
+
console.warn(`[PlusUI] Browser API not initialized: __invoke__ missing. Running in mock mode for '${method}'.`);
|
|
28
|
+
return Promise.resolve(null);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
return _invoke!(method, args);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#include <plusui/router.hpp>
|
|
2
|
+
|
|
3
|
+
namespace plusui {
|
|
4
|
+
|
|
5
|
+
struct Router::Impl {
|
|
6
|
+
std::map<std::string, std::string> routes;
|
|
7
|
+
std::string initialRoute = "/";
|
|
8
|
+
std::map<std::string, std::string> currentRoutes;
|
|
9
|
+
std::vector<RouteChangeCallback> callbacks;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
Router::Router() : pImpl(std::make_unique<Impl>()) {}
|
|
13
|
+
Router::~Router() = default;
|
|
14
|
+
|
|
15
|
+
Router& Router::instance() {
|
|
16
|
+
static Router router;
|
|
17
|
+
return router;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void Router::setRoutes(const std::map<std::string, std::string>& routes) {
|
|
21
|
+
pImpl->routes = routes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::map<std::string, std::string> Router::getRoutes() const {
|
|
25
|
+
return pImpl->routes;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void Router::push(const std::string& route, const std::string& windowId) {
|
|
29
|
+
std::string wid = windowId.empty() ? "__main__" : windowId;
|
|
30
|
+
pImpl->currentRoutes[wid] = route;
|
|
31
|
+
for (auto& cb : pImpl->callbacks) {
|
|
32
|
+
cb(route, wid);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void Router::replace(const std::string& route, const std::string& windowId) {
|
|
37
|
+
std::string wid = windowId.empty() ? "__main__" : windowId;
|
|
38
|
+
pImpl->currentRoutes[wid] = route;
|
|
39
|
+
for (auto& cb : pImpl->callbacks) {
|
|
40
|
+
cb(route, wid);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::string Router::getCurrentRoute(const std::string& windowId) const {
|
|
45
|
+
std::string wid = windowId.empty() ? "__main__" : windowId;
|
|
46
|
+
auto it = pImpl->currentRoutes.find(wid);
|
|
47
|
+
if (it != pImpl->currentRoutes.end()) {
|
|
48
|
+
return it->second;
|
|
49
|
+
}
|
|
50
|
+
return pImpl->initialRoute;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void Router::setInitialRoute(const std::string& route) {
|
|
54
|
+
pImpl->initialRoute = route;
|
|
55
|
+
pImpl->currentRoutes["__main__"] = route;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void Router::onRouteChange(RouteChangeCallback callback) {
|
|
59
|
+
pImpl->callbacks.push_back(std::move(callback));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
} // namespace plusui
|
|
@@ -33,7 +33,8 @@ async function invoke(method: string, args?: unknown[]): Promise<unknown> {
|
|
|
33
33
|
if (typeof window !== 'undefined' && (window as any).__invoke__) {
|
|
34
34
|
_invoke = (window as any).__invoke__;
|
|
35
35
|
} else {
|
|
36
|
-
|
|
36
|
+
console.warn(`[PlusUI] Router API not initialized: __invoke__ missing. Running in mock mode for '${method}'.`);
|
|
37
|
+
return Promise.resolve(null);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
return _invoke!(method, args);
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PlusUI C++ API
|
|
5
|
+
*
|
|
6
|
+
* Mirrors: Core/Features/API/index.ts
|
|
7
|
+
*
|
|
8
|
+
* ONE INCLUDE. ALL FEATURES.
|
|
9
|
+
*
|
|
10
|
+
* #include <plusui/plusui> // get everything
|
|
11
|
+
* using namespace plusui;
|
|
12
|
+
*
|
|
13
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
14
|
+
* FEATURE MAP (C++ class ↔ TypeScript object)
|
|
15
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
*
|
|
17
|
+
* TypeScript C++ class / accessor Header
|
|
18
|
+
* ─────────────────── ────────────────────────── ──────────────────
|
|
19
|
+
* window Window window.hpp
|
|
20
|
+
* app / createApp() App, App::Builder app.hpp
|
|
21
|
+
* browser Browser browser.hpp
|
|
22
|
+
* clipboard Clipboard clipboard.hpp
|
|
23
|
+
* keyboard Keyboard keyboard.hpp
|
|
24
|
+
* tray TrayManager tray.hpp
|
|
25
|
+
* display DisplayManager display.hpp
|
|
26
|
+
* menu MenuManager menu.hpp
|
|
27
|
+
* router Router router.hpp
|
|
28
|
+
* fileDrop FileDrop filedrop.hpp
|
|
29
|
+
* gpu WebGPU webgpu.hpp
|
|
30
|
+
* connect Connect connect.hpp
|
|
31
|
+
*
|
|
32
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
* FRONTEND ↔ BACKEND MIRROR
|
|
34
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
35
|
+
*
|
|
36
|
+
* IMPORT / INCLUDE
|
|
37
|
+
* TS: import plusui from 'plusui'
|
|
38
|
+
* C++: #include <plusui/plusui>
|
|
39
|
+
* using namespace plusui;
|
|
40
|
+
*
|
|
41
|
+
* ── WINDOW ───────────────────────────────────────────────────────────────────
|
|
42
|
+
* Actions
|
|
43
|
+
* TS: window.show() C++: win.show()
|
|
44
|
+
* TS: window.hide() C++: win.hide()
|
|
45
|
+
* TS: window.minimize() C++: win.minimize()
|
|
46
|
+
* TS: window.maximize() C++: win.maximize()
|
|
47
|
+
* TS: window.restore() C++: win.restore()
|
|
48
|
+
* TS: window.close() C++: win.close()
|
|
49
|
+
* TS: window.center() C++: win.center()
|
|
50
|
+
* TS: window.focus() C++: win.focus()
|
|
51
|
+
* TS: window.setTitle("My App") C++: win.setTitle("My App")
|
|
52
|
+
* TS: window.setSize(800, 600) C++: win.setSize(800, 600)
|
|
53
|
+
* TS: window.setPosition(100, 100) C++: win.setPosition(100, 100)
|
|
54
|
+
* TS: window.setFullscreen(true) C++: win.setFullscreen(true)
|
|
55
|
+
* TS: window.setAlwaysOnTop(true) C++: win.setAlwaysOnTop(true)
|
|
56
|
+
* TS: window.setResizable(false) C++: win.setResizable(false)
|
|
57
|
+
* TS: window.setDecorations(false) C++: win.setDecorations(false)
|
|
58
|
+
* TS: window.setTransparency(0.5) C++: win.setOpacity(0.5)
|
|
59
|
+
* TS: window.setIcon(path) C++: win.setIconFromMemory(data, size)
|
|
60
|
+
* TS: window.isMaximized() C++: win.isMaximized()
|
|
61
|
+
* TS: window.isMinimized() C++: win.isMinimized()
|
|
62
|
+
* TS: window.isVisible() C++: win.isVisible()
|
|
63
|
+
* Events
|
|
64
|
+
* TS: window.onResize(cb) C++: win.onResize(cb)
|
|
65
|
+
* TS: window.onMove(cb) C++: win.onMove(cb)
|
|
66
|
+
* TS: window.onClose(cb) C++: win.onClose(cb)
|
|
67
|
+
* TS: window.onFocus(cb) C++: win.onFocus(cb)
|
|
68
|
+
* TS: window.onStateChange(cb) C++: win.onStateChange(cb)
|
|
69
|
+
* TS: window.onFileDrop(cb) C++: win.onFileDrop(cb)
|
|
70
|
+
*
|
|
71
|
+
* ── APP ──────────────────────────────────────────────────────────────────────
|
|
72
|
+
* TS: createApp() C++: createApp()
|
|
73
|
+
* .title("My App") .title("My App")
|
|
74
|
+
* .width(1200) .width(1200)
|
|
75
|
+
* .height(800) .height(800)
|
|
76
|
+
* .devtools(true) .devtools(true)
|
|
77
|
+
* .enableFileDrop(true); .enableFileDrop(true)
|
|
78
|
+
* .build() ← returns Window
|
|
79
|
+
* TS: app.quit() C++: app.quit()
|
|
80
|
+
* TS: app.onReady(cb) C++: (start after build())
|
|
81
|
+
* TS: app.onQuit(cb) C++: app.run() ← blocks until quit
|
|
82
|
+
*
|
|
83
|
+
* ── ROUTER ───────────────────────────────────────────────────────────────────
|
|
84
|
+
* TS: router.setRoutes({'/': url}) C++: Router::instance().setRoutes({...})
|
|
85
|
+
* TS: router.push("/settings") C++: Router::instance().push("/settings")
|
|
86
|
+
* TS: router.replace("/settings") C++: Router::instance().replace("/settings")
|
|
87
|
+
* TS: router.getCurrentRoute() C++: Router::instance().getCurrentRoute()
|
|
88
|
+
* TS: router.setInitialRoute("/") C++: Router::instance().setInitialRoute("/")
|
|
89
|
+
* TS: router.onRouteChange(cb) C++: Router::instance().onRouteChange(cb)
|
|
90
|
+
*
|
|
91
|
+
* ── BROWSER (WebView navigation) ─────────────────────────────────────────────
|
|
92
|
+
* TS: browser.navigate(url) C++: browser.navigate(url)
|
|
93
|
+
* TS: browser.open(url) C++: browser.navigate(url)
|
|
94
|
+
* TS: browser.openExternal(url) C++: browser.openExternal(url)
|
|
95
|
+
* TS: browser.openNewWindow(url) C++: browser.openNewWindow(url)
|
|
96
|
+
* TS: browser.goBack() C++: browser.goBack()
|
|
97
|
+
* TS: browser.goForward() C++: browser.goForward()
|
|
98
|
+
* TS: browser.reload() C++: browser.reload()
|
|
99
|
+
* TS: browser.stop() C++: browser.stop()
|
|
100
|
+
* TS: browser.getUrl() C++: browser.getURL()
|
|
101
|
+
* TS: browser.getTitle() C++: browser.getTitle()
|
|
102
|
+
* TS: browser.getState() C++: browser.getState()
|
|
103
|
+
* TS: browser.canGoBack() C++: browser.canGoBack()
|
|
104
|
+
* TS: browser.canGoForward() C++: browser.canGoForward()
|
|
105
|
+
* TS: browser.isLoading() C++: browser.isLoading()
|
|
106
|
+
* Events
|
|
107
|
+
* TS: browser.onNavigate(cb) C++: browser.onNavigate(cb)
|
|
108
|
+
* TS: browser.onStateChange(cb) C++: browser.onStateChange(cb)
|
|
109
|
+
* TS: browser.onLoadStart(cb) C++: browser.onLoadStart(cb)
|
|
110
|
+
* TS: browser.onLoadEnd(cb) C++: browser.onLoadEnd(cb)
|
|
111
|
+
* TS: browser.onLoadError(cb) C++: browser.onLoadError(cb)
|
|
112
|
+
*
|
|
113
|
+
* ── CLIPBOARD ────────────────────────────────────────────────────────────────
|
|
114
|
+
* TS: clipboard.getText() C++: Clipboard::getText()
|
|
115
|
+
* TS: clipboard.setText("hello") C++: Clipboard::setText("hello")
|
|
116
|
+
* TS: clipboard.hasText() C++: Clipboard::hasText()
|
|
117
|
+
* TS: clipboard.getImage() C++: Clipboard::getImage()
|
|
118
|
+
* TS: clipboard.setImage(b64) C++: Clipboard::setImage(b64)
|
|
119
|
+
* TS: clipboard.hasImage() C++: Clipboard::hasImage()
|
|
120
|
+
* TS: clipboard.clear() C++: Clipboard::clear()
|
|
121
|
+
* TS: clipboard.onChange(cb) C++: Clipboard::instance().onChange(cb)
|
|
122
|
+
*
|
|
123
|
+
* ── KEYBOARD ─────────────────────────────────────────────────────────────────
|
|
124
|
+
* TS: keyboard.isKeyPressed(key) C++: Keyboard::instance().isKeyPressed(key)
|
|
125
|
+
* TS: keyboard.registerShortcut(...) C++: Keyboard::instance().registerShortcut(...)
|
|
126
|
+
* TS: keyboard.unregisterShortcut(id) C++: Keyboard::instance().unregisterShortcut(id)
|
|
127
|
+
* TS: keyboard.clearShortcuts() C++: Keyboard::instance().clearShortcuts()
|
|
128
|
+
* TS: keyboard.onKeyDown(cb) C++: Keyboard::instance().onKeyDown(cb)
|
|
129
|
+
* TS: keyboard.onKeyUp(cb) C++: Keyboard::instance().onKeyUp(cb)
|
|
130
|
+
* TS: keyboard.onShortcut(cb) C++: Keyboard::instance().onShortcut(cb)
|
|
131
|
+
*
|
|
132
|
+
* ── TRAY ─────────────────────────────────────────────────────────────────────
|
|
133
|
+
* TS: tray.setIcon(path) C++: win.tray().setIcon(path)
|
|
134
|
+
* TS: tray.setTooltip(text) C++: win.tray().setTooltip(text)
|
|
135
|
+
* TS: tray.setVisible(true) C++: win.tray().setVisible(true)
|
|
136
|
+
* TS: tray.setMenu(items) C++: win.tray().setMenu(items)
|
|
137
|
+
* TS: tray.setContextMenu(items) C++: win.tray().setContextMenu(items)
|
|
138
|
+
* TS: tray.onClick(cb) C++: win.tray().onClick(cb)
|
|
139
|
+
* TS: tray.onDoubleClick(cb) C++: win.tray().onDoubleClick(cb)
|
|
140
|
+
* TS: tray.onRightClick(cb) C++: win.tray().onRightClick(cb)
|
|
141
|
+
* TS: tray.onMenuItemClick(cb) C++: win.tray().onMenuItemClick(cb)
|
|
142
|
+
*
|
|
143
|
+
* ── DISPLAY ──────────────────────────────────────────────────────────────────
|
|
144
|
+
* TS: display.getAllDisplays() C++: DisplayManager::instance().getAllDisplays()
|
|
145
|
+
* TS: display.getPrimaryDisplay() C++: DisplayManager::instance().getPrimary()
|
|
146
|
+
* TS: display.getDisplayAt(x, y) C++: DisplayManager::instance().getAt(x, y)
|
|
147
|
+
* TS: display.getScreenWidth() C++: DisplayManager::instance().getScreenWidth()
|
|
148
|
+
* TS: display.getScreenHeight() C++: DisplayManager::instance().getScreenHeight()
|
|
149
|
+
* TS: display.onConnected(cb) C++: DisplayManager::instance().onConnected(cb)
|
|
150
|
+
* TS: display.onDisconnected(cb) C++: DisplayManager::instance().onDisconnected(cb)
|
|
151
|
+
* TS: display.onChanged(cb) C++: DisplayManager::instance().onChanged(cb)
|
|
152
|
+
*
|
|
153
|
+
* ── MENU ─────────────────────────────────────────────────────────────────────
|
|
154
|
+
* TS: menu.create(items) C++: MenuManager::instance().create(items)
|
|
155
|
+
* TS: menu.popup(id, x, y) C++: MenuManager::instance().popup(id, x, y)
|
|
156
|
+
* TS: menu.setApplicationMenu(items) C++: MenuManager::instance().setApplicationMenu(items)
|
|
157
|
+
* TS: menu.showContextMenu(items) C++: MenuManager::instance().showContextMenu(items)
|
|
158
|
+
* TS: menu.onItemClick(cb) C++: MenuManager::instance().onItemClick(cb)
|
|
159
|
+
* TS: menu.onContextOpen(cb) C++: MenuManager::instance().onContextOpen(cb)
|
|
160
|
+
*
|
|
161
|
+
* ── FILEDROP ─────────────────────────────────────────────────────────────────
|
|
162
|
+
* TS: fileDrop.setEnabled(true) C++: FileDrop::instance().setEnabled(true)
|
|
163
|
+
* TS: fileDrop.startDrag(paths) C++: FileDrop::instance().startDrag(paths)
|
|
164
|
+
* TS: fileDrop.onFilesDropped(cb) C++: FileDrop::instance().onFilesDropped(cb)
|
|
165
|
+
* TS: fileDrop.onDragEnter(cb) C++: FileDrop::instance().onDragEnter(cb)
|
|
166
|
+
* TS: fileDrop.onDragLeave(cb) C++: FileDrop::instance().onDragLeave(cb)
|
|
167
|
+
*
|
|
168
|
+
* ── GPU (WebGPU) ──────────────────────────────────────────────────────────────
|
|
169
|
+
* TS: gpu.requestAdapter() C++: WebGPU::instance().requestAdapter()
|
|
170
|
+
* TS: gpu.getPreferredCanvasFormat() C++: WebGPU::instance().getPreferredCanvasFormat()
|
|
171
|
+
* TS: gpu.onAdapterLost(cb) C++: WebGPU::instance().onAdapterLost(cb)
|
|
172
|
+
* TS: gpu.onDeviceLost(cb) C++: WebGPU::instance().onDeviceLost(cb)
|
|
173
|
+
* TS: gpu.onError(cb) C++: WebGPU::instance().onError(cb)
|
|
174
|
+
*
|
|
175
|
+
* ── CONNECT (custom bidirectional channels) ───────────────────────────────────
|
|
176
|
+
* TS: connect.emit("name", data) C++: connect.emit("name", {{"key", val}})
|
|
177
|
+
* TS: connect.on("name", cb) C++: connect.on("name", cb)
|
|
178
|
+
* TS: connect.on("name", cb) C++: connect.on("name", [](const json& d){ ... })
|
|
179
|
+
* TS: createChannel("name") C++: connect.channel("name")
|
|
180
|
+
* TS: createFeatureConnect("scope") C++: connect.feature("scope")
|
|
181
|
+
* TS: handleMessage override C++: override handleMessage(name, data)
|
|
182
|
+
*
|
|
183
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
184
|
+
* USAGE EXAMPLE
|
|
185
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
186
|
+
*
|
|
187
|
+
* #include <plusui/plusui>
|
|
188
|
+
* using namespace plusui;
|
|
189
|
+
*
|
|
190
|
+
* class MyApp : public Connect {
|
|
191
|
+
* protected:
|
|
192
|
+
* void handleMessage(const std::string& name, const nlohmann::json& data) override {
|
|
193
|
+
* if (name == "greet") {
|
|
194
|
+
* emit("greeting", {{"message", "Hello " + data["name"].get<std::string>()}});
|
|
195
|
+
* }
|
|
196
|
+
* }
|
|
197
|
+
* };
|
|
198
|
+
*
|
|
199
|
+
* int main() {
|
|
200
|
+
* auto win = createApp()
|
|
201
|
+
* .title("My App")
|
|
202
|
+
* .width(1200)
|
|
203
|
+
* .height(800)
|
|
204
|
+
* .enableFileDrop(true)
|
|
205
|
+
* .build();
|
|
206
|
+
*
|
|
207
|
+
* MyApp connect;
|
|
208
|
+
* bindConnect(win, connect);
|
|
209
|
+
*
|
|
210
|
+
* win.loadURL("http://localhost:5173");
|
|
211
|
+
*
|
|
212
|
+
* win.onClose([]{ app.quit(); });
|
|
213
|
+
* win.tray().setIcon("icon.png");
|
|
214
|
+
* win.tray().onClick([&](int, int){ win.show(); });
|
|
215
|
+
*
|
|
216
|
+
* Router::instance().setRoutes({{"/", "http://localhost:5173"}});
|
|
217
|
+
* Router::instance().push("/");
|
|
218
|
+
*
|
|
219
|
+
* app.run();
|
|
220
|
+
* }
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
// ─── Feature Headers ──────────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
#include <plusui/app.hpp>
|
|
226
|
+
#include <plusui/browser.hpp>
|
|
227
|
+
#include <plusui/clipboard.hpp>
|
|
228
|
+
#include <plusui/connect.hpp>
|
|
229
|
+
#include <plusui/connection.hpp>
|
|
230
|
+
#include <plusui/display.hpp>
|
|
231
|
+
#include <plusui/filedrop.hpp>
|
|
232
|
+
#include <plusui/keyboard.hpp>
|
|
233
|
+
#include <plusui/menu.hpp>
|
|
234
|
+
#include <plusui/router.hpp>
|
|
235
|
+
#include <plusui/tray.hpp>
|
|
236
|
+
#include <plusui/webgpu.hpp>
|
|
237
|
+
#include <plusui/window.hpp>
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* the specific headers you need instead of this convenience header.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
#include <plusui/api.hpp>
|
|
25
26
|
#include <plusui/app.hpp>
|
|
26
27
|
#include <plusui/browser.hpp>
|
|
27
28
|
#include <plusui/clipboard.hpp>
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
#include <plusui/filedrop.hpp>
|
|
32
33
|
#include <plusui/keyboard.hpp>
|
|
33
34
|
#include <plusui/menu.hpp>
|
|
35
|
+
#include <plusui/router.hpp>
|
|
34
36
|
#include <plusui/tray.hpp>
|
|
35
37
|
#include <plusui/webgpu.hpp>
|
|
36
38
|
#include <plusui/window.hpp>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#ifndef PLUSUI_ROUTER_H
|
|
2
|
+
#define PLUSUI_ROUTER_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace plusui {
|
|
11
|
+
|
|
12
|
+
class Router {
|
|
13
|
+
public:
|
|
14
|
+
Router();
|
|
15
|
+
~Router();
|
|
16
|
+
|
|
17
|
+
static Router& instance();
|
|
18
|
+
|
|
19
|
+
void setRoutes(const std::map<std::string, std::string>& routes);
|
|
20
|
+
std::map<std::string, std::string> getRoutes() const;
|
|
21
|
+
|
|
22
|
+
void push(const std::string& route, const std::string& windowId = "");
|
|
23
|
+
void replace(const std::string& route, const std::string& windowId = "");
|
|
24
|
+
|
|
25
|
+
std::string getCurrentRoute(const std::string& windowId = "") const;
|
|
26
|
+
void setInitialRoute(const std::string& route);
|
|
27
|
+
|
|
28
|
+
using RouteChangeCallback = std::function<void(const std::string& route, const std::string& windowId)>;
|
|
29
|
+
void onRouteChange(RouteChangeCallback callback);
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
struct Impl;
|
|
33
|
+
std::unique_ptr<Impl> pImpl;
|
|
34
|
+
|
|
35
|
+
// Prevent copying
|
|
36
|
+
Router(const Router&) = delete;
|
|
37
|
+
Router& operator=(const Router&) = delete;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace plusui
|
|
41
|
+
|
|
42
|
+
#endif // PLUSUI_ROUTER_H
|