@vention/machine-logic-ui-sdk 0.46.1 → 0.47.1

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
@@ -3115,7 +3115,7 @@ var Headers = safeGetBuiltIn('Headers');
3115
3115
  var RequestPrototype = NativeRequest && NativeRequest.prototype;
3116
3116
  var HeadersPrototype = Headers && Headers.prototype;
3117
3117
  var TypeError$2 = globalThis$5.TypeError;
3118
- var encodeURIComponent$1 = globalThis$5.encodeURIComponent;
3118
+ var encodeURIComponent$2 = globalThis$5.encodeURIComponent;
3119
3119
  var fromCharCode$2 = String.fromCharCode;
3120
3120
  var fromCodePoint = getBuiltIn$3('String', 'fromCodePoint');
3121
3121
  var $parseInt$1 = parseInt;
@@ -3280,7 +3280,7 @@ var replacer = function (match) {
3280
3280
  };
3281
3281
 
3282
3282
  var serialize = function (it) {
3283
- return replace$2(encodeURIComponent$1(it), find, replacer);
3283
+ return replace$2(encodeURIComponent$2(it), find, replacer);
3284
3284
  };
3285
3285
 
3286
3286
  var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
@@ -4744,7 +4744,7 @@ var getInternalSearchParamsState = URLSearchParamsModule.getState;
4744
4744
 
4745
4745
  var NativeURL = globalThis$2.URL;
4746
4746
  var TypeError$1 = globalThis$2.TypeError;
4747
- var encodeURIComponent = globalThis$2.encodeURIComponent;
4747
+ var encodeURIComponent$1 = globalThis$2.encodeURIComponent;
4748
4748
  var parseInt$1 = globalThis$2.parseInt;
4749
4749
  var floor = Math.floor;
4750
4750
  var pow = Math.pow;
@@ -4994,7 +4994,7 @@ var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
4994
4994
  var percentEncode = function (chr, set) {
4995
4995
  var code = codeAt(chr, 0);
4996
4996
  // encodeURIComponent does not encode ', which is in the special-query percent-encode set
4997
- return code >= 0x20 && code < 0x7F && !hasOwn$2(set, chr) ? chr : chr === "'" && hasOwn$2(set, chr) ? '%27' : encodeURIComponent(chr);
4997
+ return code >= 0x20 && code < 0x7F && !hasOwn$2(set, chr) ? chr : chr === "'" && hasOwn$2(set, chr) ? '%27' : encodeURIComponent$1(chr);
4998
4998
  };
4999
4999
 
5000
5000
  // https://url.spec.whatwg.org/#special-scheme
@@ -5816,7 +5816,7 @@ const getMqttWsUrlGivenMqttPath = (host, mqttPath) => {
5816
5816
  return url.toString();
5817
5817
  };
5818
5818
 
5819
- var _a;
5819
+ var _a$1;
5820
5820
  const isTouchScreenDevice = () => "ontouchstart" in window || navigator.maxTouchPoints > 0;
5821
5821
  const isOnEdge = () => {
5822
5822
  return window.location.hostname.startsWith("192.168") || window.location.hostname.startsWith("localhost");
@@ -5827,7 +5827,7 @@ const getExecutionEngineHttpUrl = () => {
5827
5827
  // A host page may give the broker's path on the custom UI's own host, whose cookie authenticates the socket, as this
5828
5828
  // query parameter. It is read once when the SDK loads, before the custom UI's router can rewrite the URL.
5829
5829
  const MQTT_PATH_QUERY_PARAMETER = "mqttPath";
5830
- const mqttPathGivenByHost = new URLSearchParams((_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.search).get(MQTT_PATH_QUERY_PARAMETER);
5830
+ const mqttPathGivenByHost = new URLSearchParams((_a$1 = globalThis.location) === null || _a$1 === void 0 ? void 0 : _a$1.search).get(MQTT_PATH_QUERY_PARAMETER);
5831
5831
  const getMqttWsUrl = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (version = "v2") {
5832
5832
  const urlOnEdge = version === "v2" ? "ws://192.168.5.2:9001" : `ws://${window.location.hostname}:9001`;
5833
5833
  if (isOnEdge()) return urlOnEdge;
@@ -5868,6 +5868,31 @@ const navigateControlCenter = route => {
5868
5868
  window.parent.postMessage(`navigateTo${capitalizedRoute}`, "*");
5869
5869
  };
5870
5870
 
5871
+ var _a;
5872
+ // The host page gives the custom UI its application's id as this query parameter. It is read once when the SDK loads,
5873
+ // before the custom UI's router can rewrite the URL.
5874
+ const APPLICATION_ID_QUERY_PARAMETER = "applicationId";
5875
+ const applicationIdGivenByHost = new URLSearchParams((_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.search).get(APPLICATION_ID_QUERY_PARAMETER);
5876
+ /**
5877
+ * The URL of a process of the application `applicationId`, through the engine's proxy:
5878
+ * `<engine>/v1/machineCode/services/<applicationId>/<processName>`. Without an id, the unscoped URL of
5879
+ * getMachineCodeProcessHttpUrl().
5880
+ */
5881
+ const getMachineCodeProcessHttpUrlGivenApplicationId = (processName, applicationId) => {
5882
+ const encodedProcessName = encodeURIComponent(processName);
5883
+ if (applicationId === null || applicationId === "") return getMachineCodeProcessHttpUrl(encodedProcessName);
5884
+ return getMachineCodeProcessHttpUrl(`${encodeURIComponent(applicationId)}/${encodedProcessName}`);
5885
+ };
5886
+ /**
5887
+ * The URL of a process of this custom UI's own application, through the engine's proxy.
5888
+ *
5889
+ * Unlike getMachineCodeProcessHttpUrl(), which names no application and which the engine routes to
5890
+ * whichever application it finds running first, this names the application the host page gave, so each
5891
+ * UI reaches its own backend when several applications run. Without an id from the host, it falls back
5892
+ * to getMachineCodeProcessHttpUrl().
5893
+ */
5894
+ const getOwnMachineCodeProcessHttpUrl = processName => getMachineCodeProcessHttpUrlGivenApplicationId(processName, applicationIdGivenByHost);
5895
+
5871
5896
  var uncurryThis$3 = functionUncurryThis;
5872
5897
 
5873
5898
  // eslint-disable-next-line es/no-set -- safe
@@ -6754,4 +6779,4 @@ const useMqttSubscription = props => {
6754
6779
  return message;
6755
6780
  };
6756
6781
 
6757
- export { MqttClient, MqttProvider, VirtualKeyboard, closeCustomUi, connectToMqttAndGetClient, getExecutionEngineHttpUrl, getMachineCodeApiBaseUrl, getMachineCodeProcessHttpUrl, getMqttWsUrl, getMqttWsUrlGivenUiIframeUrl, isOnEdge, isTouchScreenDevice, mqttContext, navigateControlCenter, useMqttSubscription, useStyles };
6782
+ export { MqttClient, MqttProvider, VirtualKeyboard, closeCustomUi, connectToMqttAndGetClient, getExecutionEngineHttpUrl, getMachineCodeApiBaseUrl, getMachineCodeProcessHttpUrl, getMachineCodeProcessHttpUrlGivenApplicationId, getMqttWsUrl, getMqttWsUrlGivenUiIframeUrl, getOwnMachineCodeProcessHttpUrl, isOnEdge, isTouchScreenDevice, mqttContext, navigateControlCenter, useMqttSubscription, useStyles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/machine-logic-ui-sdk",
3
- "version": "0.46.1",
3
+ "version": "0.47.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/VentionCo/machine-cloud.git"
package/src/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./lib/components/virtual-keyboard/virtual-keyboard";
2
2
  export * from "./lib/utils/machine-logic-ui-sdk-utils";
3
+ export * from "./lib/utils/own-process-url";
3
4
  export * from "./lib/mqtt-browser/mqtt-client";
4
5
  export * from "./lib/mqtt/mqtt-context";
5
6
  export * from "./lib/mqtt/use-mqtt-subscription";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The URL of a process of the application `applicationId`, through the engine's proxy:
3
+ * `<engine>/v1/machineCode/services/<applicationId>/<processName>`. Without an id, the unscoped URL of
4
+ * getMachineCodeProcessHttpUrl().
5
+ */
6
+ export declare const getMachineCodeProcessHttpUrlGivenApplicationId: (processName: string, applicationId: string | null) => string;
7
+ /**
8
+ * The URL of a process of this custom UI's own application, through the engine's proxy.
9
+ *
10
+ * Unlike getMachineCodeProcessHttpUrl(), which names no application and which the engine routes to
11
+ * whichever application it finds running first, this names the application the host page gave, so each
12
+ * UI reaches its own backend when several applications run. Without an id from the host, it falls back
13
+ * to getMachineCodeProcessHttpUrl().
14
+ */
15
+ export declare const getOwnMachineCodeProcessHttpUrl: (processName: string) => string;