Skip to content

Commit 83c7f28

Browse files
authored
Merge branch 'main' into add-pause-queries-hook
2 parents 61c98d9 + 7b666b9 commit 83c7f28

File tree

6 files changed

+55
-56
lines changed

6 files changed

+55
-56
lines changed

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Package Managers
22
package-lock.json
33
pnpm-lock.yaml
4-
yarn.lock
4+
yarn.lock
5+
.changeset/*.md

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @viamrobotics/svelte-sdk
22

3+
## 0.6.1
4+
5+
### Patch Changes
6+
7+
- 92cfb39: Fix tanstack stream query options
8+
- 5c0c4b4: Use new `robotClient.dial` method for connection
9+
310
## 0.6.0
411

512
### Minor Changes

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@viamrobotics/svelte-sdk",
33
"description": "Build Svelte apps with Viam",
44
"license": "Apache-2.0",
5-
"version": "0.6.0",
5+
"version": "0.6.1",
66
"scripts": {
77
"dev": "vite dev",
88
"build": "vite build && npm run prepack",
@@ -43,8 +43,8 @@
4343
"runed": "^0.29.1"
4444
},
4545
"peerDependencies": {
46-
"@tanstack/svelte-query": ">=5",
47-
"@viamrobotics/sdk": ">=0.38",
46+
"@tanstack/svelte-query": "5.87.1",
47+
"@viamrobotics/sdk": ">=0.51",
4848
"svelte": ">=5"
4949
},
5050
"devDependencies": {
@@ -57,13 +57,13 @@
5757
"@sveltejs/package": "^2.3.12",
5858
"@sveltejs/vite-plugin-svelte": "^5.1.0",
5959
"@tailwindcss/vite": "^4.1.11",
60-
"@tanstack/svelte-query": "^5.81.5",
61-
"@tanstack/svelte-query-devtools": "^5.81.5",
60+
"@tanstack/svelte-query": "5.87.1",
61+
"@tanstack/svelte-query-devtools": "5.87.3",
6262
"@testing-library/jest-dom": "^6.6.3",
6363
"@testing-library/svelte": "^5.2.8",
6464
"@viamrobotics/eslint-config": "^1.1.0",
6565
"@viamrobotics/prettier-config-svelte": "^1.1.0",
66-
"@viamrobotics/sdk": "^0.49.1",
66+
"@viamrobotics/sdk": "^0.51.0",
6767
"@viamrobotics/typescript-config": "^0.1.1",
6868
"eslint": "^9.30.0",
6969
"eslint-config-prettier": "^10.1.5",

pnpm-lock.yaml

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/hooks/create-resource-stream.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const createResourceStream = <T extends Resource, K extends keyof T>(
101101
_options?.enabled !== false &&
102102
enabledQueries.resourceQueries,
103103
queryFn: streamedQuery<StreamItemType<T[K]>>({
104-
queryFn: processStream,
104+
streamFn: processStream,
105105
..._options,
106106
}),
107107
})

src/lib/hooks/robot-clients.svelte.ts

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {
22
type Client,
3-
createRobotClient,
43
type DialConf,
54
MachineConnectionEvent,
6-
type RobotClient,
5+
RobotClient,
76
} from '@viamrobotics/sdk';
87
import { getContext, onMount, setContext } from 'svelte';
98
import { useQueryClient } from '@tanstack/svelte-query';
@@ -35,12 +34,7 @@ export const provideRobotClientsContext = (
3534

3635
let lastConfigs: Record<PartID, DialConf | undefined> = {};
3736

38-
const disconnect = async (partID: PartID, config?: DialConf) => {
39-
// If currently making the initial connection, abort it.
40-
if (config?.reconnectAbortSignal !== undefined) {
41-
config.reconnectAbortSignal.abort = true;
42-
}
43-
37+
const disconnect = async (partID: PartID) => {
4438
const client = clients[partID];
4539

4640
if (!client) {
@@ -65,22 +59,18 @@ export const provideRobotClientsContext = (
6559
connectionStatus[partID] ??= MachineConnectionEvent.DISCONNECTED;
6660

6761
try {
68-
await disconnect(partID, config);
69-
70-
connectionStatus[partID] = MachineConnectionEvent.CONNECTING;
71-
72-
// Reset the abort signal if it exists
73-
if (config.reconnectAbortSignal !== undefined) {
74-
config.reconnectAbortSignal = {
75-
abort: false,
76-
};
77-
}
62+
await disconnect(partID);
7863

7964
config.reconnectMaxAttempts ??= 1e9;
8065
config.reconnectMaxWait ??= 1000;
8166

82-
const client = await createRobotClient(config);
67+
const client = new RobotClient();
8368
(client as RobotClient & { partID: string }).partID = partID;
69+
70+
clients[partID] = client;
71+
72+
connectionStatus[partID] = MachineConnectionEvent.CONNECTING;
73+
8474
client.on('connectionstatechange', async (event) => {
8575
connectionStatus[partID] = (
8676
event as { eventType: MachineConnectionEvent }
@@ -97,7 +87,8 @@ export const provideRobotClientsContext = (
9787
}
9888
});
9989

100-
clients[partID] = client;
90+
await client.dial(config);
91+
10192
connectionStatus[partID] = MachineConnectionEvent.CONNECTED;
10293
} catch (error) {
10394
console.error(error);
@@ -113,10 +104,8 @@ export const provideRobotClientsContext = (
113104
Object.keys(lastConfigs)
114105
);
115106

116-
lastConfigs = $state.snapshot(configs);
117-
118107
for (const partID of removed) {
119-
disconnect(partID, lastConfigs[partID]);
108+
disconnect(partID);
120109
}
121110

122111
for (const partID of added) {
@@ -134,6 +123,8 @@ export const provideRobotClientsContext = (
134123
connect(partID, config);
135124
}
136125
}
126+
127+
lastConfigs = $state.snapshot(configs);
137128
});
138129

139130
onMount(() => {

0 commit comments

Comments
 (0)