@vention/machine-logic-ui-sdk 0.21.0 → 0.23.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, void 0, void 0, function* () {
2860
- return isOnEdge() ? `ws://${window.location.hostname}:9001` : getMqttWsUrlGivenUiIframeUrl(window.location.href);
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();
@@ -2884,12 +2885,19 @@ const getMqttWsUrlGivenUiIframeUrl = uiIframeUrl => {
2884
2885
  const closeCustomUi = () => {
2885
2886
  window.parent.postMessage("closeCustomUi", "*");
2886
2887
  };
2888
+ const navigateControlCenter = route => {
2889
+ const capitalizedRoute = route.charAt(0).toUpperCase() + route.slice(1);
2890
+ window.parent.postMessage(`navigateTo${capitalizedRoute}`, "*");
2891
+ };
2887
2892
 
2888
2893
  const defaultContext = {
2889
2894
  client: null,
2890
2895
  connectionStatus: "disconnected"
2891
2896
  };
2892
2897
  const mqttContext = /*#__PURE__*/createContext(defaultContext);
2898
+ const defaultProps = {
2899
+ version: "v2"
2900
+ };
2893
2901
  const MqttProvider = props => {
2894
2902
  const [connectionStatus, setConnectionStatus] = useState("disconnected");
2895
2903
  const [mqttClient, setMqttClient] = useState(null);
@@ -2900,8 +2908,9 @@ const MqttProvider = props => {
2900
2908
  useEffect(function mqttConnection() {
2901
2909
  function connectToMqtt() {
2902
2910
  return __awaiter(this, void 0, void 0, function* () {
2911
+ var _a;
2903
2912
  console.log("Connecting to MQTT");
2904
- const client = mqtt.connect(yield getMqttWsUrl());
2913
+ const client = mqtt.connect(yield getMqttWsUrl((_a = props.version) !== null && _a !== void 0 ? _a : defaultProps.version));
2905
2914
  client.on("connect", () => {
2906
2915
  setConnectionStatus("connected");
2907
2916
  console.log("Connected to MQTT");
@@ -2952,4 +2961,4 @@ const useMqttSubscription = props => {
2952
2961
  return message;
2953
2962
  };
2954
2963
 
2955
- export { MqttClient, MqttProvider, VirtualKeyboard, closeCustomUi, connectToMqttAndGetClient, getExecutionEngineHttpUrl, getMachineCodeProcessHttpUrl, getMqttWsUrl, getMqttWsUrlGivenUiIframeUrl, isOnEdge, isTouchScreenDevice, mqttContext, useMqttSubscription };
2964
+ export { MqttClient, MqttProvider, VirtualKeyboard, closeCustomUi, connectToMqttAndGetClient, getExecutionEngineHttpUrl, getMachineCodeProcessHttpUrl, getMqttWsUrl, getMqttWsUrlGivenUiIframeUrl, isOnEdge, isTouchScreenDevice, mqttContext, navigateControlCenter, useMqttSubscription };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-logic-ui-sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
@@ -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,8 +2,9 @@ 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;
9
9
  export declare const closeCustomUi: () => void;
10
+ export declare const navigateControlCenter: (route: "remoteSupport" | "controlCenterHomepage") => void;