@wandelbots/wandelbots-js-react-components 1.9.3 → 1.9.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "files": [
6
6
  "dist",
@@ -79,7 +79,9 @@
79
79
  "typescript": "^5.5.4",
80
80
  "vite": "^5.3.5",
81
81
  "vite-plugin-svgr": "^4.2.0",
82
- "vitest": "^2.0.5"
82
+ "vitest": "^2.0.5",
83
+ "@chromatic-com/storybook": "^1.6.1",
84
+ "storybook-preset-inline-svg": "^1.0.1"
83
85
  },
84
86
  "peerDependencies": {
85
87
  "@emotion/react": "^11.11.1",
@@ -100,19 +102,16 @@
100
102
  }
101
103
  },
102
104
  "dependencies": {
103
- "@chromatic-com/storybook": "^1.6.1",
104
105
  "@monaco-editor/react": "^4.6.0",
105
106
  "@mui/icons-material": "^5.16.6",
106
107
  "@mui/lab": "^5.0.0-alpha.173",
107
108
  "@shikijs/monaco": "^1.12.0",
108
- "@storybook/addon-onboarding": "^8.2.9",
109
109
  "i18next-browser-languagedetector": "^8.0.0",
110
110
  "lodash-es": "^4.17.21",
111
111
  "mobx": "^6.13.1",
112
112
  "mobx-react-lite": "^4.0.7",
113
113
  "react-error-boundary": "^4.0.13",
114
114
  "react-i18next": "^15.0.0",
115
- "shiki": "^1.12.0",
116
- "storybook-preset-inline-svg": "^1.0.1"
115
+ "shiki": "^1.12.0"
117
116
  }
118
117
  }
@@ -18,6 +18,7 @@ import { JoggingVelocitySlider } from "./JoggingVelocitySlider"
18
18
  import { useReaction } from "../utils/hooks"
19
19
  import { JoggingCartesianValues } from "./JoggingCartesianValues"
20
20
  import { JoggingJointLimitDetector } from "./JoggingJointLimitDetector"
21
+ import { useEffect } from "react"
21
22
 
22
23
  type JoggingCartesianOpts = {
23
24
  axis: "x" | "y" | "z"
@@ -49,6 +50,31 @@ export const JoggingCartesianTab = observer(
49
50
  { fireImmediately: true } as any,
50
51
  )
51
52
 
53
+ useEffect(() => {
54
+ // Start in increment mode with no websockets open
55
+ store.jogger.setJoggingMode("increment")
56
+
57
+ window.addEventListener("blur", disconnectJogger)
58
+
59
+ return () => {
60
+ window.removeEventListener("blur", disconnectJogger)
61
+ }
62
+ }, [])
63
+
64
+ async function connectJogger() {
65
+ store.jogger.setJoggingMode(
66
+ store.selectedDiscreteIncrement ? "increment" : "cartesian",
67
+ {
68
+ tcpId: store.selectedTcpId,
69
+ coordSystemId: store.selectedCoordSystemId,
70
+ },
71
+ )
72
+ }
73
+
74
+ async function disconnectJogger() {
75
+ store.jogger.setJoggingMode("increment")
76
+ }
77
+
52
78
  async function runIncrementalCartesianJog(
53
79
  opts: JoggingCartesianOpts,
54
80
  increment: DiscreteIncrementOption,
@@ -85,6 +111,8 @@ export const JoggingCartesianTab = observer(
85
111
  async function startCartesianJogging(opts: JoggingCartesianOpts) {
86
112
  if (store.isLocked) return
87
113
 
114
+ connectJogger()
115
+
88
116
  if (store.selectedDiscreteIncrement) {
89
117
  return runIncrementalCartesianJog(opts, store.selectedDiscreteIncrement)
90
118
  }
@@ -143,7 +171,7 @@ export const JoggingCartesianTab = observer(
143
171
  }
144
172
 
145
173
  return (
146
- <Stack>
174
+ <Stack onMouseEnter={connectJogger} onMouseLeave={disconnectJogger}>
147
175
  {/* Show Wandelscript string for the current coords */}
148
176
  <JoggingCartesianValues store={store} />
149
177
 
@@ -5,9 +5,29 @@ import type { JoggingStore } from "./JoggingStore"
5
5
  import { JoggingVelocitySlider } from "./JoggingVelocitySlider"
6
6
  import { JoggingJointRotationControl } from "./JoggingJointRotationControl"
7
7
  import { JoggingJointValues } from "./JoggingJointValues"
8
+ import { useEffect } from "react"
8
9
 
9
10
  export const JoggingJointTab = observer(
10
- ({ store }: { store: JoggingStore; }) => {
11
+ ({ store }: { store: JoggingStore }) => {
12
+ useEffect(() => {
13
+ // Start in increment mode with no websockets open
14
+ store.jogger.setJoggingMode("increment")
15
+
16
+ window.addEventListener("blur", disconnectJogger)
17
+
18
+ return () => {
19
+ window.removeEventListener("blur", disconnectJogger)
20
+ }
21
+ }, [])
22
+
23
+ async function connectJogger() {
24
+ store.jogger.setJoggingMode("joint")
25
+ }
26
+
27
+ async function disconnectJogger() {
28
+ store.jogger.setJoggingMode("increment")
29
+ }
30
+
11
31
  async function startJointJogging(opts: {
12
32
  joint: number
13
33
  direction: "-" | "+"
@@ -22,16 +42,14 @@ export const JoggingJointTab = observer(
22
42
  async function stopJointJogging() {
23
43
  await store.jogger.stop()
24
44
  }
25
-
45
+
26
46
  return (
27
- <Stack>
47
+ <Stack onMouseEnter={connectJogger} onMouseLeave={disconnectJogger}>
28
48
  <JoggingJointValues store={store} />
29
49
  <Stack>
30
50
  {store.jogger.motionStream.joints.map((joint) => {
31
51
  const jointLimits =
32
- store.motionGroupSpec.mechanical_joint_limits?.[
33
- joint.index
34
- ]
52
+ store.motionGroupSpec.mechanical_joint_limits?.[joint.index]
35
53
  const lowerLimitDegs =
36
54
  jointLimits?.lower_limit !== undefined
37
55
  ? radiansToDegrees(jointLimits.lower_limit)