plusui-native-core 0.1.0
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 +34 -0
- package/Core/README.md +29 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj +185 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj.filters +8 -0
- package/Core/build/win32/x64/CMakeCache.txt +335 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/INSTALL_force.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/generate.stamp.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeCXXCompiler.cmake +104 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeRCCompiler.cmake +6 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeSystem.cmake +15 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.vcxproj +72 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +4 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/Cl.items.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +22 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.secondary.1.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.txt +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.vcxproj +31 -0
- package/Core/build/win32/x64/CMakeFiles/CMakeConfigureLog.yaml +2698 -0
- package/Core/build/win32/x64/CMakeFiles/InstallScripts.json +7 -0
- package/Core/build/win32/x64/CMakeFiles/TargetDirectories.txt +4 -0
- package/Core/build/win32/x64/CMakeFiles/cmake.check_cache +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.depend +34 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.list +1 -0
- package/Core/build/win32/x64/Capsule.sln +67 -0
- package/Core/build/win32/x64/INSTALL.vcxproj +209 -0
- package/Core/build/win32/x64/INSTALL.vcxproj.filters +13 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj +179 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj.filters +13 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.read.1.tlog +33 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/capsule.lastbuildstate +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/unsuccessfulbuild +0 -0
- package/Core/build/win32/x64/capsule.vcxproj +332 -0
- package/Core/build/win32/x64/capsule.vcxproj.filters +25 -0
- package/Core/build/win32/x64/cmake_install.cmake +72 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +11 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +34 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +2 -0
- package/Core/include/app.hpp +121 -0
- package/Core/include/display.hpp +90 -0
- package/Core/include/keyboard.hpp +135 -0
- package/Core/include/menu.hpp +79 -0
- package/Core/include/tray.hpp +81 -0
- package/Core/include/window.hpp +106 -0
- package/Core/src/app.cpp +311 -0
- package/Core/src/display.cpp +424 -0
- package/Core/src/tray.cpp +275 -0
- package/Core/src/window.cpp +528 -0
- package/Core/vendor/webview.h +551 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +198 -0
- package/package.json +19 -0
- package/src/index.ts +574 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export interface WindowSize {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface WindowPosition {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WindowRect {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
export type WindowId = string;
|
|
16
|
+
export declare const win: {
|
|
17
|
+
minimize: (id?: WindowId) => Promise<unknown>;
|
|
18
|
+
maximize: (id?: WindowId) => Promise<unknown>;
|
|
19
|
+
restore: (id?: WindowId) => Promise<unknown>;
|
|
20
|
+
close: (id?: WindowId) => Promise<unknown>;
|
|
21
|
+
show: (id?: WindowId) => Promise<unknown>;
|
|
22
|
+
hide: (id?: WindowId) => Promise<unknown>;
|
|
23
|
+
center: (id?: WindowId) => Promise<unknown>;
|
|
24
|
+
setSize: (w: number, h: number, id?: WindowId) => Promise<unknown>;
|
|
25
|
+
setPosition: (x: number, y: number, id?: WindowId) => Promise<unknown>;
|
|
26
|
+
getSize: (id?: WindowId) => Promise<WindowSize>;
|
|
27
|
+
getPosition: (id?: WindowId) => Promise<WindowPosition>;
|
|
28
|
+
setTitle: (title: string, id?: WindowId) => Promise<unknown>;
|
|
29
|
+
setFullscreen: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
30
|
+
setAlwaysOnTop: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
31
|
+
setResizable: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
32
|
+
setDecorations: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
33
|
+
setTransparency: (alpha: number, id?: WindowId) => Promise<unknown>;
|
|
34
|
+
isMaximized: (id?: WindowId) => Promise<boolean>;
|
|
35
|
+
isMinimized: (id?: WindowId) => Promise<boolean>;
|
|
36
|
+
isVisible: (id?: WindowId) => Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
export declare const tray: {
|
|
39
|
+
setIcon: (iconPath: string) => Promise<unknown>;
|
|
40
|
+
setTooltip: (tooltip: string) => Promise<unknown>;
|
|
41
|
+
setVisible: (visible: boolean) => Promise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
export declare const app: {
|
|
44
|
+
quit: () => Promise<unknown>;
|
|
45
|
+
invoke: (method: string, args?: unknown[]) => Promise<unknown>;
|
|
46
|
+
};
|
|
47
|
+
export interface Display {
|
|
48
|
+
id: number;
|
|
49
|
+
name: string;
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
scale: number;
|
|
55
|
+
isPrimary: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare const display: {
|
|
58
|
+
getAll: () => Promise<Display[]>;
|
|
59
|
+
getPrimary: () => Promise<Display>;
|
|
60
|
+
getCurrent: () => Promise<Display>;
|
|
61
|
+
};
|
|
62
|
+
export declare const clipboard: {
|
|
63
|
+
writeText: (text: string) => Promise<unknown>;
|
|
64
|
+
readText: () => Promise<string>;
|
|
65
|
+
writeImage: (base64: string) => Promise<unknown>;
|
|
66
|
+
readImage: () => Promise<string>;
|
|
67
|
+
clear: () => Promise<unknown>;
|
|
68
|
+
};
|
|
69
|
+
export interface GPUAdapter {
|
|
70
|
+
requestDevice(descriptor?: any): Promise<GPUDevice>;
|
|
71
|
+
features: Set<string>;
|
|
72
|
+
limits: Record<string, number>;
|
|
73
|
+
info?: {
|
|
74
|
+
vendor?: string;
|
|
75
|
+
architecture?: string;
|
|
76
|
+
device?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface GPUDevice {
|
|
80
|
+
createBuffer(descriptor: any): any;
|
|
81
|
+
createTexture(descriptor: any): any;
|
|
82
|
+
createShaderModule(descriptor: any): any;
|
|
83
|
+
createRenderPipeline(descriptor: any): any;
|
|
84
|
+
createCommandEncoder(): any;
|
|
85
|
+
queue: {
|
|
86
|
+
submit(commandBuffers: any[]): void;
|
|
87
|
+
writeBuffer(buffer: any, offset: number, data: ArrayBuffer): void;
|
|
88
|
+
};
|
|
89
|
+
destroy(): void;
|
|
90
|
+
}
|
|
91
|
+
export interface GPURequestAdapterOptions {
|
|
92
|
+
powerPreference?: 'low-power' | 'high-performance';
|
|
93
|
+
forceFallbackAdapter?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare const webgpu: {
|
|
96
|
+
requestAdapter: (options?: GPURequestAdapterOptions) => Promise<GPUAdapter | null>;
|
|
97
|
+
getPreferredCanvasFormat: () => string;
|
|
98
|
+
};
|
|
99
|
+
export interface BrowserState {
|
|
100
|
+
url: string;
|
|
101
|
+
title: string;
|
|
102
|
+
canGoBack: boolean;
|
|
103
|
+
canGoForward: boolean;
|
|
104
|
+
isLoading: boolean;
|
|
105
|
+
}
|
|
106
|
+
type NavigateCallback = (url: string) => void;
|
|
107
|
+
type StateCallback = (state: BrowserState) => void;
|
|
108
|
+
export declare const browser: {
|
|
109
|
+
navigate: (url: string) => Promise<unknown>;
|
|
110
|
+
goBack: () => Promise<unknown>;
|
|
111
|
+
goForward: () => Promise<unknown>;
|
|
112
|
+
reload: () => Promise<unknown>;
|
|
113
|
+
stop: () => Promise<unknown>;
|
|
114
|
+
getUrl: () => Promise<string>;
|
|
115
|
+
getTitle: () => Promise<string>;
|
|
116
|
+
getState: () => BrowserState;
|
|
117
|
+
canGoBack: () => Promise<boolean>;
|
|
118
|
+
canGoForward: () => Promise<boolean>;
|
|
119
|
+
onNavigate: (callback: NavigateCallback) => () => void;
|
|
120
|
+
onStateChange: (callback: StateCallback) => () => void;
|
|
121
|
+
};
|
|
122
|
+
export declare const router: {
|
|
123
|
+
setRoutes: (routes: Record<string, string>) => void;
|
|
124
|
+
setInitialRoute: (route: string) => Promise<void>;
|
|
125
|
+
push: (route: string) => Promise<void>;
|
|
126
|
+
replace: (route: string) => Promise<void>;
|
|
127
|
+
getCurrentRoute: () => string;
|
|
128
|
+
getRoutes: () => {
|
|
129
|
+
[x: string]: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
declare const _default: {
|
|
133
|
+
win: {
|
|
134
|
+
minimize: (id?: WindowId) => Promise<unknown>;
|
|
135
|
+
maximize: (id?: WindowId) => Promise<unknown>;
|
|
136
|
+
restore: (id?: WindowId) => Promise<unknown>;
|
|
137
|
+
close: (id?: WindowId) => Promise<unknown>;
|
|
138
|
+
show: (id?: WindowId) => Promise<unknown>;
|
|
139
|
+
hide: (id?: WindowId) => Promise<unknown>;
|
|
140
|
+
center: (id?: WindowId) => Promise<unknown>;
|
|
141
|
+
setSize: (w: number, h: number, id?: WindowId) => Promise<unknown>;
|
|
142
|
+
setPosition: (x: number, y: number, id?: WindowId) => Promise<unknown>;
|
|
143
|
+
getSize: (id?: WindowId) => Promise<WindowSize>;
|
|
144
|
+
getPosition: (id?: WindowId) => Promise<WindowPosition>;
|
|
145
|
+
setTitle: (title: string, id?: WindowId) => Promise<unknown>;
|
|
146
|
+
setFullscreen: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
147
|
+
setAlwaysOnTop: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
148
|
+
setResizable: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
149
|
+
setDecorations: (enabled: boolean, id?: WindowId) => Promise<unknown>;
|
|
150
|
+
setTransparency: (alpha: number, id?: WindowId) => Promise<unknown>;
|
|
151
|
+
isMaximized: (id?: WindowId) => Promise<boolean>;
|
|
152
|
+
isMinimized: (id?: WindowId) => Promise<boolean>;
|
|
153
|
+
isVisible: (id?: WindowId) => Promise<boolean>;
|
|
154
|
+
};
|
|
155
|
+
tray: {
|
|
156
|
+
setIcon: (iconPath: string) => Promise<unknown>;
|
|
157
|
+
setTooltip: (tooltip: string) => Promise<unknown>;
|
|
158
|
+
setVisible: (visible: boolean) => Promise<unknown>;
|
|
159
|
+
};
|
|
160
|
+
app: {
|
|
161
|
+
quit: () => Promise<unknown>;
|
|
162
|
+
invoke: (method: string, args?: unknown[]) => Promise<unknown>;
|
|
163
|
+
};
|
|
164
|
+
display: {
|
|
165
|
+
getAll: () => Promise<Display[]>;
|
|
166
|
+
getPrimary: () => Promise<Display>;
|
|
167
|
+
getCurrent: () => Promise<Display>;
|
|
168
|
+
};
|
|
169
|
+
clipboard: {
|
|
170
|
+
writeText: (text: string) => Promise<unknown>;
|
|
171
|
+
readText: () => Promise<string>;
|
|
172
|
+
writeImage: (base64: string) => Promise<unknown>;
|
|
173
|
+
readImage: () => Promise<string>;
|
|
174
|
+
clear: () => Promise<unknown>;
|
|
175
|
+
};
|
|
176
|
+
webgpu: {
|
|
177
|
+
requestAdapter: (options?: GPURequestAdapterOptions) => Promise<GPUAdapter | null>;
|
|
178
|
+
getPreferredCanvasFormat: () => string;
|
|
179
|
+
};
|
|
180
|
+
browser: {
|
|
181
|
+
navigate: (url: string) => Promise<unknown>;
|
|
182
|
+
goBack: () => Promise<unknown>;
|
|
183
|
+
goForward: () => Promise<unknown>;
|
|
184
|
+
reload: () => Promise<unknown>;
|
|
185
|
+
stop: () => Promise<unknown>;
|
|
186
|
+
getUrl: () => Promise<string>;
|
|
187
|
+
getTitle: () => Promise<string>;
|
|
188
|
+
getState: () => BrowserState;
|
|
189
|
+
canGoBack: () => Promise<boolean>;
|
|
190
|
+
canGoForward: () => Promise<boolean>;
|
|
191
|
+
onNavigate: (callback: NavigateCallback) => () => void;
|
|
192
|
+
onStateChange: (callback: StateCallback) => () => void;
|
|
193
|
+
};
|
|
194
|
+
router: {
|
|
195
|
+
setRoutes: (routes: Record<string, string>) => void;
|
|
196
|
+
setInitialRoute: (route: string) => Promise<void>;
|
|
197
|
+
push: (route: string) => Promise<void>;
|
|
198
|
+
replace: (route: string) => Promise<void>;
|
|
199
|
+
getCurrentRoute: () => string;
|
|
200
|
+
getRoutes: () => {
|
|
201
|
+
[x: string]: string;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// PlusUI Core SDK
|
|
2
|
+
// Matches Core/Features structure - each feature has backend (C++) and frontend (TS)
|
|
3
|
+
let _invoke = null;
|
|
4
|
+
let _pending = {};
|
|
5
|
+
function initBridge() {
|
|
6
|
+
if (typeof window === 'undefined')
|
|
7
|
+
return;
|
|
8
|
+
const w = window;
|
|
9
|
+
if (w.__invoke__) {
|
|
10
|
+
_invoke = w.__invoke__;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
_pending = {};
|
|
14
|
+
w.__pending__ = _pending;
|
|
15
|
+
w.__invoke__ = (method, args) => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const id = Math.random().toString(36).substr(2, 9);
|
|
18
|
+
const request = JSON.stringify({ id, method, params: args || [] });
|
|
19
|
+
_pending[id] = { resolve, reject };
|
|
20
|
+
if (typeof w.__native_invoke__ === 'function') {
|
|
21
|
+
w.__native_invoke__(request);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.warn(`[PlusUI] Native binding not available for: ${method}`);
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
delete _pending[id];
|
|
27
|
+
resolve(null);
|
|
28
|
+
}, 0);
|
|
29
|
+
}
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
if (_pending[id]) {
|
|
32
|
+
delete _pending[id];
|
|
33
|
+
reject(new Error(`${method} timed out`));
|
|
34
|
+
}
|
|
35
|
+
}, 30000);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
w.__response__ = (id, result) => {
|
|
39
|
+
const pending = _pending[id];
|
|
40
|
+
if (pending) {
|
|
41
|
+
pending.resolve(result);
|
|
42
|
+
delete _pending[id];
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
_invoke = w.__invoke__;
|
|
46
|
+
}
|
|
47
|
+
initBridge();
|
|
48
|
+
async function invoke(method, args) {
|
|
49
|
+
if (!_invoke) {
|
|
50
|
+
initBridge();
|
|
51
|
+
if (!_invoke) {
|
|
52
|
+
throw new Error('Bridge not initialized');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _invoke(method, args);
|
|
56
|
+
}
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Window API - Core/Features/Window
|
|
59
|
+
// ============================================================================
|
|
60
|
+
export const win = {
|
|
61
|
+
minimize: async (id) => await invoke('window.minimize', id ? [id] : []),
|
|
62
|
+
maximize: async (id) => await invoke('window.maximize', id ? [id] : []),
|
|
63
|
+
restore: async (id) => await invoke('window.restore', id ? [id] : []),
|
|
64
|
+
close: async (id) => await invoke('window.close', id ? [id] : []),
|
|
65
|
+
show: async (id) => await invoke('window.show', id ? [id] : []),
|
|
66
|
+
hide: async (id) => await invoke('window.hide', id ? [id] : []),
|
|
67
|
+
center: async (id) => await invoke('window.center', id ? [id] : []),
|
|
68
|
+
setSize: async (w, h, id) => await invoke('window.setSize', id ? [w, h, id] : [w, h]),
|
|
69
|
+
setPosition: async (x, y, id) => await invoke('window.setPosition', id ? [x, y, id] : [x, y]),
|
|
70
|
+
getSize: async (id) => await invoke('window.getSize', id ? [id] : []),
|
|
71
|
+
getPosition: async (id) => await invoke('window.getPosition', id ? [id] : []),
|
|
72
|
+
setTitle: async (title, id) => await invoke('window.setTitle', id ? [title, id] : [title]),
|
|
73
|
+
setFullscreen: async (enabled, id) => await invoke('window.setFullscreen', id ? [enabled, id] : [enabled]),
|
|
74
|
+
setAlwaysOnTop: async (enabled, id) => await invoke('window.setAlwaysOnTop', id ? [enabled, id] : [enabled]),
|
|
75
|
+
setResizable: async (enabled, id) => await invoke('window.setResizable', id ? [enabled, id] : [enabled]),
|
|
76
|
+
setDecorations: async (enabled, id) => await invoke('window.setDecorations', id ? [enabled, id] : [enabled]),
|
|
77
|
+
setTransparency: async (alpha, id) => await invoke('window.setTransparency', id ? [alpha, id] : [alpha]),
|
|
78
|
+
isMaximized: async (id) => await invoke('window.isMaximized', id ? [id] : []),
|
|
79
|
+
isMinimized: async (id) => await invoke('window.isMinimized', id ? [id] : []),
|
|
80
|
+
isVisible: async (id) => await invoke('window.isVisible', id ? [id] : []),
|
|
81
|
+
};
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// Tray API - Core/Features/Tray
|
|
84
|
+
// ============================================================================
|
|
85
|
+
export const tray = {
|
|
86
|
+
setIcon: async (iconPath) => await invoke('tray.setIcon', [iconPath]),
|
|
87
|
+
setTooltip: async (tooltip) => await invoke('tray.setTooltip', [tooltip]),
|
|
88
|
+
setVisible: async (visible) => await invoke('tray.setVisible', [visible]),
|
|
89
|
+
};
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// App API - Core/Features/App
|
|
92
|
+
// ============================================================================
|
|
93
|
+
export const app = {
|
|
94
|
+
quit: async () => await invoke('app.quit', []),
|
|
95
|
+
invoke: async (method, args) => await invoke(method, args),
|
|
96
|
+
};
|
|
97
|
+
export const display = {
|
|
98
|
+
getAll: async () => await invoke('display.getAll', []),
|
|
99
|
+
getPrimary: async () => await invoke('display.getPrimary', []),
|
|
100
|
+
getCurrent: async () => await invoke('display.getCurrent', []),
|
|
101
|
+
};
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Clipboard API - Core/Features/Clipboard
|
|
104
|
+
// ============================================================================
|
|
105
|
+
export const clipboard = {
|
|
106
|
+
writeText: async (text) => await invoke('clipboard.writeText', [text]),
|
|
107
|
+
readText: async () => await invoke('clipboard.readText', []),
|
|
108
|
+
writeImage: async (base64) => await invoke('clipboard.writeImage', [base64]),
|
|
109
|
+
readImage: async () => await invoke('clipboard.readImage', []),
|
|
110
|
+
clear: async () => await invoke('clipboard.clear', []),
|
|
111
|
+
};
|
|
112
|
+
export const webgpu = {
|
|
113
|
+
requestAdapter: async (options) => {
|
|
114
|
+
const result = await invoke('webgpu.requestAdapter', [options || {}]);
|
|
115
|
+
return result;
|
|
116
|
+
},
|
|
117
|
+
getPreferredCanvasFormat: () => 'bgra8unorm',
|
|
118
|
+
};
|
|
119
|
+
// Initialize navigator.gpu polyfill if not already present
|
|
120
|
+
if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
|
|
121
|
+
const nav = window.navigator;
|
|
122
|
+
if (!nav.gpu) {
|
|
123
|
+
nav.gpu = {
|
|
124
|
+
requestAdapter: webgpu.requestAdapter,
|
|
125
|
+
getPreferredCanvasFormat: webgpu.getPreferredCanvasFormat,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const _navigateCallbacks = [];
|
|
130
|
+
const _stateCallbacks = [];
|
|
131
|
+
let _currentState = { url: '', title: '', canGoBack: false, canGoForward: false, isLoading: false };
|
|
132
|
+
// Listen for navigation events from backend
|
|
133
|
+
if (typeof window !== 'undefined') {
|
|
134
|
+
window.__onNavigate__ = (url) => {
|
|
135
|
+
_currentState.url = url;
|
|
136
|
+
_navigateCallbacks.forEach(cb => cb(url));
|
|
137
|
+
};
|
|
138
|
+
window.__onBrowserState__ = (state) => {
|
|
139
|
+
_currentState = state;
|
|
140
|
+
_stateCallbacks.forEach(cb => cb(state));
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export const browser = {
|
|
144
|
+
navigate: async (url) => await invoke('browser.navigate', [url]),
|
|
145
|
+
goBack: async () => await invoke('browser.goBack', []),
|
|
146
|
+
goForward: async () => await invoke('browser.goForward', []),
|
|
147
|
+
reload: async () => await invoke('browser.reload', []),
|
|
148
|
+
stop: async () => await invoke('browser.stop', []),
|
|
149
|
+
getUrl: async () => await invoke('browser.getUrl', []),
|
|
150
|
+
getTitle: async () => await invoke('browser.getTitle', []),
|
|
151
|
+
getState: () => _currentState,
|
|
152
|
+
canGoBack: async () => await invoke('browser.canGoBack', []),
|
|
153
|
+
canGoForward: async () => await invoke('browser.canGoForward', []),
|
|
154
|
+
onNavigate: (callback) => {
|
|
155
|
+
_navigateCallbacks.push(callback);
|
|
156
|
+
return () => {
|
|
157
|
+
const idx = _navigateCallbacks.indexOf(callback);
|
|
158
|
+
if (idx > -1)
|
|
159
|
+
_navigateCallbacks.splice(idx, 1);
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
onStateChange: (callback) => {
|
|
163
|
+
_stateCallbacks.push(callback);
|
|
164
|
+
return () => {
|
|
165
|
+
const idx = _stateCallbacks.indexOf(callback);
|
|
166
|
+
if (idx > -1)
|
|
167
|
+
_stateCallbacks.splice(idx, 1);
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Router API - Simple window routing for SPAs
|
|
173
|
+
// ============================================================================
|
|
174
|
+
let _routes = {};
|
|
175
|
+
let _currentRoute = '/';
|
|
176
|
+
export const router = {
|
|
177
|
+
setRoutes: (routes) => {
|
|
178
|
+
_routes = routes;
|
|
179
|
+
},
|
|
180
|
+
setInitialRoute: async (route) => {
|
|
181
|
+
_currentRoute = route;
|
|
182
|
+
const url = _routes[route] || route;
|
|
183
|
+
await browser.navigate(url);
|
|
184
|
+
},
|
|
185
|
+
push: async (route) => {
|
|
186
|
+
_currentRoute = route;
|
|
187
|
+
const url = _routes[route] || route;
|
|
188
|
+
await browser.navigate(url);
|
|
189
|
+
},
|
|
190
|
+
replace: async (route) => {
|
|
191
|
+
_currentRoute = route;
|
|
192
|
+
const url = _routes[route] || route;
|
|
193
|
+
await browser.navigate(url);
|
|
194
|
+
},
|
|
195
|
+
getCurrentRoute: () => _currentRoute,
|
|
196
|
+
getRoutes: () => ({ ..._routes }),
|
|
197
|
+
};
|
|
198
|
+
export default { win, tray, app, display, clipboard, webgpu, browser, router };
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plusui-native-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PlusUI TypeScript SDK for C++ desktop apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"Core",
|
|
10
|
+
"dist",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"watch": "tsc --watch"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["desktop", "cpp", "webview", "gui"],
|
|
18
|
+
"license": "MIT"
|
|
19
|
+
}
|