@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.
- package/README.md +15 -1
- package/dist/api-docs-href.d.ts +2 -2
- package/dist/api-docs-href.js +0 -1
- package/dist/components/api-section.svelte +58 -49
- package/dist/components/api-section.svelte.d.ts +24 -10
- package/dist/components/boundary.svelte +51 -0
- package/dist/components/boundary.svelte.d.ts +5 -0
- package/dist/components/connection-status.svelte +57 -61
- package/dist/components/connection-status.svelte.d.ts +5 -5
- package/dist/components/content-rect.svelte +10 -5
- package/dist/components/content-rect.svelte.d.ts +3 -1
- package/dist/components/error.svelte +15 -5
- package/dist/components/error.svelte.d.ts +8 -1
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +4 -3
- package/dist/components/is-moving.svelte +29 -35
- package/dist/components/is-moving.svelte.d.ts +6 -6
- package/dist/components/maplibre/index.svelte +5 -6
- package/dist/components/maplibre/index.svelte.d.ts +3 -1
- package/dist/components/pose-editor.svelte +83 -15
- package/dist/components/pose-editor.svelte.d.ts +11 -4
- package/dist/components/progress.svelte +1 -0
- package/dist/components/queries.svelte +14 -4
- package/dist/components/queries.svelte.d.ts +6 -1
- package/dist/components/query.svelte +11 -3
- package/dist/components/query.svelte.d.ts +6 -1
- package/dist/components/section/error-key.d.ts +2 -0
- package/dist/components/section/error-key.js +2 -0
- package/dist/components/section/index.d.ts +21 -0
- package/dist/components/section/index.js +21 -0
- package/dist/components/section/section-body.svelte +36 -0
- package/dist/components/section/section-body.svelte.d.ts +13 -0
- package/dist/components/section/section-error-reporter.d.ts +8 -0
- package/dist/components/section/section-error-reporter.js +7 -0
- package/dist/components/section/section-error.svelte +36 -0
- package/dist/components/section/section-error.svelte.d.ts +9 -0
- package/dist/components/section/section-errors.svelte +145 -0
- package/dist/components/section/section-errors.svelte.d.ts +6 -0
- package/dist/components/section/section-heading.svelte +21 -0
- package/dist/components/section/section-heading.svelte.d.ts +9 -0
- package/dist/components/section/section-loading.d.ts +4 -0
- package/dist/components/section/section-loading.js +10 -0
- package/dist/components/section/section-method.svelte +29 -0
- package/dist/components/section/section-method.svelte.d.ts +9 -0
- package/dist/components/section/section-placeholder.svelte +29 -0
- package/dist/components/section/section-placeholder.svelte.d.ts +7 -0
- package/dist/components/section/section-text.svelte +17 -0
- package/dist/components/section/section-text.svelte.d.ts +8 -0
- package/dist/components/section/section-tooltip.svelte +25 -0
- package/dist/components/section/section-tooltip.svelte.d.ts +7 -0
- package/dist/components/section/section.svelte +23 -0
- package/dist/components/section/section.svelte.d.ts +11 -0
- package/dist/components/section/use-section-errors.svelte.d.ts +19 -0
- package/dist/components/section/use-section-errors.svelte.js +49 -0
- package/dist/components/stop-button.svelte +1 -5
- package/dist/components/stop-button.svelte.d.ts +0 -1
- package/dist/components/stop.svelte +31 -14
- package/dist/components/stop.svelte.d.ts +6 -1
- package/dist/components/widgets/arm/arm.svelte +43 -40
- package/dist/components/widgets/arm/get-joint-positions-widget.svelte +10 -9
- package/dist/components/widgets/arm/joint-position-editor.svelte +105 -27
- package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +4 -3
- package/dist/components/widgets/arm/joint-position-slider.svelte +6 -2
- package/dist/components/widgets/arm/joint-position-slider.svelte.d.ts +2 -1
- package/dist/components/widgets/arm/manual-mode-widget.svelte +16 -6
- package/dist/components/widgets/arm/manual-mode.svelte +1 -5
- package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +22 -8
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +15 -17
- package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-position-control.svelte +45 -33
- package/dist/components/widgets/arm/move-to-position.svelte +97 -34
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -2
- package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
- package/dist/components/widgets/arm/quick-move.svelte +1 -4
- package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.d.ts +16 -0
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.js +37 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.d.ts +9 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.js +24 -0
- package/dist/components/widgets/audio-input/audio-input.svelte +80 -77
- package/dist/components/widgets/audio-input/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/audio-output/audio-output.svelte +87 -84
- package/dist/components/widgets/audio-output/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/base/base.svelte +78 -43
- package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
- package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
- package/dist/components/widgets/base/quick-move.svelte +5 -6
- package/dist/components/widgets/base/set-power-widget.svelte +20 -8
- package/dist/components/widgets/base/set-power.svelte +6 -4
- package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
- package/dist/components/widgets/base/set-velocity.svelte +6 -4
- package/dist/components/widgets/base/spin-widget.svelte +20 -8
- package/dist/components/widgets/base/vec3-builder.svelte +3 -2
- package/dist/components/widgets/base/vec3-builder.svelte.d.ts +2 -1
- package/dist/components/widgets/board/analog-read.svelte +2 -4
- package/dist/components/widgets/board/analog-write.svelte +2 -4
- package/dist/components/widgets/board/gpio-read.svelte +2 -1
- package/dist/components/widgets/board/gpio-write.svelte +2 -1
- package/dist/components/widgets/board/pin-section.svelte +5 -6
- package/dist/components/widgets/board/pin-section.svelte.d.ts +3 -2
- package/dist/components/widgets/board/read-write-pins.svelte +2 -2
- package/dist/components/widgets/button/push.svelte +2 -2
- package/dist/components/widgets/camera/camera.svelte +17 -24
- package/dist/components/widgets/camera/live-or-polling-video.svelte +33 -30
- package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
- package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
- package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
- package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
- package/dist/components/widgets/custom-control/custom-control.js +85 -0
- package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
- package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
- package/dist/components/widgets/discovery/discovery.svelte +13 -17
- package/dist/components/widgets/encoder/encoder.svelte +25 -21
- package/dist/components/widgets/encoder/get-position-widget.svelte +19 -16
- package/dist/components/widgets/gantry/gantry.svelte +58 -76
- package/dist/components/widgets/gantry/get-position-widget.svelte +15 -14
- package/dist/components/widgets/gantry/home.svelte +21 -10
- package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
- package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
- package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
- package/dist/components/widgets/gantry/quick-move-widget.svelte +3 -2
- package/dist/components/widgets/gantry/quick-move.svelte +1 -5
- package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/generic/generic.svelte +11 -6
- package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
- package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/grab.svelte +3 -19
- package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
- package/dist/components/widgets/gripper/gripper.svelte +18 -18
- package/dist/components/widgets/gripper/is-holding-something.svelte +21 -21
- package/dist/components/widgets/gripper/open-widget.svelte +26 -0
- package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/open.svelte +3 -19
- package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
- package/dist/components/widgets/input-controller/input-controller.svelte +10 -16
- package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
- package/dist/components/widgets/ml-model-service/ml-model-service.svelte +1 -1
- package/dist/components/widgets/motion/frame-select.svelte +4 -2
- package/dist/components/widgets/motion/frame-select.svelte.d.ts +2 -1
- package/dist/components/widgets/motion/motion.svelte +27 -31
- package/dist/components/widgets/motion/move-widget.svelte +32 -12
- package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
- package/dist/components/widgets/motion/move.svelte +6 -16
- package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
- package/dist/components/widgets/motor/go-for-view.svelte +16 -8
- package/dist/components/widgets/motor/go-to-view.svelte +12 -4
- package/dist/components/widgets/motor/motor.svelte +100 -64
- package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
- package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
- package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
- package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-position-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +64 -66
- package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
- package/dist/components/widgets/power-sensor/get-current-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-power-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/power-sensor.svelte +35 -45
- package/dist/components/widgets/sensor/sensor.svelte +8 -12
- package/dist/components/widgets/servo/move-widget.svelte +2 -1
- package/dist/components/widgets/servo/move.svelte +1 -4
- package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
- package/dist/components/widgets/servo/quick-move.svelte +1 -5
- package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/servo.svelte +53 -37
- package/dist/components/widgets/slam/get-position-widget.svelte +8 -11
- package/dist/components/widgets/slam/move-on-map.svelte +9 -6
- package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
- package/dist/components/widgets/slam/slam.svelte +65 -75
- package/dist/components/widgets/switch/position-view.svelte +1 -1
- package/dist/components/widgets/switch/position.svelte +2 -2
- package/dist/components/widgets/switch/switch.svelte +1 -1
- package/dist/components/widgets/vision-service/detection-row.svelte +4 -2
- package/dist/components/widgets/vision-service/detection-row.svelte.d.ts +2 -1
- package/dist/components/widgets/vision-service/fonts/public-sans.json +1 -0
- package/dist/components/widgets/vision-service/fonts/public-sans.png +0 -0
- package/dist/components/widgets/vision-service/image.svelte +4 -4
- package/dist/components/widgets/vision-service/legend.svelte +4 -4
- package/dist/components/widgets/vision-service/public-sans-font.d.ts +5 -0
- package/dist/components/widgets/vision-service/public-sans-font.js +14 -0
- package/dist/components/widgets/vision-service/vision-service.svelte +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/package.json +19 -5
- package/dist/components/board/pin-section.svelte +0 -28
- package/dist/components/board/pin-section.svelte.d.ts +0 -9
- package/dist/components/mutation-section.svelte +0 -73
- package/dist/components/mutation-section.svelte.d.ts +0 -16
- package/dist/components/mutation-view.svelte +0 -29
- package/dist/components/mutation-view.svelte.d.ts +0 -10
- package/dist/components/section-group.svelte +0 -64
- package/dist/components/section-group.svelte.d.ts +0 -14
- package/dist/components/section-title.svelte +0 -63
- package/dist/components/section-title.svelte.d.ts +0 -14
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
3
|
+
|
|
4
|
+
import { errorKey } from './error-key'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
errors: Error[]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { errors }: Props = $props()
|
|
11
|
+
|
|
12
|
+
const COPIED_MS = 750
|
|
13
|
+
|
|
14
|
+
const count = $derived(errors.length)
|
|
15
|
+
const hasErrors = $derived(count > 0)
|
|
16
|
+
const summary = $derived(hasErrors ? `${count} ${count === 1 ? 'error' : 'errors'}` : 'No errors')
|
|
17
|
+
const text = $derived(errors.map((error) => `${error.name}: ${error.message}`).join('\n'))
|
|
18
|
+
|
|
19
|
+
let copied = $state(false)
|
|
20
|
+
let copiedTimer: ReturnType<typeof setTimeout> | undefined
|
|
21
|
+
|
|
22
|
+
const label = $derived.by(() => {
|
|
23
|
+
if (copied) return `Copied ${summary}`
|
|
24
|
+
return hasErrors ? `${summary}, copy to clipboard` : summary
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const iconName = $derived.by(() => {
|
|
28
|
+
if (copied) return 'check'
|
|
29
|
+
return hasErrors ? 'alert-circle' : 'alert-circle-outline'
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// The cue replays only when the held set changes to a non-empty one, so a steady failing poll
|
|
33
|
+
// fires once and each new distinct error or failed attempt fires again.
|
|
34
|
+
let lastKeys = ''
|
|
35
|
+
let arrivals = 0
|
|
36
|
+
const arrival = $derived.by(() => {
|
|
37
|
+
const keys = errors.map((error) => errorKey(error)).join('\0\0')
|
|
38
|
+
if (keys !== lastKeys) {
|
|
39
|
+
lastKeys = keys
|
|
40
|
+
if (keys !== '') arrivals += 1
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return arrivals
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const copy = async () => {
|
|
47
|
+
if (!hasErrors) return
|
|
48
|
+
try {
|
|
49
|
+
await globalThis.navigator.clipboard.writeText(text)
|
|
50
|
+
copied = true
|
|
51
|
+
clearTimeout(copiedTimer)
|
|
52
|
+
copiedTimer = setTimeout(() => {
|
|
53
|
+
copied = false
|
|
54
|
+
}, COPIED_MS)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Failed to copy errors to clipboard', error)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$effect(() => () => clearTimeout(copiedTimer))
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<Tooltip let:tooltipID>
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
aria-label={label}
|
|
67
|
+
aria-describedby={tooltipID}
|
|
68
|
+
onclick={copy}
|
|
69
|
+
class={[
|
|
70
|
+
// The pseudo-element pads the hit area to 24px (WCAG 2.5.8) without growing the heading row.
|
|
71
|
+
'relative inline-flex items-center gap-0.5 p-0.5 after:absolute after:-inset-0.5',
|
|
72
|
+
{
|
|
73
|
+
'text-gray-6': !hasErrors && !copied,
|
|
74
|
+
'text-danger-dark hover:bg-medium': hasErrors && !copied,
|
|
75
|
+
'text-success-dark': copied,
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
>
|
|
79
|
+
{#key arrival}
|
|
80
|
+
<span class={['inline-flex rounded-full', arrival > 0 && 'arrival']}>
|
|
81
|
+
<Icon name={iconName} />
|
|
82
|
+
</span>
|
|
83
|
+
{/key}
|
|
84
|
+
{#if hasErrors}
|
|
85
|
+
<span class="font-roboto-mono text-xs leading-none">{count}</span>
|
|
86
|
+
{/if}
|
|
87
|
+
</button>
|
|
88
|
+
<div
|
|
89
|
+
slot="description"
|
|
90
|
+
class="flex flex-col gap-1"
|
|
91
|
+
>
|
|
92
|
+
<div class="text-gray-5 flex justify-between gap-3">
|
|
93
|
+
<span>{summary}</span>
|
|
94
|
+
{#if hasErrors}
|
|
95
|
+
<span>{copied ? 'Copied' : 'Click to copy'}</span>
|
|
96
|
+
{/if}
|
|
97
|
+
</div>
|
|
98
|
+
{#each errors as error (errorKey(error))}
|
|
99
|
+
<p class="font-roboto-mono">{error.name}: {error.message}</p>
|
|
100
|
+
{/each}
|
|
101
|
+
</div>
|
|
102
|
+
</Tooltip>
|
|
103
|
+
|
|
104
|
+
<style>
|
|
105
|
+
@keyframes arrival {
|
|
106
|
+
0% {
|
|
107
|
+
transform: scale(1) rotate(0deg);
|
|
108
|
+
background-color: transparent;
|
|
109
|
+
}
|
|
110
|
+
15% {
|
|
111
|
+
transform: scale(1.35) rotate(-14deg);
|
|
112
|
+
background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
|
|
113
|
+
}
|
|
114
|
+
30% {
|
|
115
|
+
transform: scale(1.35) rotate(14deg);
|
|
116
|
+
background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
|
|
117
|
+
}
|
|
118
|
+
45% {
|
|
119
|
+
transform: scale(1.35) rotate(-14deg);
|
|
120
|
+
background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
|
|
121
|
+
}
|
|
122
|
+
60% {
|
|
123
|
+
transform: scale(1.35) rotate(14deg);
|
|
124
|
+
background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
|
|
125
|
+
}
|
|
126
|
+
80% {
|
|
127
|
+
transform: scale(1.35) rotate(0deg);
|
|
128
|
+
background-color: color-mix(in srgb, var(--color-danger-light) 50%, transparent);
|
|
129
|
+
}
|
|
130
|
+
100% {
|
|
131
|
+
transform: scale(1) rotate(0deg);
|
|
132
|
+
background-color: transparent;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.arrival {
|
|
137
|
+
animation: arrival 600ms cubic-bezier(0.165, 0.84, 0.44, 1) 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@media (prefers-reduced-motion: reduce) {
|
|
141
|
+
.arrival {
|
|
142
|
+
animation: none;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: Snippet
|
|
7
|
+
aside?: Snippet
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { children, aside, class: className, ...rest }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class={['flex flex-row items-center gap-1', className]}
|
|
15
|
+
{...rest}
|
|
16
|
+
>
|
|
17
|
+
<h3 class="flex flex-row items-center gap-1 text-sm font-semibold">
|
|
18
|
+
{@render children()}
|
|
19
|
+
</h3>
|
|
20
|
+
{@render aside?.()}
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
aside?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const SectionHeading: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SectionHeading = ReturnType<typeof SectionHeading>;
|
|
9
|
+
export default SectionHeading;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const SECTION_LOADING_KEY = Symbol('section-loading');
|
|
3
|
+
export const provideSectionLoading = (isLoading) => {
|
|
4
|
+
return setContext(SECTION_LOADING_KEY, {
|
|
5
|
+
get isLoading() {
|
|
6
|
+
return isLoading();
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export const useSectionLoading = () => getContext(SECTION_LOADING_KEY) ?? { isLoading: false };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ResourceTriplet } from '../../resource-triplet'
|
|
3
|
+
|
|
4
|
+
import { apiDocsHref } from '../../api-docs-href'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** RDK method name in PascalCase. */
|
|
8
|
+
method: string
|
|
9
|
+
api: ResourceTriplet
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { method, api }: Props = $props()
|
|
13
|
+
|
|
14
|
+
// Method names are the camelCase form of the PascalCase heading (GetPosition → getPosition).
|
|
15
|
+
const href = $derived(apiDocsHref(api, method.charAt(0).toLowerCase() + method.slice(1)))
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{#if href}
|
|
19
|
+
<a
|
|
20
|
+
{href}
|
|
21
|
+
target="_blank"
|
|
22
|
+
rel="noopener noreferrer external"
|
|
23
|
+
class="decoration-gray-5 hover:decoration-default font-mono underline underline-offset-3"
|
|
24
|
+
>
|
|
25
|
+
{method}
|
|
26
|
+
</a>
|
|
27
|
+
{:else}
|
|
28
|
+
<span class="font-mono">{method}</span>
|
|
29
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResourceTriplet } from '../../resource-triplet';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** RDK method name in PascalCase. */
|
|
4
|
+
method: string;
|
|
5
|
+
api: ResourceTriplet;
|
|
6
|
+
}
|
|
7
|
+
declare const SectionMethod: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type SectionMethod = ReturnType<typeof SectionMethod>;
|
|
9
|
+
export default SectionMethod;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ClassValue } from 'svelte/elements'
|
|
3
|
+
|
|
4
|
+
import { useSectionLoading } from './section-loading'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: ClassValue
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { class: className = 'w-12' }: Props = $props()
|
|
11
|
+
|
|
12
|
+
const loading = useSectionLoading()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if loading.isLoading}
|
|
16
|
+
<span
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
data-testid="section-placeholder-loading"
|
|
19
|
+
class={[
|
|
20
|
+
'bg-light inline-block h-2.5 animate-pulse align-middle motion-reduce:animate-none',
|
|
21
|
+
className,
|
|
22
|
+
]}
|
|
23
|
+
></span>
|
|
24
|
+
{:else}
|
|
25
|
+
<span class="text-subtle-2">
|
|
26
|
+
<span aria-hidden="true">—</span>
|
|
27
|
+
<span class="sr-only">No data</span>
|
|
28
|
+
</span>
|
|
29
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
interface Props {
|
|
3
|
+
class?: ClassValue;
|
|
4
|
+
}
|
|
5
|
+
declare const SectionPlaceholder: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type SectionPlaceholder = ReturnType<typeof SectionPlaceholder>;
|
|
7
|
+
export default SectionPlaceholder;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLAttributes<HTMLParagraphElement> {
|
|
6
|
+
children: Snippet
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { children, class: className, ...rest }: Props = $props()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<p
|
|
13
|
+
class={['text-subtle-2 text-xs', className]}
|
|
14
|
+
{...rest}
|
|
15
|
+
>
|
|
16
|
+
{@render children()}
|
|
17
|
+
</p>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLParagraphElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
}
|
|
6
|
+
declare const SectionText: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type SectionText = ReturnType<typeof SectionText>;
|
|
8
|
+
export default SectionText;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import { Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children: Snippet
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { children }: Props = $props()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Tooltip>
|
|
14
|
+
<Icon
|
|
15
|
+
name="information-outline"
|
|
16
|
+
cx="text-gray-6"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<p
|
|
20
|
+
slot="description"
|
|
21
|
+
class="text-xs whitespace-pre-line"
|
|
22
|
+
>
|
|
23
|
+
{@render children()}
|
|
24
|
+
</p>
|
|
25
|
+
</Tooltip>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
import { provideSectionErrorReporter, type SectionErrorReporter } from './section-error-reporter'
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
8
|
+
children: Snippet
|
|
9
|
+
/** Collects errors that `Section.Error` parts inside the section report, e.g. `useSectionErrors`' result. */
|
|
10
|
+
errorReporter?: SectionErrorReporter
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { children, errorReporter, class: className, ...rest }: Props = $props()
|
|
14
|
+
|
|
15
|
+
provideSectionErrorReporter(() => errorReporter)
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<section
|
|
19
|
+
class={['flex p-4', className]}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{@render children()}
|
|
23
|
+
</section>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type SectionErrorReporter } from './section-error-reporter';
|
|
4
|
+
interface Props extends HTMLAttributes<HTMLElement> {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
/** Collects errors that `Section.Error` parts inside the section report, e.g. `useSectionErrors`' result. */
|
|
7
|
+
errorReporter?: SectionErrorReporter;
|
|
8
|
+
}
|
|
9
|
+
declare const Section: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type Section = ReturnType<typeof Section>;
|
|
11
|
+
export default Section;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { QueryObserverResult } from '@tanstack/svelte-query';
|
|
2
|
+
export type SectionQuery = Pick<QueryObserverResult, 'error' | 'fetchStatus' | 'isLoading' | 'isSuccess'>;
|
|
3
|
+
export interface SectionMutation {
|
|
4
|
+
error: Error | null;
|
|
5
|
+
}
|
|
6
|
+
export interface SectionSources {
|
|
7
|
+
queries?: SectionQuery[];
|
|
8
|
+
mutations?: SectionMutation[];
|
|
9
|
+
}
|
|
10
|
+
export declare const dedupeErrors: (errors: (Error | null)[]) => Error[];
|
|
11
|
+
/**
|
|
12
|
+
* A section's distinct errors across its queries and mutations, and whether its first load is
|
|
13
|
+
* still running.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useSectionErrors: (getSources: () => SectionSources) => {
|
|
16
|
+
readonly errors: Error[];
|
|
17
|
+
readonly isLoading: boolean;
|
|
18
|
+
report(getError: () => Error | null): () => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
2
|
+
import { errorKey } from './error-key';
|
|
3
|
+
export const dedupeErrors = (errors) => {
|
|
4
|
+
const present = errors.filter((error) => error !== null);
|
|
5
|
+
return present.filter((error, index) => present.findIndex((seen) => errorKey(seen) === errorKey(error)) === index);
|
|
6
|
+
};
|
|
7
|
+
const serializeErrors = (errors) => errors.map((error) => errorKey(error)).join('\0\0');
|
|
8
|
+
/**
|
|
9
|
+
* A section's distinct errors across its queries and mutations, and whether its first load is
|
|
10
|
+
* still running.
|
|
11
|
+
*/
|
|
12
|
+
export const useSectionErrors = (getSources) => {
|
|
13
|
+
let held = [];
|
|
14
|
+
const queryErrors = $derived.by(() => {
|
|
15
|
+
const queries = getSources().queries ?? [];
|
|
16
|
+
const next = dedupeErrors(queries.map((query) => query.error));
|
|
17
|
+
if (next.length > 0) {
|
|
18
|
+
if (serializeErrors(next) !== serializeErrors(held)) {
|
|
19
|
+
held = next;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (queries.every((query) => query.fetchStatus === 'idle')) {
|
|
23
|
+
held = [];
|
|
24
|
+
}
|
|
25
|
+
return held;
|
|
26
|
+
});
|
|
27
|
+
// Errors that `Section.Error` parts inside the section report, e.g. an inner form's mutation.
|
|
28
|
+
const reported = new SvelteSet();
|
|
29
|
+
const errors = $derived.by(() => {
|
|
30
|
+
const mutationErrors = (getSources().mutations ?? []).map((mutation) => mutation.error);
|
|
31
|
+
const reportedErrors = [...reported].map((getError) => getError());
|
|
32
|
+
return dedupeErrors([...queryErrors, ...mutationErrors, ...reportedErrors]);
|
|
33
|
+
});
|
|
34
|
+
const isLoading = $derived(errors.length === 0 && (getSources().queries ?? []).some((query) => query.isLoading));
|
|
35
|
+
return {
|
|
36
|
+
get errors() {
|
|
37
|
+
return errors;
|
|
38
|
+
},
|
|
39
|
+
get isLoading() {
|
|
40
|
+
return isLoading;
|
|
41
|
+
},
|
|
42
|
+
report(getError) {
|
|
43
|
+
reported.add(getError);
|
|
44
|
+
return () => {
|
|
45
|
+
reported.delete(getError);
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Button } from '@viamrobotics/prime-core'
|
|
3
3
|
|
|
4
|
-
import ErrorDisplay from './error.svelte'
|
|
5
|
-
|
|
6
4
|
interface Props {
|
|
7
5
|
onStop: () => void
|
|
8
|
-
error: Error | null
|
|
9
6
|
}
|
|
10
7
|
|
|
11
|
-
const {
|
|
8
|
+
const { onStop }: Props = $props()
|
|
12
9
|
</script>
|
|
13
10
|
|
|
14
11
|
<Button
|
|
@@ -18,4 +15,3 @@
|
|
|
18
15
|
>
|
|
19
16
|
Stop
|
|
20
17
|
</Button>
|
|
21
|
-
<ErrorDisplay lastError={error} />
|
|
@@ -13,24 +13,32 @@
|
|
|
13
13
|
Servo,
|
|
14
14
|
ServoClient,
|
|
15
15
|
} from '@viamrobotics/sdk'
|
|
16
|
+
import type { Snippet } from 'svelte'
|
|
16
17
|
|
|
17
18
|
import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
|
|
18
19
|
|
|
20
|
+
import type { ResourceTriplet } from '../resource-triplet'
|
|
21
|
+
|
|
22
|
+
import ApiSection from './api-section.svelte'
|
|
19
23
|
import StopButton from './stop-button.svelte'
|
|
20
24
|
|
|
25
|
+
type Client =
|
|
26
|
+
| typeof ArmClient
|
|
27
|
+
| typeof BaseClient
|
|
28
|
+
| typeof GantryClient
|
|
29
|
+
| typeof GripperClient
|
|
30
|
+
| typeof MotorClient
|
|
31
|
+
| typeof ServoClient
|
|
32
|
+
|
|
21
33
|
interface Props {
|
|
34
|
+
client: Client
|
|
22
35
|
partID: string
|
|
23
36
|
resourceName: string
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| typeof BaseClient
|
|
27
|
-
| typeof GantryClient
|
|
28
|
-
| typeof GripperClient
|
|
29
|
-
| typeof MotorClient
|
|
30
|
-
| typeof ServoClient
|
|
37
|
+
api: ResourceTriplet
|
|
38
|
+
children?: Snippet
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
const { partID, resourceName,
|
|
41
|
+
const { client: clientClass, partID, resourceName, api, children }: Props = $props()
|
|
34
42
|
|
|
35
43
|
const client = $derived(
|
|
36
44
|
createResourceClient<Arm | Base | Gantry | Gripper | Motor | Servo>(
|
|
@@ -43,9 +51,18 @@
|
|
|
43
51
|
const stopMutation = $derived(createResourceMutation(client, 'stop'))
|
|
44
52
|
</script>
|
|
45
53
|
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
54
|
+
<ApiSection
|
|
55
|
+
class="grow flex-col gap-4"
|
|
56
|
+
method="Stop"
|
|
57
|
+
{api}
|
|
58
|
+
mutations={[stopMutation]}
|
|
59
|
+
>
|
|
60
|
+
<StopButton
|
|
61
|
+
onStop={() => {
|
|
62
|
+
stopMutation.mutate([])
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<!-- snippet for additional actuation info Ex: Motor's IsPowered & GetPosition -->
|
|
67
|
+
{@render children?.()}
|
|
68
|
+
</ApiSection>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ArmClient, BaseClient, GantryClient, GripperClient, MotorClient, ServoClient } from '@viamrobotics/sdk';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ResourceTriplet } from '../resource-triplet';
|
|
4
|
+
type Client = typeof ArmClient | typeof BaseClient | typeof GantryClient | typeof GripperClient | typeof MotorClient | typeof ServoClient;
|
|
2
5
|
interface Props {
|
|
6
|
+
client: Client;
|
|
3
7
|
partID: string;
|
|
4
8
|
resourceName: string;
|
|
5
|
-
|
|
9
|
+
api: ResourceTriplet;
|
|
10
|
+
children?: Snippet;
|
|
6
11
|
}
|
|
7
12
|
declare const Stop: import("svelte").Component<Props, {}, "">;
|
|
8
13
|
type Stop = ReturnType<typeof Stop>;
|