@adcops/autocore-react 3.0.26 → 3.0.28
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/dist/hub/index.js +1 -1
- package/package.json +1 -1
- package/src/hub/index.ts +36 -22
package/dist/hub/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";export function createHub(){return void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};
|
|
1
|
+
import{HubTauri}from"./HubTauri";import{HubWebSocket}from"./HubWebSocket";import{HubSimulate}from"./HubSimulate";let hubInstance=null;export function createHub(){return hubInstance||(hubInstance=void 0!==window.__TAURI__&&null!==window.__TAURI__?new HubTauri:new HubWebSocket),hubInstance}export{HubBase as Hub}from"./HubBase";export{HubTauri};export{HubWebSocket};export{HubSimulate};
|
package/package.json
CHANGED
package/src/hub/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
|
|
3
3
|
* Created Date: 2024-01-16 21:07:29
|
|
4
4
|
* -----
|
|
5
|
-
* Last Modified: 2024-
|
|
5
|
+
* Last Modified: 2024-05-31 07:51:19
|
|
6
6
|
* Modified By: ADC
|
|
7
7
|
* -----
|
|
8
8
|
*
|
|
@@ -14,35 +14,49 @@ import { HubWebSocket } from "./HubWebSocket";
|
|
|
14
14
|
import {HubSimulate} from "./HubSimulate"
|
|
15
15
|
import { CommandMessage, CommandMessageResult } from './CommandMessage';
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
let hubInstance: Hub | null = null;
|
|
19
|
+
|
|
17
20
|
/**
|
|
18
21
|
* Creates a connection to the backend.
|
|
19
22
|
* @returns Hub
|
|
20
23
|
*/
|
|
21
24
|
export function createHub(): Hub {
|
|
22
25
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if (!hubInstance) {
|
|
27
|
+
if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
28
|
+
console.log("HUB: Starting link to Tauri backend.");
|
|
29
|
+
hubInstance = new HubTauri();
|
|
30
|
+
} else {
|
|
31
|
+
console.log("HUB: Starting websocket connection.");
|
|
32
|
+
hubInstance = new HubWebSocket();
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
+
return hubInstance;
|
|
36
|
+
|
|
37
|
+
// if (window.__TAURI__ !== undefined && window.__TAURI__ !== null) {
|
|
38
|
+
// // Standalone Tauri application
|
|
39
|
+
// console.log("HUB: Starting link to Tauri backend.");
|
|
40
|
+
// return new HubTauri();
|
|
41
|
+
// }
|
|
42
|
+
// // else if (
|
|
43
|
+
// // window.location.port !== undefined
|
|
44
|
+
// // && window.location.port.length > 0
|
|
45
|
+
// // && window.location.port !== '80'
|
|
46
|
+
// // && window.location.port !== '8080'
|
|
47
|
+
// // && window.location.port !== '443'
|
|
48
|
+
// // ) {
|
|
35
49
|
|
|
36
|
-
// // We're loaded in some development environment
|
|
37
|
-
// console.log("HUB: Starting HUB SIMULATOR.");
|
|
38
|
-
// return new HubSimulate();
|
|
39
|
-
|
|
40
|
-
// }
|
|
41
|
-
else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
50
|
+
// // // We're loaded in some development environment
|
|
51
|
+
// // console.log("HUB: Starting HUB SIMULATOR.");
|
|
52
|
+
// // return new HubSimulate();
|
|
53
|
+
|
|
54
|
+
// // }
|
|
55
|
+
// else {
|
|
56
|
+
// // A web-app that must communicate with a backend in another process.
|
|
57
|
+
// console.log("HUB: Starting websocket connection.");
|
|
58
|
+
// return new HubWebSocket();
|
|
59
|
+
// }
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
|