@wandelbots/wandelbots-js-react-components 6.0.0 → 6.1.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.
@@ -1,80 +1,80 @@
1
- import { jsx as p, jsxs as V } from "react/jsx-runtime";
2
- import { useTheme as f } from "@mui/material/styles";
3
- import R from "@mui/material/Chip";
4
- import _ from "@mui/material/Typography";
5
- import { observer as P } from "mobx-react-lite";
6
- import { useTranslation as C } from "react-i18next";
7
- import { e as O } from "./externalizeComponent-EDymnaGR.js";
8
- import x from "@mui/icons-material/Pause";
9
- import I from "@mui/icons-material/PlayArrow";
10
- import S from "@mui/icons-material/Stop";
11
- import E from "@mui/material/Box";
12
- import N from "@mui/material/Button";
13
- import { autorun as v, reaction as M } from "mobx";
14
- import A, { useEffect as Y } from "react";
15
- var c = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.PREPARING = "preparing", t.STARTING = "starting", t.RUNNING = "running", t.PAUSING = "pausing", t.PAUSED = "paused", t.STOPPING = "stopping", t.COMPLETED = "completed", t.FAILED = "failed", t.STOPPED = "stopped", t.ERROR = "error", t))(c || {});
16
- const Q = O(
17
- P(
1
+ import { jsx as g, jsxs as M } from "react/jsx-runtime";
2
+ import { useTheme as O } from "@mui/material/styles";
3
+ import w from "@mui/material/Chip";
4
+ import F from "@mui/material/Typography";
5
+ import { observer as R } from "mobx-react-lite";
6
+ import { useTranslation as V } from "react-i18next";
7
+ import { e as x } from "./externalizeComponent-EDymnaGR.js";
8
+ import Y from "@mui/icons-material/Pause";
9
+ import S from "@mui/icons-material/PlayArrow";
10
+ import P from "@mui/icons-material/Stop";
11
+ import A from "@mui/material/Box";
12
+ import D from "@mui/material/Button";
13
+ import { autorun as N, reaction as U, observable as L, runInAction as C } from "mobx";
14
+ import b, { useEffect as _, useState as G, useRef as I } from "react";
15
+ var d = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.PREPARING = "preparing", t.STARTING = "starting", t.RUNNING = "running", t.PAUSING = "pausing", t.PAUSED = "paused", t.STOPPING = "stopping", t.COMPLETED = "completed", t.FAILED = "failed", t.STOPPED = "stopped", t.ERROR = "error", t))(d || {});
16
+ const et = x(
17
+ R(
18
18
  ({
19
19
  state: t,
20
20
  onRun: e,
21
- onPause: n,
22
- onStop: l,
23
- onReset: a,
21
+ onPause: i,
22
+ onStop: s,
23
+ onReset: o,
24
24
  requiresManualReset: r = !1,
25
- variant: o = "with_pause",
26
- className: h
25
+ variant: a = "with_pause",
26
+ className: p
27
27
  }) => {
28
- const s = f(), { t: m } = C(), d = () => {
29
- const i = {
28
+ const u = O(), { t: m } = V(), l = () => {
29
+ const n = {
30
30
  run: {
31
31
  enabled: t === "idle" || t === "stopped" || t === "paused" || t === "completed" || t === "failed" || t === "error",
32
32
  label: m(t === "paused" ? "ProgramControl.Resume.bt" : t === "error" || t === "failed" ? "ProgramControl.Retry.bt" : "ProgramControl.Start.bt"),
33
- color: s.palette.success.main,
33
+ color: u.palette.success.main,
34
34
  onClick: e
35
35
  },
36
36
  pause: {
37
37
  enabled: t === "running",
38
38
  label: m("ProgramControl.Pause.bt"),
39
39
  color: "#FFFFFF33",
40
- onClick: n || (() => {
40
+ onClick: i || (() => {
41
41
  })
42
42
  },
43
43
  stop: {
44
44
  enabled: t === "preparing" || t === "starting" || t === "running" || t === "pausing" || t === "paused",
45
45
  label: m("ProgramControl.Stop.bt"),
46
- color: s.palette.error.main,
47
- onClick: l
46
+ color: u.palette.error.main,
47
+ onClick: s
48
48
  }
49
49
  };
50
- return o === "without_pause" ? [i.run, i.stop] : [i.run, i.pause, i.stop];
51
- }, g = (i) => {
52
- const u = { sx: { fontSize: "55px" } };
53
- if (o === "without_pause")
54
- return i === 0 ? /* @__PURE__ */ p(I, { ...u }) : /* @__PURE__ */ p(S, { ...u });
55
- switch (i) {
50
+ return a === "without_pause" ? [n.run, n.stop] : [n.run, n.pause, n.stop];
51
+ }, h = (n) => {
52
+ const c = { sx: { fontSize: "55px" } };
53
+ if (a === "without_pause")
54
+ return n === 0 ? /* @__PURE__ */ g(S, { ...c }) : /* @__PURE__ */ g(P, { ...c });
55
+ switch (n) {
56
56
  case 0:
57
- return /* @__PURE__ */ p(I, { ...u });
57
+ return /* @__PURE__ */ g(S, { ...c });
58
58
  case 1:
59
- return /* @__PURE__ */ p(x, { ...u });
59
+ return /* @__PURE__ */ g(Y, { ...c });
60
60
  case 2:
61
- return /* @__PURE__ */ p(S, { ...u });
61
+ return /* @__PURE__ */ g(P, { ...c });
62
62
  default:
63
63
  return null;
64
64
  }
65
- }, T = d();
66
- return /* @__PURE__ */ p(
67
- E,
65
+ }, T = l();
66
+ return /* @__PURE__ */ g(
67
+ A,
68
68
  {
69
- className: h,
69
+ className: p,
70
70
  sx: {
71
71
  display: "flex",
72
72
  flexDirection: "column",
73
73
  alignItems: "center",
74
74
  gap: 2
75
75
  },
76
- children: /* @__PURE__ */ p(
77
- E,
76
+ children: /* @__PURE__ */ g(
77
+ A,
78
78
  {
79
79
  sx: {
80
80
  display: "flex",
@@ -83,8 +83,8 @@ const Q = O(
83
83
  justifyContent: "center",
84
84
  alignItems: "center"
85
85
  },
86
- children: T.map((i, u) => /* @__PURE__ */ V(
87
- E,
86
+ children: T.map((n, c) => /* @__PURE__ */ M(
87
+ A,
88
88
  {
89
89
  sx: {
90
90
  display: "flex",
@@ -93,47 +93,47 @@ const Q = O(
93
93
  gap: 1
94
94
  },
95
95
  children: [
96
- /* @__PURE__ */ p(
97
- N,
96
+ /* @__PURE__ */ g(
97
+ D,
98
98
  {
99
99
  variant: "contained",
100
- disabled: !i.enabled || t === "preparing" || t === "starting" || t === "pausing" || t === "stopping" && !r,
101
- onClick: i.onClick,
100
+ disabled: !n.enabled || t === "preparing" || t === "starting" || t === "pausing" || t === "stopping" && !r,
101
+ onClick: n.onClick,
102
102
  sx: {
103
103
  width: "88px",
104
104
  height: "88px",
105
105
  borderRadius: "88px",
106
- backgroundColor: i.color,
107
- opacity: i.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 1 : 0.3,
106
+ backgroundColor: n.color,
107
+ opacity: n.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 1 : 0.3,
108
108
  "&:hover": {
109
- backgroundColor: i.color,
110
- opacity: i.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 0.8 : 0.3
109
+ backgroundColor: n.color,
110
+ opacity: n.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 0.8 : 0.3
111
111
  },
112
112
  "&:disabled": {
113
- backgroundColor: i.color,
113
+ backgroundColor: n.color,
114
114
  opacity: 0.3
115
115
  },
116
116
  minWidth: "88px",
117
117
  flexShrink: 0
118
118
  },
119
- children: g(u)
119
+ children: h(c)
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ p(
123
- _,
122
+ /* @__PURE__ */ g(
123
+ F,
124
124
  {
125
125
  variant: "body1",
126
126
  sx: {
127
- color: i.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? i.color : s.palette.text.disabled,
127
+ color: n.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? n.color : u.palette.text.disabled,
128
128
  textAlign: "center",
129
- opacity: i.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 1 : 0.3
129
+ opacity: n.enabled && t !== "preparing" && t !== "starting" && t !== "pausing" && !(t === "stopping" && !r) ? 1 : 0.3
130
130
  },
131
- children: i.label
131
+ children: n.label
132
132
  }
133
133
  )
134
134
  ]
135
135
  },
136
- i.label
136
+ n.label
137
137
  ))
138
138
  }
139
139
  )
@@ -141,89 +141,89 @@ const Q = O(
141
141
  );
142
142
  }
143
143
  )
144
- ), Z = O(
145
- P(
144
+ ), rt = x(
145
+ R(
146
146
  ({
147
147
  programState: t,
148
148
  safetyState: e,
149
- operationMode: n,
150
- className: l
149
+ operationMode: i,
150
+ className: s
151
151
  }) => {
152
- const a = f(), { t: r } = C(), o = () => {
152
+ const o = O(), { t: r } = V(), a = () => {
153
153
  if (e === "SAFETY_STATE_DEVICE_EMERGENCY_STOP" || e === "SAFETY_STATE_ROBOT_EMERGENCY_STOP" || e === "SAFETY_STATE_STOP_0" || e === "SAFETY_STATE_STOP_1" || e === "SAFETY_STATE_STOP_2" || e === "SAFETY_STATE_PROTECTIVE_STOP" || e === "SAFETY_STATE_STOP" || e === "SAFETY_STATE_REDUCED" || e === "SAFETY_STATE_MASTERING" || e === "SAFETY_STATE_CONFIRM_SAFETY" || e === "SAFETY_STATE_OPERATOR_SAFETY" || e === "SAFETY_STATE_RECOVERY" || e === "SAFETY_STATE_VIOLATION")
154
154
  return {
155
155
  label: r("ProgramStateIndicator.EStop.lb"),
156
- color: a.palette.error.main
156
+ color: o.palette.error.main
157
157
  };
158
158
  if (e === "SAFETY_STATE_UNKNOWN" || e === "SAFETY_STATE_FAULT")
159
159
  return {
160
160
  label: r("ProgramStateIndicator.Error.lb"),
161
- color: a.palette.error.main
161
+ color: o.palette.error.main
162
162
  };
163
163
  if (e === "SAFETY_STATE_NORMAL")
164
164
  switch (t) {
165
- case c.PREPARING:
165
+ case d.PREPARING:
166
166
  return {
167
167
  label: r("ProgramStateIndicator.Preparing.lb"),
168
- color: a.palette.warning.main
168
+ color: o.palette.warning.main
169
169
  };
170
- case c.STARTING:
170
+ case d.STARTING:
171
171
  return {
172
172
  label: r("ProgramStateIndicator.Starting.lb"),
173
- color: a.palette.warning.main
173
+ color: o.palette.warning.main
174
174
  };
175
- case c.RUNNING:
175
+ case d.RUNNING:
176
176
  return {
177
177
  label: r("ProgramStateIndicator.Running.lb"),
178
- color: a.palette.success.main
178
+ color: o.palette.success.main
179
179
  };
180
- case c.PAUSING:
180
+ case d.PAUSING:
181
181
  return {
182
182
  label: r("ProgramStateIndicator.Pausing.lb"),
183
- color: a.palette.warning.main
183
+ color: o.palette.warning.main
184
184
  };
185
- case c.PAUSED:
185
+ case d.PAUSED:
186
186
  return {
187
187
  label: r("ProgramStateIndicator.Paused.lb"),
188
- color: a.palette.grey[600]
188
+ color: o.palette.grey[600]
189
189
  };
190
- case c.STOPPING:
190
+ case d.STOPPING:
191
191
  return {
192
192
  label: r("ProgramStateIndicator.Stopping.lb"),
193
- color: a.palette.warning.main
193
+ color: o.palette.warning.main
194
194
  };
195
- case c.COMPLETED:
195
+ case d.COMPLETED:
196
196
  return {
197
197
  label: r("ProgramStateIndicator.Completed.lb"),
198
- color: a.palette.success.main
198
+ color: o.palette.success.main
199
199
  };
200
- case c.FAILED:
200
+ case d.FAILED:
201
201
  return {
202
202
  label: r("ProgramStateIndicator.Failed.lb"),
203
- color: a.palette.error.main
203
+ color: o.palette.error.main
204
204
  };
205
- case c.STOPPED:
205
+ case d.STOPPED:
206
206
  return {
207
207
  label: r("ProgramStateIndicator.Stopped.lb"),
208
- color: a.palette.warning.main
208
+ color: o.palette.warning.main
209
209
  };
210
- case c.ERROR:
210
+ case d.ERROR:
211
211
  return {
212
212
  label: r("ProgramStateIndicator.Error.lb"),
213
- color: a.palette.error.main
213
+ color: o.palette.error.main
214
214
  };
215
215
  default:
216
216
  return {
217
217
  label: r("ProgramStateIndicator.Ready.lb"),
218
- color: a.palette.success.main
218
+ color: o.palette.success.main
219
219
  };
220
220
  }
221
221
  return {
222
222
  label: r("ProgramStateIndicator.Idle.lb"),
223
- color: a.palette.grey[600]
223
+ color: o.palette.grey[600]
224
224
  };
225
- }, { label: h, color: s } = o(), d = `${h} / ${(() => {
226
- switch (n) {
225
+ }, { label: p, color: u } = a(), l = `${p} / ${(() => {
226
+ switch (i) {
227
227
  case "OPERATION_MODE_AUTO":
228
228
  return r("ProgramStateIndicator.Auto.lb");
229
229
  case "OPERATION_MODE_MANUAL":
@@ -236,12 +236,12 @@ const Q = O(
236
236
  return r("ProgramStateIndicator.Auto.lb");
237
237
  }
238
238
  })()}`;
239
- return /* @__PURE__ */ p(
240
- R,
239
+ return /* @__PURE__ */ g(
240
+ w,
241
241
  {
242
- className: l,
243
- label: /* @__PURE__ */ p(
244
- _,
242
+ className: s,
243
+ label: /* @__PURE__ */ g(
244
+ F,
245
245
  {
246
246
  variant: "body2",
247
247
  sx: {
@@ -249,13 +249,13 @@ const Q = O(
249
249
  // Smaller than body2
250
250
  lineHeight: 1.2
251
251
  },
252
- children: d
252
+ children: l
253
253
  }
254
254
  ),
255
255
  variant: "filled",
256
256
  sx: {
257
- backgroundColor: s,
258
- color: a.palette.getContrastText(s),
257
+ backgroundColor: u,
258
+ color: o.palette.getContrastText(u),
259
259
  fontWeight: 500,
260
260
  height: "auto",
261
261
  "& .MuiChip-label": {
@@ -268,28 +268,28 @@ const Q = O(
268
268
  }
269
269
  )
270
270
  );
271
- function b(t) {
272
- Y(t, []);
271
+ function E(t) {
272
+ _(t, []);
273
273
  }
274
- function q(t) {
275
- b(() => v(t));
274
+ function nt(t) {
275
+ E(() => N(t));
276
276
  }
277
- function tt(t, e, n) {
278
- b(() => M(t, e, n));
277
+ function ot(t, e, i) {
278
+ E(() => U(t, e, i));
279
279
  }
280
- function et(t) {
281
- return b(() => {
280
+ function it(t) {
281
+ return E(() => {
282
282
  let e;
283
- function n() {
284
- t(), e = requestAnimationFrame(n);
283
+ function i() {
284
+ t(), e = requestAnimationFrame(i);
285
285
  }
286
- return e = requestAnimationFrame(n), () => {
286
+ return e = requestAnimationFrame(i), () => {
287
287
  cancelAnimationFrame(e);
288
288
  };
289
289
  });
290
290
  }
291
- class D {
292
- constructor(e = [], n = {}) {
291
+ class v {
292
+ constructor(e = [], i = {}) {
293
293
  this.currentValues = [], this.targetValues = [], this.previousTargetValues = [], this.targetUpdateTime = 0, this.animationId = null, this.updateCount = 0, this.velocities = [], this.animate = () => {
294
294
  this.update(0.016666666666666666) ? this.animationId = null : this.animationId = requestAnimationFrame(this.animate);
295
295
  }, this.options = {
@@ -300,7 +300,7 @@ class D {
300
300
  },
301
301
  onComplete: () => {
302
302
  },
303
- ...n
303
+ ...i
304
304
  }, this.currentValues = [...e], this.targetValues = [...e], this.previousTargetValues = [...e], this.velocities = new Array(e.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0;
305
305
  }
306
306
  /**
@@ -313,14 +313,14 @@ class D {
313
313
  * @returns true when interpolation is complete (all values reached their targets)
314
314
  */
315
315
  update(e = 1 / 60) {
316
- let n = !1, l = !0;
316
+ let i = !1, s = !0;
317
317
  this.updateCount++;
318
- const a = Math.min(e, 1 / 15), r = this.updateCount === 1 ? 0.7 : 1;
319
- for (let o = 0; o < this.currentValues.length; o++) {
320
- const h = this.currentValues[o], s = this.targetValues[o], m = this.velocities[o], d = s - h, g = d * this.options.tension * r, T = m * this.options.friction, i = g - T, u = m + i * a, F = h + u * a;
321
- Math.abs(d) < this.options.threshold && Math.abs(u) < this.options.threshold * 10 ? this.currentValues[o] !== s && (this.currentValues[o] = s, this.velocities[o] = 0, n = !0) : (l = !1, this.currentValues[o] = F, this.velocities[o] = u, n = !0);
318
+ const o = Math.min(e, 1 / 15), r = this.updateCount === 1 ? 0.7 : 1;
319
+ for (let a = 0; a < this.currentValues.length; a++) {
320
+ const p = this.currentValues[a], u = this.targetValues[a], m = this.velocities[a], l = u - p, h = l * this.options.tension * r, T = m * this.options.friction, n = h - T, c = m + n * o, f = p + c * o;
321
+ Math.abs(l) < this.options.threshold && Math.abs(c) < this.options.threshold * 10 ? this.currentValues[a] !== u && (this.currentValues[a] = u, this.velocities[a] = 0, i = !0) : (s = !1, this.currentValues[a] = f, this.velocities[a] = c, i = !0);
322
322
  }
323
- return n && this.options.onChange(this.currentValues), l && this.options.onComplete(this.currentValues), l;
323
+ return i && this.options.onChange(this.currentValues), s && this.options.onComplete(this.currentValues), s;
324
324
  }
325
325
  /**
326
326
  * Set new target values for the interpolation to move towards
@@ -329,16 +329,16 @@ class D {
329
329
  * to prevent jarring movements when targets change frequently.
330
330
  */
331
331
  setTarget(e) {
332
- const n = performance.now(), l = n - this.targetUpdateTime;
333
- this.previousTargetValues = [...this.targetValues], this.targetValues = [...e], this.targetUpdateTime = n, this.updateCount = 0;
334
- const a = this.previousTargetValues.every(
335
- (r, o) => r === this.currentValues[o]
332
+ const i = performance.now(), s = i - this.targetUpdateTime;
333
+ this.previousTargetValues = [...this.targetValues], this.targetValues = [...e], this.targetUpdateTime = i, this.updateCount = 0;
334
+ const o = this.previousTargetValues.every(
335
+ (r, a) => r === this.currentValues[a]
336
336
  );
337
- if (l < 8 && l > 0 && this.previousTargetValues.length > 0 && !a) {
338
- const r = Math.min(l / 8, 1);
339
- for (let o = 0; o < this.targetValues.length; o++) {
340
- const h = this.previousTargetValues[o] || 0, s = e[o] || 0;
341
- Math.abs(s - h) > 0.1 && (this.targetValues[o] = h + (s - h) * r);
337
+ if (s < 8 && s > 0 && this.previousTargetValues.length > 0 && !o) {
338
+ const r = Math.min(s / 8, 1);
339
+ for (let a = 0; a < this.targetValues.length; a++) {
340
+ const p = this.previousTargetValues[a] || 0, u = e[a] || 0;
341
+ Math.abs(u - p) > 0.1 && (this.targetValues[a] = p + (u - p) * r);
342
342
  }
343
343
  }
344
344
  for (; this.currentValues.length < e.length; )
@@ -410,24 +410,69 @@ class D {
410
410
  this.animationId === null && this.animate();
411
411
  }
412
412
  }
413
- function rt(t = [], e = {}) {
414
- const n = A.useRef(null);
415
- return n.current || (n.current = new D(t, e)), A.useEffect(() => {
416
- var l;
417
- (l = n.current) == null || l.updateOptions(e);
418
- }, [e]), A.useEffect(() => () => {
413
+ function at(t = [], e = {}) {
414
+ const i = b.useRef(null);
415
+ return i.current || (i.current = new v(t, e)), b.useEffect(() => {
416
+ var s;
417
+ (s = i.current) == null || s.updateOptions(e);
418
+ }, [e]), b.useEffect(() => () => {
419
+ var s;
420
+ (s = i.current) == null || s.destroy();
421
+ }, []), [i.current];
422
+ }
423
+ function st(t, e) {
424
+ const [i] = G(
425
+ () => L({ ...t })
426
+ ), s = I(null), o = I(null), r = I(0);
427
+ function a() {
428
+ o.current !== null && (cancelAnimationFrame(o.current), o.current = null);
429
+ }
430
+ function p() {
431
+ const l = s.current;
432
+ if (!l) return;
433
+ const h = performance.now(), T = (h - r.current) / 1e3;
434
+ r.current = h;
435
+ const n = l.update(T);
436
+ C(() => {
437
+ i.joint_position = l.getCurrentValues();
438
+ }), o.current = n ? null : requestAnimationFrame(p);
439
+ }
440
+ function u() {
441
+ o.current === null && (r.current = performance.now(), o.current = requestAnimationFrame(p));
442
+ }
443
+ function m(l) {
444
+ var T;
445
+ const h = l.joint_position.filter(
446
+ (n) => n !== void 0
447
+ );
448
+ (T = s.current) == null || T.setTarget(h), C(() => {
449
+ const n = l, c = i;
450
+ for (const f of Object.keys(n))
451
+ f !== "joint_position" && c[f] !== n[f] && (c[f] = n[f]);
452
+ }), u();
453
+ }
454
+ return E(() => {
455
+ const l = t.joint_position.filter(
456
+ (h) => h !== void 0
457
+ );
458
+ return s.current = new v(l, e), () => {
459
+ var h;
460
+ a(), (h = s.current) == null || h.destroy();
461
+ };
462
+ }), _(() => {
419
463
  var l;
420
- (l = n.current) == null || l.destroy();
421
- }, []), [n.current];
464
+ e && ((l = s.current) == null || l.updateOptions(e));
465
+ }, [e]), _(() => N(() => m(t)), [t]), i;
422
466
  }
423
467
  export {
424
- c as P,
425
- D as V,
426
- Q as a,
427
- Z as b,
428
- q as c,
429
- tt as d,
430
- et as e,
431
- rt as f,
432
- b as u
468
+ d as P,
469
+ v as V,
470
+ et as a,
471
+ rt as b,
472
+ E as c,
473
+ nt as d,
474
+ ot as e,
475
+ it as f,
476
+ at as g,
477
+ st as u
433
478
  };
@@ -0,0 +1 @@
1
+ "use strict";const g=require("react/jsx-runtime"),C=require("@mui/material/styles"),V=require("@mui/material/Chip"),x=require("@mui/material/Typography"),O=require("mobx-react-lite"),R=require("react-i18next"),F=require("./externalizeComponent-OO4jcrz5.cjs"),N=require("@mui/icons-material/Pause"),_=require("@mui/icons-material/PlayArrow"),P=require("@mui/icons-material/Stop"),f=require("@mui/material/Box"),v=require("@mui/material/Button"),b=require("mobx"),T=require("react");var m=(e=>(e.IDLE="idle",e.PREPARING="preparing",e.STARTING="starting",e.RUNNING="running",e.PAUSING="pausing",e.PAUSED="paused",e.STOPPING="stopping",e.COMPLETED="completed",e.FAILED="failed",e.STOPPED="stopped",e.ERROR="error",e))(m||{});const M=F.externalizeComponent(O.observer(({state:e,onRun:t,onPause:i,onStop:s,onReset:o,requiresManualReset:r=!1,variant:a="with_pause",className:p})=>{const u=C.useTheme(),{t:d}=R.useTranslation(),l=()=>{const n={run:{enabled:e==="idle"||e==="stopped"||e==="paused"||e==="completed"||e==="failed"||e==="error",label:d(e==="paused"?"ProgramControl.Resume.bt":e==="error"||e==="failed"?"ProgramControl.Retry.bt":"ProgramControl.Start.bt"),color:u.palette.success.main,onClick:t},pause:{enabled:e==="running",label:d("ProgramControl.Pause.bt"),color:"#FFFFFF33",onClick:i||(()=>{})},stop:{enabled:e==="preparing"||e==="starting"||e==="running"||e==="pausing"||e==="paused",label:d("ProgramControl.Stop.bt"),color:u.palette.error.main,onClick:s}};return a==="without_pause"?[n.run,n.stop]:[n.run,n.pause,n.stop]},h=n=>{const c={sx:{fontSize:"55px"}};if(a==="without_pause")return n===0?g.jsx(_,{...c}):g.jsx(P,{...c});switch(n){case 0:return g.jsx(_,{...c});case 1:return g.jsx(N,{...c});case 2:return g.jsx(P,{...c});default:return null}},A=l();return g.jsx(f,{className:p,sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:g.jsx(f,{sx:{display:"flex",gap:"40px",flexWrap:"wrap",justifyContent:"center",alignItems:"center"},children:A.map((n,c)=>g.jsxs(f,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[g.jsx(v,{variant:"contained",disabled:!n.enabled||e==="preparing"||e==="starting"||e==="pausing"||e==="stopping"&&!r,onClick:n.onClick,sx:{width:"88px",height:"88px",borderRadius:"88px",backgroundColor:n.color,opacity:n.enabled&&e!=="preparing"&&e!=="starting"&&e!=="pausing"&&!(e==="stopping"&&!r)?1:.3,"&:hover":{backgroundColor:n.color,opacity:n.enabled&&e!=="preparing"&&e!=="starting"&&e!=="pausing"&&!(e==="stopping"&&!r)?.8:.3},"&:disabled":{backgroundColor:n.color,opacity:.3},minWidth:"88px",flexShrink:0},children:h(c)}),g.jsx(x,{variant:"body1",sx:{color:n.enabled&&e!=="preparing"&&e!=="starting"&&e!=="pausing"&&!(e==="stopping"&&!r)?n.color:u.palette.text.disabled,textAlign:"center",opacity:n.enabled&&e!=="preparing"&&e!=="starting"&&e!=="pausing"&&!(e==="stopping"&&!r)?1:.3},children:n.label})]},n.label))})})})),w=F.externalizeComponent(O.observer(({programState:e,safetyState:t,operationMode:i,className:s})=>{const o=C.useTheme(),{t:r}=R.useTranslation(),a=()=>{if(t==="SAFETY_STATE_DEVICE_EMERGENCY_STOP"||t==="SAFETY_STATE_ROBOT_EMERGENCY_STOP"||t==="SAFETY_STATE_STOP_0"||t==="SAFETY_STATE_STOP_1"||t==="SAFETY_STATE_STOP_2"||t==="SAFETY_STATE_PROTECTIVE_STOP"||t==="SAFETY_STATE_STOP"||t==="SAFETY_STATE_REDUCED"||t==="SAFETY_STATE_MASTERING"||t==="SAFETY_STATE_CONFIRM_SAFETY"||t==="SAFETY_STATE_OPERATOR_SAFETY"||t==="SAFETY_STATE_RECOVERY"||t==="SAFETY_STATE_VIOLATION")return{label:r("ProgramStateIndicator.EStop.lb"),color:o.palette.error.main};if(t==="SAFETY_STATE_UNKNOWN"||t==="SAFETY_STATE_FAULT")return{label:r("ProgramStateIndicator.Error.lb"),color:o.palette.error.main};if(t==="SAFETY_STATE_NORMAL")switch(e){case m.PREPARING:return{label:r("ProgramStateIndicator.Preparing.lb"),color:o.palette.warning.main};case m.STARTING:return{label:r("ProgramStateIndicator.Starting.lb"),color:o.palette.warning.main};case m.RUNNING:return{label:r("ProgramStateIndicator.Running.lb"),color:o.palette.success.main};case m.PAUSING:return{label:r("ProgramStateIndicator.Pausing.lb"),color:o.palette.warning.main};case m.PAUSED:return{label:r("ProgramStateIndicator.Paused.lb"),color:o.palette.grey[600]};case m.STOPPING:return{label:r("ProgramStateIndicator.Stopping.lb"),color:o.palette.warning.main};case m.COMPLETED:return{label:r("ProgramStateIndicator.Completed.lb"),color:o.palette.success.main};case m.FAILED:return{label:r("ProgramStateIndicator.Failed.lb"),color:o.palette.error.main};case m.STOPPED:return{label:r("ProgramStateIndicator.Stopped.lb"),color:o.palette.warning.main};case m.ERROR:return{label:r("ProgramStateIndicator.Error.lb"),color:o.palette.error.main};default:return{label:r("ProgramStateIndicator.Ready.lb"),color:o.palette.success.main}}return{label:r("ProgramStateIndicator.Idle.lb"),color:o.palette.grey[600]}},{label:p,color:u}=a(),l=`${p} / ${(()=>{switch(i){case"OPERATION_MODE_AUTO":return r("ProgramStateIndicator.Auto.lb");case"OPERATION_MODE_MANUAL":return r("ProgramStateIndicator.Manual.lb");case"OPERATION_MODE_MANUAL_T1":return r("ProgramStateIndicator.ManualT1.lb");case"OPERATION_MODE_MANUAL_T2":return r("ProgramStateIndicator.ManualT2.lb");default:return r("ProgramStateIndicator.Auto.lb")}})()}`;return g.jsx(V,{className:s,label:g.jsx(x,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:l}),variant:"filled",sx:{backgroundColor:u,color:o.palette.getContrastText(u),fontWeight:500,height:"auto","& .MuiChip-label":{paddingX:1.5,paddingY:.5}}})}));function I(e){T.useEffect(e,[])}function Y(e){I(()=>b.autorun(e))}function j(e,t,i){I(()=>b.reaction(e,t,i))}function D(e){return I(()=>{let t;function i(){e(),t=requestAnimationFrame(i)}return t=requestAnimationFrame(i),()=>{cancelAnimationFrame(t)}})}class S{constructor(t=[],i={}){this.currentValues=[],this.targetValues=[],this.previousTargetValues=[],this.targetUpdateTime=0,this.animationId=null,this.updateCount=0,this.velocities=[],this.animate=()=>{this.update(.016666666666666666)?this.animationId=null:this.animationId=requestAnimationFrame(this.animate)},this.options={tension:120,friction:20,threshold:.001,onChange:()=>{},onComplete:()=>{},...i},this.currentValues=[...t],this.targetValues=[...t],this.previousTargetValues=[...t],this.velocities=new Array(t.length).fill(0),this.targetUpdateTime=performance.now(),this.updateCount=0}update(t=1/60){let i=!1,s=!0;this.updateCount++;const o=Math.min(t,1/15),r=this.updateCount===1?.7:1;for(let a=0;a<this.currentValues.length;a++){const p=this.currentValues[a],u=this.targetValues[a],d=this.velocities[a],l=u-p,h=l*this.options.tension*r,A=d*this.options.friction,n=h-A,c=d+n*o,E=p+c*o;Math.abs(l)<this.options.threshold&&Math.abs(c)<this.options.threshold*10?this.currentValues[a]!==u&&(this.currentValues[a]=u,this.velocities[a]=0,i=!0):(s=!1,this.currentValues[a]=E,this.velocities[a]=c,i=!0)}return i&&this.options.onChange(this.currentValues),s&&this.options.onComplete(this.currentValues),s}setTarget(t){const i=performance.now(),s=i-this.targetUpdateTime;this.previousTargetValues=[...this.targetValues],this.targetValues=[...t],this.targetUpdateTime=i,this.updateCount=0;const o=this.previousTargetValues.every((r,a)=>r===this.currentValues[a]);if(s<8&&s>0&&this.previousTargetValues.length>0&&!o){const r=Math.min(s/8,1);for(let a=0;a<this.targetValues.length;a++){const p=this.previousTargetValues[a]||0,u=t[a]||0;Math.abs(u-p)>.1&&(this.targetValues[a]=p+(u-p)*r)}}for(;this.currentValues.length<t.length;)this.currentValues.push(t[this.currentValues.length]),this.velocities.push(0);this.currentValues.length>t.length&&(this.currentValues=this.currentValues.slice(0,t.length),this.velocities=this.velocities.slice(0,t.length))}getCurrentValues(){return[...this.currentValues]}getValue(t){return this.currentValues[t]??0}isInterpolating(){return this.animationId!==null}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setImmediate(t){this.stop(),this.currentValues=[...t],this.targetValues=[...t],this.previousTargetValues=[...t],this.velocities=new Array(t.length).fill(0),this.targetUpdateTime=performance.now(),this.updateCount=0,this.options.onChange(this.currentValues)}updateOptions(t){this.options={...this.options,...t}}startAutoInterpolation(){this.startInterpolation()}destroy(){this.stop()}startInterpolation(){this.animationId===null&&this.animate()}}function U(e=[],t={}){const i=T.useRef(null);return i.current||(i.current=new S(e,t)),T.useEffect(()=>{var s;(s=i.current)==null||s.updateOptions(t)},[t]),T.useEffect(()=>()=>{var s;(s=i.current)==null||s.destroy()},[]),[i.current]}function L(e,t){const[i]=T.useState(()=>b.observable({...e})),s=T.useRef(null),o=T.useRef(null),r=T.useRef(0);function a(){o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}function p(){const l=s.current;if(!l)return;const h=performance.now(),A=(h-r.current)/1e3;r.current=h;const n=l.update(A);b.runInAction(()=>{i.joint_position=l.getCurrentValues()}),o.current=n?null:requestAnimationFrame(p)}function u(){o.current===null&&(r.current=performance.now(),o.current=requestAnimationFrame(p))}function d(l){var A;const h=l.joint_position.filter(n=>n!==void 0);(A=s.current)==null||A.setTarget(h),b.runInAction(()=>{const n=l,c=i;for(const E of Object.keys(n))E!=="joint_position"&&c[E]!==n[E]&&(c[E]=n[E])}),u()}return I(()=>{const l=e.joint_position.filter(h=>h!==void 0);return s.current=new S(l,t),()=>{var h;a(),(h=s.current)==null||h.destroy()}}),T.useEffect(()=>{var l;t&&((l=s.current)==null||l.updateOptions(t))},[t]),T.useEffect(()=>b.autorun(()=>d(e)),[e]),i}exports.ProgramControl=M;exports.ProgramState=m;exports.ProgramStateIndicator=w;exports.ValueInterpolator=S;exports.useAnimationFrame=D;exports.useAutorun=Y;exports.useInterpolation=U;exports.useMounted=I;exports.useReaction=j;exports.useSmoothedMotionState=L;
@@ -7,5 +7,12 @@ type LinearAxisAnimatorProps = {
7
7
  onTranslationChanged?: (joints: Object3D[], jointValues: number[]) => void;
8
8
  children: React.ReactNode;
9
9
  };
10
+ /**
11
+ * Applies the incoming motion state to the linear axis, as-is.
12
+ *
13
+ * This component performs no smoothing: it renders exactly the pose it is
14
+ * given. If damped/spring transitions are desired, run the motion state
15
+ * through {@link useSmoothedMotionState} before passing it here.
16
+ */
10
17
  export default function LinearAxisAnimator({ rapidlyChangingMotionState, dhParameters, onTranslationChanged, children, }: LinearAxisAnimatorProps): import("react/jsx-runtime").JSX.Element;
11
18
  export {};
@@ -5,5 +5,20 @@ export type MotionGroupVisualizerProps = {
5
5
  instanceUrl: string;
6
6
  inverseSolver?: string | null;
7
7
  } & (SupportedRobotProps | SupportedLinearAxisProps);
8
+ /**
9
+ * Picks the right visualizer for the motion group (robot, turntable or linear
10
+ * axis) and renders it at exactly the pose it is given — no smoothing.
11
+ *
12
+ * For spring-damped transitions, use {@link MotionGroupVisualizer}.
13
+ */
14
+ export declare const MotionGroupVisualizerExact: React.FC<MotionGroupVisualizerProps>;
15
+ /**
16
+ * Motion group visualizer with built-in spring smoothing of the joint stream.
17
+ *
18
+ * Thin wrapper that runs the incoming motion state through
19
+ * {@link useSmoothedMotionState} and renders {@link MotionGroupVisualizerExact}.
20
+ * It is the batteries-included default; drop down to `MotionGroupVisualizerExact`
21
+ * when you need to control or disable smoothing.
22
+ */
8
23
  export declare const MotionGroupVisualizer: React.FC<MotionGroupVisualizerProps>;
9
24
  export default MotionGroupVisualizer;
@@ -16,5 +16,12 @@ type RobotAnimatorProps = {
16
16
  onRotationChanged?: (joints: Object3D[], jointValues: number[]) => void;
17
17
  children: React.ReactNode;
18
18
  };
19
+ /**
20
+ * Applies the incoming motion state to the robot's joints, as-is.
21
+ *
22
+ * This component performs no smoothing: it renders exactly the pose it is
23
+ * given. If damped/spring transitions are desired, run the motion state
24
+ * through {@link useSmoothedMotionState} before passing it here.
25
+ */
19
26
  declare const RobotAnimator: React.ForwardRefExoticComponent<RobotAnimatorProps & React.RefAttributes<RobotAnimatorHandle>>;
20
27
  export default RobotAnimator;
@@ -15,5 +15,22 @@ export type SupportedLinearAxisProps = {
15
15
  postModelRender?: () => void;
16
16
  transparentColor?: string;
17
17
  } & ThreeElements["group"];
18
- export declare const SupportedLinearAxis: ({ rapidlyChangingMotionState, modelFromController, dhParameters, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedLinearAxisProps) => import("react/jsx-runtime").JSX.Element;
18
+ /**
19
+ * Renders the linear axis at exactly the pose it is given, frame by frame — no
20
+ * smoothing, so it tracks the streamed motion state with no lag or overshoot.
21
+ *
22
+ * Use this when the incoming stream is already the exact pose to display. For
23
+ * spring-damped transitions, use {@link SupportedLinearAxis}, or compose
24
+ * {@link useSmoothedMotionState} with this component yourself.
25
+ */
26
+ export declare const SupportedLinearAxisExact: ({ rapidlyChangingMotionState, modelFromController, dhParameters, getModel, flangeRef, postModelRender, transparentColor, instanceUrl, ...props }: SupportedLinearAxisProps) => import("react/jsx-runtime").JSX.Element;
27
+ /**
28
+ * Linear axis visualizer with built-in spring smoothing of the joint stream.
29
+ *
30
+ * Thin wrapper that runs the incoming motion state through
31
+ * {@link useSmoothedMotionState} and renders {@link SupportedLinearAxisExact}.
32
+ * It is the batteries-included default; drop down to `SupportedLinearAxisExact`
33
+ * when you need to control or disable smoothing.
34
+ */
35
+ export declare const SupportedLinearAxis: ({ rapidlyChangingMotionState, ...props }: SupportedLinearAxisProps) => import("react/jsx-runtime").JSX.Element;
19
36
  export default SupportedLinearAxis;