@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
package/README.md CHANGED
@@ -36,7 +36,9 @@ The playground (`pnpm dev`) can be used to develop the test-cards against prod r
36
36
 
37
37
  This is useful if you need to validate the sdk against specific behavior of modules or need to replicate a bug from another robot (why replicate locally when you could just develop directly against the robot with the bug?).
38
38
 
39
- To setup your playground, create a `.env.local` in the test-widgets directory with the following format (no need to create two robots):
39
+ The sidebar lists your machines. The `?machine=<name>` search param picks which one the playground shows, and the first machine is the default.
40
+
41
+ A `.env.local` in the test-widgets directory is optional. It seeds the list with the following format (no need to create two robots):
40
42
 
41
43
  ```json
42
44
  VITE_PLAYGROUND_ROBOTS='
@@ -70,3 +72,15 @@ VITE_PLAYGROUND_ROBOTS='
70
72
  }
71
73
  '
72
74
  ```
75
+
76
+ You can also add machines from the sidebar. Paste one machine config with a `name`, or a whole `VITE_PLAYGROUND_ROBOTS` value, into the form and submit. Machines added this way are kept in your browser's localStorage, and you can remove them from the sidebar. Machines from `.env.local` cannot be removed there.
77
+
78
+ ### Hosted playground and docs
79
+
80
+ Every push to `main` deploys the docs site to `https://viamrobotics.github.io/test-widgets/` and the playground to `https://viamrobotics.github.io/test-widgets/playground/`. The docs live in `docs/`, a separate Astro Starlight project. Run them with `pnpm docs:dev`, or build them with the playground included using `pnpm docs:build`.
81
+
82
+ ### PR previews
83
+
84
+ Each pull request from a branch in this repo deploys the playground to `https://viamrobotics.github.io/test-widgets/pr-preview/pr-<N>/`, and a bot comment links it. The preview has no machines built in, so paste a config into the sidebar form. Closing the pull request removes the preview. Pull requests from forks and Dependabot get no preview.
85
+
86
+ On GitHub Pages, every `viamrobotics` site shares the `viamrobotics.github.io` origin. Those sites can read the keys stored in localStorage. Use keys for test machines only.
@@ -1,8 +1,8 @@
1
+ import type { ResourceTriplet } from './resource-triplet';
1
2
  /**
2
3
  * Returns the docs URL for a given resource API + method, or undefined
3
4
  * when the method has no dedicated anchor (e.g. GetStatus, GetSourceNames).
4
5
  *
5
- * @param api - RDK API string, e.g. "rdk:component:movement_sensor"
6
6
  * @param method - camelCase method name, e.g. "getPosition"
7
7
  */
8
- export declare const apiDocsHref: (api: string, method: string) => string | undefined;
8
+ export declare const apiDocsHref: (api: ResourceTriplet, method: string) => string | undefined;
@@ -3,7 +3,6 @@ const NO_LINK_METHODS = new Set(['getStatus', 'getSourceNames']);
3
3
  * Returns the docs URL for a given resource API + method, or undefined
4
4
  * when the method has no dedicated anchor (e.g. GetStatus, GetSourceNames).
5
5
  *
6
- * @param api - RDK API string, e.g. "rdk:component:movement_sensor"
7
6
  * @param method - camelCase method name, e.g. "getPosition"
8
7
  */
9
8
  export const apiDocsHref = (api, method) => {
@@ -2,66 +2,75 @@
2
2
  import type { Snippet } from 'svelte'
3
3
  import type { HTMLAttributes } from 'svelte/elements'
4
4
 
5
- import { twMerge } from 'tailwind-merge'
5
+ import type { ResourceTriplet } from '../resource-triplet'
6
6
 
7
- import SectionTitle from './section-title.svelte'
7
+ import { Section } from './section'
8
+ import {
9
+ type SectionMutation,
10
+ type SectionQuery,
11
+ useSectionErrors,
12
+ } from './section/use-section-errors.svelte'
8
13
 
9
- interface Props extends HTMLAttributes<HTMLElement> {
10
- title?: string | undefined
11
- tooltip?: string | undefined
12
- description?: string | undefined
13
- bottomText?: string | undefined
14
- /** RDK API string; presence renders the title as a linked monospace method name */
15
- api?: string | undefined
16
- class?: string
17
- children?: Snippet
18
- }
14
+ /**
15
+ * What the section reads or writes. At least one list is required, so every section's errors
16
+ * reach its indicator. Query errors are distinct per query, mutation errors per mutation.
17
+ */
18
+ type Sources =
19
+ | { queries: SectionQuery[]; mutations?: SectionMutation[] }
20
+ | { queries?: SectionQuery[]; mutations: SectionMutation[] }
21
+
22
+ type Props = HTMLAttributes<HTMLElement> &
23
+ Sources & {
24
+ /** RDK method name in PascalCase. */
25
+ method: string
26
+ api: ResourceTriplet
27
+ subheading?: Snippet
28
+ tooltip?: Snippet
29
+ /**
30
+ * @deprecated Exists only for the migration. Removed once every section passes it.
31
+ */
32
+ skeleton?: boolean
33
+ }
19
34
 
20
35
  const {
21
- title,
22
- tooltip,
23
- description,
24
- bottomText,
36
+ method,
25
37
  api,
26
- class: className = '',
38
+ queries = [],
39
+ mutations = [],
40
+ subheading,
41
+ tooltip,
42
+ skeleton = false,
27
43
  children,
28
44
  ...rest
29
45
  }: Props = $props()
30
46
 
31
- const headingID = $props.id()
47
+ const sectionErrors = useSectionErrors(() => ({ queries, mutations }))
32
48
  </script>
33
49
 
34
- <section
35
- class={twMerge('flex grow flex-col gap-4 p-4', className)}
36
- aria-labelledby={title ? headingID : undefined}
50
+ <Section
51
+ errorReporter={sectionErrors}
37
52
  {...rest}
38
53
  >
39
- {#if title}
40
- <div class="flex flex-col gap-0.5">
41
- {#if api}
42
- <SectionTitle
43
- {title}
44
- {tooltip}
45
- {api}
46
- headingId={headingID}
47
- />
48
- {:else}
49
- <h3
50
- class="flex flex-row items-center gap-1 text-sm font-semibold"
51
- id={headingID}
52
- >
53
- {title}
54
- </h3>
55
- {/if}
56
- {#if description}
57
- <p class="text-subtle-2 text-xs">{description}</p>
58
- {/if}
59
- </div>
60
- {/if}
61
-
62
- {@render children?.()}
54
+ <div class="flex flex-col gap-0.5">
55
+ <Section.Heading>
56
+ <Section.Method
57
+ {method}
58
+ {api}
59
+ />
60
+ {#snippet aside()}
61
+ <Section.Errors errors={sectionErrors.errors} />
62
+ {#if tooltip}
63
+ <Section.Tooltip>{@render tooltip()}</Section.Tooltip>
64
+ {/if}
65
+ {/snippet}
66
+ </Section.Heading>
67
+ {@render subheading?.()}
68
+ </div>
63
69
 
64
- {#if bottomText}
65
- <p class="text-subtle-2 mt-auto text-xs">{bottomText}</p>
66
- {/if}
67
- </section>
70
+ <Section.Body
71
+ isLoading={sectionErrors.isLoading}
72
+ {skeleton}
73
+ >
74
+ {@render children?.()}
75
+ </Section.Body>
76
+ </Section>
@@ -1,15 +1,29 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
- interface Props extends HTMLAttributes<HTMLElement> {
4
- title?: string | undefined;
5
- tooltip?: string | undefined;
6
- description?: string | undefined;
7
- bottomText?: string | undefined;
8
- /** RDK API string; presence renders the title as a linked monospace method name */
9
- api?: string | undefined;
10
- class?: string;
11
- children?: Snippet;
12
- }
3
+ import type { ResourceTriplet } from '../resource-triplet';
4
+ import { type SectionMutation, type SectionQuery } from './section/use-section-errors.svelte';
5
+ /**
6
+ * What the section reads or writes. At least one list is required, so every section's errors
7
+ * reach its indicator. Query errors are distinct per query, mutation errors per mutation.
8
+ */
9
+ type Sources = {
10
+ queries: SectionQuery[];
11
+ mutations?: SectionMutation[];
12
+ } | {
13
+ queries?: SectionQuery[];
14
+ mutations: SectionMutation[];
15
+ };
16
+ type Props = HTMLAttributes<HTMLElement> & Sources & {
17
+ /** RDK method name in PascalCase. */
18
+ method: string;
19
+ api: ResourceTriplet;
20
+ subheading?: Snippet;
21
+ tooltip?: Snippet;
22
+ /**
23
+ * @deprecated Exists only for the migration. Removed once every section passes it.
24
+ */
25
+ skeleton?: boolean;
26
+ };
13
27
  declare const ApiSection: import("svelte").Component<Props, {}, "">;
14
28
  type ApiSection = ReturnType<typeof ApiSection>;
15
29
  export default ApiSection;
@@ -0,0 +1,51 @@
1
+ <script lang="ts">
2
+ import * as Sentry from '@sentry/svelte'
3
+
4
+ const { children } = $props()
5
+
6
+ let isErrorExpanded = $state(false)
7
+
8
+ const describeError = (error: unknown) => {
9
+ return error instanceof Error ? (error.stack ?? error.message) : String(error)
10
+ }
11
+ </script>
12
+
13
+ <svelte:boundary
14
+ onerror={(error) => {
15
+ Sentry.captureException(error)
16
+ }}
17
+ >
18
+ {@render children?.()}
19
+
20
+ {#snippet failed(error, reset)}
21
+ <div
22
+ role="alert"
23
+ class="bg-extralight flex h-full w-full flex-col items-center justify-center gap-2 p-4"
24
+ >
25
+ <div>Something went wrong</div>
26
+ <button
27
+ class="text-subtle-1 text-xs hover:underline"
28
+ type="button"
29
+ onclick={() => {
30
+ isErrorExpanded = false
31
+ reset()
32
+ }}
33
+ >
34
+ Try again
35
+ </button>
36
+ <button
37
+ class="text-danger-dark text-xs hover:underline"
38
+ type="button"
39
+ aria-expanded={isErrorExpanded}
40
+ onclick={() => {
41
+ isErrorExpanded = !isErrorExpanded
42
+ }}
43
+ >
44
+ {isErrorExpanded ? 'Hide' : 'Show'} error
45
+ </button>
46
+ {#if isErrorExpanded}
47
+ <pre class="text-danger-dark font-mono text-xs text-wrap">{describeError(error)}</pre>
48
+ {/if}
49
+ </div>
50
+ {/snippet}
51
+ </svelte:boundary>
@@ -0,0 +1,5 @@
1
+ declare const Boundary: import("svelte").Component<{
2
+ children: any;
3
+ }, {}, "">;
4
+ type Boundary = ReturnType<typeof Boundary>;
5
+ export default Boundary;
@@ -1,85 +1,81 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
3
 
4
- import { Progress } from '@viamrobotics/prime-core'
4
+ import { Icon, Progress } from '@viamrobotics/prime-core'
5
5
  import { MachineConnectionEvent } from '@viamrobotics/sdk'
6
6
  import { useConnectionStatus } from '@viamrobotics/svelte-sdk'
7
- import { twMerge } from 'tailwind-merge'
7
+
8
+ import Boundary from './boundary.svelte'
8
9
 
9
10
  interface Props {
10
11
  partID: string
11
- connectingClass?: string
12
- disconnectedClass?: string
13
- status?: MachineConnectionEvent
14
- connected?: Snippet
12
+ connected: Snippet
13
+ dialing?: Snippet
15
14
  connecting?: Snippet
15
+ reconnecting?: Snippet
16
+ reconnectionFailed?: Snippet
17
+ disconnecting?: Snippet
16
18
  disconnected?: Snippet
17
19
  }
18
20
 
19
21
  const {
20
22
  partID,
21
- connectingClass = '',
22
- disconnectedClass = '',
23
- status,
24
23
  connected,
24
+ dialing,
25
25
  connecting,
26
+ reconnecting,
27
+ reconnectionFailed,
28
+ disconnecting,
26
29
  disconnected,
27
30
  }: Props = $props()
28
31
 
29
32
  const connectionStatus = useConnectionStatus(() => partID)
30
- const currentStatus = $derived(status ?? connectionStatus.current)
31
33
 
32
- let isErrorExpanded = $state(false)
34
+ const views: Record<MachineConnectionEvent, Snippet> = $derived({
35
+ [MachineConnectionEvent.CONNECTED]: connected,
36
+ [MachineConnectionEvent.DIALING]: dialing ?? loader,
37
+ [MachineConnectionEvent.CONNECTING]: connecting ?? loader,
38
+ [MachineConnectionEvent.RECONNECTING]: reconnecting ?? loader,
39
+ [MachineConnectionEvent.RECONNECTION_FAILED]: reconnectionFailed ?? failed,
40
+ [MachineConnectionEvent.DISCONNECTING]: disconnecting ?? loader,
41
+ [MachineConnectionEvent.DISCONNECTED]: disconnected ?? offline,
42
+ })
43
+
44
+ const view = $derived(views[connectionStatus.current ?? MachineConnectionEvent.DISCONNECTED])
33
45
  </script>
34
46
 
35
- <svelte:boundary>
36
- {#if currentStatus === MachineConnectionEvent.CONNECTED}
37
- {@render connected?.()}
38
- {:else if currentStatus === MachineConnectionEvent.CONNECTING}
39
- {#if connecting}
40
- {@render connecting()}
41
- {:else}
42
- <div
43
- class={twMerge(
44
- 'bg-extralight text-disabled flex h-full min-h-40 w-full items-center justify-center gap-2',
45
- connectingClass
46
- )}
47
- >
48
- <Progress />
49
- <div class="capitalize">{currentStatus}...</div>
50
- </div>
51
- {/if}
52
- {:else if currentStatus === MachineConnectionEvent.DISCONNECTED}
53
- {#if disconnected}
54
- {@render disconnected()}
55
- {:else}
56
- <div
57
- class={twMerge(
58
- 'bg-extralight text-disabled flex h-full min-h-40 w-full items-center justify-center',
59
- disconnectedClass
60
- )}
61
- >
62
- This machine is offline
63
- </div>
64
- {/if}
65
- {/if}
47
+ {#snippet loader()}
48
+ <div
49
+ class="bg-extralight text-disabled flex h-full min-h-40 w-full items-center justify-center gap-2"
50
+ >
51
+ <Progress />
52
+ <div class="capitalize">{connectionStatus.current}...</div>
53
+ </div>
54
+ {/snippet}
55
+
56
+ {#snippet failed()}
57
+ <div
58
+ class="bg-extralight text-disabled flex h-full min-h-40 w-full items-center justify-center gap-2"
59
+ >
60
+ <Icon
61
+ name="alert"
62
+ cx="text-danger-dark"
63
+ aria-hidden="true"
64
+ />
65
+
66
+ Could not connect to the machine.
67
+ </div>
68
+ {/snippet}
69
+
70
+ {#snippet offline()}
71
+ <div class="bg-extralight text-disabled flex h-full min-h-40 w-full items-center justify-center">
72
+ This machine is offline
73
+ </div>
74
+ {/snippet}
66
75
 
67
- {#snippet failed(error, reset)}
68
- <div class="bg-extralight flex h-full w-full flex-col items-center justify-center gap-2 p-4">
69
- <div>Something went wrong</div>
70
- <button
71
- class="text-disabled text-xs hover:underline"
72
- onclick={reset}>Try again</button
73
- >
74
- <button
75
- class="text-disabled text-xs hover:underline"
76
- onclick={() => {
77
- isErrorExpanded = !isErrorExpanded
78
- }}>{isErrorExpanded ? 'Hide' : 'Show'} error</button
79
- >
80
- {#if isErrorExpanded}
81
- <pre class="font-mono text-xs text-wrap">{error}</pre>
82
- {/if}
83
- </div>
84
- {/snippet}
85
- </svelte:boundary>
76
+ {#key connectionStatus.current}
77
+ <!-- fallback outer boundary -->
78
+ <Boundary>
79
+ {@render view()}
80
+ </Boundary>
81
+ {/key}
@@ -1,12 +1,12 @@
1
1
  import type { Snippet } from 'svelte';
2
- import { MachineConnectionEvent } from '@viamrobotics/sdk';
3
2
  interface Props {
4
3
  partID: string;
5
- connectingClass?: string;
6
- disconnectedClass?: string;
7
- status?: MachineConnectionEvent;
8
- connected?: Snippet;
4
+ connected: Snippet;
5
+ dialing?: Snippet;
9
6
  connecting?: Snippet;
7
+ reconnecting?: Snippet;
8
+ reconnectionFailed?: Snippet;
9
+ disconnecting?: Snippet;
10
10
  disconnected?: Snippet;
11
11
  }
12
12
  declare const ConnectionStatus: import("svelte").Component<Props, {}, "">;
@@ -1,19 +1,24 @@
1
+ <!--
2
+ @component
3
+
4
+ @deprecated It sized the `Queries` wrapper and goes with it. A section sets its own layout class. Kept for the sectionless files until their resource PRs.
5
+ -->
6
+
1
7
  <script lang="ts">
2
8
  import type { Snippet } from 'svelte'
3
-
4
- import { twMerge } from 'tailwind-merge'
9
+ import type { ClassValue } from 'svelte/elements'
5
10
 
6
11
  interface Props {
7
12
  contentRect: DOMRect | undefined
8
- cx?: string
13
+ class?: ClassValue
9
14
  children?: Snippet
10
15
  }
11
16
 
12
- const { contentRect, cx = '', children }: Props = $props()
17
+ const { contentRect, class: classNames = 'h-full w-full', children }: Props = $props()
13
18
  </script>
14
19
 
15
20
  <div
16
- class={twMerge('h-full w-full', cx)}
21
+ class={classNames}
17
22
  style:width={contentRect ? `${contentRect.width.toString()}px` : undefined}
18
23
  style:height={contentRect ? `${contentRect.height.toString()}px` : undefined}
19
24
  >
@@ -1,9 +1,11 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { ClassValue } from 'svelte/elements';
2
3
  interface Props {
3
4
  contentRect: DOMRect | undefined;
4
- cx?: string;
5
+ class?: ClassValue;
5
6
  children?: Snippet;
6
7
  }
8
+ /** @deprecated It sized the `Queries` wrapper and goes with it. A section sets its own layout class. Kept for the sectionless files until their resource PRs. */
7
9
  declare const ContentRect: import("svelte").Component<Props, {}, "">;
8
10
  type ContentRect = ReturnType<typeof ContentRect>;
9
11
  export default ContentRect;
@@ -1,11 +1,21 @@
1
+ <!--
2
+ @component
3
+
4
+ @deprecated Errors show in the section heading's indicator. Pass the mutation to `ApiSection` as
5
+ `mutations` or to a `Section` control's `useSectionErrors` call. In a form that cannot reach its
6
+ section, use `Section.Error`, which reports to the indicator and falls back to an inline line
7
+ outside a section. Kept for the sectionless files until their resource PRs.
8
+ -->
9
+
1
10
  <script lang="ts">
11
+ import type { ClassValue } from 'svelte/elements'
12
+
2
13
  import { IconButton, Tooltip } from '@viamrobotics/prime-core'
3
- import { twMerge } from 'tailwind-merge'
4
14
 
5
15
  interface Props {
6
16
  lastError: Error | null | undefined
7
17
  id?: string
8
- class?: string
18
+ class?: ClassValue
9
19
  }
10
20
 
11
21
  const defaultId = $props.id()
@@ -39,10 +49,10 @@
39
49
  <div class="flex items-center justify-between gap-1">
40
50
  <p
41
51
  {id}
42
- class={twMerge(
52
+ class={[
43
53
  'font-roboto-mono text-danger-dark min-w-0 overflow-auto text-xs wrap-break-word',
44
- className
45
- )}
54
+ className,
55
+ ]}
46
56
  >
47
57
  {errorText}
48
58
  </p>
@@ -1,8 +1,15 @@
1
+ import type { ClassValue } from 'svelte/elements';
1
2
  interface Props {
2
3
  lastError: Error | null | undefined;
3
4
  id?: string;
4
- class?: string;
5
+ class?: ClassValue;
5
6
  }
7
+ /**
8
+ * @deprecated Errors show in the section heading's indicator. Pass the mutation to `ApiSection` as
9
+ * `mutations` or to a `Section` control's `useSectionErrors` call. In a form that cannot reach its
10
+ * section, use `Section.Error`, which reports to the indicator and falls back to an inline line
11
+ * outside a section. Kept for the sectionless files until their resource PRs.
12
+ */
6
13
  declare const Error: import("svelte").Component<Props, {}, "">;
7
14
  type Error = ReturnType<typeof Error>;
8
15
  export default Error;
@@ -1,5 +1,4 @@
1
1
  export { default as ConnectionStatus } from './connection-status.svelte';
2
- export { default as SectionTitle } from './section-title.svelte';
3
2
  export { default as ArmWidget } from './widgets/arm/arm.svelte';
4
3
  export { default as ArmGetJointPositionsWidget } from './widgets/arm/get-joint-positions-widget.svelte';
5
4
  export { default as ArmIsMovingWidget } from './widgets/arm/is-moving-widget.svelte';
@@ -37,11 +36,11 @@ export { default as GantryHomeWidget } from './widgets/gantry/home.svelte';
37
36
  export { default as GantryMoveToPositionWidget } from './widgets/gantry/move-to-position-widget.svelte';
38
37
  export { default as GantryQuickMoveWidget } from './widgets/gantry/quick-move-widget.svelte';
39
38
  export { default as GenericWidget } from './widgets/generic/generic.svelte';
40
- export { default as GripperGrabWidget } from './widgets/gripper/grab.svelte';
39
+ export { default as GripperGrabWidget } from './widgets/gripper/grab-widget.svelte';
41
40
  export { default as GripperWidget } from './widgets/gripper/gripper.svelte';
42
41
  export { default as GripperIsHoldingSomethingWidget } from './widgets/gripper/is-holding-something.svelte';
43
42
  export { default as GripperIsMovingWidget } from './widgets/gripper/is-moving-widget.svelte';
44
- export { default as GripperOpenWidget } from './widgets/gripper/open.svelte';
43
+ export { default as GripperOpenWidget } from './widgets/gripper/open-widget.svelte';
45
44
  export { default as InputControllerWidget } from './widgets/input-controller/input-controller.svelte';
46
45
  export { default as MLModelServiceWidget } from './widgets/ml-model-service/ml-model-service.svelte';
47
46
  export { default as MotionServiceWidget } from './widgets/motion/motion.svelte';
@@ -80,3 +79,5 @@ export { default as VisionServiceWidget } from './widgets/vision-service/vision-
80
79
  export { default as RefetchController } from './refetch-controller.svelte';
81
80
  export { NavigationMap, NavigationTab, type NavigationTabType, type Shapes, type CapsuleGeometry, type SphereGeometry, type BoxGeometry, type Geometry, type Obstacle, type Path, } from './navigation-map';
82
81
  export { MapLibre, MapLibreMarker, CenterControls, FollowControls, NavigationControls, SatelliteControls, DirectionalMarker, LngLatInput, MapProviders, type MapProvider, GeoPose, Waypoint, useMapLibre, useMapLibreEvent, useMapLibreThreeRaycast, useMapLibreThreeRenderer, lngLatToMercator, mercatorToCartesian, lngLatToCartesian, cartesianToMercator, cartesianToLngLat, } from './maplibre';
82
+ export { default as CustomControlWidget } from './widgets/custom-control/custom-control.svelte';
83
+ export { CUSTOM_CONTROL_COMMAND, CUSTOM_CONTROL_CSP, type CustomControlArtifact, loadCustomControl, prepareArtifact, } from './widgets/custom-control/custom-control.ts';
@@ -1,5 +1,4 @@
1
1
  export { default as ConnectionStatus } from './connection-status.svelte';
2
- export { default as SectionTitle } from './section-title.svelte';
3
2
  export { default as ArmWidget } from './widgets/arm/arm.svelte';
4
3
  export { default as ArmGetJointPositionsWidget } from './widgets/arm/get-joint-positions-widget.svelte';
5
4
  export { default as ArmIsMovingWidget } from './widgets/arm/is-moving-widget.svelte';
@@ -36,11 +35,11 @@ export { default as GantryHomeWidget } from './widgets/gantry/home.svelte';
36
35
  export { default as GantryMoveToPositionWidget } from './widgets/gantry/move-to-position-widget.svelte';
37
36
  export { default as GantryQuickMoveWidget } from './widgets/gantry/quick-move-widget.svelte';
38
37
  export { default as GenericWidget } from './widgets/generic/generic.svelte';
39
- export { default as GripperGrabWidget } from './widgets/gripper/grab.svelte';
38
+ export { default as GripperGrabWidget } from './widgets/gripper/grab-widget.svelte';
40
39
  export { default as GripperWidget } from './widgets/gripper/gripper.svelte';
41
40
  export { default as GripperIsHoldingSomethingWidget } from './widgets/gripper/is-holding-something.svelte';
42
41
  export { default as GripperIsMovingWidget } from './widgets/gripper/is-moving-widget.svelte';
43
- export { default as GripperOpenWidget } from './widgets/gripper/open.svelte';
42
+ export { default as GripperOpenWidget } from './widgets/gripper/open-widget.svelte';
44
43
  export { default as InputControllerWidget } from './widgets/input-controller/input-controller.svelte';
45
44
  export { default as MLModelServiceWidget } from './widgets/ml-model-service/ml-model-service.svelte';
46
45
  export { default as MotionServiceWidget } from './widgets/motion/motion.svelte';
@@ -79,3 +78,5 @@ export { default as VisionServiceWidget } from './widgets/vision-service/vision-
79
78
  export { default as RefetchController } from './refetch-controller.svelte';
80
79
  export { NavigationMap, NavigationTab, } from './navigation-map';
81
80
  export { MapLibre, MapLibreMarker, CenterControls, FollowControls, NavigationControls, SatelliteControls, DirectionalMarker, LngLatInput, MapProviders, GeoPose, Waypoint, useMapLibre, useMapLibreEvent, useMapLibreThreeRaycast, useMapLibreThreeRenderer, lngLatToMercator, mercatorToCartesian, lngLatToCartesian, cartesianToMercator, cartesianToLngLat, } from './maplibre';
81
+ export { default as CustomControlWidget } from './widgets/custom-control/custom-control.svelte';
82
+ export { CUSTOM_CONTROL_COMMAND, CUSTOM_CONTROL_CSP, loadCustomControl, prepareArtifact, } from "./widgets/custom-control/custom-control.js";