@luxonis/visualizer-protobuf 2.0.0 → 2.0.1

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 (91) hide show
  1. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts +3 -2
  2. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts.map +1 -1
  3. package/dist/apps/depthai-visualizer/src/connection/adapter.js.map +1 -1
  4. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts +1 -1
  5. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts.map +1 -1
  6. package/dist/apps/depthai-visualizer/src/connection/communicator.js +1 -1
  7. package/dist/apps/depthai-visualizer/src/connection/communicator.js.map +1 -1
  8. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts +3 -1
  9. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts.map +1 -1
  10. package/dist/apps/depthai-visualizer/src/connection/connection.js +3 -2
  11. package/dist/apps/depthai-visualizer/src/connection/connection.js.map +1 -1
  12. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts +8 -0
  13. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts.map +1 -0
  14. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js +137 -0
  15. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js.map +1 -0
  16. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts +43 -26
  17. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts.map +1 -1
  18. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js +59 -92
  19. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js.map +1 -1
  20. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker.js +13 -2
  21. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker.js.map +1 -1
  22. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js +1 -1
  23. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js.map +1 -1
  24. package/dist/apps/depthai-visualizer/src/index.d.ts +0 -1
  25. package/dist/apps/depthai-visualizer/src/index.d.ts.map +1 -1
  26. package/dist/apps/depthai-visualizer/src/index.js +0 -1
  27. package/dist/apps/depthai-visualizer/src/index.js.map +1 -1
  28. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/custom.d.ts.map +1 -1
  29. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/custom.js +37 -17
  30. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/custom.js.map +1 -1
  31. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.d.ts.map +1 -1
  32. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js +0 -3
  33. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js.map +1 -1
  34. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.d.ts.map +1 -1
  35. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js +0 -3
  36. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js.map +1 -1
  37. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.d.ts.map +1 -1
  38. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js +0 -3
  39. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js.map +1 -1
  40. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.d.ts.map +1 -1
  41. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js +0 -3
  42. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js.map +1 -1
  43. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.d.ts.map +1 -1
  44. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js +0 -3
  45. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js.map +1 -1
  46. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.d.ts.map +1 -1
  47. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js +0 -3
  48. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js.map +1 -1
  49. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.d.ts.map +1 -1
  50. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js +0 -3
  51. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js.map +1 -1
  52. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts +6 -0
  53. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts.map +1 -0
  54. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js +16 -0
  55. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js.map +1 -0
  56. package/dist/apps/depthai-visualizer/src/utils/encoding.d.ts.map +1 -1
  57. package/dist/{communicator-D_EeiIbd.js → communicator-ZAqNuwq6.js} +37 -23
  58. package/dist/{index-doJtQKmP.js → index-BPkCb-qN.js} +3 -4
  59. package/dist/{index-Al0pDnqr.js → index-BS1BKdpU.js} +3 -4
  60. package/dist/{index-DpXY8ing.js → index-BarbRpkf.js} +3 -4
  61. package/dist/{index-CnbrHWCd.js → index-Bg_SBKcj.js} +3 -4
  62. package/dist/{index-BOSrUvKZ.js → index-C1jY05Dy.js} +3 -4
  63. package/dist/{index-QNisWGZ4.js → index-CKhCSBGi.js} +3 -4
  64. package/dist/{index-CgoOLCnB.js → index-CLrFiqp0.js} +10 -7
  65. package/dist/{index-r1jTO4Ay.js → index-COiPTu-O.js} +3 -4
  66. package/dist/{index-DudYiuIt.js → index-CdE_fknn.js} +3 -4
  67. package/dist/{index-BeQsiPfT.js → index-D6Z2XgEd.js} +3 -4
  68. package/dist/{index-IoSJKto7.js → index-D7G90Nuw.js} +4 -5
  69. package/dist/{index-BfF6NM_p.js → index-D8Bx_kL-.js} +3 -4
  70. package/dist/{index-FOw7-sDA.js → index-DFFtL_uP.js} +3 -4
  71. package/dist/{index-D-Et9RVh.js → index-DULznPlC.js} +3 -4
  72. package/dist/{index-DQCAxiet.js → index-D_KeDxU5.js} +544 -44
  73. package/dist/{index-BtdqjdG0.js → index-MKv43hnI.js} +3 -4
  74. package/dist/{index-By94udNp.js → index-PZaaEO31.js} +3 -4
  75. package/dist/{index-M-zdB4A1.js → index-XkjbxWyS.js} +3 -4
  76. package/dist/{index-D0vwBTE3.js → index-sK4DWbBt.js} +3 -4
  77. package/dist/index.js +3 -4
  78. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/RenderableLineAnnotation.js +3 -3
  79. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/RenderableLineAnnotation.js.map +1 -1
  80. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/normalizeAnnotations.d.ts +8 -0
  81. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/normalizeAnnotations.d.ts.map +1 -1
  82. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/normalizeAnnotations.js +2 -0
  83. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/normalizeAnnotations.js.map +1 -1
  84. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/types.d.ts +2 -0
  85. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/annotations/types.d.ts.map +1 -1
  86. package/dist/worker-ByVSTHSI.js +102 -0
  87. package/dist/{worker-1z9jlpUn.js → worker-DlZ2xp8p.js} +2 -2
  88. package/dist/{worker-utils-DfViKOHw.js → worker-utils-BNThsbdN.js} +2 -2
  89. package/package.json +2 -2
  90. package/dist/worker-DNYPTnyn.js +0 -9
  91. package/dist/worker-utils-BbyBpOVt.js +0 -453
@@ -1,12 +1,11 @@
1
- import { c as commonjsGlobal, g as getAugmentedNamespace, a as getDefaultExportFromCjs } from './worker-utils-DfViKOHw.js';
2
- import { T as Type$1, P as PointsAnnotationType$2, a as Profile, p as protobufsBySchema } from './communicator-D_EeiIbd.js';
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';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { useContext, useRef, useLayoutEffect, createContext, useReducer, useState, useCallback, useMemo, forwardRef, createElement, Component, useEffect, Children, isValidElement, cloneElement, Fragment, useImperativeHandle, Suspense } from 'react';
5
5
  import { createStore, useStore } from 'zustand';
6
6
  import { isParent as isParent$1, getLeaves, createRemoveUpdate, updateTree, getNodeAtPath, createHideUpdate, createDragToUpdates, MosaicContext, MosaicWindowContext } from 'react-mosaic-component';
7
7
  import { useTheme as useTheme$3, alpha, Typography, Divider, Link, Button as Button$1, GlobalStyles, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Stack as Stack$3 } from '@mui/material';
8
8
  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$1, 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';
9
- import './worker-utils-BbyBpOVt.js';
10
9
  import { DndProvider } from 'react-dnd';
11
10
  import { HTML5Backend } from 'react-dnd-html5-backend';
12
11
  import { ThemeContext, __unsafe_useEmotionCache } from '@emotion/react';
@@ -2922,7 +2921,7 @@ function getAllKeys(object) {
2922
2921
  }
2923
2922
 
2924
2923
  /* Built-in method references that are verified to be native. */
2925
- var DataView = getNative(root$6, 'DataView');
2924
+ var DataView$1 = getNative(root$6, 'DataView');
2926
2925
 
2927
2926
  /* Built-in method references that are verified to be native. */
2928
2927
  var Promise$1 = getNative(root$6, 'Promise');
@@ -2940,7 +2939,7 @@ var mapTag$2 = '[object Map]',
2940
2939
  var dataViewTag$1 = '[object DataView]';
2941
2940
 
2942
2941
  /** Used to detect maps, sets, and weakmaps. */
2943
- var dataViewCtorString = toSource(DataView),
2942
+ var dataViewCtorString = toSource(DataView$1),
2944
2943
  mapCtorString = toSource(Map$1),
2945
2944
  promiseCtorString = toSource(Promise$1),
2946
2945
  setCtorString = toSource(Set$1),
@@ -2956,7 +2955,7 @@ var dataViewCtorString = toSource(DataView),
2956
2955
  var getTag = baseGetTag;
2957
2956
 
2958
2957
  // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
2959
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
2958
+ if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1) ||
2960
2959
  (Map$1 && getTag(new Map$1) != mapTag$2) ||
2961
2960
  (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
2962
2961
  (Set$1 && getTag(new Set$1) != setTag$2) ||
@@ -11002,17 +11001,36 @@ function deserializeImgDetectionsCustom({
11002
11001
  width: DEFAULT_WIDTH,
11003
11002
  height: DEFAULT_HEIGHT
11004
11003
  };
11005
- for (const annotation of message.annotations) {
11006
- const points = annotation.points.map(annotation => ({
11007
- timestamp: receiveTime,
11008
- type: annotation.type === PointsAnnotationType$2.UNRECOGNIZED ? typescript$1.PointsAnnotationType.UNKNOWN : Number(annotation.type),
11009
- points: annotation.points,
11010
- outline_color: annotation.outlineColor ?? DEFAULT_STYLE.outline,
11011
- outline_colors: [],
11012
- fill_color: annotation.fillColor ?? DEFAULT_STYLE.fill,
11013
- thickness: annotation.thickness
11014
- }));
11015
- const texts = annotation.texts.map(annotation => ({
11004
+ const xMultiplier = width >= height ? 1 : height / width;
11005
+ const yMultiplier = height >= width ? 1 : width / height;
11006
+ for (const annotations of message.annotations) {
11007
+ const points = [];
11008
+ const circles = [];
11009
+ for (const annotation of annotations.points) {
11010
+ if (annotation.type === PointsAnnotationType$2.POINTS) {
11011
+ circles.push(...annotation.points.map(point => ({
11012
+ timestamp: receiveTime,
11013
+ position: point,
11014
+ xMultiplier,
11015
+ yMultiplier,
11016
+ diameter: annotation.thickness / 200,
11017
+ thickness: annotation.thickness,
11018
+ fill_color: annotation.fillColor ?? DEFAULT_STYLE.fill,
11019
+ outline_color: annotation.outlineColor ?? DEFAULT_STYLE.fill
11020
+ })));
11021
+ } else {
11022
+ points.push({
11023
+ timestamp: receiveTime,
11024
+ type: annotation.type === PointsAnnotationType$2.UNRECOGNIZED ? typescript$1.PointsAnnotationType.UNKNOWN : Number(annotation.type),
11025
+ points: annotation.points,
11026
+ outline_color: annotation.outlineColor ?? DEFAULT_STYLE.outline,
11027
+ outline_colors: [],
11028
+ fill_color: annotation.fillColor ?? DEFAULT_STYLE.fill,
11029
+ thickness: annotation.thickness
11030
+ });
11031
+ }
11032
+ }
11033
+ const texts = annotations.texts.map(annotation => ({
11016
11034
  timestamp: receiveTime,
11017
11035
  position: annotation.position ?? {
11018
11036
  x: 0,
@@ -11023,7 +11041,7 @@ function deserializeImgDetectionsCustom({
11023
11041
  text_color: annotation.textColor ?? DEFAULT_TEXT_COLOR,
11024
11042
  background_color: annotation.backgroundColor ?? DEFAULT_BACKGROUND_COLOR
11025
11043
  }));
11026
- const circles = annotation.circles.map(annotation => ({
11044
+ circles.push(...annotations.circles.map(annotation => ({
11027
11045
  timestamp: receiveTime,
11028
11046
  position: annotation.position ?? {
11029
11047
  x: 0,
@@ -11033,7 +11051,7 @@ function deserializeImgDetectionsCustom({
11033
11051
  thickness: annotation.thickness,
11034
11052
  fill_color: annotation.fillColor ?? DEFAULT_STYLE.fill,
11035
11053
  outline_color: annotation.outlineColor ?? DEFAULT_STYLE.outline
11036
- }));
11054
+ })));
11037
11055
  const foxgloveMessage = {
11038
11056
  points,
11039
11057
  texts,
@@ -11806,6 +11824,490 @@ class FoxgloveConnection {
11806
11824
  });
11807
11825
  }
11808
11826
 
11827
+ class EventEmitter {
11828
+ id = 0;
11829
+ handlers = {};
11830
+ emit(event, data) {
11831
+ const handlers = this.handlers[event] ?? [];
11832
+ for (const { handler } of handlers) {
11833
+ handler(...data);
11834
+ }
11835
+ }
11836
+ on(event, handler) {
11837
+ const key = event;
11838
+ const id = this.id + 1;
11839
+ if (!this.handlers[key]) {
11840
+ this.handlers[key] = [];
11841
+ }
11842
+ this.handlers[key].push({ id, handler });
11843
+ return this.off(event, id);
11844
+ }
11845
+ off(event, id) {
11846
+ const key = event;
11847
+ if (!this.handlers[key]) {
11848
+ return;
11849
+ }
11850
+ const index = this.handlers[key].findIndex(handler => handler.id === id);
11851
+ if (index > 0) {
11852
+ this.handlers[key].splice(index, 1);
11853
+ }
11854
+ }
11855
+ isEventHandled(event) {
11856
+ const eventHandlers = this.handlers[event];
11857
+ return !!eventHandlers && Object.values(eventHandlers).length > 0;
11858
+ }
11859
+ }
11860
+
11861
+ class WebRtcDataChannel {
11862
+ channel;
11863
+ events = new EventEmitter();
11864
+ oldMessages = [];
11865
+ constructor(channel) {
11866
+ this.channel = channel;
11867
+ this.channel.onerror = event => this.events.emit('error', [event]);
11868
+ this.channel.onmessage = event => this.events.emit('message', [event]);
11869
+ this.channel.onclose = event => this.events.emit('close', [event]);
11870
+ this.channel.onopen = event => {
11871
+ this.events.emit('open', [event]);
11872
+ for (const message of this.oldMessages) {
11873
+ this.sendMessage(message);
11874
+ }
11875
+ this.oldMessages = [];
11876
+ };
11877
+ }
11878
+ get raw() {
11879
+ return this.channel;
11880
+ }
11881
+ get label() {
11882
+ return this.channel.label;
11883
+ }
11884
+ sendMessage(message) {
11885
+ if (this.channel.readyState === 'open') {
11886
+ this.channel.send(message);
11887
+ }
11888
+ else {
11889
+ this.oldMessages.push(message);
11890
+ }
11891
+ }
11892
+ /**
11893
+ * This method does **not** filter messages. Use this method instead of {@link on}
11894
+ * **only** if you are sure that all messages sent over this channel will contain text.
11895
+ */
11896
+ onTextMessage(callback) {
11897
+ return this.events.on('message', async (event) => {
11898
+ const buffer = await event.data.arrayBuffer();
11899
+ const message = new TextDecoder('utf-8').decode(buffer);
11900
+ callback(message);
11901
+ });
11902
+ }
11903
+ on = this.events.on.bind(this.events);
11904
+ }
11905
+
11906
+ class WebRtcConnection {
11907
+ iceServers;
11908
+ #peerConnection;
11909
+ connected = false;
11910
+ events = new EventEmitter();
11911
+ onIceCandidate;
11912
+ onConnectionEstablished;
11913
+ constructor(props) {
11914
+ this.iceServers = props.iceServers;
11915
+ this.onIceCandidate = props.onCandidate;
11916
+ this.onConnectionEstablished = props.onConnectionEstablished;
11917
+ this.#peerConnection = this.createPeerConnection();
11918
+ }
11919
+ createPeerConnection() {
11920
+ const config = {
11921
+ iceServers: this.iceServers ?? [],
11922
+ };
11923
+ const connection = new RTCPeerConnection(config);
11924
+ connection.addEventListener('connectionstatechange', () => {
11925
+ if (connection.connectionState === 'disconnected' ||
11926
+ connection.connectionState === 'failed' ||
11927
+ connection.connectionState === 'closed') {
11928
+ this.events.emit('connection_closed', []);
11929
+ this.connected = false;
11930
+ }
11931
+ });
11932
+ connection.addEventListener('iceconnectionstatechange', () => {
11933
+ if (connection.connectionState === 'connected') {
11934
+ this.onConnectionEstablished();
11935
+ this.connected = true;
11936
+ }
11937
+ else if (this.connected) {
11938
+ this.events.emit('connection_closed', []);
11939
+ this.connected = false;
11940
+ }
11941
+ });
11942
+ connection.onicecandidate = event => {
11943
+ if (event.candidate) {
11944
+ this.onIceCandidate(event.candidate);
11945
+ }
11946
+ };
11947
+ connection.ondatachannel = event => {
11948
+ const channel = new WebRtcDataChannel(event.channel);
11949
+ if (channel.label === 'ping-pong') {
11950
+ channel.on('message', () => channel.sendMessage('pong'));
11951
+ }
11952
+ this.events.emit('data_channel', [channel]);
11953
+ };
11954
+ return connection;
11955
+ }
11956
+ get peerConnection() {
11957
+ return this.#peerConnection;
11958
+ }
11959
+ createDataChannel(label, options) {
11960
+ const channel = this.#peerConnection.createDataChannel(label, options);
11961
+ return new WebRtcDataChannel(channel);
11962
+ }
11963
+ setRemoteDescription(type, sdp) {
11964
+ return this.#peerConnection.setRemoteDescription({ type, sdp });
11965
+ }
11966
+ async createDescription(type) {
11967
+ const description = await this.#peerConnection[type === 'offer' ? 'createOffer' : 'createAnswer']();
11968
+ await this.#peerConnection.setLocalDescription(description);
11969
+ return description;
11970
+ }
11971
+ addIceCandidate(candidate) {
11972
+ return this.#peerConnection.addIceCandidate(new RTCIceCandidate(candidate));
11973
+ }
11974
+ close() {
11975
+ return this.#peerConnection.close();
11976
+ }
11977
+ on = this.events.on.bind(this.events);
11978
+ }
11979
+
11980
+ const DEFAULT_SIGNALING_SERVER_URL = 'wss://signal.cloud.luxonis.com/session/';
11981
+ class WebRtcClient {
11982
+ config;
11983
+ socket;
11984
+ connection = null;
11985
+ signalingConnectionRetries;
11986
+ events = new EventEmitter();
11987
+ iceCandidates = [];
11988
+ constructor(config) {
11989
+ this.config = config;
11990
+ this.signalingConnectionRetries = (config.signalingConnectionRetries ?? 3) || 0;
11991
+ this.connectSignalingServer();
11992
+ }
11993
+ get signalingServerConnected() {
11994
+ return this.socket.readyState === WebSocket.OPEN;
11995
+ }
11996
+ disconnect(reason) {
11997
+ this.connection?.close();
11998
+ this.sendMessage({
11999
+ Disconnect: {
12000
+ type: 'normal',
12001
+ reason,
12002
+ },
12003
+ });
12004
+ }
12005
+ connect() {
12006
+ this.sendMessage({
12007
+ ConnectSession: {
12008
+ client_id: this.config.clientId,
12009
+ application_identifier: this.config.applicationIdentifier,
12010
+ auth_payload: this.config.authPayload,
12011
+ },
12012
+ });
12013
+ }
12014
+ connectSignalingServer() {
12015
+ this.socket = new WebSocket(this.config.signalingServerUrl ?? DEFAULT_SIGNALING_SERVER_URL);
12016
+ this.socket.onopen = () => {
12017
+ this.connect();
12018
+ };
12019
+ // this.socket.onclose = () => console.debug('[WebRTC] Disconnected from signaling server');
12020
+ this.socket.onerror = error => {
12021
+ this.events.emit('error', ['signaling_connection_error', error]);
12022
+ if (!this.events.isEventHandled('error')) {
12023
+ console.error('[WebRTC] Signaling connection error:', error);
12024
+ }
12025
+ setTimeout(() => {
12026
+ if (this.signalingConnectionRetries) {
12027
+ this.signalingConnectionRetries -= 1;
12028
+ if (this.socket.readyState === WebSocket.CLOSED || this.socket.readyState === WebSocket.CLOSING) {
12029
+ // console.debug('[WebRTC] Reconnecting to signaling server');
12030
+ this.connectSignalingServer();
12031
+ }
12032
+ }
12033
+ }, 3_000);
12034
+ };
12035
+ this.socket.onmessage = event => {
12036
+ const message = JSON.parse(event.data);
12037
+ this.handleSignalingMessage(message);
12038
+ };
12039
+ }
12040
+ disconnectSignalingServer(reason) {
12041
+ if (this.signalingServerConnected) {
12042
+ this.sendMessage({
12043
+ Disconnect: {
12044
+ type: 'normal',
12045
+ reason,
12046
+ },
12047
+ });
12048
+ this.socket.close();
12049
+ }
12050
+ }
12051
+ handleSignalingMessage(message) {
12052
+ if ('AcknowledgeSession' in message) {
12053
+ if (message.AcknowledgeSession.acknowledge) {
12054
+ this.createConnection();
12055
+ }
12056
+ else {
12057
+ if (!this.events.isEventHandled('error')) {
12058
+ console.error('[WebRTC] Connection refused:', message.AcknowledgeSession.reason);
12059
+ }
12060
+ this.events.emit('error', ['signaling_rejected', message.AcknowledgeSession.reason]);
12061
+ this.dispose('Connection refused');
12062
+ }
12063
+ }
12064
+ else if ('Candidate' in message) {
12065
+ void this.handleCandidateMessage(message);
12066
+ }
12067
+ else if ('Disconnect' in message) {
12068
+ this.dispose('Targed disconnected');
12069
+ }
12070
+ }
12071
+ async handleCandidateMessage({ Candidate: { type: kind, candidate } }) {
12072
+ if (!this.connection) {
12073
+ // console.error('[WebRTC] Candidate message dropped: conenction not established');
12074
+ return;
12075
+ }
12076
+ // console.debug('[WebRTC] Processing candidate message', kind);
12077
+ switch (kind) {
12078
+ case 'answer':
12079
+ case 'offer': {
12080
+ const data = `${candidate}`;
12081
+ if (data === 'null' || data === '') {
12082
+ console.error('[WebRTC] Offer refused: remote description cannot be null');
12083
+ this.reconnect('Error: received invalid candidate');
12084
+ return;
12085
+ }
12086
+ // console.debug('[WebRTC] Offer accepted. Setting remote description..');
12087
+ await this.connection.setRemoteDescription(kind, candidate);
12088
+ // console.debug('[WebRTC] Set remote description');
12089
+ for (const candidate of this.iceCandidates) {
12090
+ // console.debug('[WebRTC] Adding stored ICE candidate');
12091
+ this.connection.addIceCandidate(JSON.parse(candidate));
12092
+ }
12093
+ this.iceCandidates = [];
12094
+ if (kind === 'offer') {
12095
+ const answer = await this.connection.createDescription('answer');
12096
+ // console.debug('[WebRTC] Answer created (set local description)');
12097
+ this.sendMessage({
12098
+ Candidate: {
12099
+ type: 'answer',
12100
+ candidate: answer.sdp ?? '',
12101
+ },
12102
+ });
12103
+ }
12104
+ return;
12105
+ }
12106
+ case 'candidate': {
12107
+ if (this.connection.peerConnection.remoteDescription === null) {
12108
+ // console.debug('[WebRTC] Storing ICE candidate (remote description is not set yet)');
12109
+ this.iceCandidates.push(candidate);
12110
+ }
12111
+ else {
12112
+ // console.debug('[WebRTC] Adding ICE candidate');
12113
+ return this.connection.addIceCandidate(JSON.parse(candidate));
12114
+ }
12115
+ }
12116
+ }
12117
+ }
12118
+ reconnect(reason) {
12119
+ // console.debug(`[WebRTC] Reconnecting: ${reason}`);
12120
+ this.disconnect(reason);
12121
+ this.connect();
12122
+ }
12123
+ sendMessage(message) {
12124
+ // console.debug('[WebRTC] Sending message', message);
12125
+ if (this.socket.readyState === WebSocket.OPEN) {
12126
+ this.socket.send(JSON.stringify(message));
12127
+ }
12128
+ }
12129
+ createConnection() {
12130
+ this.connection = new WebRtcConnection({
12131
+ iceServers: this.config.iceServers,
12132
+ onCandidate: candidate => {
12133
+ this.sendMessage({
12134
+ Candidate: {
12135
+ type: 'candidate',
12136
+ candidate: JSON.stringify(candidate),
12137
+ },
12138
+ });
12139
+ },
12140
+ onConnectionEstablished: () => this.disconnectSignalingServer('P2P connection established'),
12141
+ });
12142
+ this.events.emit('connection_established', [this.connection]);
12143
+ }
12144
+ dispose(reason) {
12145
+ this.disconnect(reason);
12146
+ this.disconnectSignalingServer(reason);
12147
+ }
12148
+ on = this.events.on.bind(this.events);
12149
+ }
12150
+
12151
+ // This Source Code Form is subject to the terms of the Mozilla Public
12152
+ // License, v2.0. If a copy of the MPL was not distributed with this
12153
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
12154
+
12155
+ class ArtificialWorker extends EventTarget {
12156
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
12157
+ postMessage(data, _transferable) {
12158
+ const event = new MessageEvent('message', {
12159
+ data
12160
+ });
12161
+ super.dispatchEvent(event);
12162
+ }
12163
+
12164
+ // @ts-expect-error Make it typed
12165
+ addEventListener(type, callback) {
12166
+ super.addEventListener(type, callback);
12167
+ }
12168
+ terminate() {}
12169
+ }
12170
+
12171
+ // This Source Code Form is subject to the terms of the Mozilla Public
12172
+ // License, v2.0. If a copy of the MPL was not distributed with this
12173
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
12174
+
12175
+ const MESSAGE_CHANNEL_NAME = "message";
12176
+ const SYSTEM_CHANNEL_NAME = "system";
12177
+ class WebRtcBridge extends ArtificialWorker {
12178
+ #worker;
12179
+ #webrtc = null;
12180
+ #messageChannel = null;
12181
+ #systemChannel = null;
12182
+ constructor() {
12183
+ super();
12184
+ this.#worker = new Worker(new URL("worker-ByVSTHSI.js", import.meta.url), {
12185
+ type: "module"
12186
+ });
12187
+ this.#setupArtificialWorker();
12188
+ }
12189
+ terminate() {
12190
+ this.#worker.terminate();
12191
+ }
12192
+ #setupArtificialWorker() {
12193
+ this.addEventListener('message', event => {
12194
+ switch (event.data.type) {
12195
+ case 'open':
12196
+ {
12197
+ if ('config' in event.data.data) {
12198
+ this.#createWebRtc(event.data.data.config);
12199
+ }
12200
+ break;
12201
+ }
12202
+ }
12203
+ });
12204
+ }
12205
+ #createWebRtc(config) {
12206
+ this.#webrtc = new WebRtcClient(config);
12207
+ this.#handleWebRtc(this.#webrtc);
12208
+ this.#handleMessages();
12209
+ }
12210
+ #handleWebRtc(client) {
12211
+ client.on("connection_established", connection => {
12212
+ connection.on("data_channel", channel => {
12213
+ channel.on('close', () => {
12214
+ if (channel.label !== MESSAGE_CHANNEL_NAME && channel.label !== SYSTEM_CHANNEL_NAME) {
12215
+ return;
12216
+ }
12217
+ this.#worker.postMessage({
12218
+ kind: "connection",
12219
+ data: {
12220
+ channel: channel.label === MESSAGE_CHANNEL_NAME ? 'message' : 'system',
12221
+ ready: false
12222
+ }
12223
+ });
12224
+ });
12225
+ if (channel.label === MESSAGE_CHANNEL_NAME) {
12226
+ this.#messageChannel = channel;
12227
+ channel.on("message", async ({
12228
+ data
12229
+ }) => {
12230
+ const operation = data.getUint8(0);
12231
+ const action = operation === 0x01 ? 'message' : operation === 0x03 ? 'service_response' : 'other';
12232
+ if (action === 'message') {
12233
+ const subscriptionId = data.getUint32(1);
12234
+ const payload = new DataView(data.buffer, data.byteOffset + 1 + 4 + 8);
12235
+ this.#worker.postMessage({
12236
+ kind: "genericMessage",
12237
+ data: {
12238
+ message: {
12239
+ subscriptionId,
12240
+ data: payload
12241
+ }
12242
+ }
12243
+ }, [payload.buffer]);
12244
+ } else {
12245
+ const callId = data.getUint32(1 + 4); // op-code + service-id
12246
+ const encodingLength = data.getUint32(1 + 4 + 4); // op-code + service-id + call-id
12247
+ const payload = new DataView(data.buffer, data.byteOffset + 1 + 4 + 4 + 4 + encodingLength); // op-code + service-id + call-id + encoding-length
12248
+ this.#worker.postMessage({
12249
+ kind: "systemMessage",
12250
+ data: {
12251
+ message: {
12252
+ op: 'serviceResponse',
12253
+ callId,
12254
+ data: payload
12255
+ }
12256
+ }
12257
+ }, [payload.buffer]);
12258
+ }
12259
+ });
12260
+ } else if (channel.label === SYSTEM_CHANNEL_NAME) {
12261
+ this.#systemChannel = channel;
12262
+ channel.on("message", async event => {
12263
+ const message = JSON.parse(event.data);
12264
+ this.#worker.postMessage({
12265
+ kind: "systemMessage",
12266
+ data: {
12267
+ message
12268
+ }
12269
+ });
12270
+ });
12271
+ }
12272
+ this.#worker.postMessage({
12273
+ kind: "connection",
12274
+ data: {
12275
+ channel: channel.label === MESSAGE_CHANNEL_NAME ? 'message' : 'system',
12276
+ ready: true
12277
+ }
12278
+ });
12279
+ });
12280
+ connection.on("connection_closed", () => {
12281
+ this.#worker.postMessage({
12282
+ kind: "connection",
12283
+ data: {
12284
+ channel: null,
12285
+ ready: false
12286
+ }
12287
+ });
12288
+ });
12289
+ });
12290
+ }
12291
+ #handleMessages() {
12292
+ this.#worker.addEventListener('message', event => {
12293
+ switch (event.data.type) {
12294
+ case 'send':
12295
+ {
12296
+ const channel = event.data.data.channel === 'message' ? this.#messageChannel : this.#systemChannel;
12297
+ if (channel) {
12298
+ channel.sendMessage(event.data.data.data);
12299
+ }
12300
+ break;
12301
+ }
12302
+ default:
12303
+ {
12304
+ this.postMessage(event.data);
12305
+ }
12306
+ }
12307
+ });
12308
+ }
12309
+ }
12310
+
11809
12311
  // This Source Code Form is subject to the terms of the Mozilla Public
11810
12312
  // License, v2.0. If a copy of the MPL was not distributed with this
11811
12313
  // file, You can obtain one at http://mozilla.org/MPL/2.0/
@@ -11823,14 +12325,12 @@ class VisualizerConnection extends FoxgloveConnection {
11823
12325
  let finalWorker = worker;
11824
12326
  if (type === 'ws') {
11825
12327
  this.#url = data.connectionUrl;
11826
- finalWorker ??= new Worker(new URL("worker-1z9jlpUn.js", import.meta.url), {
12328
+ finalWorker ??= new Worker(new URL("worker-DlZ2xp8p.js", import.meta.url), {
11827
12329
  type: "module"
11828
12330
  });
11829
12331
  } else {
11830
12332
  this.#config = data.config;
11831
- finalWorker ??= new Worker(new URL("worker-DNYPTnyn.js", import.meta.url), {
11832
- type: "module"
11833
- });
12333
+ finalWorker ??= new WebRtcBridge();
11834
12334
  }
11835
12335
  this.#open(finalWorker);
11836
12336
  }
@@ -11862,7 +12362,7 @@ class VisualizerConnection extends FoxgloveConnection {
11862
12362
  this.onMessagePacket.bind(this)(event);
11863
12363
  });
11864
12364
  this.#adapter.addEventListener("close", this.#onClose.bind(this));
11865
- this.#adapter.onerror = this.#onError.bind(this);
12365
+ this.#adapter.addEventListener("error", this.#onClose.bind(this));
11866
12366
  };
11867
12367
  #onOpen = () => {
11868
12368
  this.playerPresence = PlayerPresence.PRESENT;
@@ -83050,7 +83550,7 @@ function legacy(parser) {
83050
83550
  return new LanguageSupport(StreamLanguage.define(parser));
83051
83551
  }
83052
83552
  function sql$1(dialectName) {
83053
- return import('./index-M-zdB4A1.js').then(m => m.sql({ dialect: m[dialectName] }));
83553
+ return import('./index-XkjbxWyS.js').then(m => m.sql({ dialect: m[dialectName] }));
83054
83554
  }
83055
83555
  /**
83056
83556
  An array of language descriptions for known language packages.
@@ -83061,7 +83561,7 @@ const languages = [
83061
83561
  name: "C",
83062
83562
  extensions: ["c", "h", "ino"],
83063
83563
  load() {
83064
- return import('./index-BOSrUvKZ.js').then(m => m.cpp());
83564
+ return import('./index-C1jY05Dy.js').then(m => m.cpp());
83065
83565
  }
83066
83566
  }),
83067
83567
  /*@__PURE__*/LanguageDescription.of({
@@ -83069,7 +83569,7 @@ const languages = [
83069
83569
  alias: ["cpp"],
83070
83570
  extensions: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"],
83071
83571
  load() {
83072
- return import('./index-BOSrUvKZ.js').then(m => m.cpp());
83572
+ return import('./index-C1jY05Dy.js').then(m => m.cpp());
83073
83573
  }
83074
83574
  }),
83075
83575
  /*@__PURE__*/LanguageDescription.of({
@@ -83089,7 +83589,7 @@ const languages = [
83089
83589
  name: "Go",
83090
83590
  extensions: ["go"],
83091
83591
  load() {
83092
- return import('./index-CnbrHWCd.js').then(m => m.go());
83592
+ return import('./index-Bg_SBKcj.js').then(m => m.go());
83093
83593
  }
83094
83594
  }),
83095
83595
  /*@__PURE__*/LanguageDescription.of({
@@ -83104,7 +83604,7 @@ const languages = [
83104
83604
  name: "Java",
83105
83605
  extensions: ["java"],
83106
83606
  load() {
83107
- return import('./index-D0vwBTE3.js').then(m => m.java());
83607
+ return import('./index-sK4DWbBt.js').then(m => m.java());
83108
83608
  }
83109
83609
  }),
83110
83610
  /*@__PURE__*/LanguageDescription.of({
@@ -83120,7 +83620,7 @@ const languages = [
83120
83620
  alias: ["json5"],
83121
83621
  extensions: ["json", "map"],
83122
83622
  load() {
83123
- return import('./index-DudYiuIt.js').then(m => m.json());
83623
+ return import('./index-CdE_fknn.js').then(m => m.json());
83124
83624
  }
83125
83625
  }),
83126
83626
  /*@__PURE__*/LanguageDescription.of({
@@ -83134,14 +83634,14 @@ const languages = [
83134
83634
  name: "LESS",
83135
83635
  extensions: ["less"],
83136
83636
  load() {
83137
- return import('./index-DpXY8ing.js').then(m => m.less());
83637
+ return import('./index-BarbRpkf.js').then(m => m.less());
83138
83638
  }
83139
83639
  }),
83140
83640
  /*@__PURE__*/LanguageDescription.of({
83141
83641
  name: "Liquid",
83142
83642
  extensions: ["liquid"],
83143
83643
  load() {
83144
- return import('./index-By94udNp.js').then(m => m.liquid());
83644
+ return import('./index-PZaaEO31.js').then(m => m.liquid());
83145
83645
  }
83146
83646
  }),
83147
83647
  /*@__PURE__*/LanguageDescription.of({
@@ -83167,7 +83667,7 @@ const languages = [
83167
83667
  name: "PHP",
83168
83668
  extensions: ["php", "php3", "php4", "php5", "php7", "phtml"],
83169
83669
  load() {
83170
- return import('./index-r1jTO4Ay.js').then(m => m.php());
83670
+ return import('./index-COiPTu-O.js').then(m => m.php());
83171
83671
  }
83172
83672
  }),
83173
83673
  /*@__PURE__*/LanguageDescription.of({
@@ -83184,28 +83684,28 @@ const languages = [
83184
83684
  extensions: ["BUILD", "bzl", "py", "pyw"],
83185
83685
  filename: /^(BUCK|BUILD)$/,
83186
83686
  load() {
83187
- return import('./index-FOw7-sDA.js').then(m => m.python());
83687
+ return import('./index-DFFtL_uP.js').then(m => m.python());
83188
83688
  }
83189
83689
  }),
83190
83690
  /*@__PURE__*/LanguageDescription.of({
83191
83691
  name: "Rust",
83192
83692
  extensions: ["rs"],
83193
83693
  load() {
83194
- return import('./index-Al0pDnqr.js').then(m => m.rust());
83694
+ return import('./index-BS1BKdpU.js').then(m => m.rust());
83195
83695
  }
83196
83696
  }),
83197
83697
  /*@__PURE__*/LanguageDescription.of({
83198
83698
  name: "Sass",
83199
83699
  extensions: ["sass"],
83200
83700
  load() {
83201
- return import('./index-doJtQKmP.js').then(m => m.sass({ indented: true }));
83701
+ return import('./index-BPkCb-qN.js').then(m => m.sass({ indented: true }));
83202
83702
  }
83203
83703
  }),
83204
83704
  /*@__PURE__*/LanguageDescription.of({
83205
83705
  name: "SCSS",
83206
83706
  extensions: ["scss"],
83207
83707
  load() {
83208
- return import('./index-doJtQKmP.js').then(m => m.sass());
83708
+ return import('./index-BPkCb-qN.js').then(m => m.sass());
83209
83709
  }
83210
83710
  }),
83211
83711
  /*@__PURE__*/LanguageDescription.of({
@@ -83236,7 +83736,7 @@ const languages = [
83236
83736
  name: "WebAssembly",
83237
83737
  extensions: ["wat", "wast"],
83238
83738
  load() {
83239
- return import('./index-QNisWGZ4.js').then(m => m.wast());
83739
+ return import('./index-CKhCSBGi.js').then(m => m.wast());
83240
83740
  }
83241
83741
  }),
83242
83742
  /*@__PURE__*/LanguageDescription.of({
@@ -83244,7 +83744,7 @@ const languages = [
83244
83744
  alias: ["rss", "wsdl", "xsd"],
83245
83745
  extensions: ["xml", "xsl", "xsd", "svg"],
83246
83746
  load() {
83247
- return import('./index-BfF6NM_p.js').then(m => m.xml());
83747
+ return import('./index-D8Bx_kL-.js').then(m => m.xml());
83248
83748
  }
83249
83749
  }),
83250
83750
  /*@__PURE__*/LanguageDescription.of({
@@ -83252,7 +83752,7 @@ const languages = [
83252
83752
  alias: ["yml"],
83253
83753
  extensions: ["yaml", "yml"],
83254
83754
  load() {
83255
- return import('./index-BtdqjdG0.js').then(m => m.yaml());
83755
+ return import('./index-MKv43hnI.js').then(m => m.yaml());
83256
83756
  }
83257
83757
  }),
83258
83758
  // Legacy modes ported from CodeMirror 5
@@ -84048,13 +84548,13 @@ const languages = [
84048
84548
  name: "Vue",
84049
84549
  extensions: ["vue"],
84050
84550
  load() {
84051
- return import('./index-BeQsiPfT.js').then(m => m.vue());
84551
+ return import('./index-D6Z2XgEd.js').then(m => m.vue());
84052
84552
  }
84053
84553
  }),
84054
84554
  /*@__PURE__*/LanguageDescription.of({
84055
84555
  name: "Angular Template",
84056
84556
  load() {
84057
- return import('./index-D-Et9RVh.js').then(m => m.angular());
84557
+ return import('./index-DULznPlC.js').then(m => m.angular());
84058
84558
  }
84059
84559
  })
84060
84560
  ];
@@ -154266,7 +154766,7 @@ const Panel = ({
154266
154766
  }, children))))));
154267
154767
  };
154268
154768
 
154269
- const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-IoSJKto7.js'));
154769
+ const ImagePanelComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-D7G90Nuw.js'));
154270
154770
  const ImagePanelBody = ({
154271
154771
  topic
154272
154772
  }) => {
@@ -154301,7 +154801,7 @@ const ImagePanel = /*#__PURE__*/React__default.memo(function ImagePanel(props) {
154301
154801
  // License, v2.0. If a copy of the MPL was not distributed with this
154302
154802
  // file, You can obtain one at http://mozilla.org/MPL/2.0/
154303
154803
 
154304
- const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-CgoOLCnB.js'));
154804
+ const ThreeDeeRenderComponent = /*#__PURE__*/React__default.lazy(async () => await import('./index-CLrFiqp0.js'));
154305
154805
  const PointCloudPanelBody = ({
154306
154806
  topic
154307
154807
  }) => {