@vention/machine-logic-ui-sdk 0.43.17 → 0.44.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/README.md +2 -2
- package/index.esm.js +3123 -818
- package/package.json +1 -1
- package/src/lib/utils/mqtt-path-given-by-host.d.ts +5 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ The parameter, prop and return types of every export are in the package's type d
|
|
|
20
20
|
|
|
21
21
|
Wrap the app once in `MqttProvider`. It opens one MQTT-over-websocket connection that every `useMqttSubscription` call below it shares, and reconnects on its own.
|
|
22
22
|
|
|
23
|
-
- `version` defaults to `"v2"` and picks which broker address to derive, through `getMqttWsUrl`. On the edge both use an unencrypted websocket: `"v2"` connects to `192.168.5.2:9001` and `"v3"` connects to port `9001` on the host that serves the HMI. In the cloud iframe both
|
|
23
|
+
- `version` defaults to `"v2"` and picks which broker address to derive, through `getMqttWsUrl`. On the edge both use an unencrypted websocket: `"v2"` connects to `192.168.5.2:9001` and `"v3"` connects to port `9001` on the host that serves the HMI. In the cloud iframe both use the same `wss://` URL: `wss://<the HMI's host><mqttPath>` when the host page gives an `mqttPath` query parameter that starts with `/`, else a URL derived from the iframe URL.
|
|
24
24
|
- `url` sets the broker websocket URL yourself. When set, `version` and the URL detection are skipped. Use it for standalone development, for example `ws://localhost:9001`.
|
|
25
25
|
|
|
26
26
|
From `projects/machine-code/apps/ai-operator/frontend/src/main.tsx`, trimmed:
|
|
@@ -177,7 +177,7 @@ export async function watchBins(): Promise<MqttClient> {
|
|
|
177
177
|
URL helpers:
|
|
178
178
|
|
|
179
179
|
- `connectToMqttAndGetClient` builds a client on `await getMqttWsUrl()`, which is the `"v2"` broker address. It takes no arguments; for `"v3"` construct `new MqttClient(await getMqttWsUrl("v3"))` instead.
|
|
180
|
-
- `getMqttWsUrl` returns the broker websocket URL for `version`, which defaults to `"v2"`. When `isOnEdge()` is true it returns an unencrypted websocket URL: `192.168.5.2:9001` for `"v2"` and port `9001` on the current hostname for `"v3"`. Otherwise it returns `getMqttWsUrlGivenUiIframeUrl(window.location.href)`.
|
|
180
|
+
- `getMqttWsUrl` returns the broker websocket URL for `version`, which defaults to `"v2"`. When `isOnEdge()` is true it returns an unencrypted websocket URL: `192.168.5.2:9001` for `"v2"` and port `9001` on the current hostname for `"v3"`. Otherwise, when the HMI's URL had an `mqttPath` query parameter starting with `/` when the SDK loaded, set by the host page, it returns `wss://<the HMI's host><mqttPath>`. Otherwise it returns `getMqttWsUrlGivenUiIframeUrl(window.location.href)`.
|
|
181
181
|
- `getMqttWsUrlGivenUiIframeUrl` derives the cloud broker URL from a remote iframe URL. It keeps the URL up to and including the `digital-twin` path segment, switches `https:` to `wss:`, then appends the path segment that follows `passthrough` and `/mqtt`: `wss://<host>/.../digital-twin/<token>/mqtt`.
|
|
182
182
|
|
|
183
183
|
## Talking to the application's backend
|