@viamrobotics/test-widgets 0.17.4 → 0.18.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 (59) hide show
  1. package/dist/components/boundary.svelte +6 -1
  2. package/dist/components/index.d.ts +8 -1
  3. package/dist/components/index.js +8 -1
  4. package/dist/components/section/section-error.svelte +52 -8
  5. package/dist/components/section/section-error.svelte.d.ts +2 -0
  6. package/dist/components/section/section-errors.svelte +10 -2
  7. package/dist/components/widgets/arm/arm.svelte +5 -14
  8. package/dist/components/widgets/arm/stop-widget.svelte +20 -0
  9. package/dist/components/widgets/arm/stop-widget.svelte.d.ts +7 -0
  10. package/dist/components/widgets/base/base.svelte +32 -150
  11. package/dist/components/widgets/base/stop-widget.svelte +20 -0
  12. package/dist/components/widgets/base/stop-widget.svelte.d.ts +7 -0
  13. package/dist/components/widgets/camera/camera.svelte +28 -10
  14. package/dist/components/widgets/camera/export-screenshot.svelte +12 -20
  15. package/dist/components/widgets/camera/export-screenshot.svelte.d.ts +2 -0
  16. package/dist/components/widgets/camera/live-or-polling-video.svelte +13 -12
  17. package/dist/components/widgets/camera/picture-in-picture-button.svelte +7 -15
  18. package/dist/components/widgets/custom-control/custom-control.svelte +2 -2
  19. package/dist/components/widgets/do-command/do-command.svelte +6 -6
  20. package/dist/components/widgets/gantry/move-to-position-widget.svelte +12 -8
  21. package/dist/components/widgets/gantry/quick-move-widget.svelte +29 -15
  22. package/dist/components/widgets/gripper/grab-widget.svelte +10 -3
  23. package/dist/components/widgets/gripper/gripper.svelte +15 -54
  24. package/dist/components/widgets/gripper/is-holding-something-widget.svelte.d.ts +7 -0
  25. package/dist/components/widgets/gripper/open-grab-control.svelte +60 -0
  26. package/dist/components/widgets/gripper/open-grab-control.svelte.d.ts +9 -0
  27. package/dist/components/widgets/gripper/open-widget.svelte +10 -3
  28. package/dist/components/widgets/gripper/stop-widget.svelte +20 -0
  29. package/dist/components/widgets/gripper/stop-widget.svelte.d.ts +7 -0
  30. package/dist/components/widgets/ml-model-service/metadata-widget.svelte +52 -0
  31. package/dist/components/widgets/ml-model-service/metadata-widget.svelte.d.ts +13 -0
  32. package/dist/components/widgets/ml-model-service/ml-model-service.svelte +9 -22
  33. package/dist/components/widgets/movement-sensor/movement-sensor.svelte +102 -125
  34. package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +11 -7
  35. package/dist/components/widgets/servo/get-position-widget.svelte +42 -0
  36. package/dist/components/widgets/servo/get-position-widget.svelte.d.ts +7 -0
  37. package/dist/components/widgets/servo/move-widget.svelte +10 -5
  38. package/dist/components/widgets/servo/quick-move-widget.svelte +28 -10
  39. package/dist/components/widgets/servo/servo.svelte +22 -111
  40. package/dist/components/widgets/servo/stop-widget.svelte +20 -0
  41. package/dist/components/widgets/servo/stop-widget.svelte.d.ts +7 -0
  42. package/dist/components/widgets/switch/position-view.svelte +8 -5
  43. package/dist/components/widgets/switch/position.svelte +1 -5
  44. package/dist/components/widgets/switch/position.svelte.d.ts +0 -1
  45. package/dist/components/widgets/switch/switch.svelte +18 -17
  46. package/dist/components/widgets/vision-service/vision-service.svelte +12 -7
  47. package/dist/registry.d.ts +2 -2
  48. package/dist/registry.js +15 -5
  49. package/package.json +13 -13
  50. package/dist/components/content-rect.svelte +0 -26
  51. package/dist/components/content-rect.svelte.d.ts +0 -11
  52. package/dist/components/error.svelte +0 -71
  53. package/dist/components/error.svelte.d.ts +0 -15
  54. package/dist/components/queries.svelte +0 -97
  55. package/dist/components/queries.svelte.d.ts +0 -17
  56. package/dist/components/query.svelte +0 -29
  57. package/dist/components/query.svelte.d.ts +0 -15
  58. package/dist/components/widgets/gripper/is-holding-something.svelte.d.ts +0 -7
  59. /package/dist/components/widgets/gripper/{is-holding-something.svelte → is-holding-something-widget.svelte} +0 -0
@@ -4,8 +4,6 @@
4
4
 
5
5
  import { Button } from '@viamrobotics/prime-core'
6
6
 
7
- import ErrorDisplay from '../../error.svelte'
8
-
9
7
  import { getBlobForViamDepth, VIAM_DEPTH_MIME_TYPE } from './decode-viam-depth'
10
8
  import { pickImageForSource } from './pick-image-for-source'
11
9
 
@@ -13,11 +11,11 @@
13
11
  name: string
14
12
  sourceName?: string
15
13
  getImage: () => Promise<QueryObserverResult<Awaited<ReturnType<CameraClient['getImages']>>>>
14
+ /** Called with the export's failure, and with null once an export gets its image. */
15
+ onExportError: (error: Error | null) => void
16
16
  }
17
17
 
18
- const { name, sourceName = '', getImage }: Props = $props()
19
-
20
- let lastError = $state<Error>()
18
+ const { name, sourceName = '', getImage, onExportError }: Props = $props()
21
19
 
22
20
  // en-CA for iso formatting (better for filename sorting)
23
21
  const dateFormatter = new Intl.DateTimeFormat('en-CA', {
@@ -41,11 +39,11 @@
41
39
  const handleExport = async () => {
42
40
  const image = await getImage()
43
41
  if (image.error) {
44
- lastError = image.error
42
+ onExportError(image.error)
45
43
  return
46
44
  }
47
45
 
48
- lastError = undefined
46
+ onExportError(null)
49
47
  const matchingImage = pickImageForSource(image.data?.images, sourceName)
50
48
  if (!matchingImage?.image) {
51
49
  return
@@ -59,7 +57,7 @@
59
57
  // Decode depth frames to a viewable PNG so the exported file matches the live feed.
60
58
  const depthBlob = await getBlobForViamDepth(bytes)
61
59
  if (!depthBlob) {
62
- lastError = new Error('Failed to decode depth image')
60
+ onExportError(new Error('Failed to decode depth image'))
63
61
  return
64
62
  }
65
63
  blob = depthBlob
@@ -79,15 +77,9 @@
79
77
  }
80
78
  </script>
81
79
 
82
- <div class="flex flex-col items-start gap-1">
83
- <Button
84
- icon="camera-outline"
85
- onclick={handleExport}
86
- >
87
- Screenshot
88
- </Button>
89
- <ErrorDisplay
90
- class="max-w-50"
91
- {lastError}
92
- />
93
- </div>
80
+ <Button
81
+ icon="camera-outline"
82
+ onclick={handleExport}
83
+ >
84
+ Screenshot
85
+ </Button>
@@ -4,6 +4,8 @@ interface Props {
4
4
  name: string;
5
5
  sourceName?: string;
6
6
  getImage: () => Promise<QueryObserverResult<Awaited<ReturnType<CameraClient['getImages']>>>>;
7
+ /** Called with the export's failure, and with null once an export gets its image. */
8
+ onExportError: (error: Error | null) => void;
7
9
  }
8
10
  declare const ExportScreenshot: import("svelte").Component<Props, {}, "">;
9
11
  type ExportScreenshot = ReturnType<typeof ExportScreenshot>;
@@ -9,8 +9,6 @@
9
9
 
10
10
  import { assertExists } from '../../../assert'
11
11
  import ApiSection from '../../api-section.svelte'
12
- import ContentRect from '../../content-rect.svelte'
13
- import ErrorDisplay from '../../error.svelte'
14
12
  import Progress from '../../progress.svelte'
15
13
  import { Section } from '../../section'
16
14
  import { formatNumeric } from '../../../format'
@@ -261,6 +259,8 @@
261
259
  })
262
260
 
263
261
  let contentRect = $state.raw<DOMRect>()
262
+ const overlayWidth = $derived(contentRect ? `${contentRect.width.toString()}px` : undefined)
263
+ const overlayHeight = $derived(contentRect ? `${contentRect.height.toString()}px` : undefined)
264
264
  useResizeObserver(
265
265
  () => videoElement,
266
266
  ([entry]) => {
@@ -337,25 +337,26 @@
337
337
  </script>
338
338
 
339
339
  <div class="relative">
340
- <!-- This breaks out of using the Query component
341
- to merge live stream and TanStack query errors -->
340
+ <!-- One overlay merges the live stream error with the polling query's error. -->
342
341
  {#if lastError}
343
- <ContentRect
344
- {contentRect}
342
+ <div
345
343
  class="bg-medium/50 absolute top-0 left-0 flex h-64 w-80 max-w-full items-center justify-center"
344
+ style:width={overlayWidth}
345
+ style:height={overlayHeight}
346
346
  >
347
- <ErrorDisplay
347
+ <Section.Error
348
348
  class="pb-4"
349
- {lastError}
349
+ error={lastError}
350
350
  />
351
- </ContentRect>
351
+ </div>
352
352
  {:else if isLive ? isStreamLoading : isLoading}
353
- <ContentRect
354
- {contentRect}
353
+ <div
355
354
  class="absolute top-0 left-0 h-64 w-80 max-w-full"
355
+ style:width={overlayWidth}
356
+ style:height={overlayHeight}
356
357
  >
357
358
  <Progress />
358
- </ContentRect>
359
+ </div>
359
360
  {/if}
360
361
  <div
361
362
  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"
@@ -1,8 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { Button } from '@viamrobotics/prime-core'
3
3
 
4
- import ErrorDisplay from '../../error.svelte'
5
-
6
4
  import { usePip } from '../../../pip/context.svelte'
7
5
 
8
6
  interface Props {
@@ -21,16 +19,10 @@
21
19
  })
22
20
  </script>
23
21
 
24
- <div class="flex flex-col items-start gap-1">
25
- <Button
26
- icon="picture-in-picture-top-right"
27
- onclick={() => pip.toggle(resourceName)}
28
- progress={pip.readyState === 'loading' ? 'indeterminate' : undefined}
29
- >
30
- Picture-in-picture
31
- </Button>
32
- <ErrorDisplay
33
- class="max-w-50"
34
- lastError={pip.error}
35
- />
36
- </div>
22
+ <Button
23
+ icon="picture-in-picture-top-right"
24
+ onclick={() => pip.toggle(resourceName)}
25
+ progress={pip.readyState === 'loading' ? 'indeterminate' : undefined}
26
+ >
27
+ Picture-in-picture
28
+ </Button>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
3
 
4
- import ErrorDisplay from '../../error.svelte'
4
+ import { Section } from '../../section'
5
5
 
6
6
  import ControlFrame from './control-frame.svelte'
7
7
 
@@ -37,7 +37,7 @@
37
37
  {#if error}
38
38
  {@render error({ failure, reset })}
39
39
  {:else}
40
- <ErrorDisplay lastError={failure} />
40
+ <Section.Error error={failure} />
41
41
  {/if}
42
42
  </div>
43
43
  {/snippet}
@@ -8,10 +8,10 @@
8
8
  import { PersistedState } from 'runed'
9
9
 
10
10
  import { supportsDoCommand } from '../../../client-map'
11
+ import { Section } from '../../section'
11
12
  import { getResourceAPI } from '../../../get-resource-api'
12
13
  import { getResourceKey } from '../../../get-resource-key'
13
14
 
14
- import ErrorDisplay from '../../error.svelte'
15
15
  import { createDoCommandClient } from './create-do-command-client.svelte'
16
16
 
17
17
  interface Props {
@@ -68,7 +68,7 @@
68
68
  output = JSON.stringify(data, null, 2)
69
69
  lastErr = null
70
70
  } catch (error) {
71
- lastErr = error as Error
71
+ lastErr = error instanceof Error ? error : new Error(String(error))
72
72
  }
73
73
  }
74
74
  </script>
@@ -120,19 +120,19 @@
120
120
  class="h-40 overflow-y-auto @2xl:h-56"
121
121
  />
122
122
  {:else}
123
- <ErrorDisplay
123
+ <Section.Error
124
124
  id={uid}
125
125
  class="h-40 px-4 @2xl:h-56"
126
- lastError={lastErr}
126
+ error={lastErr}
127
127
  />
128
128
  {/if}
129
129
  </div>
130
130
  </div>
131
131
  </div>
132
132
  {:else}
133
- <ErrorDisplay
133
+ <Section.Error
134
134
  class="p-4"
135
- lastError={new Error(
135
+ error={new Error(
136
136
  `DoCommand for ${getResourceAPI(
137
137
  resource
138
138
  )} is not supported in the UI. Consider using one of our SDKs.`
@@ -6,8 +6,8 @@
6
6
  createResourceQuery,
7
7
  } from '@viamrobotics/svelte-sdk'
8
8
 
9
- import Query from '../../query.svelte'
10
- import { Section } from '../../section'
9
+ import ApiSection from '../../api-section.svelte'
10
+ import { ResourceTriplets } from '../../../resource-triplet'
11
11
 
12
12
  import MoveToPosition from './move-to-position.svelte'
13
13
 
@@ -30,15 +30,19 @@
30
30
  const moveMutation = createResourceMutation(client, 'moveToPosition')
31
31
  </script>
32
32
 
33
- <Query query={positionQuery}>
34
- {@const positions = positionQuery.data}
35
- {#if positions !== undefined}
33
+ <ApiSection
34
+ class="grow flex-col gap-4"
35
+ method="MoveToPosition"
36
+ api={ResourceTriplets.Gantry}
37
+ queries={[positionQuery]}
38
+ mutations={[moveMutation]}
39
+ >
40
+ {#if positionQuery.data !== undefined}
36
41
  <MoveToPosition
37
- {positions}
42
+ positions={positionQuery.data}
38
43
  moveTo={(newPos: number[], speeds: number[]) => {
39
44
  moveMutation.mutate([newPos, speeds], {})
40
45
  }}
41
46
  />
42
47
  {/if}
43
- </Query>
44
- <Section.Error error={moveMutation.error} />
48
+ </ApiSection>
@@ -6,8 +6,8 @@
6
6
  createResourceQuery,
7
7
  } from '@viamrobotics/svelte-sdk'
8
8
 
9
- import Query from '../../query.svelte'
10
9
  import { Section } from '../../section'
10
+ import { useSectionErrors } from '../../section/use-section-errors.svelte'
11
11
 
12
12
  import QuickMove from './quick-move.svelte'
13
13
 
@@ -29,20 +29,34 @@
29
29
  })
30
30
 
31
31
  const quickMoveMutation = createResourceMutation(client, 'moveToPosition')
32
+
33
+ const quickMoveErrors = useSectionErrors(() => ({
34
+ queries: [positionQuery],
35
+ mutations: [quickMoveMutation],
36
+ }))
32
37
  </script>
33
38
 
34
- <Query
35
- query={positionQuery}
36
- class="h-6"
39
+ <Section
40
+ errorReporter={quickMoveErrors}
41
+ class="grow flex-col gap-4"
37
42
  >
38
- {@const positions = positionQuery.data}
39
- {#if positions !== undefined}
40
- <QuickMove
41
- {positions}
42
- moveTo={(newPos: number[], speeds: number[]) => {
43
- quickMoveMutation.mutate([newPos, speeds], {})
44
- }}
45
- />
46
- {/if}
47
- </Query>
48
- <Section.Error error={quickMoveMutation.error} />
43
+ <div class="flex flex-col gap-0.5">
44
+ <Section.Heading>
45
+ Quick move
46
+ {#snippet aside()}
47
+ <Section.Errors errors={quickMoveErrors.errors} />
48
+ {/snippet}
49
+ </Section.Heading>
50
+ </div>
51
+ <Section.Body isLoading={quickMoveErrors.isLoading}>
52
+ {#if positionQuery.data !== undefined}
53
+ <QuickMove
54
+ positions={positionQuery.data}
55
+ moveTo={(newPos: number[], speeds: number[]) => {
56
+ quickMoveMutation.mutate([newPos, speeds], {})
57
+ }}
58
+ />
59
+ {/if}
60
+ <Section.Text class="mt-auto">Press a button to execute</Section.Text>
61
+ </Section.Body>
62
+ </Section>
@@ -2,7 +2,8 @@
2
2
  import { GripperClient } from '@viamrobotics/sdk'
3
3
  import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
4
 
5
- import { Section } from '../../section'
5
+ import ApiSection from '../../api-section.svelte'
6
+ import { ResourceTriplets } from '../../../resource-triplet'
6
7
 
7
8
  import Grab from './grab.svelte'
8
9
 
@@ -22,5 +23,11 @@
22
23
  const grabMutation = createResourceMutation(client, 'grab')
23
24
  </script>
24
25
 
25
- <Grab onGrab={() => grabMutation.mutate([], {})} />
26
- <Section.Error error={grabMutation.error} />
26
+ <ApiSection
27
+ method="Grab"
28
+ api={ResourceTriplets.Gripper}
29
+ mutations={[grabMutation]}
30
+ class="grow-0 flex-col gap-3"
31
+ >
32
+ <Grab onGrab={() => grabMutation.mutate([], {})} />
33
+ </ApiSection>
@@ -1,16 +1,10 @@
1
1
  <script lang="ts">
2
- import { GripperClient } from '@viamrobotics/sdk'
3
- import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
-
5
- import ApiSection from '../../api-section.svelte'
6
2
  import ConnectionStatus from '../../connection-status.svelte'
7
- import IsMoving from '../../is-moving.svelte'
8
- import StopButton from '../../stop-button.svelte'
9
- import { ResourceTriplets } from '../../../resource-triplet'
10
3
 
11
- import Grab from './grab.svelte'
12
- import IsHoldingSomething from './is-holding-something.svelte'
13
- import Open from './open.svelte'
4
+ import IsHoldingSomethingWidget from './is-holding-something-widget.svelte'
5
+ import IsMovingWidget from './is-moving-widget.svelte'
6
+ import OpenGrabControl from './open-grab-control.svelte'
7
+ import StopWidget from './stop-widget.svelte'
14
8
 
15
9
  interface Props {
16
10
  partID: string
@@ -18,60 +12,27 @@
18
12
  }
19
13
 
20
14
  const { partID, resourceName }: Props = $props()
21
-
22
- const client = createResourceClient(
23
- GripperClient,
24
- () => partID,
25
- () => resourceName
26
- )
27
-
28
- const openMutation = createResourceMutation(client, 'open')
29
- const grabMutation = createResourceMutation(client, 'grab')
30
- const stopMutation = createResourceMutation(client, 'stop')
31
15
  </script>
32
16
 
33
17
  <ConnectionStatus {partID}>
34
18
  {#snippet connected()}
35
19
  <div class="@container">
36
20
  <div class="flex flex-col divide-y @lg:flex-row @lg:divide-x @lg:divide-y-0">
37
- <span class="flex grow flex-wrap gap-4">
38
- <ApiSection
39
- method="Open"
40
- api={ResourceTriplets.Gripper}
41
- mutations={[openMutation]}
42
- class="grow-0 flex-col gap-3 @xs:pr-0"
43
- >
44
- <Open onOpen={() => openMutation.mutate([], {})} />
45
- </ApiSection>
46
- <ApiSection
47
- method="Grab"
48
- api={ResourceTriplets.Gripper}
49
- mutations={[grabMutation]}
50
- class="grow-0 flex-col gap-3 @xs:pl-0"
51
- >
52
- <Grab onGrab={() => grabMutation.mutate([], {})} />
53
- </ApiSection>
54
- </span>
21
+ <OpenGrabControl
22
+ class="grow"
23
+ {partID}
24
+ {resourceName}
25
+ />
55
26
  <div class="flex flex-col divide-y">
56
- <ApiSection
57
- class="grow flex-col gap-4"
58
- method="Stop"
59
- api={ResourceTriplets.Gripper}
60
- mutations={[stopMutation]}
61
- >
62
- <StopButton
63
- onStop={() => {
64
- stopMutation.mutate([])
65
- }}
66
- />
67
- </ApiSection>
68
- <IsMoving
69
- client={GripperClient}
70
- api={ResourceTriplets.Gripper}
27
+ <StopWidget
28
+ {partID}
29
+ {resourceName}
30
+ />
31
+ <IsMovingWidget
71
32
  {partID}
72
33
  {resourceName}
73
34
  />
74
- <IsHoldingSomething
35
+ <IsHoldingSomethingWidget
75
36
  {partID}
76
37
  {resourceName}
77
38
  />
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ partID: string;
3
+ resourceName: string;
4
+ }
5
+ declare const IsHoldingSomethingWidget: import("svelte").Component<Props, {}, "">;
6
+ type IsHoldingSomethingWidget = ReturnType<typeof IsHoldingSomethingWidget>;
7
+ export default IsHoldingSomethingWidget;
@@ -0,0 +1,60 @@
1
+ <script lang="ts">
2
+ import type { ClassValue } from 'svelte/elements'
3
+
4
+ import { GripperClient } from '@viamrobotics/sdk'
5
+ import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
6
+
7
+ import { Section, useSectionErrors } from '../../section'
8
+ import { ResourceTriplets } from '../../../resource-triplet'
9
+
10
+ import Grab from './grab.svelte'
11
+ import Open from './open.svelte'
12
+
13
+ interface Props {
14
+ partID: string
15
+ resourceName: string
16
+ class?: ClassValue
17
+ }
18
+
19
+ const { partID, resourceName, class: className }: Props = $props()
20
+
21
+ const client = createResourceClient(
22
+ GripperClient,
23
+ () => partID,
24
+ () => resourceName
25
+ )
26
+
27
+ const openMutation = createResourceMutation(client, 'open')
28
+ const grabMutation = createResourceMutation(client, 'grab')
29
+
30
+ const sectionErrors = useSectionErrors(() => ({
31
+ mutations: [openMutation, grabMutation],
32
+ }))
33
+ </script>
34
+
35
+ <Section
36
+ errorReporter={sectionErrors}
37
+ class={['flex-col gap-3', className]}
38
+ >
39
+ <Section.Heading>
40
+ <Section.Method
41
+ method="Open"
42
+ api={ResourceTriplets.Gripper}
43
+ />
44
+ <span>/</span>
45
+ <Section.Method
46
+ method="Grab"
47
+ api={ResourceTriplets.Gripper}
48
+ />
49
+ {#snippet aside()}
50
+ <Section.Errors errors={sectionErrors.errors} />
51
+ {/snippet}
52
+ </Section.Heading>
53
+
54
+ <Section.Body>
55
+ <div class="flex flex-wrap gap-4">
56
+ <Open onOpen={() => openMutation.mutate([], {})} />
57
+ <Grab onGrab={() => grabMutation.mutate([], {})} />
58
+ </div>
59
+ </Section.Body>
60
+ </Section>
@@ -0,0 +1,9 @@
1
+ import type { ClassValue } from 'svelte/elements';
2
+ interface Props {
3
+ partID: string;
4
+ resourceName: string;
5
+ class?: ClassValue;
6
+ }
7
+ declare const OpenGrabControl: import("svelte").Component<Props, {}, "">;
8
+ type OpenGrabControl = ReturnType<typeof OpenGrabControl>;
9
+ export default OpenGrabControl;
@@ -2,7 +2,8 @@
2
2
  import { GripperClient } from '@viamrobotics/sdk'
3
3
  import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
4
4
 
5
- import { Section } from '../../section'
5
+ import ApiSection from '../../api-section.svelte'
6
+ import { ResourceTriplets } from '../../../resource-triplet'
6
7
 
7
8
  import Open from './open.svelte'
8
9
 
@@ -22,5 +23,11 @@
22
23
  const openMutation = createResourceMutation(client, 'open')
23
24
  </script>
24
25
 
25
- <Open onOpen={() => openMutation.mutate([], {})} />
26
- <Section.Error error={openMutation.error} />
26
+ <ApiSection
27
+ method="Open"
28
+ api={ResourceTriplets.Gripper}
29
+ mutations={[openMutation]}
30
+ class="grow-0 flex-col gap-3"
31
+ >
32
+ <Open onOpen={() => openMutation.mutate([], {})} />
33
+ </ApiSection>
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { GripperClient } from '@viamrobotics/sdk'
3
+
4
+ import Stop from '../../stop.svelte'
5
+ import { ResourceTriplets } from '../../../resource-triplet'
6
+
7
+ interface Props {
8
+ partID: string
9
+ resourceName: string
10
+ }
11
+
12
+ const { partID, resourceName }: Props = $props()
13
+ </script>
14
+
15
+ <Stop
16
+ client={GripperClient}
17
+ api={ResourceTriplets.Gripper}
18
+ {partID}
19
+ {resourceName}
20
+ />
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ partID: string;
3
+ resourceName: string;
4
+ }
5
+ declare const StopWidget: import("svelte").Component<Props, {}, "">;
6
+ type StopWidget = ReturnType<typeof StopWidget>;
7
+ export default StopWidget;
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import { type Metadata, MLModelClient } from '@viamrobotics/sdk'
3
+ import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
4
+
5
+ import ApiSection from '../../api-section.svelte'
6
+ import {
7
+ type RefetchInterval,
8
+ RefetchIntervals,
9
+ } from '../../refetch-interval-store.svelte'
10
+ import { ResourceTriplets } from '../../../resource-triplet'
11
+
12
+ import ResultsTable from './results-table.svelte'
13
+
14
+ interface Props {
15
+ partID: string
16
+ resourceName: string
17
+ /**
18
+ * How often to poll. The composite card passes its refresh-rate picker's value. A rate
19
+ * faster than once a second is slowed to once a second.
20
+ */
21
+ refetchInterval?: RefetchInterval
22
+ }
23
+
24
+ const { partID, resourceName, refetchInterval = RefetchIntervals.ONE_SEC }: Props = $props()
25
+
26
+ const client = createResourceClient(
27
+ // @ts-expect-error No resource type overlap
28
+ MLModelClient,
29
+ () => partID,
30
+ () => resourceName
31
+ )
32
+
33
+ // @ts-expect-error No resource overlap
34
+ const metadataQuery = createResourceQuery(client, 'metadata', () => ({
35
+ // A model's metadata rarely changes, so polling faster than 1 Hz is wasteful.
36
+ refetchInterval:
37
+ refetchInterval === false ? false : Math.max(refetchInterval, RefetchIntervals.ONE_SEC),
38
+ }))
39
+
40
+ const metadata = $derived((metadataQuery.data as unknown as { metadata: Metadata })?.metadata)
41
+ </script>
42
+
43
+ <ApiSection
44
+ method="Metadata"
45
+ api={ResourceTriplets.MLModel}
46
+ queries={[metadataQuery]}
47
+ class="flex-col gap-4"
48
+ >
49
+ {#if metadata !== undefined}
50
+ <ResultsTable {metadata} />
51
+ {/if}
52
+ </ApiSection>
@@ -0,0 +1,13 @@
1
+ import { type RefetchInterval } from '../../refetch-interval-store.svelte';
2
+ interface Props {
3
+ partID: string;
4
+ resourceName: string;
5
+ /**
6
+ * How often to poll. The composite card passes its refresh-rate picker's value. A rate
7
+ * faster than once a second is slowed to once a second.
8
+ */
9
+ refetchInterval?: RefetchInterval;
10
+ }
11
+ declare const MetadataWidget: import("svelte").Component<Props, {}, "">;
12
+ type MetadataWidget = ReturnType<typeof MetadataWidget>;
13
+ export default MetadataWidget;