@viamrobotics/motion-tools 0.18.2 → 0.18.3
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default MockCanvas;
|
|
2
|
+
type MockCanvas = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const MockCanvas: import("svelte").Component<{
|
|
7
|
+
child: any;
|
|
8
|
+
} & Record<string, any>, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
child: any;
|
|
11
|
+
} & Record<string, any>;
|
|
@@ -10,17 +10,17 @@ import { createPose, createPoseFromFrame } from '../transform';
|
|
|
10
10
|
import { useCameraControls } from './useControls.svelte';
|
|
11
11
|
import { useThrelte } from '@threlte/core';
|
|
12
12
|
import { OrientationVector } from '../three/OrientationVector';
|
|
13
|
+
import { useLogs } from './useLogs.svelte';
|
|
13
14
|
const axis = new Vector3();
|
|
14
15
|
const quaternion = new Quaternion();
|
|
15
16
|
const ov = new OrientationVector();
|
|
16
17
|
const key = Symbol('draw-api-context-key');
|
|
17
18
|
const tryParse = (json) => {
|
|
18
19
|
try {
|
|
19
|
-
return JSON.parse(json);
|
|
20
|
+
return [null, JSON.parse(json)];
|
|
20
21
|
}
|
|
21
22
|
catch (error) {
|
|
22
|
-
|
|
23
|
-
return;
|
|
23
|
+
return [error, null];
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
@@ -55,6 +55,7 @@ class Float32Reader {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
export const provideDrawAPI = () => {
|
|
58
|
+
const logs = useLogs();
|
|
58
59
|
const cameraControls = useCameraControls();
|
|
59
60
|
const { invalidate } = useThrelte();
|
|
60
61
|
let pointsIndex = 0;
|
|
@@ -380,23 +381,27 @@ export const provideDrawAPI = () => {
|
|
|
380
381
|
const scheduleReconnect = () => {
|
|
381
382
|
setTimeout(() => {
|
|
382
383
|
reconnectDelay = Math.min(reconnectDelay * 2, maxReconnectDelay);
|
|
383
|
-
|
|
384
|
+
logs.add(`Reconnecting to drawing server in ${reconnectDelay / 1000} seconds...`, 'warn');
|
|
384
385
|
connect();
|
|
385
386
|
}, reconnectDelay);
|
|
386
387
|
};
|
|
387
388
|
const onOpen = () => {
|
|
388
389
|
connectionStatus = 'open';
|
|
389
390
|
reconnectDelay = 1000;
|
|
390
|
-
|
|
391
|
+
logs.add(`Connected to drawing server at ${BACKEND_IP}:${BUN_SERVER_PORT}`);
|
|
391
392
|
};
|
|
392
393
|
const onClose = () => {
|
|
393
394
|
connectionStatus = 'closed';
|
|
394
|
-
|
|
395
|
+
logs.add('Disconnected from drawing server', 'warn');
|
|
395
396
|
scheduleReconnect();
|
|
396
397
|
};
|
|
397
398
|
const onError = (event) => {
|
|
398
|
-
|
|
399
|
+
const stringified = JSON.stringify(event);
|
|
399
400
|
ws.close();
|
|
401
|
+
if (stringified === '{"isTrusted":true}') {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
logs.add(`Drawing server error: ${JSON.stringify(event)}`, 'error');
|
|
400
405
|
};
|
|
401
406
|
const onMessage = async (event) => {
|
|
402
407
|
if (typeof event.data === 'object' && 'arrayBuffer' in event.data) {
|
|
@@ -418,7 +423,10 @@ export const provideDrawAPI = () => {
|
|
|
418
423
|
return drawGLTF(reader.buffer);
|
|
419
424
|
}
|
|
420
425
|
}
|
|
421
|
-
const data = tryParse(event.data);
|
|
426
|
+
const [error, data] = tryParse(event.data);
|
|
427
|
+
if (error) {
|
|
428
|
+
logs.add(`Failed to parse JSON from drawing server: ${JSON.stringify(error)}`, 'error');
|
|
429
|
+
}
|
|
422
430
|
if (!data)
|
|
423
431
|
return;
|
|
424
432
|
if ('setCameraPose' in data) {
|
|
@@ -24,7 +24,11 @@ export const provideFrames = (partID) => {
|
|
|
24
24
|
if (revision) {
|
|
25
25
|
untrack(() => query.current).refetch();
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
});
|
|
28
|
+
$effect.pre(() => {
|
|
29
|
+
if (query.current.isFetching) {
|
|
30
|
+
logs.add('Fetching frames...');
|
|
31
|
+
}
|
|
28
32
|
});
|
|
29
33
|
$effect.pre(() => {
|
|
30
34
|
if (partConfig.isDirty) {
|
package/dist/lib.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Components
|
|
2
|
+
// NOTE: These components should be pure and not use any hooks if you add a new component to export here
|
|
3
|
+
// ensure you write a corresponding unit test to assert the component works in absence of parent providers in /src/lib/__tests__/PureComponents.svelte.spec.ts
|
|
2
4
|
export { default as Geometry } from './components/Geometry.svelte';
|
|
3
5
|
export { default as AxesHelper } from './components/AxesHelper.svelte';
|
|
4
6
|
// Classes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@viamrobotics/sdk": "0.55.0",
|
|
41
41
|
"@viamrobotics/svelte-sdk": "0.7.1",
|
|
42
42
|
"@vitejs/plugin-basic-ssl": "2.1.0",
|
|
43
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
43
44
|
"@zag-js/svelte": "1.22.1",
|
|
44
45
|
"@zag-js/tree-view": "1.22.1",
|
|
45
46
|
"camera-controls": "3.1.0",
|
|
@@ -129,6 +130,7 @@
|
|
|
129
130
|
"test:unit": "vitest",
|
|
130
131
|
"test:client": "go test ./client/... -count=1",
|
|
131
132
|
"test": "pnpm test:unit -- --run",
|
|
133
|
+
"test:coverage": "npx vitest run --coverage",
|
|
132
134
|
"test:e2e": "playwright test",
|
|
133
135
|
"model-pipeline:run": "node scripts/model-pipeline.js",
|
|
134
136
|
"release": "changeset publish"
|