@luxonis/visualizer-protobuf 2.2.0 → 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 (116) hide show
  1. package/dist/{communicator-DKKKAI0H.js → FoxgloveServer-tJZcJH5-.js} +1216 -174
  2. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.d.ts.map +1 -1
  3. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js +9 -10
  4. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js.map +1 -1
  5. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts +4 -7
  6. package/dist/apps/depthai-visualizer/src/connection/adapter.d.ts.map +1 -1
  7. package/dist/apps/depthai-visualizer/src/connection/adapter.js +5 -5
  8. package/dist/apps/depthai-visualizer/src/connection/adapter.js.map +1 -1
  9. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts +7 -13
  10. package/dist/apps/depthai-visualizer/src/connection/communicator.d.ts.map +1 -1
  11. package/dist/apps/depthai-visualizer/src/connection/communicator.js +5 -4
  12. package/dist/apps/depthai-visualizer/src/connection/communicator.js.map +1 -1
  13. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts +8 -13
  14. package/dist/apps/depthai-visualizer/src/connection/connection.d.ts.map +1 -1
  15. package/dist/apps/depthai-visualizer/src/connection/connection.js +19 -22
  16. package/dist/apps/depthai-visualizer/src/connection/connection.js.map +1 -1
  17. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.d.ts +6 -0
  18. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.d.ts.map +1 -0
  19. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.js +63 -0
  20. package/dist/apps/depthai-visualizer/src/connection/foxglove-protocol.js.map +1 -0
  21. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts +2 -2
  22. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.d.ts.map +1 -1
  23. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js +29 -49
  24. package/dist/apps/depthai-visualizer/src/connection/webrtc/bridge.js.map +1 -1
  25. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts +20 -20
  26. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.d.ts.map +1 -1
  27. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js +34 -35
  28. package/dist/apps/depthai-visualizer/src/connection/webrtc/worker-utils.js.map +1 -1
  29. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts +16 -1
  30. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts.map +1 -1
  31. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js +114 -2
  32. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js.map +1 -1
  33. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts +1 -1
  34. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts.map +1 -1
  35. package/dist/apps/depthai-visualizer/src/index.d.ts +1 -2
  36. package/dist/apps/depthai-visualizer/src/index.d.ts.map +1 -1
  37. package/dist/apps/depthai-visualizer/src/index.js +0 -1
  38. package/dist/apps/depthai-visualizer/src/index.js.map +1 -1
  39. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/detection.js +2 -2
  40. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/detection.js.map +1 -1
  41. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/utils.d.ts.map +1 -1
  42. package/dist/apps/depthai-visualizer/src/messaging/deserialization/detections/utils.js.map +1 -1
  43. package/dist/apps/depthai-visualizer/src/messaging/deserialization.js +5 -5
  44. package/dist/apps/depthai-visualizer/src/messaging/deserialization.js.map +1 -1
  45. package/dist/apps/depthai-visualizer/src/messaging/utils.d.ts +7 -6
  46. package/dist/apps/depthai-visualizer/src/messaging/utils.d.ts.map +1 -1
  47. package/dist/apps/depthai-visualizer/src/messaging/utils.js +2 -2
  48. package/dist/apps/depthai-visualizer/src/messaging/utils.js.map +1 -1
  49. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.d.ts.map +1 -1
  50. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js +3 -0
  51. package/dist/apps/depthai-visualizer/src/protobuf.generated/EncodedFrame.js.map +1 -1
  52. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.d.ts.map +1 -1
  53. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js +3 -0
  54. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImageAnnotations.js.map +1 -1
  55. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.d.ts.map +1 -1
  56. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js +3 -0
  57. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgDetections.js.map +1 -1
  58. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.d.ts.map +1 -1
  59. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js +3 -0
  60. package/dist/apps/depthai-visualizer/src/protobuf.generated/ImgFrame.js.map +1 -1
  61. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.d.ts.map +1 -1
  62. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js +3 -0
  63. package/dist/apps/depthai-visualizer/src/protobuf.generated/PointCloudData.js.map +1 -1
  64. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.d.ts.map +1 -1
  65. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js +3 -0
  66. package/dist/apps/depthai-visualizer/src/protobuf.generated/SpatialImgDetections.js.map +1 -1
  67. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.d.ts.map +1 -1
  68. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js +3 -0
  69. package/dist/apps/depthai-visualizer/src/protobuf.generated/common.js.map +1 -1
  70. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts +6 -6
  71. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.d.ts.map +1 -1
  72. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js +10 -7
  73. package/dist/apps/depthai-visualizer/src/utils/artificial-worker.js.map +1 -1
  74. package/dist/apps/depthai-visualizer/src/utils/callback-manager.d.ts +1 -1
  75. package/dist/apps/depthai-visualizer/src/utils/callback-manager.d.ts.map +1 -1
  76. package/dist/apps/depthai-visualizer/src/utils/callback-manager.js +5 -5
  77. package/dist/apps/depthai-visualizer/src/utils/callback-manager.js.map +1 -1
  78. package/dist/apps/depthai-visualizer/src/utils/compatibility.d.ts.map +1 -1
  79. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.d.ts.map +1 -1
  80. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js +1 -0
  81. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js.map +1 -1
  82. package/dist/communicator-D9LSiWws.js +147 -0
  83. package/dist/foxglove-protocol-RBwoTi12.js +76 -0
  84. package/dist/{index-DbIgJEn4.js → index-BatOjqHR.js} +4 -5
  85. package/dist/{index-BZjzIIuE.js → index-BeMujwTx.js} +4 -5
  86. package/dist/{index-CE1LH59a.js → index-Bmv-vCsr.js} +4 -5
  87. package/dist/{index-Dai0K-_7.js → index-Bpb1nLXX.js} +4 -5
  88. package/dist/{index-FdS8KlrP.js → index-C38MwKQ5.js} +4 -5
  89. package/dist/{index-BsdqQ862.js → index-C4Xw5gJf.js} +4 -5
  90. package/dist/{index-C6m30paN.js → index-CCjTYhIj.js} +4 -5
  91. package/dist/{index-D0g7yNKD.js → index-CRzS8jhh.js} +4 -5
  92. package/dist/{index-MOg_zBJW.js → index-CTV8k4Ur.js} +4 -5
  93. package/dist/{index-Cqzhj8jS.js → index-Cjzn2Mk3.js} +4 -5
  94. package/dist/{index-SZgAiOi4.js → index-CzJG5yoW.js} +4 -5
  95. package/dist/{index-Cmp_Tjng.js → index-D2tE4ai8.js} +5 -6
  96. package/dist/{index-DleEaqya.js → index-D8PL1mUz.js} +4 -5
  97. package/dist/{index-B3F-eA-i.js → index-Dx5rKk7S.js} +115 -126
  98. package/dist/{index-DkDTcHOl.js → index-JdSlhtdz.js} +4 -5
  99. package/dist/{index-D_AhdZqi.js → index-LBWmbzab.js} +4 -5
  100. package/dist/{index-D7I7neMi.js → index-fDKFJqYA.js} +4 -5
  101. package/dist/{index-1yvlF6NH.js → index-kO40p_fI.js} +4 -5
  102. package/dist/{index-B4j3EVf8.js → index-lcxcWrBB.js} +4 -5
  103. package/dist/index.js +4 -5
  104. package/dist/{worker-CMZIJlQN.js → worker-BX0SIDt0.js} +24 -20
  105. package/dist/worker-C6ruK-iB.js +150 -0
  106. package/package.json +1 -1
  107. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts +0 -19
  108. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts.map +0 -1
  109. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js +0 -128
  110. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js.map +0 -1
  111. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.d.ts +0 -12
  112. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.d.ts.map +0 -1
  113. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.js +0 -52
  114. package/dist/apps/depthai-visualizer/src/panels/CanvasPanel.js.map +0 -1
  115. package/dist/worker-DtDgSl3T.js +0 -11
  116. package/dist/worker-utils-BuUq1bP1.js +0 -1357
@@ -1,1357 +0,0 @@
1
- import { Waterfall } from 'hydrated-ws';
2
- import require$$0 from 'ms';
3
- import { F as FoxgloveCommunicator } from './communicator-DKKKAI0H.js';
4
-
5
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
-
7
- function getDefaultExportFromCjs (x) {
8
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
9
- }
10
-
11
- function getAugmentedNamespace(n) {
12
- if (n.__esModule) return n;
13
- var f = n.default;
14
- if (typeof f == "function") {
15
- var a = function a () {
16
- if (this instanceof a) {
17
- return Reflect.construct(f, arguments, this.constructor);
18
- }
19
- return f.apply(this, arguments);
20
- };
21
- a.prototype = f.prototype;
22
- } else a = {};
23
- Object.defineProperty(a, '__esModule', {value: true});
24
- Object.keys(n).forEach(function (k) {
25
- var d = Object.getOwnPropertyDescriptor(n, k);
26
- Object.defineProperty(a, k, d.get ? d : {
27
- enumerable: true,
28
- get: function () {
29
- return n[k];
30
- }
31
- });
32
- });
33
- return a;
34
- }
35
-
36
- var eventemitter3 = {exports: {}};
37
-
38
- (function (module) {
39
-
40
- var has = Object.prototype.hasOwnProperty
41
- , prefix = '~';
42
-
43
- /**
44
- * Constructor to create a storage for our `EE` objects.
45
- * An `Events` instance is a plain object whose properties are event names.
46
- *
47
- * @constructor
48
- * @private
49
- */
50
- function Events() {}
51
-
52
- //
53
- // We try to not inherit from `Object.prototype`. In some engines creating an
54
- // instance in this way is faster than calling `Object.create(null)` directly.
55
- // If `Object.create(null)` is not supported we prefix the event names with a
56
- // character to make sure that the built-in object properties are not
57
- // overridden or used as an attack vector.
58
- //
59
- if (Object.create) {
60
- Events.prototype = Object.create(null);
61
-
62
- //
63
- // This hack is needed because the `__proto__` property is still inherited in
64
- // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
65
- //
66
- if (!new Events().__proto__) prefix = false;
67
- }
68
-
69
- /**
70
- * Representation of a single event listener.
71
- *
72
- * @param {Function} fn The listener function.
73
- * @param {*} context The context to invoke the listener with.
74
- * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
75
- * @constructor
76
- * @private
77
- */
78
- function EE(fn, context, once) {
79
- this.fn = fn;
80
- this.context = context;
81
- this.once = once || false;
82
- }
83
-
84
- /**
85
- * Add a listener for a given event.
86
- *
87
- * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
88
- * @param {(String|Symbol)} event The event name.
89
- * @param {Function} fn The listener function.
90
- * @param {*} context The context to invoke the listener with.
91
- * @param {Boolean} once Specify if the listener is a one-time listener.
92
- * @returns {EventEmitter}
93
- * @private
94
- */
95
- function addListener(emitter, event, fn, context, once) {
96
- if (typeof fn !== 'function') {
97
- throw new TypeError('The listener must be a function');
98
- }
99
-
100
- var listener = new EE(fn, context || emitter, once)
101
- , evt = prefix ? prefix + event : event;
102
-
103
- if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
104
- else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
105
- else emitter._events[evt] = [emitter._events[evt], listener];
106
-
107
- return emitter;
108
- }
109
-
110
- /**
111
- * Clear event by name.
112
- *
113
- * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
114
- * @param {(String|Symbol)} evt The Event name.
115
- * @private
116
- */
117
- function clearEvent(emitter, evt) {
118
- if (--emitter._eventsCount === 0) emitter._events = new Events();
119
- else delete emitter._events[evt];
120
- }
121
-
122
- /**
123
- * Minimal `EventEmitter` interface that is molded against the Node.js
124
- * `EventEmitter` interface.
125
- *
126
- * @constructor
127
- * @public
128
- */
129
- function EventEmitter() {
130
- this._events = new Events();
131
- this._eventsCount = 0;
132
- }
133
-
134
- /**
135
- * Return an array listing the events for which the emitter has registered
136
- * listeners.
137
- *
138
- * @returns {Array}
139
- * @public
140
- */
141
- EventEmitter.prototype.eventNames = function eventNames() {
142
- var names = []
143
- , events
144
- , name;
145
-
146
- if (this._eventsCount === 0) return names;
147
-
148
- for (name in (events = this._events)) {
149
- if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
150
- }
151
-
152
- if (Object.getOwnPropertySymbols) {
153
- return names.concat(Object.getOwnPropertySymbols(events));
154
- }
155
-
156
- return names;
157
- };
158
-
159
- /**
160
- * Return the listeners registered for a given event.
161
- *
162
- * @param {(String|Symbol)} event The event name.
163
- * @returns {Array} The registered listeners.
164
- * @public
165
- */
166
- EventEmitter.prototype.listeners = function listeners(event) {
167
- var evt = prefix ? prefix + event : event
168
- , handlers = this._events[evt];
169
-
170
- if (!handlers) return [];
171
- if (handlers.fn) return [handlers.fn];
172
-
173
- for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
174
- ee[i] = handlers[i].fn;
175
- }
176
-
177
- return ee;
178
- };
179
-
180
- /**
181
- * Return the number of listeners listening to a given event.
182
- *
183
- * @param {(String|Symbol)} event The event name.
184
- * @returns {Number} The number of listeners.
185
- * @public
186
- */
187
- EventEmitter.prototype.listenerCount = function listenerCount(event) {
188
- var evt = prefix ? prefix + event : event
189
- , listeners = this._events[evt];
190
-
191
- if (!listeners) return 0;
192
- if (listeners.fn) return 1;
193
- return listeners.length;
194
- };
195
-
196
- /**
197
- * Calls each of the listeners registered for a given event.
198
- *
199
- * @param {(String|Symbol)} event The event name.
200
- * @returns {Boolean} `true` if the event had listeners, else `false`.
201
- * @public
202
- */
203
- EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
204
- var evt = prefix ? prefix + event : event;
205
-
206
- if (!this._events[evt]) return false;
207
-
208
- var listeners = this._events[evt]
209
- , len = arguments.length
210
- , args
211
- , i;
212
-
213
- if (listeners.fn) {
214
- if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
215
-
216
- switch (len) {
217
- case 1: return listeners.fn.call(listeners.context), true;
218
- case 2: return listeners.fn.call(listeners.context, a1), true;
219
- case 3: return listeners.fn.call(listeners.context, a1, a2), true;
220
- case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
221
- case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
222
- case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
223
- }
224
-
225
- for (i = 1, args = new Array(len -1); i < len; i++) {
226
- args[i - 1] = arguments[i];
227
- }
228
-
229
- listeners.fn.apply(listeners.context, args);
230
- } else {
231
- var length = listeners.length
232
- , j;
233
-
234
- for (i = 0; i < length; i++) {
235
- if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
236
-
237
- switch (len) {
238
- case 1: listeners[i].fn.call(listeners[i].context); break;
239
- case 2: listeners[i].fn.call(listeners[i].context, a1); break;
240
- case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
241
- case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
242
- default:
243
- if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
244
- args[j - 1] = arguments[j];
245
- }
246
-
247
- listeners[i].fn.apply(listeners[i].context, args);
248
- }
249
- }
250
- }
251
-
252
- return true;
253
- };
254
-
255
- /**
256
- * Add a listener for a given event.
257
- *
258
- * @param {(String|Symbol)} event The event name.
259
- * @param {Function} fn The listener function.
260
- * @param {*} [context=this] The context to invoke the listener with.
261
- * @returns {EventEmitter} `this`.
262
- * @public
263
- */
264
- EventEmitter.prototype.on = function on(event, fn, context) {
265
- return addListener(this, event, fn, context, false);
266
- };
267
-
268
- /**
269
- * Add a one-time listener for a given event.
270
- *
271
- * @param {(String|Symbol)} event The event name.
272
- * @param {Function} fn The listener function.
273
- * @param {*} [context=this] The context to invoke the listener with.
274
- * @returns {EventEmitter} `this`.
275
- * @public
276
- */
277
- EventEmitter.prototype.once = function once(event, fn, context) {
278
- return addListener(this, event, fn, context, true);
279
- };
280
-
281
- /**
282
- * Remove the listeners of a given event.
283
- *
284
- * @param {(String|Symbol)} event The event name.
285
- * @param {Function} fn Only remove the listeners that match this function.
286
- * @param {*} context Only remove the listeners that have this context.
287
- * @param {Boolean} once Only remove one-time listeners.
288
- * @returns {EventEmitter} `this`.
289
- * @public
290
- */
291
- EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
292
- var evt = prefix ? prefix + event : event;
293
-
294
- if (!this._events[evt]) return this;
295
- if (!fn) {
296
- clearEvent(this, evt);
297
- return this;
298
- }
299
-
300
- var listeners = this._events[evt];
301
-
302
- if (listeners.fn) {
303
- if (
304
- listeners.fn === fn &&
305
- (!once || listeners.once) &&
306
- (!context || listeners.context === context)
307
- ) {
308
- clearEvent(this, evt);
309
- }
310
- } else {
311
- for (var i = 0, events = [], length = listeners.length; i < length; i++) {
312
- if (
313
- listeners[i].fn !== fn ||
314
- (once && !listeners[i].once) ||
315
- (context && listeners[i].context !== context)
316
- ) {
317
- events.push(listeners[i]);
318
- }
319
- }
320
-
321
- //
322
- // Reset the array, or remove it completely if we have no more listeners.
323
- //
324
- if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
325
- else clearEvent(this, evt);
326
- }
327
-
328
- return this;
329
- };
330
-
331
- /**
332
- * Remove all listeners, or those of the specified event.
333
- *
334
- * @param {(String|Symbol)} [event] The event name.
335
- * @returns {EventEmitter} `this`.
336
- * @public
337
- */
338
- EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
339
- var evt;
340
-
341
- if (event) {
342
- evt = prefix ? prefix + event : event;
343
- if (this._events[evt]) clearEvent(this, evt);
344
- } else {
345
- this._events = new Events();
346
- this._eventsCount = 0;
347
- }
348
-
349
- return this;
350
- };
351
-
352
- //
353
- // Alias methods names because people roll like that.
354
- //
355
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
356
- EventEmitter.prototype.addListener = EventEmitter.prototype.on;
357
-
358
- //
359
- // Expose the prefix.
360
- //
361
- EventEmitter.prefixed = prefix;
362
-
363
- //
364
- // Allow `EventEmitter` to be imported as module namespace.
365
- //
366
- EventEmitter.EventEmitter = EventEmitter;
367
-
368
- //
369
- // Expose the module.
370
- //
371
- {
372
- module.exports = EventEmitter;
373
- }
374
- } (eventemitter3));
375
-
376
- var eventemitter3Exports = eventemitter3.exports;
377
- var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
378
-
379
- var BinaryOpcode;
380
- (function (BinaryOpcode) {
381
- BinaryOpcode[BinaryOpcode["MESSAGE_DATA"] = 1] = "MESSAGE_DATA";
382
- BinaryOpcode[BinaryOpcode["TIME"] = 2] = "TIME";
383
- BinaryOpcode[BinaryOpcode["SERVICE_CALL_RESPONSE"] = 3] = "SERVICE_CALL_RESPONSE";
384
- BinaryOpcode[BinaryOpcode["FETCH_ASSET_RESPONSE"] = 4] = "FETCH_ASSET_RESPONSE";
385
- })(BinaryOpcode || (BinaryOpcode = {}));
386
- var ClientBinaryOpcode;
387
- (function (ClientBinaryOpcode) {
388
- ClientBinaryOpcode[ClientBinaryOpcode["MESSAGE_DATA"] = 1] = "MESSAGE_DATA";
389
- ClientBinaryOpcode[ClientBinaryOpcode["SERVICE_CALL_REQUEST"] = 2] = "SERVICE_CALL_REQUEST";
390
- })(ClientBinaryOpcode || (ClientBinaryOpcode = {}));
391
- var StatusLevel;
392
- (function (StatusLevel) {
393
- StatusLevel[StatusLevel["INFO"] = 0] = "INFO";
394
- StatusLevel[StatusLevel["WARNING"] = 1] = "WARNING";
395
- StatusLevel[StatusLevel["ERROR"] = 2] = "ERROR";
396
- })(StatusLevel || (StatusLevel = {}));
397
- var ServerCapability;
398
- (function (ServerCapability) {
399
- ServerCapability["clientPublish"] = "clientPublish";
400
- ServerCapability["time"] = "time";
401
- ServerCapability["parameters"] = "parameters";
402
- ServerCapability["parametersSubscribe"] = "parametersSubscribe";
403
- ServerCapability["services"] = "services";
404
- ServerCapability["connectionGraph"] = "connectionGraph";
405
- ServerCapability["assets"] = "assets";
406
- })(ServerCapability || (ServerCapability = {}));
407
- var FetchAssetStatus;
408
- (function (FetchAssetStatus) {
409
- FetchAssetStatus[FetchAssetStatus["SUCCESS"] = 0] = "SUCCESS";
410
- FetchAssetStatus[FetchAssetStatus["ERROR"] = 1] = "ERROR";
411
- })(FetchAssetStatus || (FetchAssetStatus = {}));
412
-
413
- const textDecoder = new TextDecoder();
414
- function parseServerMessage(buffer) {
415
- const view = new DataView(buffer);
416
- let offset = 0;
417
- const op = view.getUint8(offset);
418
- offset += 1;
419
- switch (op) {
420
- case BinaryOpcode.MESSAGE_DATA: {
421
- const subscriptionId = view.getUint32(offset, true);
422
- offset += 4;
423
- const timestamp = view.getBigUint64(offset, true);
424
- offset += 8;
425
- const data = new DataView(buffer, offset);
426
- return { op, subscriptionId, timestamp, data };
427
- }
428
- case BinaryOpcode.TIME: {
429
- const timestamp = view.getBigUint64(offset, true);
430
- return { op, timestamp };
431
- }
432
- case BinaryOpcode.SERVICE_CALL_RESPONSE: {
433
- const serviceId = view.getUint32(offset, true);
434
- offset += 4;
435
- const callId = view.getUint32(offset, true);
436
- offset += 4;
437
- const encodingLength = view.getUint32(offset, true);
438
- offset += 4;
439
- const encodingBytes = new DataView(buffer, offset, encodingLength);
440
- const encoding = textDecoder.decode(encodingBytes);
441
- offset += encodingLength;
442
- const data = new DataView(buffer, offset, buffer.byteLength - offset);
443
- return { op, serviceId, callId, encoding, data };
444
- }
445
- case BinaryOpcode.FETCH_ASSET_RESPONSE: {
446
- const requestId = view.getUint32(offset, true);
447
- offset += 4;
448
- const status = view.getUint8(offset);
449
- offset += 1;
450
- const errorMsgLength = view.getUint32(offset, true);
451
- offset += 4;
452
- const error = textDecoder.decode(new DataView(buffer, offset, errorMsgLength));
453
- offset += errorMsgLength;
454
- switch (status) {
455
- case FetchAssetStatus.SUCCESS: {
456
- const data = new DataView(buffer, offset, buffer.byteLength - offset);
457
- return { op, requestId, status, data };
458
- }
459
- case FetchAssetStatus.ERROR:
460
- return { op, requestId, status, error };
461
- default:
462
- throw new Error(`Unrecognized fetch asset status: ${status}`);
463
- }
464
- }
465
- }
466
- throw new Error(`Unrecognized server opcode in binary message: ${op.toString(16)}`);
467
- }
468
-
469
- const textEncoder = new TextEncoder();
470
- class FoxgloveClient {
471
- static SUPPORTED_SUBPROTOCOL = "foxglove.websocket.v1";
472
- #emitter = new EventEmitter();
473
- #ws;
474
- #nextSubscriptionId = 0;
475
- #nextAdvertisementId = 0;
476
- constructor({ ws }) {
477
- this.#ws = ws;
478
- this.#reconnect();
479
- }
480
- on(name, listener) {
481
- this.#emitter.on(name, listener);
482
- }
483
- off(name, listener) {
484
- this.#emitter.off(name, listener);
485
- }
486
- #reconnect() {
487
- this.#ws.binaryType = "arraybuffer";
488
- this.#ws.onerror = (event) => {
489
- this.#emitter.emit("error", event.error);
490
- };
491
- this.#ws.onopen = (_event) => {
492
- if (this.#ws.protocol !== FoxgloveClient.SUPPORTED_SUBPROTOCOL) {
493
- throw new Error(`Expected subprotocol ${FoxgloveClient.SUPPORTED_SUBPROTOCOL}, got '${this.#ws.protocol}'`);
494
- }
495
- this.#emitter.emit("open");
496
- };
497
- this.#ws.onmessage = (event) => {
498
- let message;
499
- try {
500
- if (event.data instanceof ArrayBuffer) {
501
- message = parseServerMessage(event.data);
502
- }
503
- else {
504
- message = JSON.parse(event.data);
505
- }
506
- }
507
- catch (error) {
508
- this.#emitter.emit("error", error);
509
- return;
510
- }
511
- switch (message.op) {
512
- case "serverInfo":
513
- this.#emitter.emit("serverInfo", message);
514
- return;
515
- case "status":
516
- this.#emitter.emit("status", message);
517
- return;
518
- case "advertise":
519
- this.#emitter.emit("advertise", message.channels);
520
- return;
521
- case "unadvertise":
522
- this.#emitter.emit("unadvertise", message.channelIds);
523
- return;
524
- case "parameterValues":
525
- this.#emitter.emit("parameterValues", message);
526
- return;
527
- case "advertiseServices":
528
- this.#emitter.emit("advertiseServices", message.services);
529
- return;
530
- case "unadvertiseServices":
531
- this.#emitter.emit("unadvertiseServices", message.serviceIds);
532
- return;
533
- case "connectionGraphUpdate":
534
- this.#emitter.emit("connectionGraphUpdate", message);
535
- return;
536
- case BinaryOpcode.MESSAGE_DATA:
537
- this.#emitter.emit("message", message);
538
- return;
539
- case BinaryOpcode.TIME:
540
- this.#emitter.emit("time", message);
541
- return;
542
- case BinaryOpcode.SERVICE_CALL_RESPONSE:
543
- this.#emitter.emit("serviceCallResponse", message);
544
- return;
545
- case BinaryOpcode.FETCH_ASSET_RESPONSE:
546
- this.#emitter.emit("fetchAssetResponse", message);
547
- return;
548
- }
549
- this.#emitter.emit("error", new Error(`Unrecognized server opcode: ${message.op}`));
550
- };
551
- this.#ws.onclose = (event) => {
552
- this.#emitter.emit("close", event);
553
- };
554
- }
555
- close() {
556
- this.#ws.close();
557
- }
558
- subscribe(channelId) {
559
- const id = this.#nextSubscriptionId++;
560
- const subscriptions = [{ id, channelId }];
561
- this.#send({ op: "subscribe", subscriptions });
562
- return id;
563
- }
564
- unsubscribe(subscriptionId) {
565
- this.#send({ op: "unsubscribe", subscriptionIds: [subscriptionId] });
566
- }
567
- advertise(clientChannel) {
568
- const id = ++this.#nextAdvertisementId;
569
- const channels = [{ id, ...clientChannel }];
570
- this.#send({ op: "advertise", channels });
571
- return id;
572
- }
573
- unadvertise(channelId) {
574
- this.#send({ op: "unadvertise", channelIds: [channelId] });
575
- }
576
- getParameters(parameterNames, id) {
577
- this.#send({ op: "getParameters", parameterNames, id });
578
- }
579
- setParameters(parameters, id) {
580
- this.#send({ op: "setParameters", parameters, id });
581
- }
582
- subscribeParameterUpdates(parameterNames) {
583
- this.#send({ op: "subscribeParameterUpdates", parameterNames });
584
- }
585
- unsubscribeParameterUpdates(parameterNames) {
586
- this.#send({ op: "unsubscribeParameterUpdates", parameterNames });
587
- }
588
- sendMessage(channelId, data) {
589
- const payload = new Uint8Array(5 + data.byteLength);
590
- const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
591
- view.setUint8(0, ClientBinaryOpcode.MESSAGE_DATA);
592
- view.setUint32(1, channelId, true);
593
- payload.set(data, 5);
594
- this.#ws.send(payload);
595
- }
596
- sendServiceCallRequest(request) {
597
- const encoding = textEncoder.encode(request.encoding);
598
- const payload = new Uint8Array(1 + 4 + 4 + 4 + encoding.length + request.data.byteLength);
599
- const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
600
- let offset = 0;
601
- view.setUint8(offset, ClientBinaryOpcode.SERVICE_CALL_REQUEST);
602
- offset += 1;
603
- view.setUint32(offset, request.serviceId, true);
604
- offset += 4;
605
- view.setUint32(offset, request.callId, true);
606
- offset += 4;
607
- view.setUint32(offset, request.encoding.length, true);
608
- offset += 4;
609
- payload.set(encoding, offset);
610
- offset += encoding.length;
611
- const data = new Uint8Array(request.data.buffer, request.data.byteOffset, request.data.byteLength);
612
- payload.set(data, offset);
613
- this.#ws.send(payload);
614
- }
615
- subscribeConnectionGraph() {
616
- this.#send({ op: "subscribeConnectionGraph" });
617
- }
618
- unsubscribeConnectionGraph() {
619
- this.#send({ op: "unsubscribeConnectionGraph" });
620
- }
621
- fetchAsset(uri, requestId) {
622
- this.#send({ op: "fetchAsset", uri, requestId });
623
- }
624
- /**
625
- * @deprecated Use `sendServiceCallRequest` instead
626
- */
627
- sendCallServiceRequest(request) {
628
- this.sendServiceCallRequest(request);
629
- }
630
- #send(message) {
631
- this.#ws.send(JSON.stringify(message));
632
- }
633
- }
634
-
635
- var browser = {exports: {}};
636
-
637
- /**
638
- * This is the common logic for both the Node.js and web browser
639
- * implementations of `debug()`.
640
- */
641
-
642
- function setup(env) {
643
- createDebug.debug = createDebug;
644
- createDebug.default = createDebug;
645
- createDebug.coerce = coerce;
646
- createDebug.disable = disable;
647
- createDebug.enable = enable;
648
- createDebug.enabled = enabled;
649
- createDebug.humanize = require$$0;
650
- createDebug.destroy = destroy;
651
-
652
- Object.keys(env).forEach(key => {
653
- createDebug[key] = env[key];
654
- });
655
-
656
- /**
657
- * The currently active debug mode names, and names to skip.
658
- */
659
-
660
- createDebug.names = [];
661
- createDebug.skips = [];
662
-
663
- /**
664
- * Map of special "%n" handling functions, for the debug "format" argument.
665
- *
666
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
667
- */
668
- createDebug.formatters = {};
669
-
670
- /**
671
- * Selects a color for a debug namespace
672
- * @param {String} namespace The namespace string for the debug instance to be colored
673
- * @return {Number|String} An ANSI color code for the given namespace
674
- * @api private
675
- */
676
- function selectColor(namespace) {
677
- let hash = 0;
678
-
679
- for (let i = 0; i < namespace.length; i++) {
680
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
681
- hash |= 0; // Convert to 32bit integer
682
- }
683
-
684
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
685
- }
686
- createDebug.selectColor = selectColor;
687
-
688
- /**
689
- * Create a debugger with the given `namespace`.
690
- *
691
- * @param {String} namespace
692
- * @return {Function}
693
- * @api public
694
- */
695
- function createDebug(namespace) {
696
- let prevTime;
697
- let enableOverride = null;
698
- let namespacesCache;
699
- let enabledCache;
700
-
701
- function debug(...args) {
702
- // Disabled?
703
- if (!debug.enabled) {
704
- return;
705
- }
706
-
707
- const self = debug;
708
-
709
- // Set `diff` timestamp
710
- const curr = Number(new Date());
711
- const ms = curr - (prevTime || curr);
712
- self.diff = ms;
713
- self.prev = prevTime;
714
- self.curr = curr;
715
- prevTime = curr;
716
-
717
- args[0] = createDebug.coerce(args[0]);
718
-
719
- if (typeof args[0] !== 'string') {
720
- // Anything else let's inspect with %O
721
- args.unshift('%O');
722
- }
723
-
724
- // Apply any `formatters` transformations
725
- let index = 0;
726
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
727
- // If we encounter an escaped % then don't increase the array index
728
- if (match === '%%') {
729
- return '%';
730
- }
731
- index++;
732
- const formatter = createDebug.formatters[format];
733
- if (typeof formatter === 'function') {
734
- const val = args[index];
735
- match = formatter.call(self, val);
736
-
737
- // Now we need to remove `args[index]` since it's inlined in the `format`
738
- args.splice(index, 1);
739
- index--;
740
- }
741
- return match;
742
- });
743
-
744
- // Apply env-specific formatting (colors, etc.)
745
- createDebug.formatArgs.call(self, args);
746
-
747
- const logFn = self.log || createDebug.log;
748
- logFn.apply(self, args);
749
- }
750
-
751
- debug.namespace = namespace;
752
- debug.useColors = createDebug.useColors();
753
- debug.color = createDebug.selectColor(namespace);
754
- debug.extend = extend;
755
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
756
-
757
- Object.defineProperty(debug, 'enabled', {
758
- enumerable: true,
759
- configurable: false,
760
- get: () => {
761
- if (enableOverride !== null) {
762
- return enableOverride;
763
- }
764
- if (namespacesCache !== createDebug.namespaces) {
765
- namespacesCache = createDebug.namespaces;
766
- enabledCache = createDebug.enabled(namespace);
767
- }
768
-
769
- return enabledCache;
770
- },
771
- set: v => {
772
- enableOverride = v;
773
- }
774
- });
775
-
776
- // Env-specific initialization logic for debug instances
777
- if (typeof createDebug.init === 'function') {
778
- createDebug.init(debug);
779
- }
780
-
781
- return debug;
782
- }
783
-
784
- function extend(namespace, delimiter) {
785
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
786
- newDebug.log = this.log;
787
- return newDebug;
788
- }
789
-
790
- /**
791
- * Enables a debug mode by namespaces. This can include modes
792
- * separated by a colon and wildcards.
793
- *
794
- * @param {String} namespaces
795
- * @api public
796
- */
797
- function enable(namespaces) {
798
- createDebug.save(namespaces);
799
- createDebug.namespaces = namespaces;
800
-
801
- createDebug.names = [];
802
- createDebug.skips = [];
803
-
804
- let i;
805
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
806
- const len = split.length;
807
-
808
- for (i = 0; i < len; i++) {
809
- if (!split[i]) {
810
- // ignore empty strings
811
- continue;
812
- }
813
-
814
- namespaces = split[i].replace(/\*/g, '.*?');
815
-
816
- if (namespaces[0] === '-') {
817
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
818
- } else {
819
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
820
- }
821
- }
822
- }
823
-
824
- /**
825
- * Disable debug output.
826
- *
827
- * @return {String} namespaces
828
- * @api public
829
- */
830
- function disable() {
831
- const namespaces = [
832
- ...createDebug.names.map(toNamespace),
833
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
834
- ].join(',');
835
- createDebug.enable('');
836
- return namespaces;
837
- }
838
-
839
- /**
840
- * Returns true if the given mode name is enabled, false otherwise.
841
- *
842
- * @param {String} name
843
- * @return {Boolean}
844
- * @api public
845
- */
846
- function enabled(name) {
847
- if (name[name.length - 1] === '*') {
848
- return true;
849
- }
850
-
851
- let i;
852
- let len;
853
-
854
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
855
- if (createDebug.skips[i].test(name)) {
856
- return false;
857
- }
858
- }
859
-
860
- for (i = 0, len = createDebug.names.length; i < len; i++) {
861
- if (createDebug.names[i].test(name)) {
862
- return true;
863
- }
864
- }
865
-
866
- return false;
867
- }
868
-
869
- /**
870
- * Convert regexp to namespace
871
- *
872
- * @param {RegExp} regxep
873
- * @return {String} namespace
874
- * @api private
875
- */
876
- function toNamespace(regexp) {
877
- return regexp.toString()
878
- .substring(2, regexp.toString().length - 2)
879
- .replace(/\.\*\?$/, '*');
880
- }
881
-
882
- /**
883
- * Coerce `val`.
884
- *
885
- * @param {Mixed} val
886
- * @return {Mixed}
887
- * @api private
888
- */
889
- function coerce(val) {
890
- if (val instanceof Error) {
891
- return val.stack || val.message;
892
- }
893
- return val;
894
- }
895
-
896
- /**
897
- * XXX DO NOT USE. This is a temporary stub function.
898
- * XXX It WILL be removed in the next major release.
899
- */
900
- function destroy() {
901
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
902
- }
903
-
904
- createDebug.enable(createDebug.load());
905
-
906
- return createDebug;
907
- }
908
-
909
- var common = setup;
910
-
911
- /* eslint-env browser */
912
-
913
- (function (module, exports) {
914
- /**
915
- * This is the web browser implementation of `debug()`.
916
- */
917
-
918
- exports.formatArgs = formatArgs;
919
- exports.save = save;
920
- exports.load = load;
921
- exports.useColors = useColors;
922
- exports.storage = localstorage();
923
- exports.destroy = (() => {
924
- let warned = false;
925
-
926
- return () => {
927
- if (!warned) {
928
- warned = true;
929
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
930
- }
931
- };
932
- })();
933
-
934
- /**
935
- * Colors.
936
- */
937
-
938
- exports.colors = [
939
- '#0000CC',
940
- '#0000FF',
941
- '#0033CC',
942
- '#0033FF',
943
- '#0066CC',
944
- '#0066FF',
945
- '#0099CC',
946
- '#0099FF',
947
- '#00CC00',
948
- '#00CC33',
949
- '#00CC66',
950
- '#00CC99',
951
- '#00CCCC',
952
- '#00CCFF',
953
- '#3300CC',
954
- '#3300FF',
955
- '#3333CC',
956
- '#3333FF',
957
- '#3366CC',
958
- '#3366FF',
959
- '#3399CC',
960
- '#3399FF',
961
- '#33CC00',
962
- '#33CC33',
963
- '#33CC66',
964
- '#33CC99',
965
- '#33CCCC',
966
- '#33CCFF',
967
- '#6600CC',
968
- '#6600FF',
969
- '#6633CC',
970
- '#6633FF',
971
- '#66CC00',
972
- '#66CC33',
973
- '#9900CC',
974
- '#9900FF',
975
- '#9933CC',
976
- '#9933FF',
977
- '#99CC00',
978
- '#99CC33',
979
- '#CC0000',
980
- '#CC0033',
981
- '#CC0066',
982
- '#CC0099',
983
- '#CC00CC',
984
- '#CC00FF',
985
- '#CC3300',
986
- '#CC3333',
987
- '#CC3366',
988
- '#CC3399',
989
- '#CC33CC',
990
- '#CC33FF',
991
- '#CC6600',
992
- '#CC6633',
993
- '#CC9900',
994
- '#CC9933',
995
- '#CCCC00',
996
- '#CCCC33',
997
- '#FF0000',
998
- '#FF0033',
999
- '#FF0066',
1000
- '#FF0099',
1001
- '#FF00CC',
1002
- '#FF00FF',
1003
- '#FF3300',
1004
- '#FF3333',
1005
- '#FF3366',
1006
- '#FF3399',
1007
- '#FF33CC',
1008
- '#FF33FF',
1009
- '#FF6600',
1010
- '#FF6633',
1011
- '#FF9900',
1012
- '#FF9933',
1013
- '#FFCC00',
1014
- '#FFCC33'
1015
- ];
1016
-
1017
- /**
1018
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1019
- * and the Firebug extension (any Firefox version) are known
1020
- * to support "%c" CSS customizations.
1021
- *
1022
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
1023
- */
1024
-
1025
- // eslint-disable-next-line complexity
1026
- function useColors() {
1027
- // NB: In an Electron preload script, document will be defined but not fully
1028
- // initialized. Since we know we're in Chrome, we'll just detect this case
1029
- // explicitly
1030
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1031
- return true;
1032
- }
1033
-
1034
- // Internet Explorer and Edge do not support colors.
1035
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1036
- return false;
1037
- }
1038
-
1039
- // Is webkit? http://stackoverflow.com/a/16459606/376773
1040
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1041
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1042
- // Is firebug? http://stackoverflow.com/a/398120/376773
1043
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1044
- // Is firefox >= v31?
1045
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1046
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
1047
- // Double check webkit in userAgent just in case we are in a worker
1048
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1049
- }
1050
-
1051
- /**
1052
- * Colorize log arguments if enabled.
1053
- *
1054
- * @api public
1055
- */
1056
-
1057
- function formatArgs(args) {
1058
- args[0] = (this.useColors ? '%c' : '') +
1059
- this.namespace +
1060
- (this.useColors ? ' %c' : ' ') +
1061
- args[0] +
1062
- (this.useColors ? '%c ' : ' ') +
1063
- '+' + module.exports.humanize(this.diff);
1064
-
1065
- if (!this.useColors) {
1066
- return;
1067
- }
1068
-
1069
- const c = 'color: ' + this.color;
1070
- args.splice(1, 0, c, 'color: inherit');
1071
-
1072
- // The final "%c" is somewhat tricky, because there could be other
1073
- // arguments passed either before or after the %c, so we need to
1074
- // figure out the correct index to insert the CSS into
1075
- let index = 0;
1076
- let lastC = 0;
1077
- args[0].replace(/%[a-zA-Z%]/g, match => {
1078
- if (match === '%%') {
1079
- return;
1080
- }
1081
- index++;
1082
- if (match === '%c') {
1083
- // We only are interested in the *last* %c
1084
- // (the user may have provided their own)
1085
- lastC = index;
1086
- }
1087
- });
1088
-
1089
- args.splice(lastC, 0, c);
1090
- }
1091
-
1092
- /**
1093
- * Invokes `console.debug()` when available.
1094
- * No-op when `console.debug` is not a "function".
1095
- * If `console.debug` is not available, falls back
1096
- * to `console.log`.
1097
- *
1098
- * @api public
1099
- */
1100
- exports.log = console.debug || console.log || (() => {});
1101
-
1102
- /**
1103
- * Save `namespaces`.
1104
- *
1105
- * @param {String} namespaces
1106
- * @api private
1107
- */
1108
- function save(namespaces) {
1109
- try {
1110
- if (namespaces) {
1111
- exports.storage.setItem('debug', namespaces);
1112
- } else {
1113
- exports.storage.removeItem('debug');
1114
- }
1115
- } catch (error) {
1116
- // Swallow
1117
- // XXX (@Qix-) should we be logging these?
1118
- }
1119
- }
1120
-
1121
- /**
1122
- * Load `namespaces`.
1123
- *
1124
- * @return {String} returns the previously persisted debug modes
1125
- * @api private
1126
- */
1127
- function load() {
1128
- let r;
1129
- try {
1130
- r = exports.storage.getItem('debug');
1131
- } catch (error) {
1132
- // Swallow
1133
- // XXX (@Qix-) should we be logging these?
1134
- }
1135
-
1136
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1137
- if (!r && typeof process !== 'undefined' && 'env' in process) {
1138
- r = process.env.DEBUG;
1139
- }
1140
-
1141
- return r;
1142
- }
1143
-
1144
- /**
1145
- * Localstorage attempts to return the localstorage.
1146
- *
1147
- * This is necessary because safari throws
1148
- * when a user disables cookies/localstorage
1149
- * and you attempt to access it.
1150
- *
1151
- * @return {LocalStorage}
1152
- * @api private
1153
- */
1154
-
1155
- function localstorage() {
1156
- try {
1157
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1158
- // The Browser also has localStorage in the global context.
1159
- return localStorage;
1160
- } catch (error) {
1161
- // Swallow
1162
- // XXX (@Qix-) should we be logging these?
1163
- }
1164
- }
1165
-
1166
- module.exports = common(exports);
1167
-
1168
- const {formatters} = module.exports;
1169
-
1170
- /**
1171
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1172
- */
1173
-
1174
- formatters.j = function (v) {
1175
- try {
1176
- return JSON.stringify(v);
1177
- } catch (error) {
1178
- return '[UnexpectedJSONParseError]: ' + error.message;
1179
- }
1180
- };
1181
- } (browser, browser.exports));
1182
-
1183
- var browserExports = browser.exports;
1184
- var createDebug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
1185
-
1186
- createDebug("foxglove:server");
1187
- new TextEncoder();
1188
- ({
1189
- subscribe: undefined,
1190
- unsubscribe: undefined,
1191
- advertise: ServerCapability.clientPublish,
1192
- unadvertise: ServerCapability.clientPublish,
1193
- [ClientBinaryOpcode.MESSAGE_DATA]: ServerCapability.clientPublish,
1194
- getParameters: ServerCapability.parameters,
1195
- setParameters: ServerCapability.parameters,
1196
- subscribeParameterUpdates: ServerCapability.parametersSubscribe,
1197
- unsubscribeParameterUpdates: ServerCapability.parametersSubscribe,
1198
- [ClientBinaryOpcode.SERVICE_CALL_REQUEST]: ServerCapability.services,
1199
- subscribeConnectionGraph: ServerCapability.connectionGraph,
1200
- unsubscribeConnectionGraph: ServerCapability.connectionGraph,
1201
- fetchAsset: ServerCapability.assets,
1202
- });
1203
-
1204
- // This Source Code Form is subject to the terms of the Mozilla Public
1205
- // License, v2.0. If a copy of the MPL was not distributed with this
1206
- // file, You can obtain one at http://mozilla.org/MPL/2.0/
1207
-
1208
- class WsWorker extends FoxgloveCommunicator {
1209
- #ws;
1210
- #client;
1211
- #subscriptions = new Map();
1212
- #createWs(url, onReconnect) {
1213
- this.#ws = new Waterfall(url, FoxgloveClient.SUPPORTED_SUBPROTOCOL, {
1214
- connectionTimeout: 2000,
1215
- retryPolicy: _attempt => {
1216
- onReconnect();
1217
- return 1_000;
1218
- },
1219
- factory: wsUrl => {
1220
- const rawWs = new WebSocket(wsUrl, FoxgloveClient.SUPPORTED_SUBPROTOCOL);
1221
- rawWs.binaryType = "arraybuffer";
1222
- return rawWs;
1223
- }
1224
- });
1225
- }
1226
- #createClient() {
1227
- this.#client = new FoxgloveClient({
1228
- ws: this.#ws
1229
- });
1230
- this.#client.on("open", () => {
1231
- this.send({
1232
- type: "open"
1233
- });
1234
- });
1235
- this.#client.on("close", () => {
1236
- this.send({
1237
- type: "close"
1238
- });
1239
- });
1240
- this.#client.on("error", error => {
1241
- this.send({
1242
- type: "error",
1243
- error
1244
- });
1245
- });
1246
- this.#client.on("message", ({
1247
- subscriptionId,
1248
- data
1249
- }) => {
1250
- const subscription = this.#subscriptions.get(subscriptionId);
1251
- if (subscription) {
1252
- this.handleGenericMessage(subscription.topic, subscription.schema, data);
1253
- }
1254
- });
1255
- }
1256
- #handleMessages() {
1257
- this.#client.on("advertise", this.handleChannelsAdvertisement.bind(this));
1258
- this.#client.on("unadvertise", this.handleChannelsUnadvertisement.bind(this));
1259
- this.#client.on("advertiseServices", this.handleServicesAdvertisement.bind(this));
1260
- this.#client.on("unadvertiseServices", this.handleServicesUnadvertisement.bind(this));
1261
- this.#client.on("serviceCallResponse", this.handleServiceResponse.bind(this));
1262
- }
1263
- isReady() {
1264
- return this.#ws.readyState === this.#ws.OPEN;
1265
- }
1266
- sendServiceCallRequest(request) {
1267
- this.#client.sendServiceCallRequest(request);
1268
- }
1269
- subscribe(topics) {
1270
- const channels = this.getPublicChannels().filter(publicChannel => topics.includes(publicChannel.topic));
1271
- for (const channel of channels) {
1272
- const subscription = this.#client.subscribe(channel.id);
1273
- this.#subscriptions.set(subscription, {
1274
- topic: channel.topic,
1275
- schema: channel.schemaName,
1276
- kind: channel.kind
1277
- });
1278
- }
1279
- }
1280
- unsubscribe(topics) {
1281
- const subscriptionIds = [...this.#subscriptions.entries()].filter(([_id, data]) => topics.includes(data.topic)).map(subscription => subscription[0]);
1282
- for (const subscriptionId of subscriptionIds) {
1283
- this.#subscriptions.delete(subscriptionId);
1284
- this.#client.unsubscribe(subscriptionId);
1285
- }
1286
- }
1287
- constructor(wsUrl, send, sendWithTransfer) {
1288
- super();
1289
- this.send = send;
1290
- this.sendWithTransfer = sendWithTransfer;
1291
- try {
1292
- this.#createWs(wsUrl, this.handleReconnect.bind(this));
1293
- this.#createClient();
1294
- this.#handleMessages();
1295
- } catch (error) {
1296
- // try-catch is needed to catch `Mixed Content` errors in Chrome, where the client
1297
- // attempts to load `ws://` from `https://`. (Safari would catch these in `ws.onerror`
1298
- // but with `undefined` as an error.)
1299
- send({
1300
- type: "error",
1301
- error: error ?? {
1302
- message: "Insecure WebSocket connection"
1303
- }
1304
- });
1305
- }
1306
- }
1307
- rawSend(data) {
1308
- if (this.#ws.readyState === this.#ws.OPEN) {
1309
- this.#ws.send(data);
1310
- }
1311
- }
1312
- close() {
1313
- this.#client.close();
1314
- }
1315
- callService({
1316
- name,
1317
- serviceCallId,
1318
- body = {}
1319
- }) {
1320
- super.callService({
1321
- name,
1322
- serviceCallId,
1323
- body
1324
- });
1325
- }
1326
- }
1327
- function createWsWorkerMessageListener(send, sendWithTransfer) {
1328
- let wsWorker = null;
1329
- return async event => {
1330
- const {
1331
- type,
1332
- data
1333
- } = event.data;
1334
- switch (type) {
1335
- case "open":
1336
- wsWorker = new WsWorker('wsUrl' in data ? data.wsUrl : '', send, sendWithTransfer);
1337
- break;
1338
- case "close":
1339
- wsWorker?.close();
1340
- break;
1341
- case "send":
1342
- wsWorker?.rawSend(data);
1343
- break;
1344
- case "call_service":
1345
- wsWorker?.callService(data);
1346
- break;
1347
- case 'subscribe':
1348
- wsWorker?.subscribe(data);
1349
- break;
1350
- case 'unsubscribe':
1351
- wsWorker?.unsubscribe(data);
1352
- break;
1353
- }
1354
- };
1355
- }
1356
-
1357
- export { EventEmitter as E, getDefaultExportFromCjs as a, createWsWorkerMessageListener as b, commonjsGlobal as c, getAugmentedNamespace as g };