@luxonis/visualizer-protobuf 1.8.7 → 1.9.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 (75) hide show
  1. package/dist/apps/depthai-visualizer/src/components/Panel.d.ts.map +1 -1
  2. package/dist/apps/depthai-visualizer/src/components/Panel.js.map +1 -1
  3. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.d.ts.map +1 -1
  4. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js +14 -1
  5. package/dist/apps/depthai-visualizer/src/components/PanelToolbar.js.map +1 -1
  6. package/dist/apps/depthai-visualizer/src/connection/BaseConnection.d.ts +17 -9
  7. package/dist/apps/depthai-visualizer/src/connection/BaseConnection.d.ts.map +1 -1
  8. package/dist/apps/depthai-visualizer/src/connection/BaseConnection.js +23 -38
  9. package/dist/apps/depthai-visualizer/src/connection/BaseConnection.js.map +1 -1
  10. package/dist/apps/depthai-visualizer/src/connection/ws/Adapter.d.ts +1 -1
  11. package/dist/apps/depthai-visualizer/src/connection/ws/Adapter.d.ts.map +1 -1
  12. package/dist/apps/depthai-visualizer/src/connection/ws/Adapter.js +6 -3
  13. package/dist/apps/depthai-visualizer/src/connection/ws/Adapter.js.map +1 -1
  14. package/dist/apps/depthai-visualizer/src/connection/ws/Connection.d.ts +6 -6
  15. package/dist/apps/depthai-visualizer/src/connection/ws/Connection.d.ts.map +1 -1
  16. package/dist/apps/depthai-visualizer/src/connection/ws/Connection.js +5 -6
  17. package/dist/apps/depthai-visualizer/src/connection/ws/Connection.js.map +1 -1
  18. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts +83 -0
  19. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.d.ts.map +1 -0
  20. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js +184 -0
  21. package/dist/apps/depthai-visualizer/src/connection/ws/worker-utils.js.map +1 -0
  22. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts +1 -57
  23. package/dist/apps/depthai-visualizer/src/connection/ws/worker.d.ts.map +1 -1
  24. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js +2 -171
  25. package/dist/apps/depthai-visualizer/src/connection/ws/worker.js.map +1 -1
  26. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts +4 -0
  27. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.d.ts.map +1 -0
  28. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.js +4 -0
  29. package/dist/apps/depthai-visualizer/src/context/ConnectionsProvider.js.map +1 -0
  30. package/dist/apps/depthai-visualizer/src/context/MessagePipelineProvider.d.ts +1 -4
  31. package/dist/apps/depthai-visualizer/src/context/MessagePipelineProvider.d.ts.map +1 -1
  32. package/dist/apps/depthai-visualizer/src/context/MessagePipelineProvider.js +3 -2
  33. package/dist/apps/depthai-visualizer/src/context/MessagePipelineProvider.js.map +1 -1
  34. package/dist/apps/depthai-visualizer/src/context/VisualizerContext.d.ts.map +1 -1
  35. package/dist/apps/depthai-visualizer/src/context/VisualizerContext.js +3 -1
  36. package/dist/apps/depthai-visualizer/src/context/VisualizerContext.js.map +1 -1
  37. package/dist/apps/depthai-visualizer/src/index.d.ts +3 -4
  38. package/dist/apps/depthai-visualizer/src/index.d.ts.map +1 -1
  39. package/dist/apps/depthai-visualizer/src/index.js +1 -2
  40. package/dist/apps/depthai-visualizer/src/index.js.map +1 -1
  41. package/dist/apps/depthai-visualizer/src/panels/ImagePanel.d.ts +4 -2
  42. package/dist/apps/depthai-visualizer/src/panels/ImagePanel.d.ts.map +1 -1
  43. package/dist/apps/depthai-visualizer/src/panels/ImagePanel.js.map +1 -1
  44. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.d.ts +6 -0
  45. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.d.ts.map +1 -0
  46. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js +25 -0
  47. package/dist/apps/depthai-visualizer/src/utils/metrics-manager.js.map +1 -0
  48. package/dist/{index-DbBAYYLN.js → index-2SFix7KY.js} +4 -2
  49. package/dist/{index-CzFeKxPw.js → index-7n6fnp2B.js} +4 -2
  50. package/dist/{index-DiuZWhZw.js → index-B8Cado6g.js} +4 -2
  51. package/dist/{index-BOt4IOh5.js → index-B8FQDMoh.js} +4 -2
  52. package/dist/{index-CVP9pfZS.js → index-B8t-Gi4x.js} +4 -2
  53. package/dist/{index-BuuOsI5x.js → index-BEcWpcB1.js} +7 -4
  54. package/dist/{index-DTSS5_f7.js → index-Bay9MnxH.js} +4 -2
  55. package/dist/{index-CxLTPANc.js → index-Bk6p8-al.js} +4 -2
  56. package/dist/{index-DY872ZDo.js → index-BkQgkjmO.js} +4 -2
  57. package/dist/{index-BgXnyRS5.js → index-BvNZUlo_.js} +4 -2
  58. package/dist/{index-PRD8Vx5h.js → index-CNWGMhCW.js} +107 -499
  59. package/dist/{index-BYKYHdD1.js → index-ChQWCJEj.js} +4 -2
  60. package/dist/{index-BbjcxqKn.js → index-Cp3omW6p.js} +5 -4
  61. package/dist/{index-tsO6geQz.js → index-DKfQ_S8i.js} +4 -2
  62. package/dist/{index-ByXG8O46.js → index-DSLjhjen.js} +4 -2
  63. package/dist/{index-iE53L-9n.js → index-Dn-E1-20.js} +4 -2
  64. package/dist/{index-CeDdrD6U.js → index-GbwWdY6w.js} +4 -2
  65. package/dist/{index-Du_K2fSC.js → index-otpYhpPx.js} +4 -2
  66. package/dist/{index-BKodwqoN.js → index-txFQeh8N.js} +4 -2
  67. package/dist/index.js +5 -3
  68. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/Images/WorkerImageDecoder.d.ts.map +1 -1
  69. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/Images/WorkerImageDecoder.js +1 -1
  70. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/Images/WorkerImageDecoder.js.map +1 -1
  71. package/dist/worker-D2k1TTky.js +10 -0
  72. package/dist/{protobuf-CjDCjqx3.js → worker-utils-Jii8lIsy.js} +1406 -1
  73. package/package.json +1 -1
  74. package/dist/index-CcszYLTP.js +0 -346
  75. package/dist/worker-CHyNU_Ed.js +0 -1059
@@ -1,1059 +0,0 @@
1
- import { Waterfall } from 'hydrated-ws';
2
- import { E as EventEmitter } from './index-CcszYLTP.js';
3
- import { a as getDefaultExportFromCjs, p as protobufsBySchema } from './protobuf-CjDCjqx3.js';
4
- import require$$0 from 'ms';
5
- import 'protobufjs/minimal';
6
-
7
- var BinaryOpcode;
8
- (function (BinaryOpcode) {
9
- BinaryOpcode[BinaryOpcode["MESSAGE_DATA"] = 1] = "MESSAGE_DATA";
10
- BinaryOpcode[BinaryOpcode["TIME"] = 2] = "TIME";
11
- BinaryOpcode[BinaryOpcode["SERVICE_CALL_RESPONSE"] = 3] = "SERVICE_CALL_RESPONSE";
12
- BinaryOpcode[BinaryOpcode["FETCH_ASSET_RESPONSE"] = 4] = "FETCH_ASSET_RESPONSE";
13
- })(BinaryOpcode || (BinaryOpcode = {}));
14
- var ClientBinaryOpcode;
15
- (function (ClientBinaryOpcode) {
16
- ClientBinaryOpcode[ClientBinaryOpcode["MESSAGE_DATA"] = 1] = "MESSAGE_DATA";
17
- ClientBinaryOpcode[ClientBinaryOpcode["SERVICE_CALL_REQUEST"] = 2] = "SERVICE_CALL_REQUEST";
18
- })(ClientBinaryOpcode || (ClientBinaryOpcode = {}));
19
- var StatusLevel;
20
- (function (StatusLevel) {
21
- StatusLevel[StatusLevel["INFO"] = 0] = "INFO";
22
- StatusLevel[StatusLevel["WARNING"] = 1] = "WARNING";
23
- StatusLevel[StatusLevel["ERROR"] = 2] = "ERROR";
24
- })(StatusLevel || (StatusLevel = {}));
25
- var ServerCapability;
26
- (function (ServerCapability) {
27
- ServerCapability["clientPublish"] = "clientPublish";
28
- ServerCapability["time"] = "time";
29
- ServerCapability["parameters"] = "parameters";
30
- ServerCapability["parametersSubscribe"] = "parametersSubscribe";
31
- ServerCapability["services"] = "services";
32
- ServerCapability["connectionGraph"] = "connectionGraph";
33
- ServerCapability["assets"] = "assets";
34
- })(ServerCapability || (ServerCapability = {}));
35
- var FetchAssetStatus;
36
- (function (FetchAssetStatus) {
37
- FetchAssetStatus[FetchAssetStatus["SUCCESS"] = 0] = "SUCCESS";
38
- FetchAssetStatus[FetchAssetStatus["ERROR"] = 1] = "ERROR";
39
- })(FetchAssetStatus || (FetchAssetStatus = {}));
40
-
41
- const textDecoder = new TextDecoder();
42
- function parseServerMessage(buffer) {
43
- const view = new DataView(buffer);
44
- let offset = 0;
45
- const op = view.getUint8(offset);
46
- offset += 1;
47
- switch (op) {
48
- case BinaryOpcode.MESSAGE_DATA: {
49
- const subscriptionId = view.getUint32(offset, true);
50
- offset += 4;
51
- const timestamp = view.getBigUint64(offset, true);
52
- offset += 8;
53
- const data = new DataView(buffer, offset);
54
- return { op, subscriptionId, timestamp, data };
55
- }
56
- case BinaryOpcode.TIME: {
57
- const timestamp = view.getBigUint64(offset, true);
58
- return { op, timestamp };
59
- }
60
- case BinaryOpcode.SERVICE_CALL_RESPONSE: {
61
- const serviceId = view.getUint32(offset, true);
62
- offset += 4;
63
- const callId = view.getUint32(offset, true);
64
- offset += 4;
65
- const encodingLength = view.getUint32(offset, true);
66
- offset += 4;
67
- const encodingBytes = new DataView(buffer, offset, encodingLength);
68
- const encoding = textDecoder.decode(encodingBytes);
69
- offset += encodingLength;
70
- const data = new DataView(buffer, offset, buffer.byteLength - offset);
71
- return { op, serviceId, callId, encoding, data };
72
- }
73
- case BinaryOpcode.FETCH_ASSET_RESPONSE: {
74
- const requestId = view.getUint32(offset, true);
75
- offset += 4;
76
- const status = view.getUint8(offset);
77
- offset += 1;
78
- const errorMsgLength = view.getUint32(offset, true);
79
- offset += 4;
80
- const error = textDecoder.decode(new DataView(buffer, offset, errorMsgLength));
81
- offset += errorMsgLength;
82
- switch (status) {
83
- case FetchAssetStatus.SUCCESS: {
84
- const data = new DataView(buffer, offset, buffer.byteLength - offset);
85
- return { op, requestId, status, data };
86
- }
87
- case FetchAssetStatus.ERROR:
88
- return { op, requestId, status, error };
89
- default:
90
- throw new Error(`Unrecognized fetch asset status: ${status}`);
91
- }
92
- }
93
- }
94
- throw new Error(`Unrecognized server opcode in binary message: ${op.toString(16)}`);
95
- }
96
-
97
- const textEncoder = new TextEncoder();
98
- class FoxgloveClient {
99
- static SUPPORTED_SUBPROTOCOL = "foxglove.websocket.v1";
100
- #emitter = new EventEmitter();
101
- #ws;
102
- #nextSubscriptionId = 0;
103
- #nextAdvertisementId = 0;
104
- constructor({ ws }) {
105
- this.#ws = ws;
106
- this.#reconnect();
107
- }
108
- on(name, listener) {
109
- this.#emitter.on(name, listener);
110
- }
111
- off(name, listener) {
112
- this.#emitter.off(name, listener);
113
- }
114
- #reconnect() {
115
- this.#ws.binaryType = "arraybuffer";
116
- this.#ws.onerror = (event) => {
117
- this.#emitter.emit("error", event.error);
118
- };
119
- this.#ws.onopen = (_event) => {
120
- if (this.#ws.protocol !== FoxgloveClient.SUPPORTED_SUBPROTOCOL) {
121
- throw new Error(`Expected subprotocol ${FoxgloveClient.SUPPORTED_SUBPROTOCOL}, got '${this.#ws.protocol}'`);
122
- }
123
- this.#emitter.emit("open");
124
- };
125
- this.#ws.onmessage = (event) => {
126
- let message;
127
- try {
128
- if (event.data instanceof ArrayBuffer) {
129
- message = parseServerMessage(event.data);
130
- }
131
- else {
132
- message = JSON.parse(event.data);
133
- }
134
- }
135
- catch (error) {
136
- this.#emitter.emit("error", error);
137
- return;
138
- }
139
- switch (message.op) {
140
- case "serverInfo":
141
- this.#emitter.emit("serverInfo", message);
142
- return;
143
- case "status":
144
- this.#emitter.emit("status", message);
145
- return;
146
- case "advertise":
147
- this.#emitter.emit("advertise", message.channels);
148
- return;
149
- case "unadvertise":
150
- this.#emitter.emit("unadvertise", message.channelIds);
151
- return;
152
- case "parameterValues":
153
- this.#emitter.emit("parameterValues", message);
154
- return;
155
- case "advertiseServices":
156
- this.#emitter.emit("advertiseServices", message.services);
157
- return;
158
- case "unadvertiseServices":
159
- this.#emitter.emit("unadvertiseServices", message.serviceIds);
160
- return;
161
- case "connectionGraphUpdate":
162
- this.#emitter.emit("connectionGraphUpdate", message);
163
- return;
164
- case BinaryOpcode.MESSAGE_DATA:
165
- this.#emitter.emit("message", message);
166
- return;
167
- case BinaryOpcode.TIME:
168
- this.#emitter.emit("time", message);
169
- return;
170
- case BinaryOpcode.SERVICE_CALL_RESPONSE:
171
- this.#emitter.emit("serviceCallResponse", message);
172
- return;
173
- case BinaryOpcode.FETCH_ASSET_RESPONSE:
174
- this.#emitter.emit("fetchAssetResponse", message);
175
- return;
176
- }
177
- this.#emitter.emit("error", new Error(`Unrecognized server opcode: ${message.op}`));
178
- };
179
- this.#ws.onclose = (event) => {
180
- this.#emitter.emit("close", event);
181
- };
182
- }
183
- close() {
184
- this.#ws.close();
185
- }
186
- subscribe(channelId) {
187
- const id = this.#nextSubscriptionId++;
188
- const subscriptions = [{ id, channelId }];
189
- this.#send({ op: "subscribe", subscriptions });
190
- return id;
191
- }
192
- unsubscribe(subscriptionId) {
193
- this.#send({ op: "unsubscribe", subscriptionIds: [subscriptionId] });
194
- }
195
- advertise(clientChannel) {
196
- const id = ++this.#nextAdvertisementId;
197
- const channels = [{ id, ...clientChannel }];
198
- this.#send({ op: "advertise", channels });
199
- return id;
200
- }
201
- unadvertise(channelId) {
202
- this.#send({ op: "unadvertise", channelIds: [channelId] });
203
- }
204
- getParameters(parameterNames, id) {
205
- this.#send({ op: "getParameters", parameterNames, id });
206
- }
207
- setParameters(parameters, id) {
208
- this.#send({ op: "setParameters", parameters, id });
209
- }
210
- subscribeParameterUpdates(parameterNames) {
211
- this.#send({ op: "subscribeParameterUpdates", parameterNames });
212
- }
213
- unsubscribeParameterUpdates(parameterNames) {
214
- this.#send({ op: "unsubscribeParameterUpdates", parameterNames });
215
- }
216
- sendMessage(channelId, data) {
217
- const payload = new Uint8Array(5 + data.byteLength);
218
- const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
219
- view.setUint8(0, ClientBinaryOpcode.MESSAGE_DATA);
220
- view.setUint32(1, channelId, true);
221
- payload.set(data, 5);
222
- this.#ws.send(payload);
223
- }
224
- sendServiceCallRequest(request) {
225
- const encoding = textEncoder.encode(request.encoding);
226
- const payload = new Uint8Array(1 + 4 + 4 + 4 + encoding.length + request.data.byteLength);
227
- const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
228
- let offset = 0;
229
- view.setUint8(offset, ClientBinaryOpcode.SERVICE_CALL_REQUEST);
230
- offset += 1;
231
- view.setUint32(offset, request.serviceId, true);
232
- offset += 4;
233
- view.setUint32(offset, request.callId, true);
234
- offset += 4;
235
- view.setUint32(offset, request.encoding.length, true);
236
- offset += 4;
237
- payload.set(encoding, offset);
238
- offset += encoding.length;
239
- const data = new Uint8Array(request.data.buffer, request.data.byteOffset, request.data.byteLength);
240
- payload.set(data, offset);
241
- this.#ws.send(payload);
242
- }
243
- subscribeConnectionGraph() {
244
- this.#send({ op: "subscribeConnectionGraph" });
245
- }
246
- unsubscribeConnectionGraph() {
247
- this.#send({ op: "unsubscribeConnectionGraph" });
248
- }
249
- fetchAsset(uri, requestId) {
250
- this.#send({ op: "fetchAsset", uri, requestId });
251
- }
252
- /**
253
- * @deprecated Use `sendServiceCallRequest` instead
254
- */
255
- sendCallServiceRequest(request) {
256
- this.sendServiceCallRequest(request);
257
- }
258
- #send(message) {
259
- this.#ws.send(JSON.stringify(message));
260
- }
261
- }
262
-
263
- var browser = {exports: {}};
264
-
265
- /**
266
- * This is the common logic for both the Node.js and web browser
267
- * implementations of `debug()`.
268
- */
269
-
270
- function setup(env) {
271
- createDebug.debug = createDebug;
272
- createDebug.default = createDebug;
273
- createDebug.coerce = coerce;
274
- createDebug.disable = disable;
275
- createDebug.enable = enable;
276
- createDebug.enabled = enabled;
277
- createDebug.humanize = require$$0;
278
- createDebug.destroy = destroy;
279
-
280
- Object.keys(env).forEach(key => {
281
- createDebug[key] = env[key];
282
- });
283
-
284
- /**
285
- * The currently active debug mode names, and names to skip.
286
- */
287
-
288
- createDebug.names = [];
289
- createDebug.skips = [];
290
-
291
- /**
292
- * Map of special "%n" handling functions, for the debug "format" argument.
293
- *
294
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
295
- */
296
- createDebug.formatters = {};
297
-
298
- /**
299
- * Selects a color for a debug namespace
300
- * @param {String} namespace The namespace string for the debug instance to be colored
301
- * @return {Number|String} An ANSI color code for the given namespace
302
- * @api private
303
- */
304
- function selectColor(namespace) {
305
- let hash = 0;
306
-
307
- for (let i = 0; i < namespace.length; i++) {
308
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
309
- hash |= 0; // Convert to 32bit integer
310
- }
311
-
312
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
313
- }
314
- createDebug.selectColor = selectColor;
315
-
316
- /**
317
- * Create a debugger with the given `namespace`.
318
- *
319
- * @param {String} namespace
320
- * @return {Function}
321
- * @api public
322
- */
323
- function createDebug(namespace) {
324
- let prevTime;
325
- let enableOverride = null;
326
- let namespacesCache;
327
- let enabledCache;
328
-
329
- function debug(...args) {
330
- // Disabled?
331
- if (!debug.enabled) {
332
- return;
333
- }
334
-
335
- const self = debug;
336
-
337
- // Set `diff` timestamp
338
- const curr = Number(new Date());
339
- const ms = curr - (prevTime || curr);
340
- self.diff = ms;
341
- self.prev = prevTime;
342
- self.curr = curr;
343
- prevTime = curr;
344
-
345
- args[0] = createDebug.coerce(args[0]);
346
-
347
- if (typeof args[0] !== 'string') {
348
- // Anything else let's inspect with %O
349
- args.unshift('%O');
350
- }
351
-
352
- // Apply any `formatters` transformations
353
- let index = 0;
354
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
355
- // If we encounter an escaped % then don't increase the array index
356
- if (match === '%%') {
357
- return '%';
358
- }
359
- index++;
360
- const formatter = createDebug.formatters[format];
361
- if (typeof formatter === 'function') {
362
- const val = args[index];
363
- match = formatter.call(self, val);
364
-
365
- // Now we need to remove `args[index]` since it's inlined in the `format`
366
- args.splice(index, 1);
367
- index--;
368
- }
369
- return match;
370
- });
371
-
372
- // Apply env-specific formatting (colors, etc.)
373
- createDebug.formatArgs.call(self, args);
374
-
375
- const logFn = self.log || createDebug.log;
376
- logFn.apply(self, args);
377
- }
378
-
379
- debug.namespace = namespace;
380
- debug.useColors = createDebug.useColors();
381
- debug.color = createDebug.selectColor(namespace);
382
- debug.extend = extend;
383
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
384
-
385
- Object.defineProperty(debug, 'enabled', {
386
- enumerable: true,
387
- configurable: false,
388
- get: () => {
389
- if (enableOverride !== null) {
390
- return enableOverride;
391
- }
392
- if (namespacesCache !== createDebug.namespaces) {
393
- namespacesCache = createDebug.namespaces;
394
- enabledCache = createDebug.enabled(namespace);
395
- }
396
-
397
- return enabledCache;
398
- },
399
- set: v => {
400
- enableOverride = v;
401
- }
402
- });
403
-
404
- // Env-specific initialization logic for debug instances
405
- if (typeof createDebug.init === 'function') {
406
- createDebug.init(debug);
407
- }
408
-
409
- return debug;
410
- }
411
-
412
- function extend(namespace, delimiter) {
413
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
414
- newDebug.log = this.log;
415
- return newDebug;
416
- }
417
-
418
- /**
419
- * Enables a debug mode by namespaces. This can include modes
420
- * separated by a colon and wildcards.
421
- *
422
- * @param {String} namespaces
423
- * @api public
424
- */
425
- function enable(namespaces) {
426
- createDebug.save(namespaces);
427
- createDebug.namespaces = namespaces;
428
-
429
- createDebug.names = [];
430
- createDebug.skips = [];
431
-
432
- let i;
433
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
434
- const len = split.length;
435
-
436
- for (i = 0; i < len; i++) {
437
- if (!split[i]) {
438
- // ignore empty strings
439
- continue;
440
- }
441
-
442
- namespaces = split[i].replace(/\*/g, '.*?');
443
-
444
- if (namespaces[0] === '-') {
445
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
446
- } else {
447
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
448
- }
449
- }
450
- }
451
-
452
- /**
453
- * Disable debug output.
454
- *
455
- * @return {String} namespaces
456
- * @api public
457
- */
458
- function disable() {
459
- const namespaces = [
460
- ...createDebug.names.map(toNamespace),
461
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
462
- ].join(',');
463
- createDebug.enable('');
464
- return namespaces;
465
- }
466
-
467
- /**
468
- * Returns true if the given mode name is enabled, false otherwise.
469
- *
470
- * @param {String} name
471
- * @return {Boolean}
472
- * @api public
473
- */
474
- function enabled(name) {
475
- if (name[name.length - 1] === '*') {
476
- return true;
477
- }
478
-
479
- let i;
480
- let len;
481
-
482
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
483
- if (createDebug.skips[i].test(name)) {
484
- return false;
485
- }
486
- }
487
-
488
- for (i = 0, len = createDebug.names.length; i < len; i++) {
489
- if (createDebug.names[i].test(name)) {
490
- return true;
491
- }
492
- }
493
-
494
- return false;
495
- }
496
-
497
- /**
498
- * Convert regexp to namespace
499
- *
500
- * @param {RegExp} regxep
501
- * @return {String} namespace
502
- * @api private
503
- */
504
- function toNamespace(regexp) {
505
- return regexp.toString()
506
- .substring(2, regexp.toString().length - 2)
507
- .replace(/\.\*\?$/, '*');
508
- }
509
-
510
- /**
511
- * Coerce `val`.
512
- *
513
- * @param {Mixed} val
514
- * @return {Mixed}
515
- * @api private
516
- */
517
- function coerce(val) {
518
- if (val instanceof Error) {
519
- return val.stack || val.message;
520
- }
521
- return val;
522
- }
523
-
524
- /**
525
- * XXX DO NOT USE. This is a temporary stub function.
526
- * XXX It WILL be removed in the next major release.
527
- */
528
- function destroy() {
529
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
530
- }
531
-
532
- createDebug.enable(createDebug.load());
533
-
534
- return createDebug;
535
- }
536
-
537
- var common = setup;
538
-
539
- /* eslint-env browser */
540
-
541
- (function (module, exports) {
542
- /**
543
- * This is the web browser implementation of `debug()`.
544
- */
545
-
546
- exports.formatArgs = formatArgs;
547
- exports.save = save;
548
- exports.load = load;
549
- exports.useColors = useColors;
550
- exports.storage = localstorage();
551
- exports.destroy = (() => {
552
- let warned = false;
553
-
554
- return () => {
555
- if (!warned) {
556
- warned = true;
557
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
558
- }
559
- };
560
- })();
561
-
562
- /**
563
- * Colors.
564
- */
565
-
566
- exports.colors = [
567
- '#0000CC',
568
- '#0000FF',
569
- '#0033CC',
570
- '#0033FF',
571
- '#0066CC',
572
- '#0066FF',
573
- '#0099CC',
574
- '#0099FF',
575
- '#00CC00',
576
- '#00CC33',
577
- '#00CC66',
578
- '#00CC99',
579
- '#00CCCC',
580
- '#00CCFF',
581
- '#3300CC',
582
- '#3300FF',
583
- '#3333CC',
584
- '#3333FF',
585
- '#3366CC',
586
- '#3366FF',
587
- '#3399CC',
588
- '#3399FF',
589
- '#33CC00',
590
- '#33CC33',
591
- '#33CC66',
592
- '#33CC99',
593
- '#33CCCC',
594
- '#33CCFF',
595
- '#6600CC',
596
- '#6600FF',
597
- '#6633CC',
598
- '#6633FF',
599
- '#66CC00',
600
- '#66CC33',
601
- '#9900CC',
602
- '#9900FF',
603
- '#9933CC',
604
- '#9933FF',
605
- '#99CC00',
606
- '#99CC33',
607
- '#CC0000',
608
- '#CC0033',
609
- '#CC0066',
610
- '#CC0099',
611
- '#CC00CC',
612
- '#CC00FF',
613
- '#CC3300',
614
- '#CC3333',
615
- '#CC3366',
616
- '#CC3399',
617
- '#CC33CC',
618
- '#CC33FF',
619
- '#CC6600',
620
- '#CC6633',
621
- '#CC9900',
622
- '#CC9933',
623
- '#CCCC00',
624
- '#CCCC33',
625
- '#FF0000',
626
- '#FF0033',
627
- '#FF0066',
628
- '#FF0099',
629
- '#FF00CC',
630
- '#FF00FF',
631
- '#FF3300',
632
- '#FF3333',
633
- '#FF3366',
634
- '#FF3399',
635
- '#FF33CC',
636
- '#FF33FF',
637
- '#FF6600',
638
- '#FF6633',
639
- '#FF9900',
640
- '#FF9933',
641
- '#FFCC00',
642
- '#FFCC33'
643
- ];
644
-
645
- /**
646
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
647
- * and the Firebug extension (any Firefox version) are known
648
- * to support "%c" CSS customizations.
649
- *
650
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
651
- */
652
-
653
- // eslint-disable-next-line complexity
654
- function useColors() {
655
- // NB: In an Electron preload script, document will be defined but not fully
656
- // initialized. Since we know we're in Chrome, we'll just detect this case
657
- // explicitly
658
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
659
- return true;
660
- }
661
-
662
- // Internet Explorer and Edge do not support colors.
663
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
664
- return false;
665
- }
666
-
667
- // Is webkit? http://stackoverflow.com/a/16459606/376773
668
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
669
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
670
- // Is firebug? http://stackoverflow.com/a/398120/376773
671
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
672
- // Is firefox >= v31?
673
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
674
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
675
- // Double check webkit in userAgent just in case we are in a worker
676
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
677
- }
678
-
679
- /**
680
- * Colorize log arguments if enabled.
681
- *
682
- * @api public
683
- */
684
-
685
- function formatArgs(args) {
686
- args[0] = (this.useColors ? '%c' : '') +
687
- this.namespace +
688
- (this.useColors ? ' %c' : ' ') +
689
- args[0] +
690
- (this.useColors ? '%c ' : ' ') +
691
- '+' + module.exports.humanize(this.diff);
692
-
693
- if (!this.useColors) {
694
- return;
695
- }
696
-
697
- const c = 'color: ' + this.color;
698
- args.splice(1, 0, c, 'color: inherit');
699
-
700
- // The final "%c" is somewhat tricky, because there could be other
701
- // arguments passed either before or after the %c, so we need to
702
- // figure out the correct index to insert the CSS into
703
- let index = 0;
704
- let lastC = 0;
705
- args[0].replace(/%[a-zA-Z%]/g, match => {
706
- if (match === '%%') {
707
- return;
708
- }
709
- index++;
710
- if (match === '%c') {
711
- // We only are interested in the *last* %c
712
- // (the user may have provided their own)
713
- lastC = index;
714
- }
715
- });
716
-
717
- args.splice(lastC, 0, c);
718
- }
719
-
720
- /**
721
- * Invokes `console.debug()` when available.
722
- * No-op when `console.debug` is not a "function".
723
- * If `console.debug` is not available, falls back
724
- * to `console.log`.
725
- *
726
- * @api public
727
- */
728
- exports.log = console.debug || console.log || (() => {});
729
-
730
- /**
731
- * Save `namespaces`.
732
- *
733
- * @param {String} namespaces
734
- * @api private
735
- */
736
- function save(namespaces) {
737
- try {
738
- if (namespaces) {
739
- exports.storage.setItem('debug', namespaces);
740
- } else {
741
- exports.storage.removeItem('debug');
742
- }
743
- } catch (error) {
744
- // Swallow
745
- // XXX (@Qix-) should we be logging these?
746
- }
747
- }
748
-
749
- /**
750
- * Load `namespaces`.
751
- *
752
- * @return {String} returns the previously persisted debug modes
753
- * @api private
754
- */
755
- function load() {
756
- let r;
757
- try {
758
- r = exports.storage.getItem('debug');
759
- } catch (error) {
760
- // Swallow
761
- // XXX (@Qix-) should we be logging these?
762
- }
763
-
764
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
765
- if (!r && typeof process !== 'undefined' && 'env' in process) {
766
- r = process.env.DEBUG;
767
- }
768
-
769
- return r;
770
- }
771
-
772
- /**
773
- * Localstorage attempts to return the localstorage.
774
- *
775
- * This is necessary because safari throws
776
- * when a user disables cookies/localstorage
777
- * and you attempt to access it.
778
- *
779
- * @return {LocalStorage}
780
- * @api private
781
- */
782
-
783
- function localstorage() {
784
- try {
785
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
786
- // The Browser also has localStorage in the global context.
787
- return localStorage;
788
- } catch (error) {
789
- // Swallow
790
- // XXX (@Qix-) should we be logging these?
791
- }
792
- }
793
-
794
- module.exports = common(exports);
795
-
796
- const {formatters} = module.exports;
797
-
798
- /**
799
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
800
- */
801
-
802
- formatters.j = function (v) {
803
- try {
804
- return JSON.stringify(v);
805
- } catch (error) {
806
- return '[UnexpectedJSONParseError]: ' + error.message;
807
- }
808
- };
809
- } (browser, browser.exports));
810
-
811
- var browserExports = browser.exports;
812
- var createDebug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
813
-
814
- createDebug("foxglove:server");
815
- new TextEncoder();
816
- ({
817
- subscribe: undefined,
818
- unsubscribe: undefined,
819
- advertise: ServerCapability.clientPublish,
820
- unadvertise: ServerCapability.clientPublish,
821
- [ClientBinaryOpcode.MESSAGE_DATA]: ServerCapability.clientPublish,
822
- getParameters: ServerCapability.parameters,
823
- setParameters: ServerCapability.parameters,
824
- subscribeParameterUpdates: ServerCapability.parametersSubscribe,
825
- unsubscribeParameterUpdates: ServerCapability.parametersSubscribe,
826
- [ClientBinaryOpcode.SERVICE_CALL_REQUEST]: ServerCapability.services,
827
- subscribeConnectionGraph: ServerCapability.connectionGraph,
828
- unsubscribeConnectionGraph: ServerCapability.connectionGraph,
829
- fetchAsset: ServerCapability.assets,
830
- });
831
-
832
- function recordToDataView(record) {
833
- const text = JSON.stringify(record);
834
- if (!text) {
835
- throw new Error("Invalid record");
836
- }
837
- const encoder = new TextEncoder();
838
- const data = encoder.encode(text);
839
- const dataView = new DataView(data.buffer);
840
- return dataView;
841
- }
842
-
843
- // This Source Code Form is subject to the terms of the Mozilla Public
844
- // License, v2.0. If a copy of the MPL was not distributed with this
845
- // file, You can obtain one at http://mozilla.org/MPL/2.0/
846
-
847
- class WsWorker {
848
- #ws;
849
- #client;
850
- subscriptions = new Map();
851
- services = new Map();
852
- createWs(url, onReconnect) {
853
- this.#ws = new Waterfall(url, FoxgloveClient.SUPPORTED_SUBPROTOCOL, {
854
- connectionTimeout: 2000,
855
- retryPolicy: _attempt => {
856
- onReconnect();
857
- return 1_000;
858
- },
859
- factory: url => {
860
- const rawWs = new WebSocket(url, FoxgloveClient.SUPPORTED_SUBPROTOCOL);
861
- rawWs.binaryType = "arraybuffer";
862
- return rawWs;
863
- }
864
- });
865
- }
866
- createClient() {
867
- this.#client = new FoxgloveClient({
868
- ws: this.#ws
869
- });
870
- this.#client.on("open", () => send({
871
- type: "open"
872
- }));
873
- this.#client.on("close", () => send({
874
- type: "close"
875
- }));
876
- this.#client.on("error", error => send({
877
- type: "error",
878
- error
879
- }));
880
- this.#client.on("message", ({
881
- subscriptionId,
882
- data
883
- }) => {
884
- const subscription = this.subscriptions.get(subscriptionId);
885
- if (subscription) {
886
- sendWithTransfer({
887
- type: "message",
888
- data: {
889
- ...subscription,
890
- buffer: data
891
- }
892
- }, [data.buffer]);
893
- }
894
- });
895
- }
896
- getPublicChannels() {
897
- return [...this.subscriptions.values()].map(({
898
- kind,
899
- topic
900
- }) => ({
901
- kind,
902
- topic
903
- }));
904
- }
905
- getPublicServices() {
906
- return [...this.services.values()].map(service => service.name);
907
- }
908
- handleAdvertisements() {
909
- this.#client.on("advertise", channels => {
910
- const data = this.getPublicChannels();
911
- for (const channel of channels) {
912
- const subscriptionId = this.#client.subscribe(channel.id);
913
- const kind = protobufsBySchema[channel.schemaName]?.kind ?? 'annotations';
914
- this.subscriptions.set(subscriptionId, {
915
- topic: channel.topic,
916
- schema: channel.schemaName,
917
- kind
918
- });
919
- data.push({
920
- topic: channel.topic,
921
- kind
922
- });
923
- }
924
- send({
925
- type: "channels",
926
- data
927
- });
928
- });
929
- this.#client.on("unadvertise", channels => {
930
- for (const channel of channels) {
931
- this.subscriptions.delete(channel);
932
- }
933
- const data = this.getPublicChannels();
934
- send({
935
- type: "channels",
936
- data
937
- });
938
- });
939
- this.#client.on("advertiseServices", advertisedServices => {
940
- const data = this.getPublicServices();
941
- for (const service of advertisedServices) {
942
- this.services.set(service.name, service);
943
- data.push(service.name);
944
- }
945
- send({
946
- type: "services",
947
- data
948
- });
949
- });
950
- this.#client.on("unadvertiseServices", unadvertisedServices => {
951
- for (const unadvertisedService of unadvertisedServices) {
952
- for (const [name, service] of this.services) {
953
- if (service.id === unadvertisedService) {
954
- this.services.delete(name);
955
- }
956
- }
957
- }
958
- const data = this.getPublicServices();
959
- send({
960
- type: "services",
961
- data
962
- });
963
- });
964
- }
965
- handleServiceResponses() {
966
- this.#client.on("serviceCallResponse", event => {
967
- sendWithTransfer({
968
- type: "service_response",
969
- data: {
970
- ok: true,
971
- serviceCallId: event.callId,
972
- buffer: event.data,
973
- error: null
974
- }
975
- }, [event.data.buffer]);
976
- });
977
- }
978
- constructor(wsUrl) {
979
- const onReconnect = () => {
980
- this.services.clear();
981
- this.subscriptions.clear();
982
- send({
983
- type: "reconnect"
984
- });
985
- };
986
- try {
987
- this.createWs(wsUrl, onReconnect);
988
- this.createClient();
989
- this.handleAdvertisements();
990
- this.handleServiceResponses();
991
- } catch (error) {
992
- // try-catch is needed to catch `Mixed Content` errors in Chrome, where the client
993
- // attempts to load `ws://` from `https://`. (Safari would catch these in `ws.onerror`
994
- // but with `undefined` as an error.)
995
- send({
996
- type: "error",
997
- error: error ?? {
998
- message: "Insecure WebSocket connection"
999
- }
1000
- });
1001
- }
1002
- }
1003
- send(data) {
1004
- if (this.#ws.readyState === this.#ws.OPEN) {
1005
- this.#ws.send(data);
1006
- }
1007
- }
1008
- close() {
1009
- this.#client.close();
1010
- }
1011
- callService({
1012
- name,
1013
- serviceCallId,
1014
- body = {}
1015
- }) {
1016
- const service = this.services.get(name);
1017
- if (!service) {
1018
- send({
1019
- type: "service_response",
1020
- data: {
1021
- serviceCallId,
1022
- ok: false,
1023
- error: "Service was not advertised",
1024
- buffer: null
1025
- }
1026
- });
1027
- return;
1028
- }
1029
- this.#client.sendServiceCallRequest({
1030
- serviceId: service.id,
1031
- callId: serviceCallId,
1032
- encoding: "json",
1033
- data: recordToDataView(body)
1034
- });
1035
- }
1036
- }
1037
- let wsWorker = null;
1038
- const send = self.postMessage;
1039
- const sendWithTransfer = self.postMessage;
1040
- self.addEventListener("message", async event => {
1041
- const {
1042
- type,
1043
- data
1044
- } = event.data;
1045
- switch (type) {
1046
- case "open":
1047
- wsWorker = new WsWorker(data.wsUrl);
1048
- break;
1049
- case "close":
1050
- wsWorker?.close();
1051
- break;
1052
- case "send":
1053
- wsWorker?.send(data);
1054
- break;
1055
- case "call_service":
1056
- wsWorker?.callService(data);
1057
- break;
1058
- }
1059
- });