@luxonis/depthai-viewer-common 0.0.2 → 0.0.4

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 (113) hide show
  1. package/dist/components/ButtonLink.d.ts +8 -0
  2. package/dist/components/ButtonLink.d.ts.map +1 -0
  3. package/dist/components/ButtonLink.js +8 -0
  4. package/dist/components/ButtonLink.js.map +1 -0
  5. package/dist/components/CTASubLabel.d.ts +2 -0
  6. package/dist/components/CTASubLabel.d.ts.map +1 -0
  7. package/dist/components/CTASubLabel.js +17 -0
  8. package/dist/components/CTASubLabel.js.map +1 -0
  9. package/dist/components/Link.d.ts +5 -0
  10. package/dist/components/Link.d.ts.map +1 -0
  11. package/dist/components/Link.js +8 -0
  12. package/dist/components/Link.js.map +1 -0
  13. package/dist/components/Pipeline.d.ts +3 -0
  14. package/dist/components/Pipeline.d.ts.map +1 -0
  15. package/dist/components/Pipeline.js +22 -0
  16. package/dist/components/Pipeline.js.map +1 -0
  17. package/dist/components/Resizable.d.ts +10 -0
  18. package/dist/components/Resizable.d.ts.map +1 -0
  19. package/dist/components/Resizable.js +12 -0
  20. package/dist/components/Resizable.js.map +1 -0
  21. package/dist/components/Streams.d.ts +10 -0
  22. package/dist/components/Streams.d.ts.map +1 -0
  23. package/dist/components/Streams.js +80 -0
  24. package/dist/components/Streams.js.map +1 -0
  25. package/dist/constants/connection.d.ts +36 -0
  26. package/dist/constants/connection.d.ts.map +1 -0
  27. package/dist/constants/connection.js +35 -0
  28. package/dist/constants/connection.js.map +1 -0
  29. package/dist/constants/streams.d.ts +13 -0
  30. package/dist/constants/streams.d.ts.map +1 -0
  31. package/dist/constants/streams.js +13 -0
  32. package/dist/constants/streams.js.map +1 -0
  33. package/dist/constants/url.d.ts +4 -0
  34. package/dist/constants/url.d.ts.map +1 -0
  35. package/dist/constants/url.js +4 -0
  36. package/dist/constants/url.js.map +1 -0
  37. package/dist/dai-connection/connection.d.ts +55 -0
  38. package/dist/dai-connection/connection.d.ts.map +1 -0
  39. package/dist/dai-connection/connection.js +291 -0
  40. package/dist/dai-connection/connection.js.map +1 -0
  41. package/dist/dai-connection/decoder.worker.d.ts +16 -0
  42. package/dist/dai-connection/decoder.worker.d.ts.map +1 -0
  43. package/dist/dai-connection/decoder.worker.js +24 -0
  44. package/dist/dai-connection/decoder.worker.js.map +1 -0
  45. package/dist/hooks/connection.d.ts +30 -0
  46. package/dist/hooks/connection.d.ts.map +1 -0
  47. package/dist/hooks/connection.js +145 -0
  48. package/dist/hooks/connection.js.map +1 -0
  49. package/dist/hooks/navigation.d.ts +12 -0
  50. package/dist/hooks/navigation.d.ts.map +1 -0
  51. package/dist/hooks/navigation.js +15 -0
  52. package/dist/hooks/navigation.js.map +1 -0
  53. package/dist/hooks/search.d.ts +11 -0
  54. package/dist/hooks/search.d.ts.map +1 -0
  55. package/dist/hooks/search.js +31 -0
  56. package/dist/hooks/search.js.map +1 -0
  57. package/{src/index.ts → dist/index.d.ts} +1 -8
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +22 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/providers/ConnectionProvider.d.ts +9 -0
  62. package/dist/providers/ConnectionProvider.d.ts.map +1 -0
  63. package/dist/providers/ConnectionProvider.js +29 -0
  64. package/dist/providers/ConnectionProvider.js.map +1 -0
  65. package/dist/providers/DataProvider.d.ts +13 -0
  66. package/dist/providers/DataProvider.d.ts.map +1 -0
  67. package/dist/providers/DataProvider.js +43 -0
  68. package/dist/providers/DataProvider.js.map +1 -0
  69. package/dist/utils/arrays.d.ts +2 -0
  70. package/dist/utils/arrays.d.ts.map +1 -0
  71. package/dist/utils/arrays.js +11 -0
  72. package/dist/utils/arrays.js.map +1 -0
  73. package/dist/utils/dynamic-base-worker.d.ts +8 -0
  74. package/dist/utils/dynamic-base-worker.d.ts.map +1 -0
  75. package/dist/utils/dynamic-base-worker.js +19 -0
  76. package/dist/utils/dynamic-base-worker.js.map +1 -0
  77. package/dist/utils/functions.d.ts +2 -0
  78. package/dist/utils/functions.d.ts.map +1 -0
  79. package/dist/utils/functions.js +4 -0
  80. package/dist/utils/functions.js.map +1 -0
  81. package/dist/utils/sorting.d.ts +3 -0
  82. package/dist/utils/sorting.d.ts.map +1 -0
  83. package/dist/utils/sorting.js +34 -0
  84. package/dist/utils/sorting.js.map +1 -0
  85. package/dist/utils/url.d.ts +5 -0
  86. package/dist/utils/url.d.ts.map +1 -0
  87. package/dist/utils/url.js +7 -0
  88. package/dist/utils/url.js.map +1 -0
  89. package/package.json +5 -4
  90. package/src/components/ButtonLink.tsx +0 -12
  91. package/src/components/CTASubLabel.tsx +0 -39
  92. package/src/components/Link.tsx +0 -10
  93. package/src/components/Pipeline.tsx +0 -35
  94. package/src/components/Resizable.tsx +0 -56
  95. package/src/components/Streams.tsx +0 -261
  96. package/src/constants/connection.ts +0 -45
  97. package/src/constants/streams.ts +0 -12
  98. package/src/constants/url.ts +0 -6
  99. package/src/dai-connection/connection.ts +0 -402
  100. package/src/dai-connection/decoder.worker.ts +0 -47
  101. package/src/hooks/connection.ts +0 -204
  102. package/src/hooks/navigation.ts +0 -25
  103. package/src/hooks/search.ts +0 -45
  104. package/src/models/device-configuration.ts +0 -27
  105. package/src/providers/ConnectionProvider.tsx +0 -39
  106. package/src/providers/DataProvider.tsx +0 -71
  107. package/src/utils/arrays.ts +0 -10
  108. package/src/utils/dynamic-base-worker.ts +0 -21
  109. package/src/utils/functions.ts +0 -3
  110. package/src/utils/sorting.ts +0 -42
  111. package/src/utils/url.ts +0 -8
  112. package/src/window.d.ts +0 -7
  113. package/tsconfig.json +0 -37
@@ -1,261 +0,0 @@
1
- import {
2
- Button,
3
- DropdownMenu,
4
- DropdownMenuCheckboxItem,
5
- DropdownMenuContent,
6
- DropdownMenuTrigger,
7
- Flex,
8
- Header,
9
- Input,
10
- NormalText,
11
- SubHeader,
12
- Tooltip,
13
- } from '@luxonis/common-fe-components';
14
- import { ImagePanel, PanelLayout, PointCloudPanel } from '@luxonis/visualizer-protobuf';
15
- import React from 'react';
16
-
17
- import { ResizableLayout, type Topic } from '@luxonis/depthai-viewer-common';
18
- import { StreamTypes } from '../constants/streams.js';
19
- import { useConnection } from '../providers/ConnectionProvider.js';
20
- import { useData } from '../providers/DataProvider.js';
21
- import { makeColumns } from '../utils/arrays.js';
22
- import { CTASubLabel } from './CTASubLabel.js';
23
- import { FaUsersViewfinder as VisualizerIcon } from 'react-icons/fa6';
24
- import { sortStreamsDefault } from '../utils/sorting.js';
25
- import type { DeviceConfiguration } from '../models/device-configuration.js';
26
-
27
- const EnabledStreamsView: React.FC<{
28
- topics: Topic[][];
29
- targetFps?: number;
30
- isRawSteamEnabledManually?: boolean;
31
- setIsRawSteamEnabledManually?: (value: boolean) => void;
32
- triggerToast?: () => void;
33
- deviceOptions?: DeviceConfiguration | null;
34
- }> = ({
35
- topics,
36
- targetFps,
37
- triggerToast,
38
- isRawSteamEnabledManually,
39
- setIsRawSteamEnabledManually,
40
- }) => {
41
- const { toggleTopic, topics: allTopics } = useConnection();
42
-
43
- const items = React.useMemo(() => {
44
- return topics.map((row) => {
45
- let filteredRow = row.filter((topic) => !topic.name.startsWith('_'));
46
-
47
- if (
48
- filteredRow.some((topic) => topic.name === StreamTypes.PointCloud) &&
49
- filteredRow.some((topic) => topic.name !== StreamTypes.Encoded) &&
50
- !isRawSteamEnabledManually
51
- ) {
52
- filteredRow = filteredRow.filter((topic) => topic.name !== StreamTypes.Encoded);
53
- }
54
- return filteredRow.map(({ name, annotations, extraAnnotations, kind }) => ({
55
- component:
56
- kind === 'pointCloud' || name === StreamTypes.PointCloud ? (
57
- <PointCloudPanel
58
- key={name}
59
- toggleTopic={(topic) => {
60
- if (allTopics.find((t) => t.name === StreamTypes._PointCloudColor)) {
61
- toggleTopic(StreamTypes._PointCloudColor);
62
- } else if (allTopics.find((t) => t.name === StreamTypes.Encoded)) {
63
- toggleTopic(StreamTypes.Encoded);
64
- }
65
- toggleTopic(topic);
66
- }}
67
- topic={name}
68
- />
69
- ) : name !== StreamTypes.Raw &&
70
- name !== StreamTypes.LeftRaw &&
71
- name !== StreamTypes.RightRaw &&
72
- !navigator.userAgent.includes('Chrome') ? (
73
- <PanelLayout>
74
- <Flex
75
- full
76
- justify="center"
77
- align="center"
78
- direction="column"
79
- gap="sm"
80
- textAlign="center"
81
- >
82
- <SubHeader text={`${name} is only supported in Google Chrome.`} />
83
- <SubHeader text="Please switch to Chrome for the best experience." />
84
- </Flex>
85
- </PanelLayout>
86
- ) : (
87
- <ImagePanel
88
- key={name}
89
- toggleTopic={(topic) => {
90
- if (isRawSteamEnabledManually && topic === StreamTypes.Encoded) {
91
- setIsRawSteamEnabledManually?.(false);
92
- }
93
- toggleTopic(topic);
94
- }}
95
- topic={name}
96
- annotationTopics={annotations}
97
- extraAnnotationTopics={extraAnnotations}
98
- targetFps={targetFps}
99
- triggerToast={triggerToast}
100
- disableAnnotations={
101
- name === StreamTypes.LeftRaw ||
102
- name === StreamTypes.RightRaw ||
103
- name === StreamTypes.LeftEncoded ||
104
- name === StreamTypes.RightEncoded
105
- }
106
- />
107
- ),
108
- }));
109
- });
110
- }, [topics, targetFps, triggerToast, isRawSteamEnabledManually, setIsRawSteamEnabledManually]);
111
-
112
- return <ResizableLayout items={items} />;
113
- };
114
-
115
- export const Streams: React.FC<{
116
- targetFps?: number;
117
- triggerToast?: () => void;
118
- setIsRawSteamEnabledManually?: (value: boolean) => void;
119
- isRawSteamEnabledManually?: boolean;
120
- deviceOptions?: DeviceConfiguration | null;
121
- }> = ({
122
- targetFps,
123
- triggerToast,
124
- isRawSteamEnabledManually = true,
125
- setIsRawSteamEnabledManually,
126
- deviceOptions,
127
- }) => {
128
- const { changeWsUrl, columns, connectionType, wsUrl } = useData();
129
- const { connected, topics, toggleTopic } = useConnection();
130
- const [shouldDisplayHelper, setShouldDisplayHelper] = React.useState(false);
131
- const [connecting, setConnecting] = React.useState(false);
132
-
133
- const enabledTopics = React.useMemo(
134
- () =>
135
- makeColumns(
136
- topics.filter((topic) => !topic.name.startsWith('_')).filter((topic) => topic.enabled),
137
- columns,
138
- ),
139
- [columns, topics],
140
- );
141
-
142
- const wsUrlRef = React.useRef<HTMLInputElement>(null);
143
-
144
- const handleChangeUrl = React.useCallback(
145
- () => wsUrlRef.current?.value && changeWsUrl(wsUrlRef.current.value),
146
- [changeWsUrl],
147
- );
148
-
149
- const shouldSuggestUrlChange = React.useMemo(
150
- () => window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1',
151
- [],
152
- );
153
-
154
- React.useEffect(() => {
155
- if (!shouldDisplayHelper && !shouldSuggestUrlChange) {
156
- setTimeout(() => {
157
- setShouldDisplayHelper(true);
158
- }, 10_000);
159
- }
160
- }, [shouldDisplayHelper, shouldSuggestUrlChange]);
161
-
162
- const sortedTopics = React.useMemo(
163
- () => sortStreamsDefault(topics.filter((topic) => !topic.name.startsWith('_'))),
164
- [topics],
165
- );
166
-
167
- // TODO: Store detections in url or global provider
168
- // to persist on re-renders
169
- return (
170
- <PanelLayout>
171
- {enabledTopics.length === 0 || enabledTopics[0].length === 0 ? (
172
- <Flex full justify="center" align="center" direction="column" gap="sm">
173
- <Header
174
- text={
175
- connected ? (
176
- sortedTopics.length === 0 ? (
177
- 'DepthAI connected, awaiting device...'
178
- ) : (
179
- <p>
180
- To view stream(s), select it with Streams Button{' '}
181
- <DropdownMenu>
182
- <Tooltip content="Streams">
183
- <DropdownMenuTrigger>
184
- <Button icon={VisualizerIcon} variant="outline" colorVariant="white" />
185
- </DropdownMenuTrigger>
186
- </Tooltip>
187
- <DropdownMenuContent>
188
- {sortedTopics.map((topic, i) => (
189
- <DropdownMenuCheckboxItem key={i} onClick={() => toggleTopic(topic.name)}>
190
- {topic.name}
191
- </DropdownMenuCheckboxItem>
192
- ))}
193
- </DropdownMenuContent>
194
- </DropdownMenu>{' '}
195
- either here or in the top right corner
196
- </p>
197
- )
198
- ) : // TODO: connection details (state, errors, retries, webrtc stage)
199
- connectionType === 'ws' ? (
200
- 'Connecting to DepthAI via WebSocket...'
201
- ) : (
202
- 'Connecting to DepthAI via WebRTC...'
203
- )
204
- }
205
- />
206
-
207
- {!connected &&
208
- (shouldSuggestUrlChange ? (
209
- <>
210
- <SubHeader
211
- text={connectionType === 'ws' ? 'Use another URL?' : 'Connect via WebSocket?'}
212
- />
213
- <form
214
- onSubmit={(event) => {
215
- event.stopPropagation();
216
- event.preventDefault();
217
-
218
- setConnecting(true);
219
-
220
- handleChangeUrl();
221
- }}
222
- >
223
- <Flex>
224
- <Input
225
- type="text"
226
- ref={wsUrlRef}
227
- placeholder={wsUrl}
228
- roundedRight={0}
229
- onChange={() => setConnecting(false)}
230
- />
231
- <Button
232
- type="submit"
233
- label={connecting ? 'Connecting...' : 'Connect'}
234
- style={{
235
- borderTopLeftRadius: 0,
236
- borderBottomLeftRadius: 0,
237
- }}
238
- />
239
- </Flex>
240
- </form>
241
- </>
242
- ) : (
243
- shouldDisplayHelper && (
244
- <NormalText text="Please check that you have the correct link to DepthAI Visualizer and that your device is running. You need a new link after any app or device restart." />
245
- )
246
- ))}
247
- <CTASubLabel />
248
- </Flex>
249
- ) : (
250
- <EnabledStreamsView
251
- topics={enabledTopics}
252
- targetFps={targetFps}
253
- triggerToast={triggerToast}
254
- isRawSteamEnabledManually={isRawSteamEnabledManually}
255
- setIsRawSteamEnabledManually={setIsRawSteamEnabledManually}
256
- deviceOptions={deviceOptions}
257
- />
258
- )}
259
- </PanelLayout>
260
- );
261
- };
@@ -1,45 +0,0 @@
1
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
2
- export type DAIResponse<T = any> = {
3
- data: T;
4
- error: Error | string | null;
5
- message: string | null;
6
- status: number;
7
- };
8
-
9
- export const DAI_SERVICE_NAME = {
10
- topicGroups: 'topicGroups',
11
- pipelineSchema: 'pipelineSchema',
12
- keyPressed: 'keyPressed',
13
- // Devices
14
- getDevices: 'getDevices',
15
- startDevice: 'startDevice',
16
- stopDevice: 'stopDevice',
17
- getDeviceOptions: 'getDeviceOptions',
18
- getFpsRange: 'getFpsRange',
19
- // Configs
20
- getSensors: 'getSensors',
21
- setSensors: 'setSensors',
22
- getStereoDepth: 'getStereoDepth',
23
- setStereoDepth: 'setStereoDepth',
24
- getStereoDepthPreset: 'getStereoDepthPreset',
25
- setStereoDepthPreset: 'setStereoDepthPreset',
26
- getStereoDepthCalibration: 'getStereoDepthCalibration',
27
- setStereoDepthCalibration: 'setStereoDepthCalibration',
28
- setIr: 'setIr',
29
- setPointCloud: 'setPointCloud',
30
- setThermal: 'setThermal',
31
- getCameraIntrinsics: 'getCameraIntrinsics',
32
- // Neural networks
33
- getNeuralNetworks: 'getNeuralNetworks',
34
- setNeuralNetwork: 'setNeuralNetwork',
35
- getNeuralNetworkConfiguration: 'getNeuralNetworkConfiguration',
36
- setNeuralNetworkConfiguration: 'setNeuralNetworkConfiguration',
37
- };
38
-
39
- export const SIGNALING_SERVER_URL = 'wss://signal.cloud.luxonis.com/session/';
40
- export const ICE_SERVERS_API_ENDPOINT =
41
- 'https://signal.cloud-stg.luxonis.com/api/v1/turn-credentials';
42
-
43
- export const DEFAULT_ICE_SERVERS: RTCIceServer[] = [
44
- { urls: ['stun:stun.l.google.com:19302', 'stun:stun1.l.google.com:19302'] },
45
- ];
@@ -1,12 +0,0 @@
1
- export const StreamTypes = {
2
- Encoded: 'H.264 Stream',
3
- LeftEncoded: 'Left H.264 Stream',
4
- RightEncoded: 'Right H.264 Stream',
5
- Disparity: 'Disparity Stream',
6
- Raw: 'Raw Stream',
7
- LeftRaw: 'Left Raw Stream',
8
- RightRaw: 'Right Raw Stream',
9
- PointCloud: 'Point Cloud',
10
- NeuralNetwork: 'Neural Network Stream',
11
- _PointCloudColor: '_Point Cloud Color',
12
- } as const;
@@ -1,6 +0,0 @@
1
- export const DEFAULT_WS_URL = `wss://${window.location.hostname}:8000/dai`;
2
-
3
- export const LOCALHOST_WS_URL = 'ws://localhost:8765';
4
-
5
- export const IS_LOCALHOST =
6
- window.origin.includes('localhost') || window.origin.includes('127.0.0.1');