@formant/data-sdk 1.39.0 → 1.41.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.
@@ -31507,7 +31507,7 @@ class QueryStore {
31507
31507
  ...t,
31508
31508
  start: n,
31509
31509
  end: o
31510
- }), !s || s === "too much data" || t.latestOnly ? s : filterDataByTime(s, new Date(t.start), new Date(t.end));
31510
+ }), !s || s === "too much data" || t.latestOnly ? s : filterDataByTime(s, new Date(n), new Date(o));
31511
31511
  }
31512
31512
  queryCache(t) {
31513
31513
  return this.queryStoreCache.get(t, async () => {
@@ -32196,7 +32196,7 @@ class LiveUniverseData extends BasicUniverseDataConnector {
32196
32196
  rotation: l.info.origin.orientation
32197
32197
  },
32198
32198
  data: l.data,
32199
- canvas: void 0
32199
+ alpha: l.data.map(() => 255)
32200
32200
  });
32201
32201
  }
32202
32202
  };
@@ -32223,18 +32223,20 @@ class LiveUniverseData extends BasicUniverseDataConnector {
32223
32223
  if (s && s.map) {
32224
32224
  const l = document.createElement("canvas"), u = await this.fetchImage(s.map.url);
32225
32225
  l.width = u.width, l.height = u.height;
32226
- const c = l.getContext("2d");
32226
+ const c = l.getContext("2d", {
32227
+ willReadFrequently: !0
32228
+ });
32227
32229
  c && c.drawImage(u, 0, 0);
32228
32230
  const p = c == null ? void 0 : c.getImageData(
32229
32231
  0,
32230
32232
  0,
32231
32233
  u.width,
32232
32234
  u.height
32233
- ), v = [];
32235
+ ), v = [], _ = [];
32234
32236
  if (p)
32235
- for (let _ = 0; _ < p.data.length; _ += 4) {
32236
- const y = p.data[_];
32237
- v.push(y);
32237
+ for (let y = 0; y < p.data.length; y += 4) {
32238
+ const f = p.data[y], h = p.data[y + 3];
32239
+ v.push(f), _.push(h);
32238
32240
  }
32239
32241
  g = {
32240
32242
  width: s.map.width,
@@ -32242,7 +32244,7 @@ class LiveUniverseData extends BasicUniverseDataConnector {
32242
32244
  worldToLocal: s.map.worldToLocal,
32243
32245
  resolution: s.map.resolution,
32244
32246
  origin: s.map.origin,
32245
- canvas: l,
32247
+ alpha: _,
32246
32248
  data: v
32247
32249
  };
32248
32250
  }
@@ -32337,23 +32339,31 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32337
32339
  subscribeToPath(r, n, o) {
32338
32340
  if (n.sourceType !== "telemetry")
32339
32341
  throw new Error("Telemetry sources only supported");
32340
- return this.subscribeTelemetry(
32342
+ const s = this.getAvailableDataFetchWorker();
32343
+ if (!s)
32344
+ throw new Error("No available data fetch worker");
32345
+ const g = this.subscribeTelemetry(
32341
32346
  r,
32342
32347
  n,
32343
32348
  "localization",
32344
- async (s) => {
32345
- if (s === "too much data" || s === void 0) {
32349
+ async (l) => {
32350
+ if (l === "too much data" || l === void 0) {
32346
32351
  o(NoData);
32347
32352
  return;
32348
32353
  }
32349
- const g = s[s.length - 1][1];
32350
- let l = g;
32351
- g.url && (l = await (await fetch(g.url)).json()), l.path && o({
32352
- worldToLocal: l.path.worldToLocal,
32353
- poses: l.path.poses
32354
+ const u = l[l.length - 1][1];
32355
+ let c = u;
32356
+ u.url && (s.postMessage({ url: u.url }), s.onmessage = (p) => {
32357
+ c = p.data.response, c.path && o({
32358
+ worldToLocal: c.path.worldToLocal,
32359
+ poses: c.path.poses
32360
+ });
32354
32361
  });
32355
32362
  }
32356
32363
  );
32364
+ return () => {
32365
+ this.releaseDataFetchWorker(s), g();
32366
+ };
32357
32367
  }
32358
32368
  onTimeChange(r) {
32359
32369
  r === "live" ? this.liveIntervalHandle = setInterval(() => {
@@ -32427,66 +32437,47 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32427
32437
  const s = this.getAvailablePCDWorker();
32428
32438
  if (!s)
32429
32439
  throw new Error("No available pointcloud worker");
32430
- const g = async () => new Promise((c) => {
32431
- const p = (f) => {
32432
- _(), y(), c(f);
32433
- }, v = {
32434
- ...n,
32435
- latestDataPoint: !0
32436
- }, _ = this.subscribeTelemetry(
32437
- r,
32438
- v,
32439
- "point cloud",
32440
- async (f) => {
32441
- f !== void 0 && typeof f != "symbol" && p("pointcloud");
32442
- }
32443
- ), y = this.subscribeTelemetry(
32444
- r,
32445
- v,
32446
- "localization",
32447
- async (f) => {
32448
- f !== void 0 && typeof f != "symbol" && p("localization");
32449
- }
32450
- );
32451
- });
32440
+ const g = this.getAvailableDataFetchWorker();
32441
+ if (!g)
32442
+ throw new Error("No available data fetch worker");
32452
32443
  let l = () => {
32453
32444
  }, u = () => {
32454
32445
  };
32455
- return g().then((c) => {
32456
- c === "pointcloud" ? l = this.subscribeTelemetry(
32457
- r,
32458
- n,
32459
- "point cloud",
32460
- async (p) => {
32461
- if (p === "too much data" || p === void 0) {
32462
- o(NoData);
32463
- return;
32464
- }
32465
- const v = p[p.length - 1][1];
32466
- if (typeof v == "string")
32467
- o(JSON.parse(v));
32468
- else {
32469
- const { url: _ } = v;
32470
- s.postMessage({ url: _ }), s.onmessage = (y) => {
32471
- y.data.url === _ && o({
32472
- worldToLocal: v.worldToLocal,
32473
- pcd: y.data.pcd
32474
- });
32475
- };
32476
- }
32446
+ return n.streamType === "point cloud" ? l = this.subscribeTelemetry(
32447
+ r,
32448
+ n,
32449
+ "point cloud",
32450
+ async (c) => {
32451
+ if (c === "too much data" || c === void 0) {
32452
+ o(NoData);
32453
+ return;
32477
32454
  }
32478
- ) : c === "localization" && (u = this.subscribeTelemetry(
32479
- r,
32480
- n,
32481
- "localization",
32482
- async (p) => {
32483
- if (p === "too much data" || p === void 0) {
32484
- o(NoData);
32485
- return;
32486
- }
32487
- let v = p[p.length - 1][1];
32488
- if (v.url && (v = await (await fetch(v.url)).json()), v.pointClouds) {
32489
- const { url: _, worldToLocal: y } = v.pointClouds[0];
32455
+ const p = c[c.length - 1][1];
32456
+ if (typeof p == "string")
32457
+ o(JSON.parse(p));
32458
+ else {
32459
+ const { url: v } = p;
32460
+ s.postMessage({ url: v }), s.onmessage = (_) => {
32461
+ _.data.url === v && o({
32462
+ worldToLocal: p.worldToLocal,
32463
+ pcd: _.data.pcd
32464
+ });
32465
+ };
32466
+ }
32467
+ }
32468
+ ) : n.streamType === "localization" && (u = this.subscribeTelemetry(
32469
+ r,
32470
+ n,
32471
+ "localization",
32472
+ async (c) => {
32473
+ if (c === "too much data" || c === void 0) {
32474
+ o(NoData);
32475
+ return;
32476
+ }
32477
+ let p = c[c.length - 1][1];
32478
+ p.url && (g.postMessage({ url: p.url }), g.onmessage = (v) => {
32479
+ if (p = v.data.response, p.pointClouds) {
32480
+ const { url: _, worldToLocal: y } = p.pointClouds[0];
32490
32481
  s.postMessage({ url: _ }), s.onmessage = (f) => {
32491
32482
  f.data.url === _ && o({
32492
32483
  worldToLocal: y,
@@ -32494,10 +32485,10 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32494
32485
  });
32495
32486
  };
32496
32487
  }
32497
- }
32498
- ));
32499
- }), () => {
32500
- this.releasePCDWorker(s), l(), u();
32488
+ });
32489
+ }
32490
+ )), () => {
32491
+ this.releasePCDWorker(s), this.releaseDataFetchWorker(g), l(), u();
32501
32492
  };
32502
32493
  }
32503
32494
  subscribeToOdometry(r, n, o) {
@@ -32506,31 +32497,31 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32506
32497
  const s = this.getAvailableDataFetchWorker();
32507
32498
  if (!s)
32508
32499
  throw new Error("No available data fetch worker");
32509
- return this.subscribeTelemetry(
32500
+ const g = this.subscribeTelemetry(
32510
32501
  r,
32511
32502
  n,
32512
32503
  "localization",
32513
- async (g) => {
32514
- if (g === "too much data" || g === void 0) {
32504
+ async (l) => {
32505
+ if (l === "too much data" || l === void 0) {
32515
32506
  o(NoData);
32516
32507
  return;
32517
32508
  }
32518
- const l = g[g.length - 1][1];
32519
- let u = l;
32520
- l.url && (s.postMessage({ url: l.url }), s.onmessage = (c) => {
32521
- u = c.data.response, u.odometry && o({
32522
- worldToLocal: u.odometry.worldToLocal,
32509
+ const u = l[l.length - 1][1];
32510
+ let c = u;
32511
+ u.url && (s.postMessage({ url: u.url }), s.onmessage = (p) => {
32512
+ c = p.data.response, c.odometry && o({
32513
+ worldToLocal: c.odometry.worldToLocal,
32523
32514
  pose: {
32524
32515
  translation: {
32525
- x: u.odometry.pose.translation.x,
32526
- y: u.odometry.pose.translation.y,
32527
- z: u.odometry.pose.translation.z
32516
+ x: c.odometry.pose.translation.x,
32517
+ y: c.odometry.pose.translation.y,
32518
+ z: c.odometry.pose.translation.z
32528
32519
  },
32529
32520
  rotation: {
32530
- x: u.odometry.pose.rotation.x,
32531
- y: u.odometry.pose.rotation.y,
32532
- z: u.odometry.pose.rotation.z,
32533
- w: u.odometry.pose.rotation.w
32521
+ x: c.odometry.pose.rotation.x,
32522
+ y: c.odometry.pose.rotation.y,
32523
+ z: c.odometry.pose.rotation.z,
32524
+ w: c.odometry.pose.rotation.w
32534
32525
  }
32535
32526
  },
32536
32527
  covariance: []
@@ -32538,6 +32529,9 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32538
32529
  });
32539
32530
  }
32540
32531
  );
32532
+ return () => {
32533
+ this.releaseDataFetchWorker(s), g();
32534
+ };
32541
32535
  }
32542
32536
  subscribeToPose(r, n, o) {
32543
32537
  throw new Error("Method not implemented for telemetry universe connector.");
@@ -32547,16 +32541,24 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32547
32541
  const s = this.getAvailableDataFetchWorker();
32548
32542
  if (!s)
32549
32543
  throw new Error("No available data fetch worker");
32550
- return this.subscribeTelemetry(r, n, "json", async (g) => {
32551
- if (g === "too much data" || g === void 0) {
32552
- o(NoData);
32553
- return;
32544
+ const g = this.subscribeTelemetry(
32545
+ r,
32546
+ n,
32547
+ "json",
32548
+ async (l) => {
32549
+ if (l === "too much data" || l === void 0) {
32550
+ o(NoData);
32551
+ return;
32552
+ }
32553
+ let u = l[l.length - 1][1];
32554
+ u.startsWith("http") && (s.postMessage({ url: u }), s.onmessage = (c) => {
32555
+ u = JSON.stringify(c.data), o(JSON.parse(u));
32556
+ });
32554
32557
  }
32555
- let l = g[g.length - 1][1];
32556
- l.startsWith("http") && (s.postMessage({ url: l }), s.onmessage = (u) => {
32557
- l = JSON.stringify(u.data.response), o(JSON.parse(l));
32558
- });
32559
- });
32558
+ );
32559
+ return () => {
32560
+ this.releaseDataFetchWorker(s), g();
32561
+ };
32560
32562
  } else
32561
32563
  throw new Error("Realtime geometry note supported");
32562
32564
  }
@@ -32564,53 +32566,65 @@ class TelemetryUniverseData extends BasicUniverseDataConnector {
32564
32566
  return this.subscribeToJson(r, n, o);
32565
32567
  }
32566
32568
  subscribeToGridMap(r, n, o) {
32569
+ const s = {};
32567
32570
  if (n.sourceType !== "telemetry")
32568
32571
  throw new Error("Telemetry sources only supported");
32569
- const s = this.getAvailableDataFetchWorker();
32570
- if (!s)
32572
+ const g = this.getAvailableDataFetchWorker();
32573
+ if (!g)
32571
32574
  throw new Error("No available data fetch worker");
32572
- return this.subscribeTelemetry(
32575
+ const l = this.subscribeTelemetry(
32573
32576
  r,
32574
32577
  n,
32575
32578
  "localization",
32576
- async (g) => {
32577
- if (g === "too much data" || g === void 0) {
32579
+ async (u) => {
32580
+ if (u === "too much data" || u === void 0) {
32578
32581
  o(NoData);
32579
32582
  return;
32580
32583
  }
32581
- const l = g[g.length - 1][1];
32582
- let u = l;
32583
- l.url && (s.postMessage({ url: l.url }), s.onmessage = async (c) => {
32584
- if (u = c.data.response, u.map) {
32585
- const p = document.createElement("canvas"), v = await this.fetchImage(u.map.url);
32586
- p.width = v.width, p.height = v.height;
32587
- const _ = p.getContext("2d");
32588
- _ && _.drawImage(v, 0, 0);
32589
- const y = _ == null ? void 0 : _.getImageData(
32590
- 0,
32591
- 0,
32592
- v.width,
32593
- v.height
32594
- ), f = [];
32595
- if (y)
32596
- for (let w = 0; w < y.data.length; w += 4) {
32597
- const C = y.data[w];
32598
- f.push(C);
32599
- }
32600
- const h = {
32601
- width: u.map.width,
32602
- height: u.map.height,
32603
- worldToLocal: u.map.worldToLocal,
32604
- resolution: u.map.resolution,
32605
- origin: u.map.origin,
32606
- canvas: p,
32607
- data: f
32608
- };
32609
- o(h);
32584
+ const c = u[u.length - 1][1];
32585
+ if (c.url) {
32586
+ if (s[c.url]) {
32587
+ o(s[c.url]);
32588
+ return;
32610
32589
  }
32611
- });
32590
+ g.postMessage({ url: c.url }), g.onmessage = async (p) => {
32591
+ const v = p.data.response.map;
32592
+ if (v) {
32593
+ const _ = document.createElement("canvas"), y = await this.fetchImage(v.url);
32594
+ _.width = y.width, _.height = y.height;
32595
+ const f = _.getContext("2d", {
32596
+ willReadFrequently: !0
32597
+ });
32598
+ f && f.drawImage(y, 0, 0);
32599
+ const h = f == null ? void 0 : f.getImageData(
32600
+ 0,
32601
+ 0,
32602
+ y.width,
32603
+ y.height
32604
+ ), w = [], C = [];
32605
+ if (h)
32606
+ for (let E = 0; E < h.data.length; E += 4) {
32607
+ const T = h.data[E], d = h.data[E + 3];
32608
+ w.push(T), C.push(d);
32609
+ }
32610
+ const x = {
32611
+ width: v.width,
32612
+ height: v.height,
32613
+ worldToLocal: v.worldToLocal,
32614
+ resolution: v.resolution,
32615
+ origin: v.origin,
32616
+ alpha: C,
32617
+ data: w
32618
+ };
32619
+ s[c.url] = JSON.parse(JSON.stringify(x)), o(x);
32620
+ }
32621
+ };
32622
+ }
32612
32623
  }
32613
32624
  );
32625
+ return () => {
32626
+ this.releaseDataFetchWorker(g), l();
32627
+ };
32614
32628
  }
32615
32629
  subscribeToVideo(r, n, o) {
32616
32630
  if (n.sourceType !== "telemetry")