@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
@@ -6,7 +6,8 @@
6
6
  import ApiSection from '../../api-section.svelte'
7
7
  import ConnectionStatus from '../../connection-status.svelte'
8
8
  import IsMoving from '../../is-moving.svelte'
9
- import MutationSection from '../../mutation-section.svelte'
9
+ import { Section } from '../../section'
10
+ import { useSectionErrors } from '../../section/use-section-errors.svelte'
10
11
  import StopButton from '../../stop-button.svelte'
11
12
  import { ResourceTriplets } from '../../../resource-triplet'
12
13
 
@@ -56,6 +57,8 @@
56
57
  moveStraightMutation.mutate([distanceMm, mmPerSec], {})
57
58
  }
58
59
 
60
+ const quickMoveErrors = useSectionErrors(() => ({ mutations: [quickSetPowerMutation] }))
61
+
59
62
  let quickMoveKeyboardControl = $state(false)
60
63
  </script>
61
64
 
@@ -63,11 +66,17 @@
63
66
  {#snippet connected()}
64
67
  <div class="@container">
65
68
  <div class="flex flex-col divide-y @4xl:flex-row @4xl:divide-x @4xl:divide-y-0">
66
- <MutationSection
67
- title="Quick move"
68
- lastError={quickSetPowerMutation.error}
69
+ <Section
70
+ errorReporter={quickMoveErrors}
71
+ class="flex-row flex-wrap gap-2"
69
72
  >
70
- {#snippet titleInput()}
73
+ <div class="flex flex-col gap-0.5">
74
+ <Section.Heading>
75
+ Quick move
76
+ {#snippet aside()}
77
+ <Section.Errors errors={quickMoveErrors.errors} />
78
+ {/snippet}
79
+ </Section.Heading>
71
80
  <Label>
72
81
  Keyboard control
73
82
 
@@ -77,21 +86,25 @@
77
86
  on:change={() => (quickMoveKeyboardControl = !quickMoveKeyboardControl)}
78
87
  />
79
88
  </Label>
80
- {/snippet}
89
+ </div>
81
90
 
82
- <QuickMove
83
- isKeyboardEnabled={quickMoveKeyboardControl}
84
- setPower={quickSetPower}
85
- />
86
- </MutationSection>
91
+ <Section.Body>
92
+ <div class="flex grow flex-wrap justify-between gap-2">
93
+ <QuickMove
94
+ isKeyboardEnabled={quickMoveKeyboardControl}
95
+ setPower={quickSetPower}
96
+ />
97
+ </div>
98
+ </Section.Body>
99
+ </Section>
87
100
  <div class="flex grow flex-col divide-y @4xl:ml-auto @4xl:w-full @4xl:max-w-40">
88
101
  <ApiSection
89
102
  class="grow flex-col gap-4"
90
- title="Stop"
103
+ method="Stop"
91
104
  api={ResourceTriplets.Base}
105
+ mutations={[stopMutation]}
92
106
  >
93
107
  <StopButton
94
- error={stopMutation.error}
95
108
  onStop={() => {
96
109
  stopMutation.mutate([])
97
110
  }}
@@ -106,37 +119,57 @@
106
119
  </div>
107
120
  </div>
108
121
  </div>
109
- <MutationSection
110
- title="MoveStraight"
122
+ <ApiSection
123
+ class="flex-row flex-wrap gap-2"
124
+ method="MoveStraight"
111
125
  api={ResourceTriplets.Base}
112
- description="Move across a given distance at a given velocity"
113
- lastError={moveStraightMutation.error}
126
+ mutations={[moveStraightMutation]}
114
127
  >
115
- <MoveStraight {moveStraight} />
116
- </MutationSection>
117
- <MutationSection
118
- title="Spin"
128
+ {#snippet subheading()}
129
+ <Section.Text>Move across a given distance at a given velocity</Section.Text>
130
+ {/snippet}
131
+ <div class="flex grow flex-wrap justify-between gap-2">
132
+ <MoveStraight {moveStraight} />
133
+ </div>
134
+ </ApiSection>
135
+ <ApiSection
136
+ class="flex-row flex-wrap gap-2"
137
+ method="Spin"
119
138
  api={ResourceTriplets.Base}
120
- description="Turn to a given angle at a given velocity"
121
- lastError={spinMutation.error}
139
+ mutations={[spinMutation]}
122
140
  >
123
- <Spin {spin} />
124
- </MutationSection>
125
- <MutationSection
126
- title="SetPower"
141
+ {#snippet subheading()}
142
+ <Section.Text>Turn to a given angle at a given velocity</Section.Text>
143
+ {/snippet}
144
+ <div class="flex grow flex-wrap justify-between gap-2">
145
+ <Spin {spin} />
146
+ </div>
147
+ </ApiSection>
148
+ <ApiSection
149
+ class="flex-row flex-wrap gap-2"
150
+ method="SetPower"
127
151
  api={ResourceTriplets.Base}
128
- description="Move continuously at a given amount of power"
129
- lastError={setPowerMutation.error}
152
+ mutations={[setPowerMutation]}
130
153
  >
131
- <SetPower {setPower} />
132
- </MutationSection>
133
- <MutationSection
134
- title="SetVelocity"
154
+ {#snippet subheading()}
155
+ <Section.Text>Move continuously at a given amount of power</Section.Text>
156
+ {/snippet}
157
+ <div class="flex grow flex-wrap justify-between gap-2">
158
+ <SetPower {setPower} />
159
+ </div>
160
+ </ApiSection>
161
+ <ApiSection
162
+ class="flex-row flex-wrap gap-2"
163
+ method="SetVelocity"
135
164
  api={ResourceTriplets.Base}
136
- description="Move continually at a given velocity"
137
- lastError={setVelocityMutation.error}
165
+ mutations={[setVelocityMutation]}
138
166
  >
139
- <SetVelocity {setVelocity} />
140
- </MutationSection>
167
+ {#snippet subheading()}
168
+ <Section.Text>Move continually at a given velocity</Section.Text>
169
+ {/snippet}
170
+ <div class="flex grow flex-wrap justify-between gap-2">
171
+ <SetVelocity {setVelocity} />
172
+ </div>
173
+ </ApiSection>
141
174
  {/snippet}
142
175
  </ConnectionStatus>
@@ -2,7 +2,9 @@
2
2
  import { BaseClient } 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 { Section } from '../../section'
7
+ import { ResourceTriplets } from '../../../resource-triplet'
6
8
 
7
9
  import MoveStraight from './move-straight.svelte'
8
10
 
@@ -26,6 +28,16 @@
26
28
  }
27
29
  </script>
28
30
 
29
- <MutationView lastError={moveStraightMutation.error}>
30
- <MoveStraight {moveStraight} />
31
- </MutationView>
31
+ <ApiSection
32
+ class="flex-row flex-wrap gap-2"
33
+ method="MoveStraight"
34
+ api={ResourceTriplets.Base}
35
+ mutations={[moveStraightMutation]}
36
+ >
37
+ {#snippet subheading()}
38
+ <Section.Text>Move across a given distance at a given velocity</Section.Text>
39
+ {/snippet}
40
+ <div class="flex grow flex-wrap justify-between gap-2">
41
+ <MoveStraight {moveStraight} />
42
+ </div>
43
+ </ApiSection>
@@ -3,7 +3,8 @@
3
3
  import { BaseClient, type Vector3 } from '@viamrobotics/sdk'
4
4
  import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
5
5
 
6
- import MutationView from '../../mutation-view.svelte'
6
+ import { Section } from '../../section'
7
+ import { useSectionErrors } from '../../section/use-section-errors.svelte'
7
8
 
8
9
  import QuickMove from './quick-move.svelte'
9
10
 
@@ -26,11 +27,22 @@
26
27
  quickSetPowerMutation.mutate([linear, angular], {})
27
28
  }
28
29
 
30
+ const sectionErrors = useSectionErrors(() => ({ mutations: [quickSetPowerMutation] }))
31
+
29
32
  let isKeyboardEnabled = $state(false)
30
33
  </script>
31
34
 
32
- <MutationView lastError={quickSetPowerMutation.error}>
33
- {#snippet titleInput()}
35
+ <Section
36
+ errorReporter={sectionErrors}
37
+ class="flex-row flex-wrap gap-2"
38
+ >
39
+ <div class="flex flex-col gap-0.5">
40
+ <Section.Heading>
41
+ Quick move
42
+ {#snippet aside()}
43
+ <Section.Errors errors={sectionErrors.errors} />
44
+ {/snippet}
45
+ </Section.Heading>
34
46
  <Label cx="w-fit!">
35
47
  Keyboard control
36
48
 
@@ -40,10 +52,14 @@
40
52
  on:change={() => (isKeyboardEnabled = !isKeyboardEnabled)}
41
53
  />
42
54
  </Label>
43
- {/snippet}
55
+ </div>
44
56
 
45
- <QuickMove
46
- setPower={quickSetPower}
47
- {isKeyboardEnabled}
48
- />
49
- </MutationView>
57
+ <Section.Body>
58
+ <div class="flex grow flex-wrap justify-between gap-2">
59
+ <QuickMove
60
+ setPower={quickSetPower}
61
+ {isKeyboardEnabled}
62
+ />
63
+ </div>
64
+ </Section.Body>
65
+ </Section>
@@ -2,7 +2,9 @@
2
2
  import { BaseClient, type Vector3 } 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 { Section } from '../../section'
7
+ import { ResourceTriplets } from '../../../resource-triplet'
6
8
 
7
9
  import SetPower from './set-power.svelte'
8
10
 
@@ -22,10 +24,20 @@
22
24
  const setPowerMutation = createResourceMutation(client, 'setPower')
23
25
  </script>
24
26
 
25
- <MutationView lastError={setPowerMutation.error}>
26
- <SetPower
27
- setPower={(linear: Vector3, angular: Vector3) => {
28
- setPowerMutation.mutate([linear, angular], {})
29
- }}
30
- />
31
- </MutationView>
27
+ <ApiSection
28
+ class="flex-row flex-wrap gap-2"
29
+ method="SetPower"
30
+ api={ResourceTriplets.Base}
31
+ mutations={[setPowerMutation]}
32
+ >
33
+ {#snippet subheading()}
34
+ <Section.Text>Move continuously at a given amount of power</Section.Text>
35
+ {/snippet}
36
+ <div class="flex grow flex-wrap justify-between gap-2">
37
+ <SetPower
38
+ setPower={(linear: Vector3, angular: Vector3) => {
39
+ setPowerMutation.mutate([linear, angular], {})
40
+ }}
41
+ />
42
+ </div>
43
+ </ApiSection>
@@ -2,7 +2,9 @@
2
2
  import { BaseClient, type Vector3 } 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 { Section } from '../../section'
7
+ import { ResourceTriplets } from '../../../resource-triplet'
6
8
 
7
9
  import SetVelocity from './set-velocity.svelte'
8
10
 
@@ -22,10 +24,20 @@
22
24
  const setVelocityMutation = createResourceMutation(client, 'setVelocity')
23
25
  </script>
24
26
 
25
- <MutationView lastError={setVelocityMutation.error}>
26
- <SetVelocity
27
- setVelocity={(linear: Vector3, angular: Vector3) => {
28
- setVelocityMutation.mutate([linear, angular], {})
29
- }}
30
- />
31
- </MutationView>
27
+ <ApiSection
28
+ class="flex-row flex-wrap gap-2"
29
+ method="SetVelocity"
30
+ api={ResourceTriplets.Base}
31
+ mutations={[setVelocityMutation]}
32
+ >
33
+ {#snippet subheading()}
34
+ <Section.Text>Move continually at a given velocity</Section.Text>
35
+ {/snippet}
36
+ <div class="flex grow flex-wrap justify-between gap-2">
37
+ <SetVelocity
38
+ setVelocity={(linear: Vector3, angular: Vector3) => {
39
+ setVelocityMutation.mutate([linear, angular], {})
40
+ }}
41
+ />
42
+ </div>
43
+ </ApiSection>
@@ -2,7 +2,9 @@
2
2
  import { BaseClient } 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 { Section } from '../../section'
7
+ import { ResourceTriplets } from '../../../resource-triplet'
6
8
 
7
9
  import Spin from './spin.svelte'
8
10
 
@@ -22,10 +24,20 @@
22
24
  const spinMutation = createResourceMutation(client, 'spin')
23
25
  </script>
24
26
 
25
- <MutationView lastError={spinMutation.error}>
26
- <Spin
27
- spin={(angleDeg: number, degsPerSec: number) => {
28
- spinMutation.mutate([angleDeg, degsPerSec], {})
29
- }}
30
- />
31
- </MutationView>
27
+ <ApiSection
28
+ class="flex-row flex-wrap gap-2"
29
+ method="Spin"
30
+ api={ResourceTriplets.Base}
31
+ mutations={[spinMutation]}
32
+ >
33
+ {#snippet subheading()}
34
+ <Section.Text>Turn to a given angle at a given velocity</Section.Text>
35
+ {/snippet}
36
+ <div class="flex grow flex-wrap justify-between gap-2">
37
+ <Spin
38
+ spin={(angleDeg: number, degsPerSec: number) => {
39
+ spinMutation.mutate([angleDeg, degsPerSec], {})
40
+ }}
41
+ />
42
+ </div>
43
+ </ApiSection>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import ErrorDisplay from '../../error.svelte'
2
+ import { Section } from '../../section'
3
3
 
4
4
  import AnalogReadWrapper from './analog-read-wrapper.svelte'
5
5
  import AnalogWriteWrapper from './analog-write-wrapper.svelte'
@@ -68,5 +68,5 @@
68
68
  />
69
69
  {/if}
70
70
  </div>
71
- <ErrorDisplay lastError={currentError} />
71
+ <Section.Error error={currentError} />
72
72
  </div>
@@ -3,7 +3,7 @@
3
3
  import { ButtonClient } 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
 
8
8
  interface Props {
9
9
  partID: string
@@ -29,4 +29,4 @@
29
29
  >
30
30
  Push
31
31
  </Button>
32
- <ErrorDisplay lastError={pushMutation.error} />
32
+ <Section.Error error={pushMutation.error} />
@@ -14,7 +14,7 @@
14
14
  createRefetchIntervalStore,
15
15
  RefetchIntervals,
16
16
  } from '../../refetch-interval-store.svelte'
17
- import SectionTitle from '../../section-title.svelte'
17
+ import { Section } from '../../section'
18
18
  import { ResourceTriplets } from '../../../resource-triplet'
19
19
 
20
20
  import PCDWidget from '../pcd/pcd-widget.svelte'
@@ -156,24 +156,18 @@
156
156
  const setMousePostionTooltip = (event: CustomEvent<string>) => {
157
157
  mousePostionTooltip = event.detail as 'On' | 'Off'
158
158
  }
159
-
160
- const headingID = $props.id()
161
- const getImagesHeadingID = `${headingID}-images`
162
- const getPointCloudHeadingID = `${headingID}-point-cloud`
163
159
  </script>
164
160
 
165
161
  <ConnectionStatus {partID}>
166
162
  {#snippet connected()}
167
- <section
168
- class="flex flex-col"
169
- aria-labelledby={getImagesHeadingID}
170
- >
163
+ <section class="flex flex-col">
171
164
  <div class="flex flex-col gap-0.5 p-4 pb-0">
172
- <SectionTitle
173
- title="GetImages"
174
- api={ResourceTriplets.Camera}
175
- headingId={getImagesHeadingID}
176
- />
165
+ <Section.Heading>
166
+ <Section.Method
167
+ method="GetImages"
168
+ api={ResourceTriplets.Camera}
169
+ />
170
+ </Section.Heading>
177
171
  </div>
178
172
  <div class="p-4">
179
173
  {#if isPlaying}
@@ -333,16 +327,14 @@
333
327
  </div>
334
328
  </section>
335
329
 
336
- <section
337
- class="flex flex-col gap-4 p-4"
338
- aria-labelledby={getPointCloudHeadingID}
339
- >
330
+ <section class="flex flex-col gap-4 p-4">
340
331
  <div class="flex flex-col gap-0.5">
341
- <SectionTitle
342
- title="GetPointCloud"
343
- api={ResourceTriplets.Camera}
344
- headingId={getPointCloudHeadingID}
345
- />
332
+ <Section.Heading>
333
+ <Section.Method
334
+ method="GetPointCloud"
335
+ api={ResourceTriplets.Camera}
336
+ />
337
+ </Section.Heading>
346
338
  <p class="text-subtle-2 text-xs">
347
339
  Get depth measurement data from cameras with depth sensing support
348
340
  </p>
@@ -8,10 +8,11 @@
8
8
  import { untrack } from 'svelte'
9
9
 
10
10
  import { assertExists } from '../../../assert'
11
+ import ApiSection from '../../api-section.svelte'
11
12
  import ContentRect from '../../content-rect.svelte'
12
13
  import ErrorDisplay from '../../error.svelte'
13
- import MutationSection from '../../mutation-section.svelte'
14
14
  import Progress from '../../progress.svelte'
15
+ import { Section } from '../../section'
15
16
  import { formatNumeric } from '../../../format'
16
17
  import { useMeasureFps } from '../../../fps.svelte'
17
18
  import { usePip } from '../../../pip/context.svelte'
@@ -336,7 +337,7 @@
336
337
  </script>
337
338
 
338
339
  <div class="relative">
339
- <!-- This breaks out of using the <Query> component
340
+ <!-- This breaks out of using the Query component
340
341
  to merge live stream and TanStack query errors -->
341
342
  {#if lastError}
342
343
  <ContentRect
@@ -398,14 +399,16 @@
398
399
  {/if}
399
400
 
400
401
  {#if showResolutionOptions && isLive}
401
- <MutationSection
402
- title="SetStreamOptions"
402
+ <ApiSection
403
+ method="SetStreamOptions"
403
404
  api={ResourceTriplets.Camera}
404
- description="Change the resolution of the live stream video feed"
405
- lastError={resolutionMutation.error}
406
- class="-m-4 mt-4"
405
+ mutations={[resolutionMutation]}
406
+ class={['flex-row flex-wrap gap-2', '-m-4 mt-4']}
407
407
  >
408
- <div class="flex w-full flex-wrap justify-between gap-2">
408
+ {#snippet subheading()}
409
+ <Section.Text>Change the resolution of the live stream video feed</Section.Text>
410
+ {/snippet}
411
+ <div class="flex grow flex-wrap justify-between gap-2">
409
412
  <Label cx="max-w-[96px] gap-1 text-xs">
410
413
  <span class="flex gap-1 whitespace-nowrap">
411
414
  Resolution
@@ -447,5 +450,5 @@
447
450
  </Button>
448
451
  </div>
449
452
  </div>
450
- </MutationSection>
453
+ </ApiSection>
451
454
  {/if}
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import type { ComponentProps } from 'svelte'
3
+
4
+ import Subject from '../../custom-control.svelte'
5
+
6
+ const { ...props }: ComponentProps<typeof Subject> = $props()
7
+ </script>
8
+
9
+ <p data-testid="sibling">Beside the control</p>
10
+ <Subject {...props} />
@@ -0,0 +1,60 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ import { useRobotClient } from '@viamrobotics/svelte-sdk'
5
+
6
+ import Progress from '../../progress.svelte'
7
+
8
+ import { createControlHost } from './create-control-host.svelte'
9
+ import { prepareArtifact } from './custom-control'
10
+
11
+ interface Props {
12
+ partID: string
13
+ resourceName: string
14
+ html: string
15
+ loading?: Snippet
16
+ }
17
+
18
+ const { partID, resourceName, html, loading }: Props = $props()
19
+
20
+ const robot = useRobotClient(() => partID)
21
+ const srcdoc = $derived(prepareArtifact(html))
22
+
23
+ let iframe = $state<HTMLIFrameElement | null>(null)
24
+ let height = $state<number>()
25
+
26
+ const controlHost = createControlHost({
27
+ getRobot: () => robot.current,
28
+ getIframe: () => iframe ?? undefined,
29
+ resourceName: () => resourceName,
30
+ onHeight: (px) => {
31
+ height = px
32
+ },
33
+ })
34
+
35
+ $effect(() => {
36
+ controlHost.start()
37
+ return controlHost.stop
38
+ })
39
+ </script>
40
+
41
+ <div class="relative w-full">
42
+ <iframe
43
+ bind:this={iframe}
44
+ sandbox="allow-scripts"
45
+ title="Custom control for {resourceName}"
46
+ class="block h-40 max-h-[80vh] min-h-px w-full border-0"
47
+ style:height={height === undefined ? undefined : `${height}px`}
48
+ {srcdoc}
49
+ ></iframe>
50
+
51
+ {#if height === undefined}
52
+ <div class="bg-extralight absolute inset-0">
53
+ {#if loading}
54
+ {@render loading()}
55
+ {:else}
56
+ <Progress />
57
+ {/if}
58
+ </div>
59
+ {/if}
60
+ </div>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ partID: string;
4
+ resourceName: string;
5
+ html: string;
6
+ loading?: Snippet;
7
+ }
8
+ declare const ControlFrame: import("svelte").Component<Props, {}, "">;
9
+ type ControlFrame = ReturnType<typeof ControlFrame>;
10
+ export default ControlFrame;
@@ -0,0 +1,19 @@
1
+ import type { RobotClient } from '@viamrobotics/sdk';
2
+ interface Options {
3
+ getRobot: () => RobotClient | undefined;
4
+ getIframe: () => HTMLIFrameElement | undefined;
5
+ resourceName: () => string;
6
+ onHeight: (px: number) => void;
7
+ }
8
+ interface ControlHost {
9
+ /**
10
+ * Serves the iframe's guest from the robot once both exist, and does nothing until then.
11
+ *
12
+ * @throws If the iframe has no `contentWindow`.
13
+ */
14
+ start: () => void;
15
+ /** Closes the host. Safe to call when none is running. */
16
+ stop: () => void;
17
+ }
18
+ export declare const createControlHost: ({ getRobot, getIframe, resourceName, onHeight, }: Options) => ControlHost;
19
+ export {};
@@ -0,0 +1,26 @@
1
+ import { createHost } from '@viamrobotics/post-message-sdk/host';
2
+ export const createControlHost = ({ getRobot, getIframe, resourceName, onHeight, }) => {
3
+ let host;
4
+ const stop = () => {
5
+ host?.destroy();
6
+ host = undefined;
7
+ };
8
+ const start = () => {
9
+ stop();
10
+ const robot = getRobot();
11
+ const iframe = getIframe();
12
+ if (!robot || !iframe)
13
+ return;
14
+ host = createHost(robot, iframe, {
15
+ allow: ({ resource }) => resource === resourceName(),
16
+ onSize: (height) => {
17
+ // A non-finite value would reach the iframe's style as invalid CSS, which the browser
18
+ // drops, snapping the frame back to its class height. Bounds live in CSS on the frame.
19
+ if (!Number.isFinite(height))
20
+ return;
21
+ onHeight(height);
22
+ },
23
+ });
24
+ };
25
+ return { start, stop };
26
+ };