@luxonis/depthai-viewer-common 0.0.1 → 0.0.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxonis/depthai-viewer-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Common utilities and components for building a frontend application for DepthAI projects",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Luxonis Holding Corporation",
|
|
@@ -16,5 +16,17 @@
|
|
|
16
16
|
},
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@luxonis/visualizer-protobuf": "^2.31.0",
|
|
22
|
+
"@luxonis/depthai-pipeline-lib": "^1.4.8",
|
|
23
|
+
"@luxonis/common-fe-components": "1.14.0",
|
|
24
|
+
"@luxonis/common-fe-utils": "1.14.0",
|
|
25
|
+
"lodash": "^4.17.21",
|
|
26
|
+
"zod": "^3.24.3"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.3.1",
|
|
30
|
+
"react-dom": "^18.3.1"
|
|
19
31
|
}
|
|
20
32
|
}
|
|
@@ -20,9 +20,9 @@ import { useConnection } from '../providers/ConnectionProvider.js';
|
|
|
20
20
|
import { useData } from '../providers/DataProvider.js';
|
|
21
21
|
import { makeColumns } from '../utils/arrays.js';
|
|
22
22
|
import { CTASubLabel } from './CTASubLabel.js';
|
|
23
|
-
import type { Configuration } from '@luxonis/depthai-viewer/src/models/configuration.js';
|
|
24
23
|
import { FaUsersViewfinder as VisualizerIcon } from 'react-icons/fa6';
|
|
25
24
|
import { sortStreamsDefault } from '../utils/sorting.js';
|
|
25
|
+
import type { DeviceConfiguration } from '../models/device-configuration.js';
|
|
26
26
|
|
|
27
27
|
const EnabledStreamsView: React.FC<{
|
|
28
28
|
topics: Topic[][];
|
|
@@ -30,7 +30,7 @@ const EnabledStreamsView: React.FC<{
|
|
|
30
30
|
isRawSteamEnabledManually?: boolean;
|
|
31
31
|
setIsRawSteamEnabledManually?: (value: boolean) => void;
|
|
32
32
|
triggerToast?: () => void;
|
|
33
|
-
deviceOptions?:
|
|
33
|
+
deviceOptions?: DeviceConfiguration | null;
|
|
34
34
|
}> = ({
|
|
35
35
|
topics,
|
|
36
36
|
targetFps,
|
|
@@ -38,18 +38,18 @@ const EnabledStreamsView: React.FC<{
|
|
|
38
38
|
isRawSteamEnabledManually,
|
|
39
39
|
setIsRawSteamEnabledManually,
|
|
40
40
|
}) => {
|
|
41
|
-
const { toggleTopic } = useConnection();
|
|
41
|
+
const { toggleTopic, topics: allTopics } = useConnection();
|
|
42
42
|
|
|
43
43
|
const items = React.useMemo(() => {
|
|
44
44
|
return topics.map((row) => {
|
|
45
|
-
let filteredRow = row;
|
|
45
|
+
let filteredRow = row.filter((topic) => !topic.name.startsWith('_'));
|
|
46
46
|
|
|
47
47
|
if (
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
filteredRow.some((topic) => topic.name === StreamTypes.PointCloud) &&
|
|
49
|
+
filteredRow.some((topic) => topic.name !== StreamTypes.Encoded) &&
|
|
50
50
|
!isRawSteamEnabledManually
|
|
51
51
|
) {
|
|
52
|
-
filteredRow =
|
|
52
|
+
filteredRow = filteredRow.filter((topic) => topic.name !== StreamTypes.Encoded);
|
|
53
53
|
}
|
|
54
54
|
return filteredRow.map(({ name, annotations, extraAnnotations, kind }) => ({
|
|
55
55
|
component:
|
|
@@ -57,7 +57,9 @@ const EnabledStreamsView: React.FC<{
|
|
|
57
57
|
<PointCloudPanel
|
|
58
58
|
key={name}
|
|
59
59
|
toggleTopic={(topic) => {
|
|
60
|
-
if (
|
|
60
|
+
if (allTopics.find((t) => t.name === StreamTypes._PointCloudColor)) {
|
|
61
|
+
toggleTopic(StreamTypes._PointCloudColor);
|
|
62
|
+
} else if (allTopics.find((t) => t.name === StreamTypes.Encoded)) {
|
|
61
63
|
toggleTopic(StreamTypes.Encoded);
|
|
62
64
|
}
|
|
63
65
|
toggleTopic(topic);
|
|
@@ -115,7 +117,7 @@ export const Streams: React.FC<{
|
|
|
115
117
|
triggerToast?: () => void;
|
|
116
118
|
setIsRawSteamEnabledManually?: (value: boolean) => void;
|
|
117
119
|
isRawSteamEnabledManually?: boolean;
|
|
118
|
-
deviceOptions?:
|
|
120
|
+
deviceOptions?: DeviceConfiguration | null;
|
|
119
121
|
}> = ({
|
|
120
122
|
targetFps,
|
|
121
123
|
triggerToast,
|
|
@@ -131,7 +133,7 @@ export const Streams: React.FC<{
|
|
|
131
133
|
const enabledTopics = React.useMemo(
|
|
132
134
|
() =>
|
|
133
135
|
makeColumns(
|
|
134
|
-
topics.filter((topic) => topic.enabled),
|
|
136
|
+
topics.filter((topic) => !topic.name.startsWith('_')).filter((topic) => topic.enabled),
|
|
135
137
|
columns,
|
|
136
138
|
),
|
|
137
139
|
[columns, topics],
|
|
@@ -157,7 +159,10 @@ export const Streams: React.FC<{
|
|
|
157
159
|
}
|
|
158
160
|
}, [shouldDisplayHelper, shouldSuggestUrlChange]);
|
|
159
161
|
|
|
160
|
-
const sortedTopics = React.useMemo(
|
|
162
|
+
const sortedTopics = React.useMemo(
|
|
163
|
+
() => sortStreamsDefault(topics.filter((topic) => !topic.name.startsWith('_'))),
|
|
164
|
+
[topics],
|
|
165
|
+
);
|
|
161
166
|
|
|
162
167
|
// TODO: Store detections in url or global provider
|
|
163
168
|
// to persist on re-renders
|
package/src/constants/streams.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Pipeline,
|
|
3
|
-
parsePipeline,
|
|
4
|
-
} from '../../../../node_modules/@luxonis/depthai-pipeline-lib/dist/src/services/pipeline.js';
|
|
1
|
+
import { parsePipeline, type Pipeline } from '@luxonis/depthai-pipeline-lib';
|
|
5
2
|
|
|
6
3
|
function decodeService(kind: 'pipeline' | 'json', response: DataView | null) {
|
|
7
4
|
if (!response) {
|
package/src/hooks/connection.ts
CHANGED
|
@@ -144,11 +144,16 @@ export function useCreateConnection({
|
|
|
144
144
|
|
|
145
145
|
React.useEffect(() => {
|
|
146
146
|
if (topics.length > 0) {
|
|
147
|
-
if (
|
|
148
|
-
topics.find((
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
if (topics.find((topic) => topic.name === StreamTypes.PointCloud)?.enabled) {
|
|
148
|
+
const pcColor = topics.find((t) => t.name === StreamTypes._PointCloudColor);
|
|
149
|
+
if (pcColor?.enabled === false) {
|
|
150
|
+
connection?.toggleTopic(StreamTypes._PointCloudColor);
|
|
151
|
+
} else if (
|
|
152
|
+
!pcColor &&
|
|
153
|
+
topics.find((t) => t.name === StreamTypes.Encoded)?.enabled === false
|
|
154
|
+
) {
|
|
155
|
+
connection?.toggleTopic(StreamTypes.Encoded);
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
158
|
updateSearch(
|
|
154
159
|
'streams',
|
|
@@ -161,17 +166,25 @@ export function useCreateConnection({
|
|
|
161
166
|
(topicName: string, isRawSteamEnabledManually?: boolean): void => {
|
|
162
167
|
if (
|
|
163
168
|
topicName === StreamTypes.PointCloud &&
|
|
164
|
-
topics.find((topic) => topic.name === topicName)?.enabled === false
|
|
165
|
-
topics.find((t) => t.name === StreamTypes.Encoded)?.enabled === false
|
|
169
|
+
topics.find((topic) => topic.name === topicName)?.enabled === false
|
|
166
170
|
) {
|
|
167
|
-
|
|
171
|
+
const pcColor = topics.find((t) => t.name === StreamTypes._PointCloudColor);
|
|
172
|
+
if (!pcColor?.enabled) {
|
|
173
|
+
connection?.toggleTopic(StreamTypes._PointCloudColor);
|
|
174
|
+
} else if (!pcColor && topics.find((t) => t.name === StreamTypes.Encoded)) {
|
|
175
|
+
connection?.toggleTopic(StreamTypes.Encoded);
|
|
176
|
+
}
|
|
168
177
|
}
|
|
169
178
|
if (
|
|
170
179
|
topicName === StreamTypes.PointCloud &&
|
|
171
180
|
isRawSteamEnabledManually === false &&
|
|
172
181
|
topics.find((n) => n.name === 'Point Cloud')?.enabled
|
|
173
182
|
) {
|
|
174
|
-
|
|
183
|
+
if (topics.find((n) => n.name === StreamTypes._PointCloudColor)) {
|
|
184
|
+
connection?.toggleTopic(StreamTypes._PointCloudColor);
|
|
185
|
+
} else if (topics.find((n) => n.name === StreamTypes.Encoded)) {
|
|
186
|
+
connection?.toggleTopic(StreamTypes.Encoded);
|
|
187
|
+
}
|
|
175
188
|
}
|
|
176
189
|
connection?.toggleTopic(topicName);
|
|
177
190
|
},
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export * from './hooks/connection.js';
|
|
|
17
17
|
export * from './hooks/navigation.js';
|
|
18
18
|
export * from './hooks/search.js';
|
|
19
19
|
|
|
20
|
+
export * from './models/device-configuration.js';
|
|
21
|
+
|
|
20
22
|
export * from './utils/dynamic-base-worker.js';
|
|
21
23
|
export * from './utils/functions.js';
|
|
22
24
|
export * from './utils/sorting.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DeviceListSchema } from '@luxonis/common-fe-components';
|
|
3
|
+
|
|
4
|
+
export const SensorSchema = z.object({
|
|
5
|
+
boardSocket: z.string(),
|
|
6
|
+
height: z.number(),
|
|
7
|
+
maxFps: z.number(),
|
|
8
|
+
minFps: z.number(),
|
|
9
|
+
type: z.string(),
|
|
10
|
+
width: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export type Sensor = z.infer<typeof SensorSchema>;
|
|
13
|
+
|
|
14
|
+
export const IrSchema = z.object({
|
|
15
|
+
floodLight: z.boolean(),
|
|
16
|
+
dotProjector: z.boolean(),
|
|
17
|
+
});
|
|
18
|
+
export type Ir = z.infer<typeof IrSchema>;
|
|
19
|
+
|
|
20
|
+
export const DeviceConfigurationSchema = z.object({
|
|
21
|
+
cameraSensors: z.array(SensorSchema),
|
|
22
|
+
ir: IrSchema,
|
|
23
|
+
stereo: z.boolean(),
|
|
24
|
+
thermal: z.boolean(),
|
|
25
|
+
productName: DeviceListSchema,
|
|
26
|
+
});
|
|
27
|
+
export type DeviceConfiguration = z.infer<typeof DeviceConfigurationSchema>;
|