@viamrobotics/test-widgets 0.16.0 → 0.17.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.
Files changed (132) hide show
  1. package/dist/components/api-section.svelte +58 -50
  2. package/dist/components/api-section.svelte.d.ts +24 -11
  3. package/dist/components/content-rect.svelte +6 -0
  4. package/dist/components/content-rect.svelte.d.ts +1 -0
  5. package/dist/components/error.svelte +9 -0
  6. package/dist/components/error.svelte.d.ts +6 -0
  7. package/dist/components/index.d.ts +4 -2
  8. package/dist/components/index.js +4 -2
  9. package/dist/components/is-moving.svelte +26 -34
  10. package/dist/components/is-moving.svelte.d.ts +4 -5
  11. package/dist/components/progress.svelte +1 -0
  12. package/dist/components/queries.svelte +7 -0
  13. package/dist/components/queries.svelte.d.ts +4 -0
  14. package/dist/components/query.svelte +7 -0
  15. package/dist/components/query.svelte.d.ts +4 -0
  16. package/dist/components/section/index.d.ts +2 -0
  17. package/dist/components/section/index.js +2 -0
  18. package/dist/components/section/section-error-reporter.d.ts +8 -0
  19. package/dist/components/section/section-error-reporter.js +7 -0
  20. package/dist/components/section/section-error.svelte +36 -0
  21. package/dist/components/section/section-error.svelte.d.ts +9 -0
  22. package/dist/components/section/section-errors.svelte +132 -5
  23. package/dist/components/section/section.svelte +7 -1
  24. package/dist/components/section/section.svelte.d.ts +3 -0
  25. package/dist/components/section/use-section-errors.svelte.d.ts +1 -0
  26. package/dist/components/section/use-section-errors.svelte.js +11 -1
  27. package/dist/components/stop-button.svelte +1 -5
  28. package/dist/components/stop-button.svelte.d.ts +0 -1
  29. package/dist/components/stop.svelte +2 -2
  30. package/dist/components/widgets/arm/arm.svelte +24 -32
  31. package/dist/components/widgets/arm/get-joint-positions-widget.svelte +9 -8
  32. package/dist/components/widgets/arm/manual-mode-widget.svelte +13 -4
  33. package/dist/components/widgets/arm/manual-mode.svelte +1 -5
  34. package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
  35. package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +10 -4
  36. package/dist/components/widgets/arm/move-to-joint-positions.svelte +1 -11
  37. package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
  38. package/dist/components/widgets/arm/move-to-position-control.svelte +22 -18
  39. package/dist/components/widgets/arm/move-to-position.svelte +0 -4
  40. package/dist/components/widgets/arm/move-to-position.svelte.d.ts +0 -1
  41. package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
  42. package/dist/components/widgets/arm/quick-move.svelte +1 -4
  43. package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
  44. package/dist/components/widgets/audio-input/audio-input.svelte +76 -74
  45. package/dist/components/widgets/audio-input/get-properties-widget.svelte +15 -15
  46. package/dist/components/widgets/audio-output/audio-output.svelte +83 -81
  47. package/dist/components/widgets/audio-output/get-properties-widget.svelte +15 -15
  48. package/dist/components/widgets/base/base.svelte +70 -37
  49. package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
  50. package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
  51. package/dist/components/widgets/base/set-power-widget.svelte +20 -8
  52. package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
  53. package/dist/components/widgets/base/spin-widget.svelte +20 -8
  54. package/dist/components/widgets/board/read-write-pins.svelte +2 -2
  55. package/dist/components/widgets/button/push.svelte +2 -2
  56. package/dist/components/widgets/camera/camera.svelte +15 -23
  57. package/dist/components/widgets/camera/live-or-polling-video.svelte +12 -9
  58. package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
  59. package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
  60. package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
  61. package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
  62. package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
  63. package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
  64. package/dist/components/widgets/custom-control/custom-control.js +85 -0
  65. package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
  66. package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
  67. package/dist/components/widgets/discovery/discovery.svelte +10 -15
  68. package/dist/components/widgets/encoder/encoder.svelte +20 -18
  69. package/dist/components/widgets/encoder/get-position-widget.svelte +18 -15
  70. package/dist/components/widgets/gantry/gantry.svelte +50 -74
  71. package/dist/components/widgets/gantry/get-position-widget.svelte +14 -13
  72. package/dist/components/widgets/gantry/home.svelte +21 -10
  73. package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
  74. package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
  75. package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
  76. package/dist/components/widgets/gantry/quick-move-widget.svelte +2 -1
  77. package/dist/components/widgets/gantry/quick-move.svelte +1 -5
  78. package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
  79. package/dist/components/widgets/generic/generic.svelte +7 -5
  80. package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
  81. package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
  82. package/dist/components/widgets/gripper/grab.svelte +3 -19
  83. package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
  84. package/dist/components/widgets/gripper/gripper.svelte +10 -12
  85. package/dist/components/widgets/gripper/is-holding-something.svelte +18 -19
  86. package/dist/components/widgets/gripper/open-widget.svelte +26 -0
  87. package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
  88. package/dist/components/widgets/gripper/open.svelte +3 -19
  89. package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
  90. package/dist/components/widgets/input-controller/input-controller.svelte +7 -14
  91. package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
  92. package/dist/components/widgets/motion/motion.svelte +27 -35
  93. package/dist/components/widgets/motion/move-widget.svelte +32 -12
  94. package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
  95. package/dist/components/widgets/motion/move.svelte +1 -13
  96. package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
  97. package/dist/components/widgets/motor/go-for-view.svelte +16 -8
  98. package/dist/components/widgets/motor/go-to-view.svelte +12 -4
  99. package/dist/components/widgets/motor/motor.svelte +88 -54
  100. package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
  101. package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
  102. package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
  103. package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +7 -10
  104. package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +7 -10
  105. package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +7 -10
  106. package/dist/components/widgets/movement-sensor/get-position-widget.svelte +7 -10
  107. package/dist/components/widgets/movement-sensor/movement-sensor.svelte +55 -56
  108. package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
  109. package/dist/components/widgets/power-sensor/get-current-widget.svelte +7 -10
  110. package/dist/components/widgets/power-sensor/get-power-widget.svelte +7 -10
  111. package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +7 -10
  112. package/dist/components/widgets/power-sensor/power-sensor.svelte +26 -38
  113. package/dist/components/widgets/sensor/sensor.svelte +5 -10
  114. package/dist/components/widgets/servo/move-widget.svelte +2 -1
  115. package/dist/components/widgets/servo/move.svelte +1 -4
  116. package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
  117. package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
  118. package/dist/components/widgets/servo/quick-move.svelte +1 -5
  119. package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
  120. package/dist/components/widgets/servo/servo.svelte +44 -33
  121. package/dist/components/widgets/slam/get-position-widget.svelte +7 -10
  122. package/dist/components/widgets/slam/move-on-map.svelte +6 -5
  123. package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
  124. package/dist/components/widgets/slam/slam.svelte +64 -79
  125. package/dist/components/widgets/switch/position.svelte +2 -2
  126. package/package.json +3 -2
  127. package/dist/components/mutation-section.svelte +0 -75
  128. package/dist/components/mutation-section.svelte.d.ts +0 -18
  129. package/dist/components/mutation-view.svelte +0 -29
  130. package/dist/components/mutation-view.svelte.d.ts +0 -10
  131. package/dist/components/section-title.svelte +0 -65
  132. package/dist/components/section-title.svelte.d.ts +0 -15
@@ -7,6 +7,7 @@
7
7
  } from '@viamrobotics/svelte-sdk'
8
8
 
9
9
  import Query from '../../query.svelte'
10
+ import { Section } from '../../section'
10
11
 
11
12
  import QuickMove from './quick-move.svelte'
12
13
 
@@ -38,10 +39,10 @@
38
39
  {#if positions !== undefined}
39
40
  <QuickMove
40
41
  {positions}
41
- lastError={quickMoveMutation.error}
42
42
  moveTo={(newPos: number[], speeds: number[]) => {
43
43
  quickMoveMutation.mutate([newPos, speeds], {})
44
44
  }}
45
45
  />
46
46
  {/if}
47
47
  </Query>
48
+ <Section.Error error={quickMoveMutation.error} />
@@ -1,16 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '@viamrobotics/prime-core'
3
3
 
4
- import ErrorDisplay from '../../error.svelte'
5
4
  import Table from '../../table.svelte'
6
5
 
7
6
  interface Props {
8
7
  positions: number[]
9
8
  moveTo: (newPos: number[], speeds: number[]) => void
10
- lastError: Error | null
11
9
  }
12
10
 
13
- const { positions, moveTo, lastError }: Props = $props()
11
+ const { positions, moveTo }: Props = $props()
14
12
 
15
13
  // mm/s
16
14
  const quickMoveSpeed = 50
@@ -65,5 +63,3 @@
65
63
  {/each}
66
64
  </tbody>
67
65
  </Table>
68
-
69
- <ErrorDisplay {lastError} />
@@ -1,7 +1,6 @@
1
1
  interface Props {
2
2
  positions: number[];
3
3
  moveTo: (newPos: number[], speeds: number[]) => void;
4
- lastError: Error | null;
5
4
  }
6
5
  declare const QuickMove: import("svelte").Component<Props, {}, "">;
7
6
  type QuickMove = ReturnType<typeof QuickMove>;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { ResourceName } from '@viamrobotics/sdk'
3
3
 
4
- import SectionTitle from '../../section-title.svelte'
4
+ import { Section } from '../../section'
5
5
  import { ResourceTriplets } from '../../../resource-triplet'
6
6
 
7
7
  import DoCommand from '../do-command/do-command.svelte'
@@ -27,10 +27,12 @@
27
27
  </script>
28
28
 
29
29
  <div class="flex flex-col py-2 pl-4">
30
- <SectionTitle
31
- title="DoCommand"
32
- {api}
33
- />
30
+ <Section.Heading>
31
+ <Section.Method
32
+ method="DoCommand"
33
+ {api}
34
+ />
35
+ </Section.Heading>
34
36
  </div>
35
37
 
36
38
  {#key genericResourceName}
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { GripperClient } from '@viamrobotics/sdk'
3
+ import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
+
5
+ import { Section } from '../../section'
6
+
7
+ import Grab from './grab.svelte'
8
+
9
+ interface Props {
10
+ partID: string
11
+ resourceName: string
12
+ }
13
+
14
+ const { partID, resourceName }: Props = $props()
15
+
16
+ const client = createResourceClient(
17
+ GripperClient,
18
+ () => partID,
19
+ () => resourceName
20
+ )
21
+
22
+ const grabMutation = createResourceMutation(client, 'grab')
23
+ </script>
24
+
25
+ <Grab onGrab={() => grabMutation.mutate([], {})} />
26
+ <Section.Error error={grabMutation.error} />
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ partID: string;
3
+ resourceName: string;
4
+ }
5
+ declare const GrabWidget: import("svelte").Component<Props, {}, "">;
6
+ type GrabWidget = ReturnType<typeof GrabWidget>;
7
+ export default GrabWidget;
@@ -1,32 +1,17 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '@viamrobotics/prime-core'
3
- import { GripperClient } from '@viamrobotics/sdk'
4
- import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
5
-
6
- import ErrorDisplay from '../../error.svelte'
7
3
 
8
4
  import ClosedGripperSvg from './closed-gripper-svg.svelte'
9
5
 
10
6
  interface Props {
11
- partID: string
12
- resourceName: string
7
+ onGrab: () => void
13
8
  }
14
9
 
15
- const { partID, resourceName }: Props = $props()
16
-
17
- const client = createResourceClient(
18
- GripperClient,
19
- () => partID,
20
- () => resourceName
21
- )
22
-
23
- const grabMutation = createResourceMutation(client, 'grab')
10
+ const { onGrab }: Props = $props()
24
11
  </script>
25
12
 
26
13
  <Button
27
- onclick={() => {
28
- grabMutation.mutate([], {})
29
- }}
14
+ onclick={onGrab}
30
15
  class="w-20 p-3 py-3"
31
16
  >
32
17
  <div class="flex flex-col gap-2">
@@ -34,4 +19,3 @@
34
19
  <p class="font-roboto-mono text-xs uppercase">grab</p>
35
20
  </div>
36
21
  </Button>
37
- <ErrorDisplay lastError={grabMutation.error} />
@@ -1,6 +1,5 @@
1
1
  interface Props {
2
- partID: string;
3
- resourceName: string;
2
+ onGrab: () => void;
4
3
  }
5
4
  declare const Grab: import("svelte").Component<Props, {}, "">;
6
5
  type Grab = ReturnType<typeof Grab>;
@@ -25,6 +25,8 @@
25
25
  () => resourceName
26
26
  )
27
27
 
28
+ const openMutation = createResourceMutation(client, 'open')
29
+ const grabMutation = createResourceMutation(client, 'grab')
28
30
  const stopMutation = createResourceMutation(client, 'stop')
29
31
  </script>
30
32
 
@@ -34,34 +36,30 @@
34
36
  <div class="flex flex-col divide-y @lg:flex-row @lg:divide-x @lg:divide-y-0">
35
37
  <span class="flex grow flex-wrap gap-4">
36
38
  <ApiSection
37
- title="Open"
39
+ method="Open"
38
40
  api={ResourceTriplets.Gripper}
41
+ mutations={[openMutation]}
39
42
  class="grow-0 flex-col gap-3 @xs:pr-0"
40
43
  >
41
- <Open
42
- {partID}
43
- {resourceName}
44
- />
44
+ <Open onOpen={() => openMutation.mutate([], {})} />
45
45
  </ApiSection>
46
46
  <ApiSection
47
- title="Grab"
47
+ method="Grab"
48
48
  api={ResourceTriplets.Gripper}
49
+ mutations={[grabMutation]}
49
50
  class="grow-0 flex-col gap-3 @xs:pl-0"
50
51
  >
51
- <Grab
52
- {partID}
53
- {resourceName}
54
- />
52
+ <Grab onGrab={() => grabMutation.mutate([], {})} />
55
53
  </ApiSection>
56
54
  </span>
57
55
  <div class="flex flex-col divide-y">
58
56
  <ApiSection
59
57
  class="grow flex-col gap-4"
60
- title="Stop"
58
+ method="Stop"
61
59
  api={ResourceTriplets.Gripper}
60
+ mutations={[stopMutation]}
62
61
  >
63
62
  <StopButton
64
- error={stopMutation.error}
65
63
  onStop={() => {
66
64
  stopMutation.mutate([])
67
65
  }}
@@ -4,7 +4,7 @@
4
4
  import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
5
5
 
6
6
  import ApiSection from '../../api-section.svelte'
7
- import Query from '../../query.svelte'
7
+ import { Section } from '../../section'
8
8
  import StatusPill from '../../status-pill.svelte'
9
9
  import { ResourceTriplets } from '../../../resource-triplet'
10
10
 
@@ -30,27 +30,26 @@
30
30
  </script>
31
31
 
32
32
  <ApiSection
33
- title="IsHoldingSomething"
33
+ method="IsHoldingSomething"
34
34
  api={ResourceTriplets.Gripper}
35
- bottomText="Updates automatically"
36
35
  class="grow flex-col gap-4"
36
+ queries={[query]}
37
37
  >
38
- <Query {query}>
39
- <div class="flex items-center gap-2">
40
- {#if query.data !== undefined}
41
- {#if query.data}
42
- <ClosedGripperSvg />
43
- {:else}
44
- <OpenGripperSvg />
45
- {/if}
46
- <StatusPill
47
- isActive={query.data}
48
- activeText="Holding"
49
- inactiveText="Empty"
50
- />
38
+ <div class="flex items-center gap-2">
39
+ {#if query.data !== undefined}
40
+ {#if query.data}
41
+ <ClosedGripperSvg />
51
42
  {:else}
52
- <Pill value="Loading" />
43
+ <OpenGripperSvg />
53
44
  {/if}
54
- </div>
55
- </Query>
45
+ <StatusPill
46
+ isActive={query.data}
47
+ activeText="Holding"
48
+ inactiveText="Empty"
49
+ />
50
+ {:else}
51
+ <Pill value="Loading" />
52
+ {/if}
53
+ </div>
54
+ <Section.Text class="mt-auto">Updates automatically</Section.Text>
56
55
  </ApiSection>
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { GripperClient } from '@viamrobotics/sdk'
3
+ import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
+
5
+ import { Section } from '../../section'
6
+
7
+ import Open from './open.svelte'
8
+
9
+ interface Props {
10
+ partID: string
11
+ resourceName: string
12
+ }
13
+
14
+ const { partID, resourceName }: Props = $props()
15
+
16
+ const client = createResourceClient(
17
+ GripperClient,
18
+ () => partID,
19
+ () => resourceName
20
+ )
21
+
22
+ const openMutation = createResourceMutation(client, 'open')
23
+ </script>
24
+
25
+ <Open onOpen={() => openMutation.mutate([], {})} />
26
+ <Section.Error error={openMutation.error} />
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ partID: string;
3
+ resourceName: string;
4
+ }
5
+ declare const OpenWidget: import("svelte").Component<Props, {}, "">;
6
+ type OpenWidget = ReturnType<typeof OpenWidget>;
7
+ export default OpenWidget;
@@ -1,32 +1,17 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '@viamrobotics/prime-core'
3
- import { GripperClient } from '@viamrobotics/sdk'
4
- import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
5
-
6
- import ErrorDisplay from '../../error.svelte'
7
3
 
8
4
  import OpenGripperSvg from './open-gripper-svg.svelte'
9
5
 
10
6
  interface Props {
11
- partID: string
12
- resourceName: string
7
+ onOpen: () => void
13
8
  }
14
9
 
15
- const { partID, resourceName }: Props = $props()
16
-
17
- const client = createResourceClient(
18
- GripperClient,
19
- () => partID,
20
- () => resourceName
21
- )
22
-
23
- const openMutation = createResourceMutation(client, 'open')
10
+ const { onOpen }: Props = $props()
24
11
  </script>
25
12
 
26
13
  <Button
27
- onclick={() => {
28
- openMutation.mutate([], {})
29
- }}
14
+ onclick={onOpen}
30
15
  class="w-20 p-3 py-3"
31
16
  >
32
17
  <div class="flex flex-col gap-2">
@@ -34,4 +19,3 @@
34
19
  <p class="font-roboto-mono text-xs uppercase">open</p>
35
20
  </div>
36
21
  </Button>
37
- <ErrorDisplay lastError={openMutation.error} />
@@ -1,6 +1,5 @@
1
1
  interface Props {
2
- partID: string;
3
- resourceName: string;
2
+ onOpen: () => void;
4
3
  }
5
4
  declare const Open: import("svelte").Component<Props, {}, "">;
6
5
  type Open = ReturnType<typeof Open>;
@@ -4,7 +4,6 @@
4
4
 
5
5
  import ApiSection from '../../api-section.svelte'
6
6
  import ConnectionStatus from '../../connection-status.svelte'
7
- import Query from '../../query.svelte'
8
7
  import ReadingsList from '../../readings-list.svelte'
9
8
  import RefetchController from '../../refetch-controller.svelte'
10
9
  import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
@@ -55,22 +54,16 @@
55
54
  </div>
56
55
 
57
56
  <ApiSection
58
- title="GetEvents"
57
+ method="GetEvents"
59
58
  api={ResourceTriplets.InputController}
59
+ queries={[eventsQuery]}
60
60
  class="relative grow flex-col gap-4"
61
61
  >
62
- <Query
63
- query={eventsQuery}
64
- class="h-4"
65
- >
66
- {#if eventsQuery.data !== undefined}
67
- <ReadingsList
68
- data={Object.fromEntries(
69
- eventsQuery.data.map(({ control, value }) => [control, value])
70
- )}
71
- />
72
- {/if}
73
- </Query>
62
+ {#if eventsQuery.data !== undefined}
63
+ <ReadingsList
64
+ data={Object.fromEntries(eventsQuery.data.map(({ control, value }) => [control, value]))}
65
+ />
66
+ {/if}
74
67
  </ApiSection>
75
68
  {/snippet}
76
69
  </ConnectionStatus>
@@ -3,7 +3,7 @@
3
3
  import { InputControllerClient, type InputControllerEvent } from '@viamrobotics/sdk'
4
4
  import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
5
5
 
6
- import ErrorDisplay from '../../error.svelte'
6
+ import { Section } from '../../section'
7
7
  import StatusPill from '../../status-pill.svelte'
8
8
 
9
9
  import type { StandardGamepadEvent } from './standard-gamepad-event'
@@ -139,4 +139,4 @@
139
139
  activeText="Connected"
140
140
  inactiveText="Disconnected"
141
141
  />
142
- <ErrorDisplay lastError={triggerEventMutation.error} />
142
+ <Section.Error error={triggerEventMutation.error} />
@@ -1,9 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { createRobotQuery, useRobotClient } from '@viamrobotics/svelte-sdk'
3
3
 
4
- import ApiSection from '../../api-section.svelte'
5
4
  import ConnectionStatus from '../../connection-status.svelte'
6
- import { ResourceTriplets } from '../../../resource-triplet'
7
5
 
8
6
  import FrameSelect from './frame-select.svelte'
9
7
  import { movableFrameNames, parentFrame, referenceFrameNames } from './frame-system-config'
@@ -33,39 +31,33 @@
33
31
 
34
32
  <ConnectionStatus {partID}>
35
33
  {#snippet connected()}
36
- <ApiSection
37
- class="grow flex-col gap-4"
38
- title="Move"
39
- api={ResourceTriplets.Motion}
34
+ <MoveWidget
35
+ {partID}
36
+ {resourceName}
37
+ {frameName}
38
+ {destination}
39
+ queries={[frameSystem]}
40
40
  >
41
- <div class="flex min-w-0 flex-col gap-4">
42
- <FrameSelect
43
- value={frameName}
44
- options={frameNames}
45
- onChange={(value) => {
46
- selectedFrame = value
47
- // reset the destination to the newly selected frame's parent
48
- selectedDestination = undefined
49
- }}
50
- >
51
- {#snippet label()}Component{/snippet}
52
- </FrameSelect>
53
- <FrameSelect
54
- value={destination}
55
- options={destinationOptions}
56
- onChange={(value) => {
57
- selectedDestination = value
58
- }}
59
- >
60
- {#snippet label()}Destination frame{/snippet}
61
- </FrameSelect>
62
- <MoveWidget
63
- {partID}
64
- {resourceName}
65
- {frameName}
66
- {destination}
67
- />
68
- </div>
69
- </ApiSection>
41
+ <FrameSelect
42
+ value={frameName}
43
+ options={frameNames}
44
+ onChange={(value) => {
45
+ selectedFrame = value
46
+ // reset the destination to the newly selected frame's parent
47
+ selectedDestination = undefined
48
+ }}
49
+ >
50
+ {#snippet label()}Component{/snippet}
51
+ </FrameSelect>
52
+ <FrameSelect
53
+ value={destination}
54
+ options={destinationOptions}
55
+ onChange={(value) => {
56
+ selectedDestination = value
57
+ }}
58
+ >
59
+ {#snippet label()}Destination frame{/snippet}
60
+ </FrameSelect>
61
+ </MoveWidget>
70
62
  {/snippet}
71
63
  </ConnectionStatus>
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
2
4
  import { MotionClient, type RobotClient } from '@viamrobotics/sdk'
3
5
  import {
4
6
  createResourceClient,
@@ -7,6 +9,10 @@
7
9
  useRobotClient,
8
10
  } from '@viamrobotics/svelte-sdk'
9
11
 
12
+ import ApiSection from '../../api-section.svelte'
13
+ import { type SectionQuery } from '../../section/use-section-errors.svelte'
14
+ import { ResourceTriplets } from '../../../resource-triplet'
15
+
10
16
  import Move from './move.svelte'
11
17
  import { type MoveInput, parseMoveArgs } from './parse-move-args'
12
18
 
@@ -17,9 +23,13 @@
17
23
  frameName: string
18
24
  /** The reference frame the destination pose is expressed in. */
19
25
  destination: string
26
+ /** Queries the surrounding controls read, so their errors reach the section's indicator. */
27
+ queries?: SectionQuery[]
28
+ /** Controls rendered above the move form, inside the section. */
29
+ children?: Snippet
20
30
  }
21
31
 
22
- const { partID, resourceName, frameName, destination }: Props = $props()
32
+ const { partID, resourceName, frameName, destination, queries = [], children }: Props = $props()
23
33
 
24
34
  const robotClient = useRobotClient(() => partID)
25
35
  const client = createResourceClient(
@@ -40,9 +50,9 @@
40
50
  )
41
51
 
42
52
  const currentPose = $derived(poseQuery.data?.pose)
43
- const poseError = $derived(poseQuery.error instanceof Error ? poseQuery.error : null)
44
-
45
53
  let parseError = $state<Error>()
54
+ // A mutation-shaped source, so a pose that fails to parse shows in the section's indicator.
55
+ const parseFailure = $derived({ error: parseError ?? null })
46
56
 
47
57
  const executeMove = (input: MoveInput) => {
48
58
  try {
@@ -54,12 +64,22 @@
54
64
  }
55
65
  </script>
56
66
 
57
- <Move
58
- {frameName}
59
- {destination}
60
- {currentPose}
61
- isPending={move.isPending}
62
- lastError={parseError ?? move.error ?? poseError}
63
- storageKey={`${partID}/${resourceName}/motion-move`}
64
- onExecute={executeMove}
65
- />
67
+ <ApiSection
68
+ class="grow flex-col gap-4"
69
+ method="Move"
70
+ api={ResourceTriplets.Motion}
71
+ queries={[...queries, poseQuery]}
72
+ mutations={[move, parseFailure]}
73
+ >
74
+ <div class="flex min-w-0 flex-col gap-4">
75
+ {@render children?.()}
76
+ <Move
77
+ {frameName}
78
+ {destination}
79
+ {currentPose}
80
+ isPending={move.isPending}
81
+ storageKey={`${partID}/${resourceName}/motion-move`}
82
+ onExecute={executeMove}
83
+ />
84
+ </div>
85
+ </ApiSection>
@@ -1,3 +1,5 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { type SectionQuery } from '../../section/use-section-errors.svelte';
1
3
  interface Props {
2
4
  partID: string;
3
5
  resourceName: string;
@@ -5,6 +7,10 @@ interface Props {
5
7
  frameName: string;
6
8
  /** The reference frame the destination pose is expressed in. */
7
9
  destination: string;
10
+ /** Queries the surrounding controls read, so their errors reach the section's indicator. */
11
+ queries?: SectionQuery[];
12
+ /** Controls rendered above the move form, inside the section. */
13
+ children?: Snippet;
8
14
  }
9
15
  declare const MoveWidget: import("svelte").Component<Props, {}, "">;
10
16
  type MoveWidget = ReturnType<typeof MoveWidget>;
@@ -5,7 +5,6 @@
5
5
  import { CodeEditor } from '@viamrobotics/prime-core/code-editor'
6
6
  import { PersistedState } from 'runed'
7
7
 
8
- import ErrorDisplay from '../../error.svelte'
9
8
  import PoseEditor from '../../pose-editor.svelte'
10
9
 
11
10
  import type { MoveInput } from './parse-move-args'
@@ -17,20 +16,11 @@
17
16
  destination: string
18
17
  currentPose?: Pose
19
18
  isPending: boolean
20
- lastError: Error | null
21
19
  storageKey: string
22
20
  onExecute: (input: MoveInput) => void
23
21
  }
24
22
 
25
- const {
26
- frameName,
27
- destination,
28
- currentPose,
29
- isPending,
30
- lastError,
31
- storageKey,
32
- onExecute,
33
- }: Props = $props()
23
+ const { frameName, destination, currentPose, isPending, storageKey, onExecute }: Props = $props()
34
24
 
35
25
  const zeroPose: Pose = { x: 0, y: 0, z: 0, oX: 0, oY: 0, oZ: 1, theta: 0 }
36
26
 
@@ -139,6 +129,4 @@
139
129
  <p class="text-subtle-2 text-xs">
140
130
  Move blocks until the motion completes. Stop the component itself to interrupt.
141
131
  </p>
142
-
143
- <ErrorDisplay {lastError} />
144
132
  </div>
@@ -7,7 +7,6 @@ interface Props {
7
7
  destination: string;
8
8
  currentPose?: Pose;
9
9
  isPending: boolean;
10
- lastError: Error | null;
11
10
  storageKey: string;
12
11
  onExecute: (input: MoveInput) => void;
13
12
  }
@@ -2,7 +2,8 @@
2
2
  import { MotorClient } from '@viamrobotics/sdk'
3
3
  import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
4
 
5
- import MutationView from '../../mutation-view.svelte'
5
+ import ApiSection from '../../api-section.svelte'
6
+ import { ResourceTriplets } from '../../../resource-triplet'
6
7
 
7
8
  import GoFor from './go-for.svelte'
8
9
 
@@ -22,10 +23,17 @@
22
23
  const goForMutation = createResourceMutation(client, 'goFor')
23
24
  </script>
24
25
 
25
- <MutationView lastError={goForMutation.error}>
26
- <GoFor
27
- goFor={(rpm: number, revolutions: number) => {
28
- goForMutation.mutate([rpm, revolutions], {})
29
- }}
30
- />
31
- </MutationView>
26
+ <ApiSection
27
+ class="flex-row flex-wrap gap-2"
28
+ method="GoFor"
29
+ api={ResourceTriplets.Motor}
30
+ mutations={[goForMutation]}
31
+ >
32
+ <div class="flex grow flex-wrap justify-between gap-2">
33
+ <GoFor
34
+ goFor={(rpm: number, revolutions: number) => {
35
+ goForMutation.mutate([rpm, revolutions], {})
36
+ }}
37
+ />
38
+ </div>
39
+ </ApiSection>