plusui-native-core 0.1.4 → 0.1.7
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 +190 -7
- package/Core/Features/App/app.cpp +129 -0
- package/Core/Features/App/app.ts +126 -0
- package/Core/Features/Browser/browser.cpp +181 -0
- package/Core/Features/Browser/browser.ts +182 -0
- package/Core/Features/Clipboard/clipboard.cpp +234 -0
- package/Core/Features/Clipboard/clipboard.ts +113 -0
- package/Core/Features/Display/display.cpp +209 -0
- package/Core/Features/Display/display.ts +104 -0
- package/Core/Features/Event/Events.ts +166 -0
- package/Core/Features/Event/events.cpp +200 -0
- package/Core/Features/Keyboard/keyboard.cpp +186 -0
- package/Core/Features/Keyboard/keyboard.ts +175 -0
- package/Core/Features/Menu/context-menu.css +293 -0
- package/Core/Features/Menu/menu.cpp +481 -0
- package/Core/Features/Menu/menu.ts +439 -0
- package/Core/Features/Tray/tray.cpp +310 -0
- package/Core/Features/Tray/tray.ts +68 -0
- package/Core/Features/WebGPU/webgpu.cpp +939 -0
- package/Core/Features/WebGPU/webgpu.ts +1013 -0
- package/Core/Features/WebView/webview.cpp +1052 -0
- package/Core/Features/WebView/webview.ts +510 -0
- package/Core/Features/Window/window.cpp +664 -0
- package/Core/Features/Window/window.ts +142 -0
- package/Core/Features/WindowManager/window_manager.cpp +341 -0
- package/Core/include/plusui/app.hpp +73 -0
- package/Core/include/plusui/browser.hpp +66 -0
- package/Core/include/plusui/clipboard.hpp +41 -0
- package/Core/include/plusui/events.hpp +58 -0
- package/Core/include/{keyboard.hpp → plusui/keyboard.hpp} +21 -44
- package/Core/include/plusui/menu.hpp +153 -0
- package/Core/include/plusui/tray.hpp +93 -0
- package/Core/include/plusui/webgpu.hpp +434 -0
- package/Core/include/plusui/webview.hpp +142 -0
- package/Core/include/plusui/window.hpp +111 -0
- package/Core/include/plusui/window_manager.hpp +57 -0
- package/Core/vendor/WebView2EnvironmentOptions.h +406 -0
- package/Core/vendor/stb_image.h +7988 -0
- package/Core/vendor/webview.h +618 -510
- package/Core/vendor/webview2.h +52079 -0
- package/README.md +19 -0
- package/package.json +12 -15
- package/Core/include/app.hpp +0 -121
- package/Core/include/menu.hpp +0 -79
- package/Core/include/tray.hpp +0 -81
- package/Core/include/window.hpp +0 -106
- package/Core/src/app.cpp +0 -311
- package/Core/src/display.cpp +0 -424
- package/Core/src/tray.cpp +0 -275
- package/Core/src/window.cpp +0 -528
- package/dist/index.d.ts +0 -205
- package/dist/index.js +0 -198
- package/src/index.ts +0 -574
- /package/Core/include/{display.hpp → plusui/display.hpp} +0 -0
package/dist/index.d.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
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 };
|