@vention/machine-logic-ui-sdk 0.21.0 → 0.22.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/index.esm.js
CHANGED
|
@@ -2856,8 +2856,9 @@ const isOnEdge = () => {
|
|
|
2856
2856
|
const getExecutionEngineHttpUrl = () => {
|
|
2857
2857
|
return isOnEdge() ? `http://${window.location.hostname}:3100` : getExecutionEngineUrlGivenUiIframeUrl(window.location.href);
|
|
2858
2858
|
};
|
|
2859
|
-
const getMqttWsUrl = () => __awaiter(void 0,
|
|
2860
|
-
|
|
2859
|
+
const getMqttWsUrl = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (version = "v2") {
|
|
2860
|
+
const urlOnEdge = version === "v2" ? "ws://192.168.5.2:9001" : `ws://${window.location.hostname}:9001`;
|
|
2861
|
+
return isOnEdge() ? urlOnEdge : getMqttWsUrlGivenUiIframeUrl(window.location.href);
|
|
2861
2862
|
});
|
|
2862
2863
|
const connectToMqttAndGetClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2863
2864
|
const websocketUrl = yield getMqttWsUrl();
|
|
@@ -2890,6 +2891,9 @@ const defaultContext = {
|
|
|
2890
2891
|
connectionStatus: "disconnected"
|
|
2891
2892
|
};
|
|
2892
2893
|
const mqttContext = /*#__PURE__*/createContext(defaultContext);
|
|
2894
|
+
const defaultProps = {
|
|
2895
|
+
version: "v2"
|
|
2896
|
+
};
|
|
2893
2897
|
const MqttProvider = props => {
|
|
2894
2898
|
const [connectionStatus, setConnectionStatus] = useState("disconnected");
|
|
2895
2899
|
const [mqttClient, setMqttClient] = useState(null);
|
|
@@ -2900,8 +2904,9 @@ const MqttProvider = props => {
|
|
|
2900
2904
|
useEffect(function mqttConnection() {
|
|
2901
2905
|
function connectToMqtt() {
|
|
2902
2906
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2907
|
+
var _a;
|
|
2903
2908
|
console.log("Connecting to MQTT");
|
|
2904
|
-
const client = mqtt.connect(yield getMqttWsUrl());
|
|
2909
|
+
const client = mqtt.connect(yield getMqttWsUrl((_a = props.version) !== null && _a !== void 0 ? _a : defaultProps.version));
|
|
2905
2910
|
client.on("connect", () => {
|
|
2906
2911
|
setConnectionStatus("connected");
|
|
2907
2912
|
console.log("Connected to MQTT");
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ interface MqttContext {
|
|
|
7
7
|
export declare const mqttContext: import("react").Context<MqttContext>;
|
|
8
8
|
interface Props {
|
|
9
9
|
children: ReactNode;
|
|
10
|
+
version?: "v2" | "v3";
|
|
10
11
|
}
|
|
11
12
|
export declare const MqttProvider: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -2,7 +2,7 @@ import { MqttClient } from "../mqtt-browser/mqtt-client";
|
|
|
2
2
|
export declare const isTouchScreenDevice: () => boolean;
|
|
3
3
|
export declare const isOnEdge: () => boolean;
|
|
4
4
|
export declare const getExecutionEngineHttpUrl: () => string;
|
|
5
|
-
export declare const getMqttWsUrl: () => Promise<string>;
|
|
5
|
+
export declare const getMqttWsUrl: (version?: "v2" | "v3") => Promise<string>;
|
|
6
6
|
export declare const connectToMqttAndGetClient: () => Promise<MqttClient>;
|
|
7
7
|
export declare const getMachineCodeProcessHttpUrl: (processName: string) => string;
|
|
8
8
|
export declare const getMqttWsUrlGivenUiIframeUrl: (uiIframeUrl: string) => string;
|