tauri-remote-ui 0.22.0 → 0.24.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 +1 -1
- 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 +6 -0
- package/socket.js +6 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tauri Remote UI
|
|
2
2
|
|
|
3
|
-
**Tauri Remote UI** is a plugin that allows you to expose your Tauri application's UI to any web browser, enabling seamless remote interaction and end-to-end testing. The plugin bridges your native app and commercial browsers, letting you use standard web automation tools for testing and debugging—without modifying your app's
|
|
3
|
+
**Tauri Remote UI** is a plugin that allows you to expose your Tauri application's UI to any web browser, enabling seamless remote interaction and end-to-end testing. The plugin bridges your native app and commercial browsers, letting you use standard web automation tools for testing and debugging—without modifying your app's logic.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
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.24.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
|
@@ -19,6 +19,11 @@ function getWsUrl() {
|
|
|
19
19
|
const wsUrl = `${proto}//${loc.host}/remote_ui_ws`;
|
|
20
20
|
return wsUrl;
|
|
21
21
|
}
|
|
22
|
+
function getUrl() {
|
|
23
|
+
const loc = window.location;
|
|
24
|
+
const wsUrl = `${loc.protocol}//${loc.host}/remote_ui`;
|
|
25
|
+
return wsUrl;
|
|
26
|
+
}
|
|
22
27
|
/**
|
|
23
28
|
* Initialize the WebSocket connection
|
|
24
29
|
* This should be called once at the start of your application
|
|
@@ -50,6 +55,7 @@ function initWebSocket() {
|
|
|
50
55
|
exports.ws = null;
|
|
51
56
|
exports.wsReady = null;
|
|
52
57
|
console.info("Remote Dis-Connected.");
|
|
58
|
+
window.location.replace(getUrl());
|
|
53
59
|
};
|
|
54
60
|
exports.ws.onerror = (e) => {
|
|
55
61
|
reject(e);
|
package/socket.js
CHANGED
|
@@ -17,6 +17,11 @@ function getWsUrl() {
|
|
|
17
17
|
const wsUrl = `${proto}//${loc.host}/remote_ui_ws`;
|
|
18
18
|
return wsUrl;
|
|
19
19
|
}
|
|
20
|
+
function getUrl() {
|
|
21
|
+
const loc = window.location;
|
|
22
|
+
const wsUrl = `${loc.protocol}//${loc.host}/remote_ui`;
|
|
23
|
+
return wsUrl;
|
|
24
|
+
}
|
|
20
25
|
/**
|
|
21
26
|
* Initialize the WebSocket connection
|
|
22
27
|
* This should be called once at the start of your application
|
|
@@ -48,6 +53,7 @@ function initWebSocket() {
|
|
|
48
53
|
ws = null;
|
|
49
54
|
wsReady = null;
|
|
50
55
|
console.info("Remote Dis-Connected.");
|
|
56
|
+
window.location.replace(getUrl());
|
|
51
57
|
};
|
|
52
58
|
ws.onerror = (e) => {
|
|
53
59
|
reject(e);
|