@wandelbots/wandelbots-js-react-components 2.41.0-pr.feature-seperate-timer.383.38eb55e → 2.41.0-pr.feature-seperate-timer.383.ed84a08

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": "2.41.0-pr.feature-seperate-timer.383.38eb55e",
3
+ "version": "2.41.0-pr.feature-seperate-timer.383.ed84a08",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -59,8 +59,8 @@
59
59
  "@rollup/plugin-node-resolve": "^16.0.0",
60
60
  "@rollup/plugin-terser": "^0.4.4",
61
61
  "@rollup/plugin-typescript": "^12.1.2",
62
- "@storybook/addon-docs": "^9.1.3",
63
- "@storybook/react-vite": "^9.1.3",
62
+ "@storybook/addon-docs": "^9.1.6",
63
+ "@storybook/react-vite": "^9.1.6",
64
64
  "@storybook/test-runner": "^0.23.0",
65
65
  "@svgr/rollup": "^8.1.0",
66
66
  "@testing-library/jest-dom": "^6.6.3",
@@ -72,7 +72,7 @@
72
72
  "@vitejs/plugin-react": "^4.3.4",
73
73
  "@wandelbots/nova-js": "^2.1.0",
74
74
  "add": "^2.0.6",
75
- "eslint-plugin-storybook": "^9.1.3",
75
+ "eslint-plugin-storybook": "^9.1.6",
76
76
  "glob": "^11.0.1",
77
77
  "http-server": "^14.1.1",
78
78
  "husky": "^9.1.7",
@@ -95,7 +95,7 @@
95
95
  "rollup-plugin-peer-deps-external": "^2.2.4",
96
96
  "rollup-plugin-postcss": "^4.0.2",
97
97
  "semantic-release": "^24.2.3",
98
- "storybook": "^9.1.3",
98
+ "storybook": "^9.1.6",
99
99
  "storybook-preset-inline-svg": "^1.0.1",
100
100
  "three": "^0.174.0",
101
101
  "three-stdlib": "^2.35.14",
@@ -11,28 +11,6 @@ import { externalizeComponent } from "../../externalizeComponent"
11
11
  import { CopyableText } from "../CopyableText"
12
12
  import { useAutorun } from "../utils/hooks"
13
13
 
14
- /** Minimal interface for what PoseCartesianValues needs from motion stream */
15
- type MotionStateProvider = {
16
- rapidlyChangingMotionState: MotionGroupStateResponse
17
- }
18
-
19
- /** Creates a motion state provider from either a MotionStreamConnection or ConnectedMotionGroup */
20
- function createMotionStateProvider(
21
- motionStream?: MotionStreamConnection,
22
- connectedMotionGroup?: ConnectedMotionGroup,
23
- ): MotionStateProvider | undefined {
24
- if (motionStream) {
25
- return motionStream
26
- }
27
- if (connectedMotionGroup) {
28
- return {
29
- rapidlyChangingMotionState:
30
- connectedMotionGroup.rapidlyChangingMotionState,
31
- }
32
- }
33
- return undefined
34
- }
35
-
36
14
  export type PoseCartesianValuesProps = {
37
15
  /** Either a MotionStreamConnection or ConnectedMotionGroup */
38
16
  motionStream?: MotionStreamConnection
@@ -50,20 +28,19 @@ export const PoseCartesianValues = externalizeComponent(
50
28
  const poseHolderRef = useRef<HTMLDivElement>(null)
51
29
  const [copyMessage, setCopyMessage] = useState("")
52
30
 
53
- const activeMotionStream = createMotionStateProvider(
54
- motionStream,
55
- connectedMotionGroup,
56
- )
57
-
58
- if (!activeMotionStream) {
31
+ if (!motionStream && !connectedMotionGroup) {
59
32
  throw new Error(
60
33
  "PoseCartesianValues requires either motionStream or connectedMotionGroup prop",
61
34
  )
62
35
  }
63
36
 
64
37
  function getCurrentPoseString() {
65
- if (!activeMotionStream) return ""
66
- const tcpPose = activeMotionStream.rapidlyChangingMotionState.tcp_pose
38
+ let tcpPose: MotionGroupStateResponse["tcp_pose"] | undefined
39
+ if (motionStream) {
40
+ tcpPose = motionStream.rapidlyChangingMotionState.tcp_pose
41
+ } else if (connectedMotionGroup) {
42
+ tcpPose = connectedMotionGroup.rapidlyChangingMotionState.tcp_pose
43
+ }
67
44
  if (!tcpPose) return ""
68
45
  return poseToWandelscriptString(tcpPose)
69
46
  }
@@ -80,11 +57,17 @@ export const PoseCartesianValues = externalizeComponent(
80
57
  }
81
58
 
82
59
  useAutorun(() => {
83
- if (!poseHolderRef.current || !activeMotionStream) {
60
+ if (!poseHolderRef.current) {
84
61
  return
85
62
  }
86
63
 
87
- const tcpPose = activeMotionStream.rapidlyChangingMotionState.tcp_pose
64
+ let tcpPose: MotionGroupStateResponse["tcp_pose"] | undefined
65
+ if (motionStream) {
66
+ tcpPose = motionStream.rapidlyChangingMotionState.tcp_pose
67
+ } else if (connectedMotionGroup) {
68
+ tcpPose = connectedMotionGroup.rapidlyChangingMotionState.tcp_pose
69
+ }
70
+
88
71
  if (!tcpPose) return
89
72
 
90
73
  const newPoseContent = poseToWandelscriptString(tcpPose)
@@ -1,7 +1,6 @@
1
1
  import { Button, Stack, Typography } from "@mui/material"
2
2
  import type {
3
3
  ConnectedMotionGroup,
4
- MotionGroupStateResponse,
5
4
  MotionStreamConnection,
6
5
  } from "@wandelbots/nova-js/v1"
7
6
  import { observer } from "mobx-react-lite"
@@ -10,28 +9,6 @@ import { externalizeComponent } from "../../externalizeComponent"
10
9
  import { CopyableText } from "../CopyableText"
11
10
  import { useAutorun } from "../utils/hooks"
12
11
 
13
- /** Minimal interface for what PoseJointValues needs from motion stream */
14
- type MotionStateProvider = {
15
- rapidlyChangingMotionState: MotionGroupStateResponse
16
- }
17
-
18
- /** Creates a motion state provider from either a MotionStreamConnection or ConnectedMotionGroup */
19
- function createMotionStateProvider(
20
- motionStream?: MotionStreamConnection,
21
- connectedMotionGroup?: ConnectedMotionGroup,
22
- ): MotionStateProvider | undefined {
23
- if (motionStream) {
24
- return motionStream
25
- }
26
- if (connectedMotionGroup) {
27
- return {
28
- rapidlyChangingMotionState:
29
- connectedMotionGroup.rapidlyChangingMotionState,
30
- }
31
- }
32
- return undefined
33
- }
34
-
35
12
  export type PoseJointValuesProps = {
36
13
  /** Either a MotionStreamConnection or ConnectedMotionGroup */
37
14
  motionStream?: MotionStreamConnection
@@ -49,21 +26,24 @@ export const PoseJointValues = externalizeComponent(
49
26
  const poseHolderRef = useRef<HTMLDivElement>(null)
50
27
  const [copyMessage, setCopyMessage] = useState("")
51
28
 
52
- const activeMotionStream = createMotionStateProvider(
53
- motionStream,
54
- connectedMotionGroup,
55
- )
56
-
57
- if (!activeMotionStream) {
29
+ if (!motionStream && !connectedMotionGroup) {
58
30
  throw new Error(
59
31
  "PoseJointValues requires either motionStream or connectedMotionGroup prop",
60
32
  )
61
33
  }
62
34
 
63
35
  function getCurrentPoseString() {
64
- if (!activeMotionStream) return ""
65
- const { joints } =
66
- activeMotionStream.rapidlyChangingMotionState.state.joint_position
36
+ let joints: number[]
37
+ if (motionStream) {
38
+ joints =
39
+ motionStream.rapidlyChangingMotionState.state.joint_position.joints
40
+ } else if (connectedMotionGroup) {
41
+ joints =
42
+ connectedMotionGroup.rapidlyChangingMotionState.state.joint_position
43
+ .joints
44
+ } else {
45
+ return ""
46
+ }
67
47
  return `[${joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
68
48
  }
69
49
 
@@ -79,12 +59,22 @@ export const PoseJointValues = externalizeComponent(
79
59
  }
80
60
 
81
61
  useAutorun(() => {
82
- if (!poseHolderRef.current || !activeMotionStream) {
62
+ if (!poseHolderRef.current) {
63
+ return
64
+ }
65
+
66
+ let joints: number[]
67
+ if (motionStream) {
68
+ joints =
69
+ motionStream.rapidlyChangingMotionState.state.joint_position.joints
70
+ } else if (connectedMotionGroup) {
71
+ joints =
72
+ connectedMotionGroup.rapidlyChangingMotionState.state.joint_position
73
+ .joints
74
+ } else {
83
75
  return
84
76
  }
85
77
 
86
- const { joints } =
87
- activeMotionStream.rapidlyChangingMotionState.state.joint_position
88
78
  const newPoseContent = `[${joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
89
79
 
90
80
  requestAnimationFrame(() => {