@luxonis/visualizer-protobuf 2.1.1 → 2.3.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.
Files changed (122) hide show
  1. package/dist/{communicator-ZAqNuwq6.js → FoxgloveServer-tJZcJH5-.js} +1216 -184
  2. package/dist/apps/depthai-visualizer/src/components/Panel.d.ts.map +1 -1
  3. package/dist/apps/depthai-visualizer/src/components/Panel.js +13 -4
  4. package/dist/apps/depthai-visualizer/src/components/Panel.js.map +1 -1
  5. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.d.ts.map +1 -1
  6. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js +12 -12
  7. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js.map +1 -1
  8. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts +10 -7
  9. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts.map +1 -1
  10. package/dist/apps/depthai-visualizer/src/connection/adapter.js +11 -5
  11. package/dist/apps/depthai-visualizer/src/connection/adapter.js.map +1 -1
  12. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts +17 -13
  13. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts.map +1 -1
  14. package/dist/apps/depthai-visualizer/src/connection/communicator.js +17 -24
  15. package/dist/apps/depthai-visualizer/src/connection/communicator.js.map +1 -1
  16. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts +14 -13
  17. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts.map +1 -1
  18. package/dist/apps/depthai-visualizer/src/connection/connection.js +25 -22
  19. package/dist/apps/depthai-visualizer/src/connection/connection.js.map +1 -1
  20. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.d.ts +6 -0
  21. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.d.ts.map +1 -0
  22. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.js +63 -0
  23. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.js.map +1 -0
  24. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts +2 -2
  25. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts.map +1 -1
  26. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js +76 -45
  27. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js.map +1 -1
  28. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts +50 -15
  29. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts.map +1 -1
  30. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js +71 -26
  31. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js.map +1 -1
  32. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker.js +15 -0
  33. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker.js.map +1 -1
  34. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts +16 -1
  35. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts.map +1 -1
  36. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js +114 -2
  37. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js.map +1 -1
  38. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts +1 -1
  39. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts.map +1 -1
  40. package/dist/apps/depthai-visualizer/src/index.d.ts +1 -2
  41. package/dist/apps/depthai-visualizer/src/index.d.ts.map +1 -1
  42. package/dist/apps/depthai-visualizer/src/index.js +0 -1
  43. package/dist/apps/depthai-visualizer/src/index.js.map +1 -1
  44. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/detection.js +2 -2
  45. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/detection.js.map +1 -1
  46. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/utils.d.ts.map +1 -1
  47. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/utils.js.map +1 -1
  48. package/dist/apps/depthai-visualizer/src/messaging/deserialization.js +5 -5
  49. package/dist/apps/depthai-visualizer/src/messaging/deserialization.js.map +1 -1
  50. package/dist/apps/depthai-visualizer/src/messaging/utils.d.ts +7 -6
  51. package/dist/apps/depthai-visualizer/src/messaging/utils.d.ts.map +1 -1
  52. package/dist/apps/depthai-visualizer/src/messaging/utils.js +2 -2
  53. package/dist/apps/depthai-visualizer/src/messaging/utils.js.map +1 -1
  54. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.d.ts.map +1 -1
  55. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js +3 -0
  56. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js.map +1 -1
  57. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.d.ts.map +1 -1
  58. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js +3 -0
  59. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js.map +1 -1
  60. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.d.ts.map +1 -1
  61. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js +3 -0
  62. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js.map +1 -1
  63. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.d.ts.map +1 -1
  64. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js +3 -0
  65. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js.map +1 -1
  66. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.d.ts.map +1 -1
  67. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js +3 -0
  68. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js.map +1 -1
  69. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.d.ts.map +1 -1
  70. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js +3 -0
  71. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js.map +1 -1
  72. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.d.ts.map +1 -1
  73. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js +3 -0
  74. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js.map +1 -1
  75. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts +7 -4
  76. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts.map +1 -1
  77. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js +15 -2
  78. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js.map +1 -1
  79. package/dist/apps/depthai-visualizer/src/utils/callback-manager.d.ts +1 -1
  80. package/dist/apps/depthai-visualizer/src/utils/callback-manager.d.ts.map +1 -1
  81. package/dist/apps/depthai-visualizer/src/utils/callback-manager.js +5 -5
  82. package/dist/apps/depthai-visualizer/src/utils/callback-manager.js.map +1 -1
  83. package/dist/apps/depthai-visualizer/src/utils/compatibility.d.ts.map +1 -1
  84. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.d.ts.map +1 -1
  85. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js +1 -0
  86. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js.map +1 -1
  87. package/dist/communicator-D9LSiWws.js +147 -0
  88. package/dist/foxglove-protocol-RBwoTi12.js +76 -0
  89. package/dist/{index-DvdDp1CU.js → index-BatOjqHR.js} +4 -5
  90. package/dist/{index-fkPdppby.js → index-BeMujwTx.js} +4 -5
  91. package/dist/{index-yfE-EHjv.js → index-Bmv-vCsr.js} +4 -5
  92. package/dist/{index-BNmANBei.js → index-Bpb1nLXX.js} +4 -5
  93. package/dist/{index-Cv9FekAD.js → index-C38MwKQ5.js} +4 -5
  94. package/dist/{index-DszVVt5Z.js → index-C4Xw5gJf.js} +4 -5
  95. package/dist/{index-r3QAVuN1.js → index-CCjTYhIj.js} +4 -5
  96. package/dist/{index-Bk2FsKKi.js → index-CRzS8jhh.js} +4 -5
  97. package/dist/{index-2U-xZM02.js → index-CTV8k4Ur.js} +4 -5
  98. package/dist/{index-BEeIqwPz.js → index-Cjzn2Mk3.js} +4 -5
  99. package/dist/{index-sbw9t8iK.js → index-CzJG5yoW.js} +4 -5
  100. package/dist/{index-FWvVjhSv.js → index-D2tE4ai8.js} +5 -6
  101. package/dist/{index-lPEkwJ-1.js → index-D8PL1mUz.js} +4 -5
  102. package/dist/{index-CKhCc5vm.js → index-Dx5rKk7S.js} +252 -156
  103. package/dist/{index-nxmrq-HQ.js → index-JdSlhtdz.js} +4 -5
  104. package/dist/{index-Djz0avqZ.js → index-LBWmbzab.js} +4 -5
  105. package/dist/{index-TgQ8-Lib.js → index-fDKFJqYA.js} +4 -5
  106. package/dist/{index-DakMDXW9.js → index-kO40p_fI.js} +4 -5
  107. package/dist/{index-QYS2yYV7.js → index-lcxcWrBB.js} +4 -5
  108. package/dist/index.js +4 -5
  109. package/dist/worker-BX0SIDt0.js +163 -0
  110. package/dist/worker-C6ruK-iB.js +150 -0
  111. package/package.json +2 -2
  112. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts +0 -18
  113. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts.map +0 -1
  114. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js +0 -103
  115. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js.map +0 -1
  116. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.d.ts +0 -12
  117. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.d.ts.map +0 -1
  118. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.js +0 -52
  119. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.js.map +0 -1
  120. package/dist/worker-ByVSTHSI.js +0 -102
  121. package/dist/worker-DlZ2xp8p.js +0 -11
  122. package/dist/worker-utils-BNThsbdN.js +0 -1332
@@ -1,11 +1,11 @@
1
- import { c as commonjsGlobal, g as getAugmentedNamespace, a as getDefaultExportFromCjs } from './worker-utils-BNThsbdN.js';
2
- import { T as Type$1, P as PointsAnnotationType$2, a as Profile, p as protobufsBySchema } from './communicator-ZAqNuwq6.js';
1
+ import { c as commonjsGlobal, g as getAugmentedNamespace, a as getDefaultExportFromCjs, T as Type$1, P as PointsAnnotationType$2, b as Profile, p as protobufsBySchema, B as BinaryOpcode } from './FoxgloveServer-tJZcJH5-.js';
3
2
  import * as React$1 from 'react';
4
3
  import React__default, { useContext, useRef, useLayoutEffect, createContext, useReducer, useState, useCallback, useMemo, forwardRef, createElement, Component, useEffect, useImperativeHandle, Fragment as Fragment$1, Suspense } from 'react';
5
4
  import { createStore, useStore } from 'zustand';
6
5
  import { isParent as isParent$1, getLeaves, createRemoveUpdate, updateTree, getNodeAtPath, createHideUpdate, createDragToUpdates, MosaicContext, MosaicWindowContext } from 'react-mosaic-component';
7
6
  import { useTheme as useTheme$3, alpha, Typography, Divider, Link, Button as Button$1, GlobalStyles, Dialog as Dialog$2, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, DialogContentText, DialogActions, Stack as Stack$3 } from '@mui/material';
8
7
  import { i as isObjectLike, b as baseGetTag, S as Symbol$1, a as isArray, g as getNative, r as root$6, o as overArg, c as isPrototype, d as isArrayLike, e as arrayLikeKeys, M as MapCache, f as isArguments, s as setToString, h as overRest, t as toSource, j as Map$1, k as eq, U as Uint8Array$2, l as isBuffer, m as Stack$2, n as isTypedArray, p as isObject$2, q as isLength, u as isIndex, v as identity$1, w as baseFor, x as baseRest, y as isArrayLikeObject, z as baseAssignValue, A as assignValue, B as tinycolor, C as merge$2, D as instance } from './i18next-C5Qe4-E1.js';
8
+ import { p as parseFoxgloveMessage } from './foxglove-protocol-RBwoTi12.js';
9
9
  import { DndProvider } from 'react-dnd';
10
10
  import { HTML5Backend } from 'react-dnd-html5-backend';
11
11
  import { ThemeContext, __unsafe_useEmotionCache } from '@emotion/react';
@@ -177,11 +177,15 @@ class FoxgloveWebSocketAdapter extends EventTarget {
177
177
  this.dispatchEvent(new MessageEvent("services", event.data));
178
178
  break;
179
179
  }
180
- case 'custom':
180
+ case "service_response":
181
181
  {
182
- this.dispatchEvent(new MessageEvent('custom', event.data));
182
+ // Each service request has its own response listener
183
183
  break;
184
184
  }
185
+ default:
186
+ {
187
+ console.warn(`Foxglove Ws Adapter: Worker sent unexpected message`, event.data);
188
+ }
185
189
  }
186
190
  });
187
191
  }
@@ -219,6 +223,22 @@ class FoxgloveWebSocketAdapter extends EventTarget {
219
223
  this.dispatchEvent(new Event("close"));
220
224
  }
221
225
  }
226
+ subscribe({
227
+ topics
228
+ }) {
229
+ this.#sendToWorker({
230
+ type: 'subscribe',
231
+ data: topics
232
+ });
233
+ }
234
+ unsubscribe({
235
+ topics
236
+ }) {
237
+ this.#sendToWorker({
238
+ type: 'unsubscribe',
239
+ data: topics
240
+ });
241
+ }
222
242
  async request({
223
243
  name,
224
244
  timeout = REQUEST_RESPONSE_TIMEOUT,
@@ -265,13 +285,9 @@ class FoxgloveWebSocketAdapter extends EventTarget {
265
285
  }
266
286
  });
267
287
  }
268
-
269
- // @ts-expect-error TODO: WebRTC hack
270
288
  send(data) {
271
- this.#sendToWorker({
272
- type: "send",
273
- data: data
274
- });
289
+ console.error('Foxglove Ws Aparter Error: raw send was requested', data);
290
+ // this.#sendToWorker({ type: "send", data: data as any });
275
291
  }
276
292
  }
277
293
 
@@ -10940,7 +10956,7 @@ function parseMessageType(type) {
10940
10956
  case Type$1.NV12:
10941
10957
  return ["nv12", 1];
10942
10958
  case Type$1.RGB888i:
10943
- return ["rgb8", 1];
10959
+ return ["rgb8", 3];
10944
10960
  case Type$1.RGB888p:
10945
10961
  return ["rgb8p", 1];
10946
10962
  case Type$1.RGBA8888:
@@ -10963,7 +10979,7 @@ function parseMessage(message) {
10963
10979
  const stride = message.fb?.stride ?? message.sourceFb?.stride ?? null;
10964
10980
  const p2Offset = message.fb?.p2Offset ?? message.sourceFb?.p2Offset ?? null;
10965
10981
  const p1Offset = message.fb?.p1Offset ?? message.sourceFb?.p1Offset ?? null;
10966
- let planeStride = p1Offset !== null && p2Offset !== null ? p2Offset - p1Offset : 0;
10982
+ let planeStride = p1Offset != null && p2Offset != null ? p2Offset - p1Offset : 0;
10967
10983
  if (planeStride <= 0) {
10968
10984
  planeStride = null;
10969
10985
  }
@@ -11541,14 +11557,14 @@ async function deserializeDepthAiMessage(args) {
11541
11557
  height: message.height
11542
11558
  });
11543
11559
  if (message.profile === Profile.AVC) {
11544
- deserializeEncodedFrameH264({
11560
+ await deserializeEncodedFrameH264({
11545
11561
  topic,
11546
11562
  message,
11547
11563
  topicDecoders,
11548
11564
  callback
11549
11565
  });
11550
11566
  } else if (message.profile === Profile.JPEG) {
11551
- deserializeMJPEGFrame({
11567
+ await deserializeMJPEGFrame({
11552
11568
  topic,
11553
11569
  message,
11554
11570
  callback
@@ -11561,16 +11577,16 @@ async function deserializeDepthAiMessage(args) {
11561
11577
  const {
11562
11578
  width,
11563
11579
  height,
11564
- type
11580
+ type: messageType
11565
11581
  } = parseMessage(message);
11566
11582
  topicSizes.set(topic, {
11567
11583
  width,
11568
11584
  height
11569
11585
  });
11570
- switch (type) {
11586
+ switch (messageType) {
11571
11587
  case Type$1.BITSTREAM:
11572
11588
  {
11573
- deserializeEncodedFrameH264({
11589
+ await deserializeEncodedFrameH264({
11574
11590
  topic,
11575
11591
  message,
11576
11592
  topicDecoders,
@@ -11689,6 +11705,7 @@ class MetricsManager {
11689
11705
  metrics = {};
11690
11706
  registerEvent(topic) {
11691
11707
  const currentTime = performance.now();
11708
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
11692
11709
  this.metrics[topic] ??= [];
11693
11710
  this.metrics[topic].unshift(currentTime);
11694
11711
  this.metrics[topic].length = 100;
@@ -11883,44 +11900,49 @@ class WebRtcDataChannel {
11883
11900
  constructor(channel, withFragmentation = false) {
11884
11901
  this.channel = channel;
11885
11902
  this.withFragmentation = withFragmentation;
11886
- this.channel.onerror = event => this.events.emit('error', [event]);
11887
- this.channel.onmessage = async (event) => {
11903
+ this.channel.addEventListener('error', event => this.events.emit('error', [event]));
11904
+ this.channel.addEventListener('message', async (event) => {
11905
+ if (channel.label === 'ping-pong') {
11906
+ this.sendMessage('pong');
11907
+ }
11888
11908
  if (!this.withFragmentation) {
11889
11909
  this.events.emit('message', [event]);
11890
11910
  return;
11891
11911
  }
11892
- const arrayBuffer = await event.data.arrayBuffer();
11893
- const view = new DataView(arrayBuffer);
11894
- const totalChunks = view.getInt32(0);
11895
- const chunkIndex = view.getInt32(4);
11896
- const data = new Uint8Array(arrayBuffer, 8);
11912
+ const buffer = event.data instanceof ArrayBuffer ? event.data : await event.data.arrayBuffer();
11913
+ const view = new DataView(buffer);
11914
+ const totalChunks = view.getUint32(0);
11915
+ const chunkIndex = view.getUint32(4);
11916
+ const data = new Uint8Array(buffer, 8).slice(0);
11897
11917
  if (totalChunks !== 1) {
11898
11918
  this.appendChunk(data);
11899
11919
  if (totalChunks - 1 !== chunkIndex) {
11900
11920
  return;
11901
11921
  }
11902
11922
  }
11903
- const completeData = totalChunks === 1 ? data : new Uint8Array(this.buffer);
11923
+ const completeData = totalChunks === 1 ? data : this.buffer;
11924
+ this.events.emit('message', [
11925
+ new MessageEvent('message', {
11926
+ data: completeData.buffer,
11927
+ }),
11928
+ ]);
11904
11929
  if (totalChunks !== 1) {
11905
11930
  this.buffer = new Uint8Array(0);
11906
11931
  }
11907
- this.events.emit('message', [new MessageEvent('message', {
11908
- data: new Blob([completeData], { type: 'application/octet-stream' })
11909
- })]);
11910
- };
11911
- this.channel.onclose = event => this.events.emit('close', [event]);
11912
- this.channel.onopen = event => {
11932
+ });
11933
+ this.channel.addEventListener('close', event => this.events.emit('close', [event]));
11934
+ this.channel.addEventListener('open', event => {
11913
11935
  this.events.emit('open', [event]);
11914
11936
  for (const message of this.oldMessages) {
11915
11937
  this.sendMessage(message);
11916
11938
  }
11917
11939
  this.oldMessages = [];
11918
- };
11940
+ });
11919
11941
  }
11920
11942
  appendChunk(bytes) {
11921
- const newBuffer = new Uint8Array(this.buffer.length + bytes.length);
11943
+ const newBuffer = new Uint8Array(this.buffer.byteLength + bytes.byteLength);
11922
11944
  newBuffer.set(this.buffer, 0);
11923
- newBuffer.set(bytes, this.buffer.length);
11945
+ newBuffer.set(bytes, this.buffer.byteLength);
11924
11946
  this.buffer = newBuffer;
11925
11947
  }
11926
11948
  get raw() {
@@ -11931,7 +11953,7 @@ class WebRtcDataChannel {
11931
11953
  }
11932
11954
  sendMessage(message) {
11933
11955
  if (this.channel.readyState === 'open') {
11934
- const chunks = (message instanceof DataView && this.withFragmentation) ? makeChunks(message) : [message];
11956
+ const chunks = message instanceof DataView && this.withFragmentation ? makeChunks(message) : [message];
11935
11957
  for (const chunk of chunks) {
11936
11958
  this.channel.send(chunk);
11937
11959
  }
@@ -11948,20 +11970,20 @@ class WebRtcDataChannel {
11948
11970
  */
11949
11971
  onTextMessage(callback) {
11950
11972
  return this.events.on('message', async (event) => {
11951
- const buffer = await event.data.arrayBuffer();
11973
+ const buffer = event.data instanceof ArrayBuffer ? event.data : await event.data.arrayBuffer();
11952
11974
  const message = new TextDecoder('utf-8').decode(buffer);
11953
11975
  callback(message);
11954
11976
  });
11955
11977
  }
11956
11978
  on(event, callback) {
11979
+ const specificMessageEvents = ['message:binary', 'message:string', 'message:json'];
11980
+ if (!specificMessageEvents.includes(event)) {
11981
+ return this.events.on(event, callback);
11982
+ }
11957
11983
  return this.events.on('message', async (rawEvent) => {
11958
- if (!['message:binary', 'message:string', 'message:json'].includes(event)) {
11959
- callback(rawEvent);
11960
- return;
11961
- }
11962
- const buffer = await rawEvent.data.arrayBuffer();
11963
- const view = new DataView(buffer);
11984
+ const buffer = rawEvent.data instanceof ArrayBuffer ? rawEvent.data : await rawEvent.data.arrayBuffer();
11964
11985
  if (event === 'message:binary') {
11986
+ const view = new DataView(buffer);
11965
11987
  callback(view);
11966
11988
  }
11967
11989
  else {
@@ -11984,11 +12006,11 @@ class WebRtcConnection {
11984
12006
  events = new EventEmitter();
11985
12007
  onIceCandidate;
11986
12008
  onConnectionEstablished;
11987
- constructor(props) {
11988
- this.iceServers = props.iceServers;
11989
- this.onIceCandidate = props.onCandidate;
11990
- this.onConnectionEstablished = props.onConnectionEstablished;
11991
- this.#peerConnection = this.createPeerConnection();
12009
+ constructor(args) {
12010
+ this.iceServers = args.iceServers;
12011
+ this.onIceCandidate = args.onCandidate;
12012
+ this.onConnectionEstablished = args.onConnectionEstablished;
12013
+ this.#peerConnection = this.createPeerConnection(args.withFragmentation);
11992
12014
  }
11993
12015
  createPeerConnection(withFragmentation = false) {
11994
12016
  const config = {
@@ -12018,13 +12040,10 @@ class WebRtcConnection {
12018
12040
  this.onIceCandidate(event.candidate);
12019
12041
  }
12020
12042
  };
12021
- connection.ondatachannel = event => {
12022
- const channel = new WebRtcDataChannel(event.channel, withFragmentation);
12023
- if (channel.label === 'ping-pong') {
12024
- channel.on('message', () => channel.sendMessage('pong'));
12025
- }
12043
+ connection.addEventListener('datachannel', event => {
12044
+ const channel = new WebRtcDataChannel(event.channel, event.channel.label !== 'ping-pong' && withFragmentation);
12026
12045
  this.events.emit('data_channel', [channel]);
12027
- };
12046
+ });
12028
12047
  return connection;
12029
12048
  }
12030
12049
  get peerConnection() {
@@ -12160,9 +12179,9 @@ class WebRtcClient {
12160
12179
  // console.debug('[WebRTC] Offer accepted. Setting remote description..');
12161
12180
  await this.connection.setRemoteDescription(kind, candidate);
12162
12181
  // console.debug('[WebRTC] Set remote description');
12163
- for (const candidate of this.iceCandidates) {
12182
+ for (const iceCandidate of this.iceCandidates) {
12164
12183
  // console.debug('[WebRTC] Adding stored ICE candidate');
12165
- this.connection.addIceCandidate(JSON.parse(candidate));
12184
+ void this.connection.addIceCandidate(JSON.parse(iceCandidate));
12166
12185
  }
12167
12186
  this.iceCandidates = [];
12168
12187
  if (kind === 'offer') {
@@ -12212,6 +12231,7 @@ class WebRtcClient {
12212
12231
  });
12213
12232
  },
12214
12233
  onConnectionEstablished: () => this.disconnectSignalingServer('P2P connection established'),
12234
+ withFragmentation: this.config.withFragmentation,
12215
12235
  });
12216
12236
  this.events.emit('connection_established', [this.connection]);
12217
12237
  }
@@ -12227,19 +12247,37 @@ class WebRtcClient {
12227
12247
  // file, You can obtain one at http://mozilla.org/MPL/2.0/
12228
12248
 
12229
12249
  class ArtificialWorker extends EventTarget {
12250
+ #selfTarget = new EventTarget();
12251
+
12252
+ // Post message from main to worker
12230
12253
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
12231
12254
  postMessage(data, _transferable) {
12232
12255
  const event = new MessageEvent('message', {
12233
12256
  data
12234
12257
  });
12235
- super.dispatchEvent(event);
12258
+ this.#selfTarget.dispatchEvent(event);
12236
12259
  }
12237
12260
 
12261
+ // Listen for worker-to-main messages
12238
12262
  // @ts-expect-error Make it typed
12239
12263
  addEventListener(type, callback) {
12240
12264
  super.addEventListener(type, callback);
12241
12265
  }
12242
- terminate() {}
12266
+
12267
+ // Post message from worker to main
12268
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
12269
+ postMessageToMain(data, _transferable) {
12270
+ const event = new MessageEvent('message', {
12271
+ data
12272
+ });
12273
+ super.dispatchEvent(event);
12274
+ }
12275
+
12276
+ // Listen for main-to-worker messages
12277
+ // @ts-expect-error Make it typed
12278
+ addEventListenerFromMain(type, callback) {
12279
+ this.#selfTarget.addEventListener(type, callback);
12280
+ }
12243
12281
  }
12244
12282
 
12245
12283
  // This Source Code Form is subject to the terms of the Mozilla Public
@@ -12255,7 +12293,7 @@ class WebRtcBridge extends ArtificialWorker {
12255
12293
  #systemChannel = null;
12256
12294
  constructor() {
12257
12295
  super();
12258
- this.#worker = new Worker(new URL("worker-ByVSTHSI.js", import.meta.url), {
12296
+ this.#worker = new Worker(new URL("worker-BX0SIDt0.js", import.meta.url), {
12259
12297
  type: "module"
12260
12298
  });
12261
12299
  this.#setupArtificialWorker();
@@ -12264,15 +12302,47 @@ class WebRtcBridge extends ArtificialWorker {
12264
12302
  this.#worker.terminate();
12265
12303
  }
12266
12304
  #setupArtificialWorker() {
12267
- this.addEventListener('message', event => {
12305
+ this.addEventListenerFromMain("message", event => {
12268
12306
  switch (event.data.type) {
12269
- case 'open':
12307
+ case "open":
12270
12308
  {
12271
- if ('config' in event.data.data) {
12272
- this.#createWebRtc(event.data.data.config);
12309
+ if ("config" in event.data.data) {
12310
+ this.#createWebRtc({
12311
+ withFragmentation: true,
12312
+ ...event.data.data.config
12313
+ });
12273
12314
  }
12274
12315
  break;
12275
12316
  }
12317
+ case "close":
12318
+ {
12319
+ this.#webrtc?.dispose("Client requested connection close");
12320
+ this.terminate();
12321
+ break;
12322
+ }
12323
+ case "call_service":
12324
+ {
12325
+ this.#worker.postMessage({
12326
+ kind: "serviceCall",
12327
+ data: {
12328
+ message: event.data.data
12329
+ }
12330
+ });
12331
+ break;
12332
+ }
12333
+ case "unsubscribe":
12334
+ case "subscribe":
12335
+ {
12336
+ this.#worker.postMessage({
12337
+ kind: event.data.type,
12338
+ data: {
12339
+ message: {
12340
+ topics: event.data.data
12341
+ }
12342
+ }
12343
+ });
12344
+ break;
12345
+ }
12276
12346
  }
12277
12347
  });
12278
12348
  }
@@ -12282,51 +12352,51 @@ class WebRtcBridge extends ArtificialWorker {
12282
12352
  this.#handleMessages();
12283
12353
  }
12284
12354
  #handleWebRtc(client) {
12355
+ client.on("error", error => {
12356
+ console.error("WebRtc Client Failed", error);
12357
+ });
12285
12358
  client.on("connection_established", connection => {
12286
12359
  connection.on("data_channel", channel => {
12287
- channel.on('close', () => {
12360
+ channel.on("close", () => {
12288
12361
  if (channel.label !== MESSAGE_CHANNEL_NAME && channel.label !== SYSTEM_CHANNEL_NAME) {
12289
12362
  return;
12290
12363
  }
12291
12364
  this.#worker.postMessage({
12292
12365
  kind: "connection",
12293
12366
  data: {
12294
- channel: channel.label === MESSAGE_CHANNEL_NAME ? 'message' : 'system',
12367
+ channel: channel.label === MESSAGE_CHANNEL_NAME ? "message" : "system",
12295
12368
  ready: false
12296
12369
  }
12297
12370
  });
12371
+ this.postMessageToMain({
12372
+ type: "close"
12373
+ });
12298
12374
  });
12299
12375
  if (channel.label === MESSAGE_CHANNEL_NAME) {
12300
12376
  this.#messageChannel = channel;
12301
12377
  channel.on("message:binary", async view => {
12302
- const operation = view.getUint8(0);
12303
- const action = operation === 0x01 ? 'message' : operation === 0x03 ? 'service_response' : 'other';
12304
- if (action === 'message') {
12305
- const subscriptionId = view.getUint32(1);
12306
- const payload = new DataView(view.buffer, view.byteOffset + 1 + 4 + 8);
12378
+ const message = parseFoxgloveMessage(view);
12379
+ if (!message) {
12380
+ return;
12381
+ }
12382
+ if (message.op === BinaryOpcode.MESSAGE_DATA) {
12307
12383
  this.#worker.postMessage({
12308
12384
  kind: "genericMessage",
12309
12385
  data: {
12310
- message: {
12311
- subscriptionId,
12312
- data: payload
12313
- }
12386
+ message
12314
12387
  }
12315
- }, [payload.buffer]);
12388
+ }, [message.data.buffer]);
12316
12389
  } else {
12317
- const callId = view.getUint32(1 + 4); // op-code + service-id
12318
- const encodingLength = view.getUint32(1 + 4 + 4); // op-code + service-id + call-id
12319
- const payload = new DataView(view.buffer, view.byteOffset + 1 + 4 + 4 + 4 + encodingLength); // op-code + service-id + call-id + encoding-length
12320
12390
  this.#worker.postMessage({
12321
12391
  kind: "systemMessage",
12322
12392
  data: {
12323
12393
  message: {
12324
- op: 'serviceResponse',
12325
- callId,
12326
- data: payload
12394
+ op: "serviceResponse",
12395
+ callId: message.callId,
12396
+ data: message.data
12327
12397
  }
12328
12398
  }
12329
- }, [payload.buffer]);
12399
+ }, [message.data.buffer]);
12330
12400
  }
12331
12401
  });
12332
12402
  } else if (channel.label === SYSTEM_CHANNEL_NAME) {
@@ -12340,13 +12410,20 @@ class WebRtcBridge extends ArtificialWorker {
12340
12410
  });
12341
12411
  });
12342
12412
  }
12343
- this.#worker.postMessage({
12344
- kind: "connection",
12345
- data: {
12346
- channel: channel.label === MESSAGE_CHANNEL_NAME ? 'message' : 'system',
12347
- ready: true
12348
- }
12349
- });
12413
+ if (channel.label === MESSAGE_CHANNEL_NAME || channel.label === SYSTEM_CHANNEL_NAME) {
12414
+ this.#worker.postMessage({
12415
+ kind: "connection",
12416
+ data: {
12417
+ channel: channel.label === MESSAGE_CHANNEL_NAME ? "message" : "system",
12418
+ ready: true
12419
+ }
12420
+ });
12421
+ }
12422
+ if (this.#systemChannel?.raw.readyState === "open" && this.#messageChannel?.raw.readyState === "open") {
12423
+ this.postMessageToMain({
12424
+ type: "open"
12425
+ });
12426
+ }
12350
12427
  });
12351
12428
  connection.on("connection_closed", () => {
12352
12429
  this.#worker.postMessage({
@@ -12356,15 +12433,18 @@ class WebRtcBridge extends ArtificialWorker {
12356
12433
  ready: false
12357
12434
  }
12358
12435
  });
12436
+ this.postMessageToMain({
12437
+ type: "close"
12438
+ });
12359
12439
  });
12360
12440
  });
12361
12441
  }
12362
12442
  #handleMessages() {
12363
- this.#worker.addEventListener('message', event => {
12443
+ this.#worker.addEventListener("message", event => {
12364
12444
  switch (event.data.type) {
12365
- case 'send':
12445
+ case "send":
12366
12446
  {
12367
- const channel = event.data.data.channel === 'message' ? this.#messageChannel : this.#systemChannel;
12447
+ const channel = event.data.data.channel === "message" ? this.#messageChannel : this.#systemChannel;
12368
12448
  if (channel) {
12369
12449
  channel.sendMessage(event.data.data.data);
12370
12450
  }
@@ -12372,7 +12452,7 @@ class WebRtcBridge extends ArtificialWorker {
12372
12452
  }
12373
12453
  default:
12374
12454
  {
12375
- this.postMessage(event.data);
12455
+ this.postMessageToMain(event.data);
12376
12456
  }
12377
12457
  }
12378
12458
  });
@@ -12389,21 +12469,20 @@ class VisualizerConnection extends FoxgloveConnection {
12389
12469
  #adapter;
12390
12470
  constructor({
12391
12471
  type,
12392
- data,
12393
- worker
12472
+ data
12394
12473
  }) {
12395
12474
  super(type === 'ws' ? data.connectionUrl : data.config.clientId);
12396
- let finalWorker = worker;
12475
+ let worker;
12397
12476
  if (type === 'ws') {
12398
12477
  this.#url = data.connectionUrl;
12399
- finalWorker ??= new Worker(new URL("worker-DlZ2xp8p.js", import.meta.url), {
12478
+ worker = new Worker(new URL("worker-C6ruK-iB.js", import.meta.url), {
12400
12479
  type: "module"
12401
12480
  });
12402
12481
  } else {
12403
12482
  this.#config = data.config;
12404
- finalWorker ??= new WebRtcBridge();
12483
+ worker = new WebRtcBridge();
12405
12484
  }
12406
- this.#open(finalWorker);
12485
+ this.#open(worker);
12407
12486
  }
12408
12487
  close() {
12409
12488
  this.#adapter?.close();
@@ -12418,6 +12497,12 @@ class VisualizerConnection extends FoxgloveConnection {
12418
12497
  const response = await this.#adapter?.request(args);
12419
12498
  return response ?? null;
12420
12499
  }
12500
+ subscribe(args) {
12501
+ this.#adapter?.subscribe(args);
12502
+ }
12503
+ unsubscribe(args) {
12504
+ this.#adapter?.unsubscribe(args);
12505
+ }
12421
12506
 
12422
12507
  // eslint-disable-next-line no-restricted-syntax
12423
12508
  get connected() {
@@ -12428,25 +12513,22 @@ class VisualizerConnection extends FoxgloveConnection {
12428
12513
  wsUrl: this.#url,
12429
12514
  config: this.#config
12430
12515
  }, worker);
12431
- this.#adapter.addEventListener("open", this.#onOpen.bind(this));
12516
+ this.#adapter.addEventListener("open", () => {
12517
+ this.playerPresence = PlayerPresence.PRESENT;
12518
+ this.emitState();
12519
+ });
12520
+ this.#adapter.addEventListener("close", () => {
12521
+ this.playerPresence = PlayerPresence.NOT_PRESENT;
12522
+ this.emitState();
12523
+ });
12524
+ this.#adapter.addEventListener("error", _event => {
12525
+ this.messageEvent = null;
12526
+ this.playerPresence = PlayerPresence.ERROR;
12527
+ this.emitState();
12528
+ });
12432
12529
  this.#adapter.addEventListener("message", event => {
12433
12530
  this.onMessagePacket.bind(this)(event);
12434
12531
  });
12435
- this.#adapter.addEventListener("close", this.#onClose.bind(this));
12436
- this.#adapter.addEventListener("error", this.#onClose.bind(this));
12437
- };
12438
- #onOpen = () => {
12439
- this.playerPresence = PlayerPresence.PRESENT;
12440
- this.emitState();
12441
- };
12442
- #onClose = () => {
12443
- this.playerPresence = PlayerPresence.NOT_PRESENT;
12444
- this.emitState();
12445
- };
12446
- #onError = _event => {
12447
- this.messageEvent = null;
12448
- this.playerPresence = PlayerPresence.ERROR;
12449
- this.emitState();
12450
12532
  };
12451
12533
  }
12452
12534
 
@@ -89581,7 +89663,7 @@ function legacy(parser) {
89581
89663
  return new LanguageSupport(StreamLanguage.define(parser));
89582
89664
  }
89583
89665
  function sql$1(dialectName) {
89584
- return import('./index-Djz0avqZ.js').then(m => m.sql({ dialect: m[dialectName] }));
89666
+ return import('./index-LBWmbzab.js').then(m => m.sql({ dialect: m[dialectName] }));
89585
89667
  }
89586
89668
  /**
89587
89669
  An array of language descriptions for known language packages.
@@ -89592,7 +89674,7 @@ const languages = [
89592
89674
  name: "C",
89593
89675
  extensions: ["c", "h", "ino"],
89594
89676
  load() {
89595
- return import('./index-nxmrq-HQ.js').then(m => m.cpp());
89677
+ return import('./index-JdSlhtdz.js').then(m => m.cpp());
89596
89678
  }
89597
89679
  }),
89598
89680
  /*@__PURE__*/LanguageDescription.of({
@@ -89600,7 +89682,7 @@ const languages = [
89600
89682
  alias: ["cpp"],
89601
89683
  extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
89602
89684
  load() {
89603
- return import('./index-nxmrq-HQ.js').then(m => m.cpp());
89685
+ return import('./index-JdSlhtdz.js').then(m => m.cpp());
89604
89686
  }
89605
89687
  }),
89606
89688
  /*@__PURE__*/LanguageDescription.of({
@@ -89620,7 +89702,7 @@ const languages = [
89620
89702
  name: "Go",
89621
89703
  extensions: ["go"],
89622
89704
  load() {
89623
- return import('./index-QYS2yYV7.js').then(m => m.go());
89705
+ return import('./index-lcxcWrBB.js').then(m => m.go());
89624
89706
  }
89625
89707
  }),
89626
89708
  /*@__PURE__*/LanguageDescription.of({
@@ -89635,7 +89717,7 @@ const languages = [
89635
89717
  name: "Java",
89636
89718
  extensions: ["java"],
89637
89719
  load() {
89638
- return import('./index-DakMDXW9.js').then(m => m.java());
89720
+ return import('./index-kO40p_fI.js').then(m => m.java());
89639
89721
  }
89640
89722
  }),
89641
89723
  /*@__PURE__*/LanguageDescription.of({
@@ -89651,7 +89733,7 @@ const languages = [
89651
89733
  alias: ["json5"],
89652
89734
  extensions: ["json", "map"],
89653
89735
  load() {
89654
- return import('./index-Cv9FekAD.js').then(m => m.json());
89736
+ return import('./index-C38MwKQ5.js').then(m => m.json());
89655
89737
  }
89656
89738
  }),
89657
89739
  /*@__PURE__*/LanguageDescription.of({
@@ -89665,14 +89747,14 @@ const languages = [
89665
89747
  name: "LESS",
89666
89748
  extensions: ["less"],
89667
89749
  load() {
89668
- return import('./index-2U-xZM02.js').then(m => m.less());
89750
+ return import('./index-CTV8k4Ur.js').then(m => m.less());
89669
89751
  }
89670
89752
  }),
89671
89753
  /*@__PURE__*/LanguageDescription.of({
89672
89754
  name: "Liquid",
89673
89755
  extensions: ["liquid"],
89674
89756
  load() {
89675
- return import('./index-DszVVt5Z.js').then(m => m.liquid());
89757
+ return import('./index-C4Xw5gJf.js').then(m => m.liquid());
89676
89758
  }
89677
89759
  }),
89678
89760
  /*@__PURE__*/LanguageDescription.of({
@@ -89698,7 +89780,7 @@ const languages = [
89698
89780
  name: "PHP",
89699
89781
  extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
89700
89782
  load() {
89701
- return import('./index-yfE-EHjv.js').then(m => m.php());
89783
+ return import('./index-Bmv-vCsr.js').then(m => m.php());
89702
89784
  }
89703
89785
  }),
89704
89786
  /*@__PURE__*/LanguageDescription.of({
@@ -89715,28 +89797,28 @@ const languages = [
89715
89797
  extensions: ["BUILD", "bzl", "py", "pyw"],
89716
89798
  filename: /^(BUCK|BUILD)$/,
89717
89799
  load() {
89718
- return import('./index-sbw9t8iK.js').then(m => m.python());
89800
+ return import('./index-CzJG5yoW.js').then(m => m.python());
89719
89801
  }
89720
89802
  }),
89721
89803
  /*@__PURE__*/LanguageDescription.of({
89722
89804
  name: "Rust",
89723
89805
  extensions: ["rs"],
89724
89806
  load() {
89725
- return import('./index-Bk2FsKKi.js').then(m => m.rust());
89807
+ return import('./index-CRzS8jhh.js').then(m => m.rust());
89726
89808
  }
89727
89809
  }),
89728
89810
  /*@__PURE__*/LanguageDescription.of({
89729
89811
  name: "Sass",
89730
89812
  extensions: ["sass"],
89731
89813
  load() {
89732
- return import('./index-TgQ8-Lib.js').then(m => m.sass({ indented: true }));
89814
+ return import('./index-fDKFJqYA.js').then(m => m.sass({ indented: true }));
89733
89815
  }
89734
89816
  }),
89735
89817
  /*@__PURE__*/LanguageDescription.of({
89736
89818
  name: "SCSS",
89737
89819
  extensions: ["scss"],
89738
89820
  load() {
89739
- return import('./index-TgQ8-Lib.js').then(m => m.sass());
89821
+ return import('./index-fDKFJqYA.js').then(m => m.sass());
89740
89822
  }
89741
89823
  }),
89742
89824
  /*@__PURE__*/LanguageDescription.of({
@@ -89767,7 +89849,7 @@ const languages = [
89767
89849
  name: "WebAssembly",
89768
89850
  extensions: ["wat", "wast"],
89769
89851
  load() {
89770
- return import('./index-DvdDp1CU.js').then(m => m.wast());
89852
+ return import('./index-BatOjqHR.js').then(m => m.wast());
89771
89853
  }
89772
89854
  }),
89773
89855
  /*@__PURE__*/LanguageDescription.of({
@@ -89775,7 +89857,7 @@ const languages = [
89775
89857
  alias: ["rss", "wsdl", "xsd"],
89776
89858
  extensions: ["xml", "xsl", "xsd", "svg"],
89777
89859
  load() {
89778
- return import('./index-BNmANBei.js').then(m => m.xml());
89860
+ return import('./index-Bpb1nLXX.js').then(m => m.xml());
89779
89861
  }
89780
89862
  }),
89781
89863
  /*@__PURE__*/LanguageDescription.of({
@@ -89783,7 +89865,7 @@ const languages = [
89783
89865
  alias: ["yml"],
89784
89866
  extensions: ["yaml", "yml"],
89785
89867
  load() {
89786
- return import('./index-BEeIqwPz.js').then(m => m.yaml());
89868
+ return import('./index-Cjzn2Mk3.js').then(m => m.yaml());
89787
89869
  }
89788
89870
  }),
89789
89871
  // Legacy modes ported from CodeMirror 5
@@ -90579,13 +90661,13 @@ const languages = [
90579
90661
  name: "Vue",
90580
90662
  extensions: ["vue"],
90581
90663
  load() {
90582
- return import('./index-lPEkwJ-1.js').then(m => m.vue());
90664
+ return import('./index-D8PL1mUz.js').then(m => m.vue());
90583
90665
  }
90584
90666
  }),
90585
90667
  /*@__PURE__*/LanguageDescription.of({
90586
90668
  name: "Angular Template",
90587
90669
  load() {
90588
- return import('./index-r3QAVuN1.js').then(m => m.angular());
90670
+ return import('./index-CCjTYhIj.js').then(m => m.angular());
90589
90671
  }
90590
90672
  })
90591
90673
  ];
@@ -161315,7 +161397,7 @@ const PanelAnnotationButton = ({
161315
161397
  const handleClick = React__default.useCallback(event => {
161316
161398
  event.preventDefault();
161317
161399
  onClick();
161318
- }, []);
161400
+ }, [onClick]);
161319
161401
  return /*#__PURE__*/React__default.createElement(DropdownMenuItem, {
161320
161402
  onClick: handleClick
161321
161403
  }, /*#__PURE__*/React__default.createElement(Flex, {
@@ -161346,23 +161428,33 @@ const PanelToolbar = ({
161346
161428
  return () => {
161347
161429
  clearInterval(interval);
161348
161430
  };
161431
+ // eslint-disable-next-line react-hooks/exhaustive-deps
161349
161432
  }, []);
161350
161433
  const [annotationsOpened, setAnnotationsOpened] = React__default.useState(false);
161351
- const hasExtra = React__default.useMemo(() => detections.some(topic => topic.extra && !topic.enabled), [detections]);
161434
+ const hasExtra = React__default.useMemo(() => detections.some(detection => detection.extra && !detection.enabled), [detections]);
161352
161435
  const [extraVisible, setExtraVisible] = React__default.useState(false);
161353
161436
  const onToggleTopic = React__default.useCallback(toggleTopicName => {
161354
- setDetections?.(current => current.map(topic => ({
161355
- ...topic,
161356
- ...(toggleTopicName === topic.name && {
161357
- enabled: !topic.enabled
161437
+ setDetections?.(current => current.map(detection => ({
161438
+ ...detection,
161439
+ ...(toggleTopicName === detection.name && {
161440
+ enabled: !detection.enabled
161358
161441
  })
161359
161442
  })));
161360
- }, [detections, setDetections]);
161443
+ }, [setDetections]);
161361
161444
 
161362
161445
  // TODO: show only when debug mode is ON
161363
161446
  const name = React__default.useMemo(() => {
161364
- return `${topic} - ${metrics?.inputFPS || 0}/${metrics?.postDecodeFPS || 0} FPS`;
161447
+ return `${topic} - ${metrics?.inputFPS ?? 0}/${metrics?.postDecodeFPS ?? 0} FPS`;
161365
161448
  }, [topic, metrics]);
161449
+ const makeDetection = React__default.useCallback((detection, {
161450
+ extra
161451
+ }) => (extra ? detection.extra && !detection.enabled : !detection.extra || detection.enabled) && /*#__PURE__*/React__default.createElement(PanelAnnotationButton, {
161452
+ key: detection.name,
161453
+ topic: detection,
161454
+ onClick: () => {
161455
+ onToggleTopic(detection.name);
161456
+ }
161457
+ }), [onToggleTopic]);
161366
161458
  return /*#__PURE__*/React__default.createElement(Flex, {
161367
161459
  direction: "row",
161368
161460
  gap: "sm",
@@ -161390,12 +161482,8 @@ const PanelToolbar = ({
161390
161482
  borderRadius: 0,
161391
161483
  borderTopRightRadius: 8
161392
161484
  }
161393
- })), /*#__PURE__*/React__default.createElement(DropdownMenuContent, null, detections.map(topic => (!topic.extra || topic.enabled) && /*#__PURE__*/React__default.createElement(PanelAnnotationButton, {
161394
- key: topic.name,
161395
- topic: topic,
161396
- onClick: () => {
161397
- onToggleTopic(topic.name);
161398
- }
161485
+ })), /*#__PURE__*/React__default.createElement(DropdownMenuContent, null, extraVisible && detections.map(detection => makeDetection(detection, {
161486
+ extra: false
161399
161487
  })), hasExtra && /*#__PURE__*/React__default.createElement(Button, {
161400
161488
  width: "full",
161401
161489
  paddingY: "xs",
@@ -161408,16 +161496,12 @@ const PanelToolbar = ({
161408
161496
  style: {
161409
161497
  borderRadius: 4
161410
161498
  }
161411
- }, extraVisible ? "Less" : "More"), extraVisible && detections.map(topic => topic.extra && !topic.enabled && /*#__PURE__*/React__default.createElement(PanelAnnotationButton, {
161412
- key: topic.name,
161413
- topic: topic,
161414
- onClick: () => {
161415
- onToggleTopic(topic.name);
161416
- }
161499
+ }, extraVisible ? "Less" : "More"), extraVisible && detections.map(detection => makeDetection(detection, {
161500
+ extra: true
161417
161501
  })))), kind === 'pointCloud' && /*#__PURE__*/React__default.createElement(Tooltip, {
161418
161502
  content: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Label$3, {
161419
161503
  text: "To move camera:"
161420
- }), /*#__PURE__*/React__default.createElement("ul", null, /*#__PURE__*/React__default.createElement("li", null, "w - Move camera forward"), /*#__PURE__*/React__default.createElement("li", null, "a - Move camera backward"), /*#__PURE__*/React__default.createElement("li", null, "s - Move camera to the left"), /*#__PURE__*/React__default.createElement("li", null, "d - Move camera to the right"), /*#__PURE__*/React__default.createElement("li", null, "Scroll \u2013 Zoom in and out"), /*#__PURE__*/React__default.createElement("li", null, "Drag \u2013 Move camera parallel to the ground"), /*#__PURE__*/React__default.createElement("li", null, "Right-click + Drag horizontally \u2013 Rotate the camera around the world's z-axis"), /*#__PURE__*/React__default.createElement("li", null, "Right-click + Drag vertically \u2013 Pan the camera around the world's x- and y- axes")))
161504
+ }), /*#__PURE__*/React__default.createElement("ul", null, /*#__PURE__*/React__default.createElement("li", null, "w - Move camera forward"), /*#__PURE__*/React__default.createElement("li", null, "a - Move camera backward"), /*#__PURE__*/React__default.createElement("li", null, "s - Move camera to the left"), /*#__PURE__*/React__default.createElement("li", null, "d - Move camera to the right"), /*#__PURE__*/React__default.createElement("li", null, "Scroll \u2013 Zoom in and out"), /*#__PURE__*/React__default.createElement("li", null, "Drag \u2013 Move camera parallel to the ground"), /*#__PURE__*/React__default.createElement("li", null, `Right-click + Drag horizontally Rotate the camera around the world's z-axis`), /*#__PURE__*/React__default.createElement("li", null, `Right-click + Drag vertically Pan the camera around the world's x- and y- axes`)))
161421
161505
  }, /*#__PURE__*/React__default.createElement(Button, {
161422
161506
  variant: "ghost",
161423
161507
  colorVariant: "white",
@@ -161454,10 +161538,22 @@ const Panel = ({
161454
161538
  annotationTopics = [],
161455
161539
  extraAnnotationTopics = []
161456
161540
  }) => {
161541
+ const connections = useConnections();
161457
161542
  const [detections, setDetections] = React__default.useState([]);
161458
161543
  React__default.useEffect(() => {
161459
161544
  if (!disableAnnotations) {
161460
- setDetections(current => [...rawToAnnotations(annotationTopics, 'main', current), ...rawToAnnotations(extraAnnotationTopics, 'extra', current)]);
161545
+ setDetections(current => {
161546
+ const newAnnotations = [...rawToAnnotations(annotationTopics, 'main', current), ...rawToAnnotations(extraAnnotationTopics, 'extra', current)];
161547
+ for (const connection of connections) {
161548
+ connection.unsubscribe({
161549
+ topics: current.map(c => c.name)
161550
+ });
161551
+ connection.subscribe({
161552
+ topics: newAnnotations.filter(c => c.enabled).map(c => c.name)
161553
+ });
161554
+ }
161555
+ return newAnnotations;
161556
+ });
161461
161557
  }
161462
161558
  // eslint-disable-next-line react-hooks/exhaustive-deps
161463
161559
  }, [JSON.stringify(annotationTopics), JSON.stringify(extraAnnotationTopics)]);
@@ -161486,7 +161582,7 @@ const Panel = ({
161486
161582
  }, children))))));
161487
161583
  };
161488
161584
 
161489
- const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-FWvVjhSv.js'));
161585
+ const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-D2tE4ai8.js'));
161490
161586
  const ImagePanelBody = ({
161491
161587
  topic
161492
161588
  }) => {
@@ -161521,7 +161617,7 @@ const ImagePanel = /*#__PURE__*/React__default.memo(function ImagePanel(props) {
161521
161617
  // License, v2.0. If a copy of the MPL was not distributed with this
161522
161618
  // file, You can obtain one at http://mozilla.org/MPL/2.0/
161523
161619
 
161524
- const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-fkPdppby.js'));
161620
+ const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-BeMujwTx.js'));
161525
161621
  const PointCloudPanelBody = ({
161526
161622
  topic
161527
161623
  }) => {