@viamrobotics/test-widgets 0.15.1 → 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 (200) hide show
  1. package/README.md +15 -1
  2. package/dist/api-docs-href.d.ts +2 -2
  3. package/dist/api-docs-href.js +0 -1
  4. package/dist/components/api-section.svelte +58 -49
  5. package/dist/components/api-section.svelte.d.ts +24 -10
  6. package/dist/components/boundary.svelte +51 -0
  7. package/dist/components/boundary.svelte.d.ts +5 -0
  8. package/dist/components/connection-status.svelte +57 -61
  9. package/dist/components/connection-status.svelte.d.ts +5 -5
  10. package/dist/components/content-rect.svelte +10 -5
  11. package/dist/components/content-rect.svelte.d.ts +3 -1
  12. package/dist/components/error.svelte +15 -5
  13. package/dist/components/error.svelte.d.ts +8 -1
  14. package/dist/components/index.d.ts +4 -3
  15. package/dist/components/index.js +4 -3
  16. package/dist/components/is-moving.svelte +29 -35
  17. package/dist/components/is-moving.svelte.d.ts +6 -6
  18. package/dist/components/maplibre/index.svelte +5 -6
  19. package/dist/components/maplibre/index.svelte.d.ts +3 -1
  20. package/dist/components/pose-editor.svelte +83 -15
  21. package/dist/components/pose-editor.svelte.d.ts +11 -4
  22. package/dist/components/progress.svelte +1 -0
  23. package/dist/components/queries.svelte +14 -4
  24. package/dist/components/queries.svelte.d.ts +6 -1
  25. package/dist/components/query.svelte +11 -3
  26. package/dist/components/query.svelte.d.ts +6 -1
  27. package/dist/components/section/error-key.d.ts +2 -0
  28. package/dist/components/section/error-key.js +2 -0
  29. package/dist/components/section/index.d.ts +21 -0
  30. package/dist/components/section/index.js +21 -0
  31. package/dist/components/section/section-body.svelte +36 -0
  32. package/dist/components/section/section-body.svelte.d.ts +13 -0
  33. package/dist/components/section/section-error-reporter.d.ts +8 -0
  34. package/dist/components/section/section-error-reporter.js +7 -0
  35. package/dist/components/section/section-error.svelte +36 -0
  36. package/dist/components/section/section-error.svelte.d.ts +9 -0
  37. package/dist/components/section/section-errors.svelte +145 -0
  38. package/dist/components/section/section-errors.svelte.d.ts +6 -0
  39. package/dist/components/section/section-heading.svelte +21 -0
  40. package/dist/components/section/section-heading.svelte.d.ts +9 -0
  41. package/dist/components/section/section-loading.d.ts +4 -0
  42. package/dist/components/section/section-loading.js +10 -0
  43. package/dist/components/section/section-method.svelte +29 -0
  44. package/dist/components/section/section-method.svelte.d.ts +9 -0
  45. package/dist/components/section/section-placeholder.svelte +29 -0
  46. package/dist/components/section/section-placeholder.svelte.d.ts +7 -0
  47. package/dist/components/section/section-text.svelte +17 -0
  48. package/dist/components/section/section-text.svelte.d.ts +8 -0
  49. package/dist/components/section/section-tooltip.svelte +25 -0
  50. package/dist/components/section/section-tooltip.svelte.d.ts +7 -0
  51. package/dist/components/section/section.svelte +23 -0
  52. package/dist/components/section/section.svelte.d.ts +11 -0
  53. package/dist/components/section/use-section-errors.svelte.d.ts +19 -0
  54. package/dist/components/section/use-section-errors.svelte.js +49 -0
  55. package/dist/components/stop-button.svelte +1 -5
  56. package/dist/components/stop-button.svelte.d.ts +0 -1
  57. package/dist/components/stop.svelte +31 -14
  58. package/dist/components/stop.svelte.d.ts +6 -1
  59. package/dist/components/widgets/arm/arm.svelte +43 -40
  60. package/dist/components/widgets/arm/get-joint-positions-widget.svelte +10 -9
  61. package/dist/components/widgets/arm/joint-position-editor.svelte +105 -27
  62. package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +4 -3
  63. package/dist/components/widgets/arm/joint-position-slider.svelte +6 -2
  64. package/dist/components/widgets/arm/joint-position-slider.svelte.d.ts +2 -1
  65. package/dist/components/widgets/arm/manual-mode-widget.svelte +16 -6
  66. package/dist/components/widgets/arm/manual-mode.svelte +1 -5
  67. package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
  68. package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +22 -8
  69. package/dist/components/widgets/arm/move-to-joint-positions.svelte +15 -17
  70. package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
  71. package/dist/components/widgets/arm/move-to-position-control.svelte +45 -33
  72. package/dist/components/widgets/arm/move-to-position.svelte +97 -34
  73. package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -2
  74. package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
  75. package/dist/components/widgets/arm/quick-move.svelte +1 -4
  76. package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
  77. package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.d.ts +16 -0
  78. package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.js +37 -0
  79. package/dist/components/widgets/arm/use-edited-targets.svelte.d.ts +9 -0
  80. package/dist/components/widgets/arm/use-edited-targets.svelte.js +24 -0
  81. package/dist/components/widgets/audio-input/audio-input.svelte +80 -77
  82. package/dist/components/widgets/audio-input/get-properties-widget.svelte +16 -16
  83. package/dist/components/widgets/audio-output/audio-output.svelte +87 -84
  84. package/dist/components/widgets/audio-output/get-properties-widget.svelte +16 -16
  85. package/dist/components/widgets/base/base.svelte +78 -43
  86. package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
  87. package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
  88. package/dist/components/widgets/base/quick-move.svelte +5 -6
  89. package/dist/components/widgets/base/set-power-widget.svelte +20 -8
  90. package/dist/components/widgets/base/set-power.svelte +6 -4
  91. package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
  92. package/dist/components/widgets/base/set-velocity.svelte +6 -4
  93. package/dist/components/widgets/base/spin-widget.svelte +20 -8
  94. package/dist/components/widgets/base/vec3-builder.svelte +3 -2
  95. package/dist/components/widgets/base/vec3-builder.svelte.d.ts +2 -1
  96. package/dist/components/widgets/board/analog-read.svelte +2 -4
  97. package/dist/components/widgets/board/analog-write.svelte +2 -4
  98. package/dist/components/widgets/board/gpio-read.svelte +2 -1
  99. package/dist/components/widgets/board/gpio-write.svelte +2 -1
  100. package/dist/components/widgets/board/pin-section.svelte +5 -6
  101. package/dist/components/widgets/board/pin-section.svelte.d.ts +3 -2
  102. package/dist/components/widgets/board/read-write-pins.svelte +2 -2
  103. package/dist/components/widgets/button/push.svelte +2 -2
  104. package/dist/components/widgets/camera/camera.svelte +17 -24
  105. package/dist/components/widgets/camera/live-or-polling-video.svelte +33 -30
  106. package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
  107. package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
  108. package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
  109. package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
  110. package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
  111. package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
  112. package/dist/components/widgets/custom-control/custom-control.js +85 -0
  113. package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
  114. package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
  115. package/dist/components/widgets/discovery/discovery.svelte +13 -17
  116. package/dist/components/widgets/encoder/encoder.svelte +25 -21
  117. package/dist/components/widgets/encoder/get-position-widget.svelte +19 -16
  118. package/dist/components/widgets/gantry/gantry.svelte +58 -76
  119. package/dist/components/widgets/gantry/get-position-widget.svelte +15 -14
  120. package/dist/components/widgets/gantry/home.svelte +21 -10
  121. package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
  122. package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
  123. package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
  124. package/dist/components/widgets/gantry/quick-move-widget.svelte +3 -2
  125. package/dist/components/widgets/gantry/quick-move.svelte +1 -5
  126. package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
  127. package/dist/components/widgets/generic/generic.svelte +11 -6
  128. package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
  129. package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
  130. package/dist/components/widgets/gripper/grab.svelte +3 -19
  131. package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
  132. package/dist/components/widgets/gripper/gripper.svelte +18 -18
  133. package/dist/components/widgets/gripper/is-holding-something.svelte +21 -21
  134. package/dist/components/widgets/gripper/open-widget.svelte +26 -0
  135. package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
  136. package/dist/components/widgets/gripper/open.svelte +3 -19
  137. package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
  138. package/dist/components/widgets/input-controller/input-controller.svelte +10 -16
  139. package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
  140. package/dist/components/widgets/ml-model-service/ml-model-service.svelte +1 -1
  141. package/dist/components/widgets/motion/frame-select.svelte +4 -2
  142. package/dist/components/widgets/motion/frame-select.svelte.d.ts +2 -1
  143. package/dist/components/widgets/motion/motion.svelte +27 -31
  144. package/dist/components/widgets/motion/move-widget.svelte +32 -12
  145. package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
  146. package/dist/components/widgets/motion/move.svelte +6 -16
  147. package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
  148. package/dist/components/widgets/motor/go-for-view.svelte +16 -8
  149. package/dist/components/widgets/motor/go-to-view.svelte +12 -4
  150. package/dist/components/widgets/motor/motor.svelte +100 -64
  151. package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
  152. package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
  153. package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
  154. package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +8 -11
  155. package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +8 -11
  156. package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +8 -11
  157. package/dist/components/widgets/movement-sensor/get-position-widget.svelte +8 -11
  158. package/dist/components/widgets/movement-sensor/movement-sensor.svelte +64 -66
  159. package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
  160. package/dist/components/widgets/power-sensor/get-current-widget.svelte +8 -11
  161. package/dist/components/widgets/power-sensor/get-power-widget.svelte +8 -11
  162. package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +8 -11
  163. package/dist/components/widgets/power-sensor/power-sensor.svelte +35 -45
  164. package/dist/components/widgets/sensor/sensor.svelte +8 -12
  165. package/dist/components/widgets/servo/move-widget.svelte +2 -1
  166. package/dist/components/widgets/servo/move.svelte +1 -4
  167. package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
  168. package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
  169. package/dist/components/widgets/servo/quick-move.svelte +1 -5
  170. package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
  171. package/dist/components/widgets/servo/servo.svelte +53 -37
  172. package/dist/components/widgets/slam/get-position-widget.svelte +8 -11
  173. package/dist/components/widgets/slam/move-on-map.svelte +9 -6
  174. package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
  175. package/dist/components/widgets/slam/slam.svelte +65 -75
  176. package/dist/components/widgets/switch/position-view.svelte +1 -1
  177. package/dist/components/widgets/switch/position.svelte +2 -2
  178. package/dist/components/widgets/switch/switch.svelte +1 -1
  179. package/dist/components/widgets/vision-service/detection-row.svelte +4 -2
  180. package/dist/components/widgets/vision-service/detection-row.svelte.d.ts +2 -1
  181. package/dist/components/widgets/vision-service/fonts/public-sans.json +1 -0
  182. package/dist/components/widgets/vision-service/fonts/public-sans.png +0 -0
  183. package/dist/components/widgets/vision-service/image.svelte +4 -4
  184. package/dist/components/widgets/vision-service/legend.svelte +4 -4
  185. package/dist/components/widgets/vision-service/public-sans-font.d.ts +5 -0
  186. package/dist/components/widgets/vision-service/public-sans-font.js +14 -0
  187. package/dist/components/widgets/vision-service/vision-service.svelte +2 -2
  188. package/dist/index.d.ts +1 -1
  189. package/dist/index.js +0 -1
  190. package/package.json +19 -5
  191. package/dist/components/board/pin-section.svelte +0 -28
  192. package/dist/components/board/pin-section.svelte.d.ts +0 -9
  193. package/dist/components/mutation-section.svelte +0 -73
  194. package/dist/components/mutation-section.svelte.d.ts +0 -16
  195. package/dist/components/mutation-view.svelte +0 -29
  196. package/dist/components/mutation-view.svelte.d.ts +0 -10
  197. package/dist/components/section-group.svelte +0 -64
  198. package/dist/components/section-group.svelte.d.ts +0 -14
  199. package/dist/components/section-title.svelte +0 -63
  200. package/dist/components/section-title.svelte.d.ts +0 -14
@@ -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>
@@ -17,17 +17,19 @@
17
17
 
18
18
  <div class="flex flex-wrap gap-4">
19
19
  <Vec3Builder
20
- title="Linear velocity"
21
20
  titleUnits="(mm/s)"
22
21
  yTooltip="Only Y is used for a wheeled base, since Viam’s coordinate system considers +Y to be the forward axis."
23
22
  bind:vector={linearVelocity}
24
- />
23
+ >
24
+ {#snippet title()}Linear velocity{/snippet}
25
+ </Vec3Builder>
25
26
  <Vec3Builder
26
- title="Angular velocity"
27
27
  titleUnits="(º/s)"
28
28
  zTooltip="Only Z is used for a wheeled base, since Viam’s coordinate system considers +Z to point up and the angular velocity to rotate around the Z axis."
29
29
  bind:vector={angularVelocity}
30
- />
30
+ >
31
+ {#snippet title()}Angular velocity{/snippet}
32
+ </Vec3Builder>
31
33
  </div>
32
34
 
33
35
  <Button
@@ -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>
@@ -5,13 +5,14 @@ I'd be wary of using this elsewhere unless the use case & styling is identitcal
5
5
  -->
6
6
  <script lang="ts">
7
7
  import type { Vector3 } from '@viamrobotics/sdk'
8
+ import type { Snippet } from 'svelte'
8
9
 
9
10
  import { Icon, Label, NumericInput, Tooltip } from '@viamrobotics/prime-core'
10
11
 
11
12
  import { numberValueFromEvent } from '../../../event-handlers'
12
13
 
13
14
  interface Props {
14
- title: string
15
+ title: Snippet
15
16
  titleUnits?: string | undefined
16
17
  titleTooltip?: string | undefined
17
18
  vector: Vector3
@@ -41,7 +42,7 @@ I'd be wary of using this elsewhere unless the use case & styling is identitcal
41
42
  class="bg-light flex flex-row place-content-center gap-1 px-2 py-1.5"
42
43
  id={builderID}
43
44
  >
44
- {title}
45
+ {@render title()}
45
46
  {#if titleUnits}
46
47
  <abbr class="text-disabled">{titleUnits}</abbr>
47
48
  {/if}
@@ -1,6 +1,7 @@
1
1
  import type { Vector3 } from '@viamrobotics/sdk';
2
+ import type { Snippet } from 'svelte';
2
3
  interface Props {
3
- title: string;
4
+ title: Snippet;
4
5
  titleUnits?: string | undefined;
5
6
  titleTooltip?: string | undefined;
6
7
  vector: Vector3;
@@ -16,10 +16,8 @@
16
16
  const getButtonId = `${id}-get`
17
17
  </script>
18
18
 
19
- <PinSection
20
- title="Read pin"
21
- class="h-fit"
22
- >
19
+ <PinSection class="h-fit">
20
+ {#snippet title()}Read pin{/snippet}
23
21
  <section
24
22
  class="flex h-full max-h-18.5 w-full flex-col gap-1 p-3 text-xs"
25
23
  aria-labelledby={sectionId}
@@ -15,10 +15,8 @@
15
15
  const { setValue }: Props = $props()
16
16
  </script>
17
17
 
18
- <PinSection
19
- title="Write pin"
20
- class="h-fit"
21
- >
18
+ <PinSection class="h-fit">
19
+ {#snippet title()}Write pin{/snippet}
22
20
  <div class="flex h-full max-h-18.5 w-full p-3">
23
21
  <Label cx="w-fit!">
24
22
  <h5>Value</h5>
@@ -32,7 +32,8 @@
32
32
  }
33
33
  </script>
34
34
 
35
- <PinSection title="Read pin">
35
+ <PinSection>
36
+ {#snippet title()}Read pin{/snippet}
36
37
  <section
37
38
  class="flex h-full max-h-18.5 w-full flex-col gap-1 p-3 text-xs"
38
39
  aria-labelledby={stateSectionId}
@@ -23,7 +23,8 @@
23
23
  }
24
24
  </script>
25
25
 
26
- <PinSection title="Write pin">
26
+ <PinSection>
27
+ {#snippet title()}Write pin{/snippet}
27
28
  <div class="flex w-full p-3 text-xs">
28
29
  <ToggleButtons
29
30
  cx="w-fit!"
@@ -1,11 +1,10 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
-
4
- import { twMerge } from 'tailwind-merge'
3
+ import type { ClassValue } from 'svelte/elements'
5
4
 
6
5
  interface Props {
7
- title: string
8
- class?: string
6
+ title: Snippet
7
+ class?: ClassValue
9
8
  children?: Snippet
10
9
  }
11
10
 
@@ -15,14 +14,14 @@
15
14
  </script>
16
15
 
17
16
  <section
18
- class={twMerge('border-light w-full max-w-50 gap-6 divide-y border', className)}
17
+ class={['border-light w-full max-w-50 gap-6 divide-y border', className]}
19
18
  aria-labelledby={headingID}
20
19
  >
21
20
  <h4
22
21
  id={headingID}
23
22
  class="bg-light font-roboto-mono text-subtle-1 px-3 py-1.25 text-center text-sm uppercase"
24
23
  >
25
- {title}
24
+ {@render title()}
26
25
  </h4>
27
26
  {@render children?.()}
28
27
  </section>
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { ClassValue } from 'svelte/elements';
2
3
  interface Props {
3
- title: string;
4
- class?: string;
4
+ title: Snippet;
5
+ class?: ClassValue;
5
6
  children?: Snippet;
6
7
  }
7
8
  declare const PinSection: import("svelte").Component<Props, {}, "">;
@@ -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,8 @@
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
+ import { ResourceTriplets } from '../../../resource-triplet'
18
19
 
19
20
  import PCDWidget from '../pcd/pcd-widget.svelte'
20
21
  import ExportScreenshot from './export-screenshot.svelte'
@@ -155,24 +156,18 @@
155
156
  const setMousePostionTooltip = (event: CustomEvent<string>) => {
156
157
  mousePostionTooltip = event.detail as 'On' | 'Off'
157
158
  }
158
-
159
- const headingID = $props.id()
160
- const getImagesHeadingID = `${headingID}-images`
161
- const getPointCloudHeadingID = `${headingID}-point-cloud`
162
159
  </script>
163
160
 
164
161
  <ConnectionStatus {partID}>
165
162
  {#snippet connected()}
166
- <section
167
- class="flex flex-col"
168
- aria-labelledby={getImagesHeadingID}
169
- >
163
+ <section class="flex flex-col">
170
164
  <div class="flex flex-col gap-0.5 p-4 pb-0">
171
- <SectionTitle
172
- title="GetImages"
173
- api="rdk:component:camera"
174
- headingId={getImagesHeadingID}
175
- />
165
+ <Section.Heading>
166
+ <Section.Method
167
+ method="GetImages"
168
+ api={ResourceTriplets.Camera}
169
+ />
170
+ </Section.Heading>
176
171
  </div>
177
172
  <div class="p-4">
178
173
  {#if isPlaying}
@@ -332,16 +327,14 @@
332
327
  </div>
333
328
  </section>
334
329
 
335
- <section
336
- class="flex flex-col gap-4 p-4"
337
- aria-labelledby={getPointCloudHeadingID}
338
- >
330
+ <section class="flex flex-col gap-4 p-4">
339
331
  <div class="flex flex-col gap-0.5">
340
- <SectionTitle
341
- title="GetPointCloud"
342
- api="rdk:component:camera"
343
- headingId={getPointCloudHeadingID}
344
- />
332
+ <Section.Heading>
333
+ <Section.Method
334
+ method="GetPointCloud"
335
+ api={ResourceTriplets.Camera}
336
+ />
337
+ </Section.Heading>
345
338
  <p class="text-subtle-2 text-xs">
346
339
  Get depth measurement data from cameras with depth sensing support
347
340
  </p>
@@ -356,7 +349,7 @@
356
349
  {#if isShowingPointcloud}
357
350
  <Query
358
351
  query={pointcloudQuery}
359
- contentCx="h-6"
352
+ class="h-6"
360
353
  >
361
354
  {#if pointcloudQuery.data}
362
355
  <PCDWidget data={pointcloudQuery.data} />
@@ -8,13 +8,15 @@
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'
19
+ import { ResourceTriplets } from '../../../resource-triplet'
18
20
 
19
21
  import { getBlobForViamDepth, VIAM_DEPTH_MIME_TYPE } from './decode-viam-depth'
20
22
  import { pickImageForSource } from './pick-image-for-source'
@@ -334,28 +336,27 @@
334
336
  })
335
337
  </script>
336
338
 
337
- <!-- This breaks out of using the <Query> component
338
- to merge live stream and TanStack query errors -->
339
- {#if lastError}
340
- <ContentRect
341
- {contentRect}
342
- cx="bg-medium/50 absolute flex h-64 w-80 max-w-full items-center justify-center"
343
- >
344
- <ErrorDisplay
345
- class="pb-4"
346
- {lastError}
347
- />
348
- </ContentRect>
349
- {:else if isLive ? isStreamLoading : isLoading}
350
- <ContentRect
351
- {contentRect}
352
- cx="absolute h-64 w-80 max-w-full"
353
- >
354
- <Progress />
355
- </ContentRect>
356
- {/if}
357
-
358
339
  <div class="relative">
340
+ <!-- This breaks out of using the Query component
341
+ to merge live stream and TanStack query errors -->
342
+ {#if lastError}
343
+ <ContentRect
344
+ {contentRect}
345
+ class="bg-medium/50 absolute top-0 left-0 flex h-64 w-80 max-w-full items-center justify-center"
346
+ >
347
+ <ErrorDisplay
348
+ class="pb-4"
349
+ {lastError}
350
+ />
351
+ </ContentRect>
352
+ {:else if isLive ? isStreamLoading : isLoading}
353
+ <ContentRect
354
+ {contentRect}
355
+ class="absolute top-0 left-0 h-64 w-80 max-w-full"
356
+ >
357
+ <Progress />
358
+ </ContentRect>
359
+ {/if}
359
360
  <div
360
361
  class="absolute bottom-2 left-2 z-10 rounded-[3px] bg-black/30 px-1 py-0.5 text-right font-mono text-xs text-white"
361
362
  >
@@ -398,14 +399,16 @@
398
399
  {/if}
399
400
 
400
401
  {#if showResolutionOptions && isLive}
401
- <MutationSection
402
- title="SetStreamOptions"
403
- api="rdk:component:camera"
404
- description="Change the resolution of the live stream video feed"
405
- lastError={resolutionMutation.error}
406
- class="-m-4 mt-4"
402
+ <ApiSection
403
+ method="SetStreamOptions"
404
+ api={ResourceTriplets.Camera}
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
+ };
@@ -0,0 +1,35 @@
1
+ import type { JsonValue } from '@viamrobotics/sdk';
2
+ /**
3
+ * The `doCommand` that asks a resource for its custom control artifact.
4
+ *
5
+ * @deprecated Transitional delivery path. A module declares its control per model in
6
+ * `meta.json` (`models[].custom_control`); serving the bytes over `doCommand` exists only until the
7
+ * machine or registry can serve the declared file. Do not build new integrations on it. Module
8
+ * authors keep their manifests and drop the handler when delivery moves.
9
+ */
10
+ export declare const CUSTOM_CONTROL_COMMAND = "get-custom-control";
11
+ export declare const CUSTOM_CONTROL_CSP: string;
12
+ export interface CustomControlArtifact {
13
+ html: string;
14
+ revision?: string;
15
+ /** The `custom_control` path the module declared for this model in its `meta.json`, when reported. */
16
+ path?: string;
17
+ }
18
+ interface DoCommandClient {
19
+ doCommand(command: Record<string, JsonValue>): Promise<JsonValue>;
20
+ }
21
+ /**
22
+ * Asks a resource for its custom control artifact over `doCommand` and validates the reply.
23
+ *
24
+ * @deprecated Bound to the transitional `doCommand` delivery path ({@link CUSTOM_CONTROL_COMMAND}).
25
+ * The `CustomControlArtifact` it returns is the shape every delivery path will produce; the
26
+ * function is replaced when the machine or registry can serve the manifest-declared file.
27
+ */
28
+ export declare const loadCustomControl: (client: DoCommandClient) => Promise<CustomControlArtifact>;
29
+ /**
30
+ * Returns the artifact with the host's Content Security Policy injected as the first child of
31
+ * `<head>`, creating the head when the artifact has none, so the policy applies before any other
32
+ * element parses. An artifact whose head already opens with this exact meta is returned unchanged.
33
+ */
34
+ export declare const prepareArtifact: (html: string) => string;
35
+ export {};