tauri-remote-ui 0.23.0 → 0.25.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/README.md +66 -3
- package/api/core/index.cjs +5 -11
- package/api/core/index.js +5 -11
- package/api/event/index.cjs +8 -12
- package/api/event/index.js +8 -12
- package/package.json +4 -1
- package/socket.cjs +1 -1
- package/socket.js +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
- **Zero App Changes:** No additional changes required to your app after plugin setup.
|
|
12
12
|
- **Future Compatibility:** When [CEF-RS](https://github.com/cef-rs/cef) becomes available, the same E2E tests (e.g., written with Playwright or similar tools that use the Chromium debug port) will work seamlessly in debug mode, ensuring long-term support for modern testing workflows.
|
|
13
13
|
|
|
14
|
+
## Completed Features
|
|
15
|
+
|
|
16
|
+
### Javascript
|
|
17
|
+
- **api/core** - `invoke`
|
|
18
|
+
- **api/event** - `listen`
|
|
19
|
+
- **api/app** - `defaultWindowIcon`,`fetchDataStoreIdentifiers`,`getBundleType`,`getIdentifier`,`getName`,`getTauriVersion`,`getVersion`,`hide`,`removeDataStore`,`setDockVisibility`,`setTheme`,`show`
|
|
20
|
+
|
|
21
|
+
### Rust
|
|
22
|
+
- `emit` - Emit method is updated to handle in this plugin.
|
|
23
|
+
|
|
14
24
|
## Operation Flow
|
|
15
25
|
|
|
16
26
|
- **WebView:** Uses IPC for communication between frontend and backend.
|
|
@@ -20,14 +30,67 @@
|
|
|
20
30
|
|
|
21
31
|
## Usage
|
|
22
32
|
|
|
23
|
-
1. **Install the Rust plugin** in your Tauri project
|
|
24
|
-
2. **
|
|
33
|
+
1. **Install the Rust plugin** in your Tauri project `cargo add tauri-remote-ui`.
|
|
34
|
+
2. **Initialize the Rust plugin**
|
|
35
|
+
```rust
|
|
36
|
+
pub fn run() {
|
|
37
|
+
tauri::Builder::default()
|
|
38
|
+
.plugin(tauri_remote_ui::init())
|
|
39
|
+
.invoke_handler(tauri::generate_handler![
|
|
40
|
+
increment,
|
|
41
|
+
decrement,
|
|
42
|
+
enable_server,
|
|
43
|
+
disable_server,
|
|
44
|
+
exit_app,
|
|
45
|
+
])
|
|
46
|
+
.setup(|app| {
|
|
47
|
+
app.manage(Arc::new(RwLock::new(Counter { now: 0 })));
|
|
48
|
+
Ok(())
|
|
49
|
+
})
|
|
50
|
+
.run(tauri::generate_context!())
|
|
51
|
+
.expect("error while running tauri application");
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
3. **Replace Emitter trait**
|
|
55
|
+
```rust
|
|
56
|
+
use tauri::Emitter
|
|
57
|
+
```
|
|
58
|
+
To
|
|
59
|
+
```rust
|
|
60
|
+
use tauri_remote_ui::EmitterExt;
|
|
61
|
+
```
|
|
62
|
+
4. **Start/Stop Server**
|
|
63
|
+
```rust
|
|
64
|
+
fn enable_server(app: AppHandle) -> String {
|
|
65
|
+
match app.start_remote_ui(RemoteUiConfig::default().set_port(Some(9090))) {
|
|
66
|
+
Ok(()) => format!("Server Started."),
|
|
67
|
+
Err(err) => format!("Server Error {:?}", err),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
fn disable_server(app: AppHandle) -> String {
|
|
71
|
+
match app.stop_remote_ui() {
|
|
72
|
+
Ok(()) => format!("Server Stoped"),
|
|
73
|
+
Err(err) => format!("Server Error {:?}", err),
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
5. **Install the NPM plugin** in your frontend `npm i tauri-remote-ui`.
|
|
78
|
+
6. **Replace the NPM package**
|
|
79
|
+
```typescript
|
|
80
|
+
import { invoke } from "@tauri-apps/api/core";
|
|
81
|
+
import { listen } from "@tauri-apps/api/event";
|
|
82
|
+
```
|
|
83
|
+
To
|
|
84
|
+
```typescript
|
|
85
|
+
import { invoke } from "tauri-remote-ui/api/core";
|
|
86
|
+
import { listen } from "tauri-remote-ui/api/event";
|
|
87
|
+
```
|
|
25
88
|
3. **Access the UI remotely** via the provided web interface when activated.
|
|
26
89
|
|
|
27
90
|
## Development
|
|
28
91
|
|
|
29
92
|
- Build Rust: `cargo build`
|
|
30
|
-
- Build JS: `pnpm build`
|
|
93
|
+
- Build JS: `pnpm build`
|
|
31
94
|
- Example app: See `examples/tauri-app/`
|
|
32
95
|
|
|
33
96
|
## License
|
package/api/core/index.cjs
CHANGED
|
@@ -18,18 +18,12 @@ var socket = require('../../socket.cjs');
|
|
|
18
18
|
*/
|
|
19
19
|
let msg_id = 0;
|
|
20
20
|
async function invoke(cmd, args, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
25
|
-
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
26
|
-
return await core.invoke(cmd, args, options);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new Error("Failed to Find Tauri handle");
|
|
30
|
-
}
|
|
21
|
+
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
22
|
+
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
23
|
+
return await core.invoke(cmd, args, options);
|
|
31
24
|
}
|
|
32
|
-
|
|
25
|
+
else {
|
|
26
|
+
socket.initWebSocket();
|
|
33
27
|
// If WebSocket is connecting, wait for it
|
|
34
28
|
if (socket.wsReady) {
|
|
35
29
|
await socket.wsReady;
|
package/api/core/index.js
CHANGED
|
@@ -16,18 +16,12 @@ import { initWebSocket, wsReady, ws, filterCollection } from '../../socket.js';
|
|
|
16
16
|
*/
|
|
17
17
|
let msg_id = 0;
|
|
18
18
|
async function invoke(cmd, args, options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
23
|
-
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
24
|
-
return await invoke$1(cmd, args, options);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw new Error("Failed to Find Tauri handle");
|
|
28
|
-
}
|
|
19
|
+
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
20
|
+
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
21
|
+
return await invoke$1(cmd, args, options);
|
|
29
22
|
}
|
|
30
|
-
|
|
23
|
+
else {
|
|
24
|
+
initWebSocket();
|
|
31
25
|
// If WebSocket is connecting, wait for it
|
|
32
26
|
if (wsReady) {
|
|
33
27
|
await wsReady;
|
package/api/event/index.cjs
CHANGED
|
@@ -17,17 +17,12 @@ var socket = require('../../socket.cjs');
|
|
|
17
17
|
* @param options - Options for the event listener
|
|
18
18
|
*/
|
|
19
19
|
async function listen(event$1, handler, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
24
|
-
return await event.listen(event$1, handler, options);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw new Error("Failed to Find Tauri handle");
|
|
28
|
-
}
|
|
20
|
+
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
21
|
+
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
22
|
+
return await event.listen(event$1, handler, options);
|
|
29
23
|
}
|
|
30
|
-
|
|
24
|
+
else {
|
|
25
|
+
socket.initWebSocket();
|
|
31
26
|
// If WebSocket is connecting, wait for it
|
|
32
27
|
if (socket.wsReady) {
|
|
33
28
|
await socket.wsReady;
|
|
@@ -42,7 +37,8 @@ async function listen(event$1, handler, options) {
|
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
39
|
catch (err) {
|
|
45
|
-
console.error(
|
|
40
|
+
console.error(err);
|
|
41
|
+
throw new Error('Error handling WebSocket event');
|
|
46
42
|
}
|
|
47
43
|
};
|
|
48
44
|
socket.ws.addEventListener('message', messageHandler);
|
|
@@ -52,7 +48,7 @@ async function listen(event$1, handler, options) {
|
|
|
52
48
|
};
|
|
53
49
|
}
|
|
54
50
|
else {
|
|
55
|
-
throw new Error(
|
|
51
|
+
throw new Error("No WebSocket or Tauri IPC available to invoke");
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
}
|
package/api/event/index.js
CHANGED
|
@@ -15,17 +15,12 @@ import { initWebSocket, wsReady, ws } from '../../socket.js';
|
|
|
15
15
|
* @param options - Options for the event listener
|
|
16
16
|
*/
|
|
17
17
|
async function listen(event, handler, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
22
|
-
return await listen$1(event, handler, options);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
throw new Error("Failed to Find Tauri handle");
|
|
26
|
-
}
|
|
18
|
+
if ((window.__TAURI_INTERNALS__ && window.__TAURI_INTERNALS__.invoke) ||
|
|
19
|
+
window.__TAURI__ && window.__TAURI__.invoke) {
|
|
20
|
+
return await listen$1(event, handler, options);
|
|
27
21
|
}
|
|
28
|
-
|
|
22
|
+
else {
|
|
23
|
+
initWebSocket();
|
|
29
24
|
// If WebSocket is connecting, wait for it
|
|
30
25
|
if (wsReady) {
|
|
31
26
|
await wsReady;
|
|
@@ -40,7 +35,8 @@ async function listen(event, handler, options) {
|
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
37
|
catch (err) {
|
|
43
|
-
console.error(
|
|
38
|
+
console.error(err);
|
|
39
|
+
throw new Error('Error handling WebSocket event');
|
|
44
40
|
}
|
|
45
41
|
};
|
|
46
42
|
ws.addEventListener('message', messageHandler);
|
|
@@ -50,7 +46,7 @@ async function listen(event, handler, options) {
|
|
|
50
46
|
};
|
|
51
47
|
}
|
|
52
48
|
else {
|
|
53
|
-
throw new Error(
|
|
49
|
+
throw new Error("No WebSocket or Tauri IPC available to invoke");
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-remote-ui",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"author": "DraviaVemal",
|
|
6
6
|
"description": "A Tauri plugin that exposes the application's UI to a web browser, allowing full interaction while the native app continues running. This enables end-to-end UI testing using existing web-based testing tools without requiring modifications to the app itself.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"main": "./index.cjs",
|
|
10
10
|
"module": "./index.js",
|
|
11
|
+
"repository": {
|
|
12
|
+
"url": "https://github.com/DraviaVemal/tauri-remote-ui"
|
|
13
|
+
},
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
16
|
"types": "./index.d.ts",
|
package/socket.cjs
CHANGED
package/socket.js
CHANGED