@pollen-robotics/reachy-mini-sdk 1.11.0 → 1.12.0-dev.0.main.2f2e2ba
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.
- package/APP_CREATION_GUIDE.md +90 -41
- package/README.md +1 -1
- package/dist/lib/message-chunks.d.ts +22 -0
- package/dist/lib/message-chunks.d.ts.map +1 -0
- package/dist/lib/message-chunks.js +51 -0
- package/dist/lib/message-chunks.js.map +1 -0
- package/dist/lib/message-chunks.test.d.ts +2 -0
- package/dist/lib/message-chunks.test.d.ts.map +1 -0
- package/dist/lib/message-chunks.test.js +53 -0
- package/dist/lib/message-chunks.test.js.map +1 -0
- package/dist/lib/reachy-mini.d.ts.map +1 -1
- package/dist/lib/reachy-mini.js +9 -1
- package/dist/lib/reachy-mini.js.map +1 -1
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/host/README.md +2 -2
- package/host/dist/chunks/{centralRest-vcOOpQK6.js → centralRest-K3a9U_Sk.js} +104 -82
- package/host/dist/chunks/{index-BrKBhTE0.js → index-B79tSfbK.js} +1 -1
- package/host/dist/chunks/{mountHost-CNQYkWZ4.js → mountHost-CMP4uYnZ.js} +1480 -1482
- package/host/dist/entry/auto.js +2 -2
- package/host/dist/entry/embed.js +2 -2
- package/host/dist/index.js +3 -3
- package/host/dist/lib/protocol.js +2 -2
- package/package.json +1 -1
|
@@ -195,10 +195,27 @@ function ue(s, e, t) {
|
|
|
195
195
|
[0, 0, 0, 1]
|
|
196
196
|
];
|
|
197
197
|
}
|
|
198
|
+
const he = 4096;
|
|
199
|
+
class _e {
|
|
200
|
+
_partials = /* @__PURE__ */ new Map();
|
|
201
|
+
/**
|
|
202
|
+
* Feed one parsed frame. Returns the message to handle: the frame itself
|
|
203
|
+
* when it is not a chunk, the reassembled message when this chunk
|
|
204
|
+
* completes one, or `null` while a message is still arriving.
|
|
205
|
+
*/
|
|
206
|
+
accept(e) {
|
|
207
|
+
if (e.type !== "message_chunk") return e;
|
|
208
|
+
const { id: t, index: n, count: r, data: i } = e;
|
|
209
|
+
if (typeof t != "string" || typeof n != "number" || typeof r != "number" || typeof i != "string" || r < 1 || r > he)
|
|
210
|
+
return null;
|
|
211
|
+
let o = this._partials.get(t);
|
|
212
|
+
return n === 0 && (o = [], this._partials.set(t, o)), !o || n !== o.length ? (this._partials.delete(t), null) : (o.push(i), o.length < r ? null : (this._partials.delete(t), JSON.parse(o.join(""))));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
198
215
|
const ee = 4e3;
|
|
199
216
|
class P extends Error {
|
|
200
217
|
}
|
|
201
|
-
class
|
|
218
|
+
class pe {
|
|
202
219
|
_replySlots = /* @__PURE__ */ new Map();
|
|
203
220
|
_rpcCounter = 0;
|
|
204
221
|
_pendingRpc = /* @__PURE__ */ new Map();
|
|
@@ -356,8 +373,8 @@ class he {
|
|
|
356
373
|
this._broadcastWaiters = [];
|
|
357
374
|
}
|
|
358
375
|
}
|
|
359
|
-
const M = O("session"), q = 3e3, G = 1e3,
|
|
360
|
-
class
|
|
376
|
+
const M = O("session"), q = 3e3, G = 1e3, fe = 6e4, V = [0, 2e3, 4e3, 8e3, 8e3], me = 15e3, J = 1e3, ge = 2500, we = 8e3;
|
|
377
|
+
class be {
|
|
361
378
|
_deps;
|
|
362
379
|
// ICE-blip debounce. All handler slots are scoped to the lifetime
|
|
363
380
|
// of a live session (armed from the pc's state handler, cleared by
|
|
@@ -487,7 +504,7 @@ class ge {
|
|
|
487
504
|
if (typeof document < "u" && document.hidden || (document.removeEventListener("visibilitychange", t), this._pendingVisibilityHandler = null, !this._deps.hasPc())) return;
|
|
488
505
|
const n = this._deps.iceState();
|
|
489
506
|
if (!(n === "connected" || n === "completed")) {
|
|
490
|
-
if (Date.now() - e >
|
|
507
|
+
if (Date.now() - e > fe) {
|
|
491
508
|
const r = new Error("Session expired while tab was backgrounded");
|
|
492
509
|
if (this._deps.rejectPendingSession(r)) {
|
|
493
510
|
this._redialing || this._emitError(r);
|
|
@@ -580,9 +597,9 @@ class ge {
|
|
|
580
597
|
for (let i = 1; i <= n; i++) {
|
|
581
598
|
if (!this._redialing || (this._deps.emit("sessionReconnecting", { attempt: i, maxAttempts: n, cause: t }), await this._redialSleep(V[i - 1]), !this._redialing)) return;
|
|
582
599
|
try {
|
|
583
|
-
if (this._deps.isSignalingDown() && await this._deps.reconnectSignaling(), !this._redialing || (await
|
|
600
|
+
if (this._deps.isSignalingDown() && await this._deps.reconnectSignaling(), !this._redialing || (await ye(
|
|
584
601
|
this._deps.dial(e),
|
|
585
|
-
|
|
602
|
+
me,
|
|
586
603
|
"auto-reconnect dial timed out"
|
|
587
604
|
), !this._redialing)) return;
|
|
588
605
|
this._redialing = !1, M.info(`auto-reconnect: recovered on attempt ${i}`), this._deps.emit("sessionReconnected", { attempt: i });
|
|
@@ -651,25 +668,25 @@ class ge {
|
|
|
651
668
|
return;
|
|
652
669
|
}
|
|
653
670
|
const n = e - this._lastDcInboundAt;
|
|
654
|
-
if (n <
|
|
671
|
+
if (n < ge) return;
|
|
655
672
|
if (!this._dcSilenceNudged) {
|
|
656
673
|
this._dcSilenceNudged = !0, this._deps.nudgeState();
|
|
657
674
|
return;
|
|
658
675
|
}
|
|
659
|
-
if (n <
|
|
676
|
+
if (n < we) return;
|
|
660
677
|
this._dcSilenceNudged = !1;
|
|
661
678
|
const r = `No data-channel traffic for ${n}ms`;
|
|
662
679
|
this.maybeBeginRedial(r) || (this.stopDcWatchdog(), this._emitError(new Error(r)));
|
|
663
680
|
}
|
|
664
681
|
}
|
|
665
|
-
function
|
|
682
|
+
function ye(s, e, t) {
|
|
666
683
|
return Promise.race([
|
|
667
684
|
s,
|
|
668
685
|
new Promise((n, r) => setTimeout(() => r(new Error(t)), e))
|
|
669
686
|
]);
|
|
670
687
|
}
|
|
671
|
-
const z = "0.0.0-managed-by-ci",
|
|
672
|
-
function
|
|
688
|
+
const z = "0.0.0-managed-by-ci", Se = O("sdk");
|
|
689
|
+
function ve() {
|
|
673
690
|
if (typeof window > "u" || !window.location.hash) return;
|
|
674
691
|
const s = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
675
692
|
let e;
|
|
@@ -684,7 +701,7 @@ function ye() {
|
|
|
684
701
|
try {
|
|
685
702
|
sessionStorage.setItem("hf_token", t), sessionStorage.setItem("hf_username", n), sessionStorage.setItem("hf_token_expires", i);
|
|
686
703
|
} catch (c) {
|
|
687
|
-
|
|
704
|
+
Se.warn("could not persist pre-seeded HF credentials:", c);
|
|
688
705
|
}
|
|
689
706
|
e.delete("hf_token"), e.delete("hf_username"), e.delete("hf_token_expires");
|
|
690
707
|
const o = e.toString(), a = window.location.pathname + window.location.search + (o ? "#" + o : "");
|
|
@@ -693,7 +710,7 @@ function ye() {
|
|
|
693
710
|
} catch {
|
|
694
711
|
}
|
|
695
712
|
}
|
|
696
|
-
function
|
|
713
|
+
function Re() {
|
|
697
714
|
if (typeof window > "u") return null;
|
|
698
715
|
if (window.location.hash) {
|
|
699
716
|
const s = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
@@ -711,7 +728,7 @@ function Se() {
|
|
|
711
728
|
}
|
|
712
729
|
return null;
|
|
713
730
|
}
|
|
714
|
-
function
|
|
731
|
+
function Ie(s) {
|
|
715
732
|
const e = s.split(`\r
|
|
716
733
|
`);
|
|
717
734
|
let t = !1;
|
|
@@ -719,58 +736,58 @@ function ve(s) {
|
|
|
719
736
|
if (n.startsWith("m=audio") ? t = !0 : n.startsWith("m=") && (t = !1), t && n === "a=sendrecv") return !0;
|
|
720
737
|
return !1;
|
|
721
738
|
}
|
|
722
|
-
const j = "hf_token",
|
|
723
|
-
function
|
|
739
|
+
const j = "hf_token", x = "hf_username", F = "hf_token_expires", U = "hf_token_last_seen", ke = 1440 * 60 * 1e3;
|
|
740
|
+
function Ee(s) {
|
|
724
741
|
try {
|
|
725
|
-
sessionStorage.setItem(j, s.token), sessionStorage.setItem(
|
|
742
|
+
sessionStorage.setItem(j, s.token), sessionStorage.setItem(x, s.username), sessionStorage.setItem(F, s.expires), sessionStorage.setItem(U, (/* @__PURE__ */ new Date()).toISOString());
|
|
726
743
|
} catch {
|
|
727
744
|
}
|
|
728
745
|
}
|
|
729
|
-
function
|
|
746
|
+
function Te(s = Date.now()) {
|
|
730
747
|
try {
|
|
731
|
-
const e = sessionStorage.getItem(j), t = sessionStorage.getItem(
|
|
748
|
+
const e = sessionStorage.getItem(j), t = sessionStorage.getItem(x), n = sessionStorage.getItem(F);
|
|
732
749
|
if (!e || !n) return null;
|
|
733
750
|
if (new Date(n).getTime() <= s)
|
|
734
|
-
return
|
|
735
|
-
const r = sessionStorage.getItem(
|
|
751
|
+
return N(), null;
|
|
752
|
+
const r = sessionStorage.getItem(U);
|
|
736
753
|
if (r !== null) {
|
|
737
754
|
const i = new Date(r).getTime();
|
|
738
|
-
if (!Number.isFinite(i) || s - i >
|
|
739
|
-
return
|
|
755
|
+
if (!Number.isFinite(i) || s - i > ke)
|
|
756
|
+
return N(), null;
|
|
740
757
|
}
|
|
741
|
-
return sessionStorage.setItem(
|
|
758
|
+
return sessionStorage.setItem(U, new Date(s).toISOString()), { token: e, username: t ?? "", expires: n };
|
|
742
759
|
} catch {
|
|
743
760
|
return null;
|
|
744
761
|
}
|
|
745
762
|
}
|
|
746
|
-
function
|
|
763
|
+
function N() {
|
|
747
764
|
try {
|
|
748
|
-
sessionStorage.removeItem(j), sessionStorage.removeItem(
|
|
765
|
+
sessionStorage.removeItem(j), sessionStorage.removeItem(x), sessionStorage.removeItem(F), sessionStorage.removeItem(U);
|
|
749
766
|
} catch {
|
|
750
767
|
}
|
|
751
768
|
}
|
|
752
|
-
const
|
|
769
|
+
const Ae = /* @__PURE__ */ new Set([
|
|
753
770
|
"login_required",
|
|
754
771
|
"consent_required",
|
|
755
772
|
"interaction_required",
|
|
756
773
|
"access_denied"
|
|
757
774
|
]);
|
|
758
|
-
function
|
|
775
|
+
function Ce() {
|
|
759
776
|
try {
|
|
760
777
|
const s = new URL(window.location.href), e = s.searchParams.get("error");
|
|
761
|
-
return e === null || !
|
|
778
|
+
return e === null || !Ae.has(e) ? null : (s.searchParams.delete("error"), s.searchParams.delete("error_description"), s.searchParams.delete("state"), window.history.replaceState(null, "", s.toString()), e);
|
|
762
779
|
} catch {
|
|
763
780
|
return null;
|
|
764
781
|
}
|
|
765
782
|
}
|
|
766
|
-
const y = 12 * 1024,
|
|
767
|
-
function
|
|
783
|
+
const y = 12 * 1024, L = 1 * 1024 * 1024, Me = 512 * 1024;
|
|
784
|
+
function De() {
|
|
768
785
|
return typeof CompressionStream < "u";
|
|
769
786
|
}
|
|
770
787
|
function K() {
|
|
771
788
|
return "u" + Math.random().toString(36).slice(2, 11) + Date.now().toString(36);
|
|
772
789
|
}
|
|
773
|
-
function
|
|
790
|
+
function $(s) {
|
|
774
791
|
let e = "";
|
|
775
792
|
for (let n = 0; n < s.length; n += 32768)
|
|
776
793
|
e += String.fromCharCode.apply(
|
|
@@ -779,11 +796,11 @@ function N(s) {
|
|
|
779
796
|
);
|
|
780
797
|
return btoa(e);
|
|
781
798
|
}
|
|
782
|
-
async function
|
|
799
|
+
async function Ue(s) {
|
|
783
800
|
const e = new TextEncoder().encode(s), t = await new Response(
|
|
784
801
|
new Blob([e]).stream().pipeThrough(new CompressionStream("gzip"))
|
|
785
802
|
).arrayBuffer();
|
|
786
|
-
return
|
|
803
|
+
return $(new Uint8Array(t));
|
|
787
804
|
}
|
|
788
805
|
function Y(s) {
|
|
789
806
|
const e = Math.round(Number(s) || 0);
|
|
@@ -812,8 +829,8 @@ function X(s) {
|
|
|
812
829
|
return "wav-base64";
|
|
813
830
|
}
|
|
814
831
|
}
|
|
815
|
-
const _ = O("sdk"), Q = 750,
|
|
816
|
-
class
|
|
832
|
+
const _ = O("sdk"), Q = 750, Le = 5e3;
|
|
833
|
+
class Be extends EventTarget {
|
|
817
834
|
// ─── Config ──────────────────────────────────────────────────────────
|
|
818
835
|
_signalingUrl;
|
|
819
836
|
_clientId;
|
|
@@ -862,7 +879,7 @@ class He extends EventTarget {
|
|
|
862
879
|
// ─── Pending replies (reply slots / JSON-RPC / motion / broadcast) ───
|
|
863
880
|
// All request/response waiters on the data channel live in one
|
|
864
881
|
// ledger so every teardown path settles them in a single call.
|
|
865
|
-
_pending = new
|
|
882
|
+
_pending = new pe();
|
|
866
883
|
// ─── Log subscribers ─────────────────────────────────────────────────
|
|
867
884
|
_logSubscribers = /* @__PURE__ */ new Set();
|
|
868
885
|
_updateProgressSubscribers = /* @__PURE__ */ new Set();
|
|
@@ -887,7 +904,7 @@ class He extends EventTarget {
|
|
|
887
904
|
// ─── Video element ───────────────────────────────────────────────────
|
|
888
905
|
_videoElement = null;
|
|
889
906
|
constructor(e = {}) {
|
|
890
|
-
super(), this._signalingUrl = e.signalingUrl || "https://pollen-robotics-reachy-mini-central.hf.space", this._clientId = e.clientId || null, this._appName = e.appName || "unknown", this._videoJitterBufferTargetMs = e.videoJitterBufferTargetMs ?? 0, this._autoStartFromUrl = e.autoStartFromUrl === !0, this._autoStartAttempted = !1, this._preselectedRobotId =
|
|
907
|
+
super(), this._signalingUrl = e.signalingUrl || "https://pollen-robotics-reachy-mini-central.hf.space", this._clientId = e.clientId || null, this._appName = e.appName || "unknown", this._videoJitterBufferTargetMs = e.videoJitterBufferTargetMs ?? 0, this._autoStartFromUrl = e.autoStartFromUrl === !0, this._autoStartAttempted = !1, this._preselectedRobotId = Re(), this._supervisor = new be({
|
|
891
908
|
iceState: () => this._pc?.iceConnectionState ?? null,
|
|
892
909
|
hasPc: () => !!this._pc,
|
|
893
910
|
isStreaming: () => this._state === "streaming",
|
|
@@ -984,17 +1001,17 @@ class He extends EventTarget {
|
|
|
984
1001
|
// ─── Auth ────────────────────────────────────────────────────────────
|
|
985
1002
|
async authenticate() {
|
|
986
1003
|
try {
|
|
987
|
-
|
|
988
|
-
const e =
|
|
1004
|
+
ve();
|
|
1005
|
+
const e = Ce();
|
|
989
1006
|
e && _.info("silent sign-in declined:", e);
|
|
990
1007
|
const t = await ae();
|
|
991
1008
|
if (t)
|
|
992
|
-
return this._username = t.userInfo.preferred_username || t.userInfo.name || null, this._token = t.accessToken, this._tokenExpires = t.accessTokenExpiresAt,
|
|
1009
|
+
return this._username = t.userInfo.preferred_username || t.userInfo.name || null, this._token = t.accessToken, this._tokenExpires = t.accessTokenExpiresAt, Ee({
|
|
993
1010
|
token: this._token,
|
|
994
1011
|
username: this._username ?? "",
|
|
995
1012
|
expires: typeof this._tokenExpires == "string" ? this._tokenExpires : this._tokenExpires.toISOString()
|
|
996
1013
|
}), !0;
|
|
997
|
-
const n =
|
|
1014
|
+
const n = Te();
|
|
998
1015
|
return n && n.username ? (this._token = n.token, this._username = n.username, this._tokenExpires = n.expires, !0) : !1;
|
|
999
1016
|
} catch (e) {
|
|
1000
1017
|
return _.error("authenticate failed:", e), !1;
|
|
@@ -1011,7 +1028,7 @@ class He extends EventTarget {
|
|
|
1011
1028
|
window.location.href = n;
|
|
1012
1029
|
}
|
|
1013
1030
|
logout() {
|
|
1014
|
-
|
|
1031
|
+
N(), this._username = null, this._tokenExpires = null, this.disconnect();
|
|
1015
1032
|
}
|
|
1016
1033
|
// ─── Lifecycle ───────────────────────────────────────────────────────
|
|
1017
1034
|
async connect(e) {
|
|
@@ -1232,19 +1249,24 @@ class He extends EventTarget {
|
|
|
1232
1249
|
}, this._pc.ondatachannel = (r) => {
|
|
1233
1250
|
const i = r.channel;
|
|
1234
1251
|
if (i.label === "pose") {
|
|
1235
|
-
this._lastPoseSeq = null, i.onmessage = (
|
|
1236
|
-
const
|
|
1237
|
-
if (typeof
|
|
1238
|
-
if (this._lastPoseSeq !== null &&
|
|
1239
|
-
this._lastPoseSeq =
|
|
1252
|
+
this._lastPoseSeq = null, i.onmessage = (a) => {
|
|
1253
|
+
const c = JSON.parse(a.data);
|
|
1254
|
+
if (typeof c.seq == "number") {
|
|
1255
|
+
if (this._lastPoseSeq !== null && c.seq <= this._lastPoseSeq) return;
|
|
1256
|
+
this._lastPoseSeq = c.seq;
|
|
1240
1257
|
}
|
|
1241
|
-
this._lastPoseFrameAt = Date.now(), this._handleRobotMessage(
|
|
1258
|
+
this._lastPoseFrameAt = Date.now(), this._handleRobotMessage(c, !0);
|
|
1242
1259
|
};
|
|
1243
1260
|
return;
|
|
1244
1261
|
}
|
|
1245
1262
|
this._dc = i, this._dc.onopen = () => {
|
|
1246
1263
|
this._dcOpen = !0, this._checkSessionReady();
|
|
1247
|
-
}
|
|
1264
|
+
};
|
|
1265
|
+
const o = new _e();
|
|
1266
|
+
this._dc.onmessage = (a) => {
|
|
1267
|
+
const c = o.accept(JSON.parse(a.data));
|
|
1268
|
+
c && this._handleRobotMessage(c);
|
|
1269
|
+
};
|
|
1248
1270
|
}, this._sendToServer({ type: "startSession", peerId: e }).then((r) => {
|
|
1249
1271
|
if (r?.type === "sessionRejected") {
|
|
1250
1272
|
this._failSessionRejected(r);
|
|
@@ -1545,7 +1567,7 @@ class He extends EventTarget {
|
|
|
1545
1567
|
_.info(`ensureAwake: robot asleep (motor_mode=${this._robotState?.motor_mode ?? "unknown"}), playing wake-up`);
|
|
1546
1568
|
const t = Date.now();
|
|
1547
1569
|
try {
|
|
1548
|
-
await this.wakeUp({ timeoutMs:
|
|
1570
|
+
await this.wakeUp({ timeoutMs: Le }), _.info(`ensureAwake: wake-up trajectory done in ${Date.now() - t}ms`);
|
|
1549
1571
|
} catch (n) {
|
|
1550
1572
|
_.warn(`ensureAwake: wake-up not confirmed after ${Date.now() - t}ms (continuing):`, n);
|
|
1551
1573
|
}
|
|
@@ -1762,7 +1784,7 @@ class He extends EventTarget {
|
|
|
1762
1784
|
set_target_data: e.set_target_data
|
|
1763
1785
|
}, g = JSON.stringify(m);
|
|
1764
1786
|
let f, v;
|
|
1765
|
-
i === "gzip+base64" &&
|
|
1787
|
+
i === "gzip+base64" && De() ? (f = await Ue(g), v = "gzip+base64") : (f = g, v = "json");
|
|
1766
1788
|
const w = Math.ceil(f.length / y) || 1;
|
|
1767
1789
|
d({
|
|
1768
1790
|
phase: "starting",
|
|
@@ -1778,7 +1800,7 @@ class He extends EventTarget {
|
|
|
1778
1800
|
encoding: v
|
|
1779
1801
|
});
|
|
1780
1802
|
for (let h = 0; h < w; h++) {
|
|
1781
|
-
this._dc.bufferedAmount >
|
|
1803
|
+
this._dc.bufferedAmount > L && await this._awaitDataChannelDrain();
|
|
1782
1804
|
const p = h * y;
|
|
1783
1805
|
this._sendCommand({
|
|
1784
1806
|
type: "upload_move_chunk",
|
|
@@ -1788,7 +1810,7 @@ class He extends EventTarget {
|
|
|
1788
1810
|
}), d({ phase: "upload", sent: h + 1, total: w });
|
|
1789
1811
|
}
|
|
1790
1812
|
if (this._sendCommand({ type: "upload_move_finish", upload_id: l }), d({ phase: "uploaded", sent: w, total: w }), t) {
|
|
1791
|
-
const h = new Uint8Array(await t.arrayBuffer()), p =
|
|
1813
|
+
const h = new Uint8Array(await t.arrayBuffer()), p = $(h), R = Math.ceil(p.length / y) || 1;
|
|
1792
1814
|
d({
|
|
1793
1815
|
phase: "audio-starting",
|
|
1794
1816
|
sent: 0,
|
|
@@ -1802,7 +1824,7 @@ class He extends EventTarget {
|
|
|
1802
1824
|
description: r
|
|
1803
1825
|
});
|
|
1804
1826
|
for (let T = 0; T < R; T++) {
|
|
1805
|
-
this._dc.bufferedAmount >
|
|
1827
|
+
this._dc.bufferedAmount > L && await this._awaitDataChannelDrain();
|
|
1806
1828
|
const W = T * y;
|
|
1807
1829
|
this._sendCommand({
|
|
1808
1830
|
type: "upload_audio_chunk",
|
|
@@ -1861,7 +1883,7 @@ class He extends EventTarget {
|
|
|
1861
1883
|
throw new Error("data channel not open");
|
|
1862
1884
|
if (!(e instanceof Blob))
|
|
1863
1885
|
throw new TypeError("uploadAudio: expected a Blob");
|
|
1864
|
-
const r = K(), i = new Uint8Array(await e.arrayBuffer()), o =
|
|
1886
|
+
const r = K(), i = new Uint8Array(await e.arrayBuffer()), o = $(i), a = Math.ceil(o.length / y) || 1;
|
|
1865
1887
|
n({ phase: "audio-starting", sent: 0, total: a, bytes: o.length }), this._sendCommand({
|
|
1866
1888
|
type: "upload_audio_start",
|
|
1867
1889
|
upload_id: r,
|
|
@@ -1870,7 +1892,7 @@ class He extends EventTarget {
|
|
|
1870
1892
|
description: t
|
|
1871
1893
|
});
|
|
1872
1894
|
for (let c = 0; c < a; c++) {
|
|
1873
|
-
this._dc.bufferedAmount >
|
|
1895
|
+
this._dc.bufferedAmount > L && await this._awaitDataChannelDrain();
|
|
1874
1896
|
const d = c * y;
|
|
1875
1897
|
this._sendCommand({
|
|
1876
1898
|
type: "upload_audio_chunk",
|
|
@@ -1905,7 +1927,7 @@ class He extends EventTarget {
|
|
|
1905
1927
|
return this._pending.awaitBroadcast(e, t);
|
|
1906
1928
|
}
|
|
1907
1929
|
async _awaitDataChannelDrain() {
|
|
1908
|
-
for (; this._dc && this._dc.bufferedAmount >
|
|
1930
|
+
for (; this._dc && this._dc.bufferedAmount > Me; )
|
|
1909
1931
|
if (await new Promise((e) => setTimeout(e, 30)), !this._dc || this._dc.readyState !== "open")
|
|
1910
1932
|
throw new Error("data channel closed mid-upload");
|
|
1911
1933
|
}
|
|
@@ -2028,7 +2050,7 @@ class He extends EventTarget {
|
|
|
2028
2050
|
if (e.sdp) {
|
|
2029
2051
|
const t = e.sdp;
|
|
2030
2052
|
if (t.type === "offer") {
|
|
2031
|
-
const r =
|
|
2053
|
+
const r = Ie(t.sdp);
|
|
2032
2054
|
if (this._micSupported = r, this._emit("micSupported", { supported: r }), r && this._micStream)
|
|
2033
2055
|
for (const o of this._micStream.getAudioTracks())
|
|
2034
2056
|
this._pc.addTrack(o, this._micStream);
|
|
@@ -2182,7 +2204,7 @@ class He extends EventTarget {
|
|
|
2182
2204
|
}, 2e3);
|
|
2183
2205
|
}
|
|
2184
2206
|
}
|
|
2185
|
-
const
|
|
2207
|
+
const Pe = "pollen-robotics/reachy_mini", Ne = `https://api.github.com/repos/${Pe}/releases/latest`, te = "reachy.daemonLatestRelease.v1", $e = 360 * 60 * 1e3, ne = "1.8.2";
|
|
2186
2208
|
function k(s) {
|
|
2187
2209
|
if (typeof s != "string") return null;
|
|
2188
2210
|
const e = s.trim().replace(/^v/i, "").match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
@@ -2195,21 +2217,21 @@ function k(s) {
|
|
|
2195
2217
|
function H(s, e) {
|
|
2196
2218
|
return s.major - e.major || s.minor - e.minor || s.patch - e.patch;
|
|
2197
2219
|
}
|
|
2198
|
-
function
|
|
2220
|
+
function Oe(s, e) {
|
|
2199
2221
|
const t = k(s), n = k(e);
|
|
2200
2222
|
return !t || !n ? !1 : H(t, n) < 0;
|
|
2201
2223
|
}
|
|
2202
|
-
function
|
|
2224
|
+
function qe(s, e) {
|
|
2203
2225
|
const t = k(s);
|
|
2204
2226
|
if (!t) return null;
|
|
2205
2227
|
const n = k(ne);
|
|
2206
|
-
return n && H(t, n) < 0 ? "block" :
|
|
2228
|
+
return n && H(t, n) < 0 ? "block" : Oe(s, e) ? "notice" : null;
|
|
2207
2229
|
}
|
|
2208
|
-
function
|
|
2230
|
+
function Ge(s) {
|
|
2209
2231
|
const e = k(s), t = k(ne);
|
|
2210
2232
|
return !!e && !!t && H(e, t) >= 0;
|
|
2211
2233
|
}
|
|
2212
|
-
function
|
|
2234
|
+
function je() {
|
|
2213
2235
|
try {
|
|
2214
2236
|
const s = localStorage.getItem(te);
|
|
2215
2237
|
if (!s) return null;
|
|
@@ -2222,11 +2244,11 @@ function Ne() {
|
|
|
2222
2244
|
return null;
|
|
2223
2245
|
}
|
|
2224
2246
|
}
|
|
2225
|
-
async function
|
|
2226
|
-
const s =
|
|
2227
|
-
if (s && Date.now() - s.at <
|
|
2247
|
+
async function Ve() {
|
|
2248
|
+
const s = je();
|
|
2249
|
+
if (s && Date.now() - s.at < $e) return s.value;
|
|
2228
2250
|
try {
|
|
2229
|
-
const e = await fetch(
|
|
2251
|
+
const e = await fetch(Ne, {
|
|
2230
2252
|
headers: { Accept: "application/vnd.github+json" }
|
|
2231
2253
|
});
|
|
2232
2254
|
if (!e.ok)
|
|
@@ -2241,14 +2263,14 @@ async function qe() {
|
|
|
2241
2263
|
return s?.value ?? null;
|
|
2242
2264
|
}
|
|
2243
2265
|
}
|
|
2244
|
-
const
|
|
2245
|
-
function
|
|
2266
|
+
const xe = 8e3;
|
|
2267
|
+
function Fe(s) {
|
|
2246
2268
|
if (!s) return null;
|
|
2247
2269
|
const e = s.id ?? s.peerId ?? s.peer_id;
|
|
2248
2270
|
return typeof e == "string" && e.length > 0 ? e : null;
|
|
2249
2271
|
}
|
|
2250
|
-
function
|
|
2251
|
-
const e =
|
|
2272
|
+
function He(s) {
|
|
2273
|
+
const e = Fe(s);
|
|
2252
2274
|
if (!e) return null;
|
|
2253
2275
|
const t = s.meta?.name ?? s.name, n = typeof s.meta?.transport == "string" && s.meta.transport.length > 0 ? s.meta.transport : null, r = typeof s.meta?.hardware_id == "string" && s.meta.hardware_id.length > 0 ? s.meta.hardware_id : null;
|
|
2254
2276
|
return {
|
|
@@ -2260,12 +2282,12 @@ function Fe(s) {
|
|
|
2260
2282
|
hardwareId: r
|
|
2261
2283
|
};
|
|
2262
2284
|
}
|
|
2263
|
-
async function
|
|
2285
|
+
async function Je(s) {
|
|
2264
2286
|
const { signalingUrl: e, hfToken: t } = s;
|
|
2265
2287
|
if (!t) return { ok: !1, robots: [], reason: "No HF token" };
|
|
2266
2288
|
if (!e)
|
|
2267
2289
|
return { ok: !1, robots: [], reason: "No signaling URL" };
|
|
2268
|
-
const n = `${e.replace(/\/$/, "")}/api/robot-status`, r = new AbortController(), i = setTimeout(() => r.abort(),
|
|
2290
|
+
const n = `${e.replace(/\/$/, "")}/api/robot-status`, r = new AbortController(), i = setTimeout(() => r.abort(), xe), o = s.signal ? We([r.signal, s.signal]) : r.signal;
|
|
2269
2291
|
try {
|
|
2270
2292
|
const a = await fetch(n, {
|
|
2271
2293
|
method: "GET",
|
|
@@ -2284,7 +2306,7 @@ async function Ge(s) {
|
|
|
2284
2306
|
reason: `Central returned HTTP ${a.status}`
|
|
2285
2307
|
};
|
|
2286
2308
|
const c = await a.json();
|
|
2287
|
-
return { ok: !0, robots: (Array.isArray(c.robots) ? c.robots : []).map(
|
|
2309
|
+
return { ok: !0, robots: (Array.isArray(c.robots) ? c.robots : []).map(He).filter((l) => l != null) };
|
|
2288
2310
|
} catch (a) {
|
|
2289
2311
|
if (a instanceof DOMException && a.name === "AbortError")
|
|
2290
2312
|
return { ok: !1, robots: [], reason: "Central request timed out" };
|
|
@@ -2294,7 +2316,7 @@ async function Ge(s) {
|
|
|
2294
2316
|
clearTimeout(i);
|
|
2295
2317
|
}
|
|
2296
2318
|
}
|
|
2297
|
-
function
|
|
2319
|
+
function We(s) {
|
|
2298
2320
|
const e = new AbortController();
|
|
2299
2321
|
for (const t of s) {
|
|
2300
2322
|
if (t.aborted)
|
|
@@ -2305,11 +2327,11 @@ function xe(s) {
|
|
|
2305
2327
|
}
|
|
2306
2328
|
export {
|
|
2307
2329
|
ne as M,
|
|
2308
|
-
|
|
2309
|
-
|
|
2330
|
+
Be as R,
|
|
2331
|
+
Je as a,
|
|
2310
2332
|
O as c,
|
|
2311
|
-
|
|
2312
|
-
|
|
2333
|
+
qe as d,
|
|
2334
|
+
Ve as f,
|
|
2313
2335
|
k as p,
|
|
2314
|
-
|
|
2336
|
+
Ge as s
|
|
2315
2337
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decodeCredsFromHash as $, PROTOCOL_VERSION as y, PROTOCOL_SOURCE as b, isProtocolMessage as D } from "../lib/protocol.js";
|
|
2
|
-
import { p as L, a as J, c as G } from "./centralRest-
|
|
2
|
+
import { p as L, a as J, c as G } from "./centralRest-K3a9U_Sk.js";
|
|
3
3
|
const Y = "@pollen-robotics/reachy-mini-sdk", Z = `https://registry.npmjs.org/${Y}/latest`, V = "reachy.sdkLatestRelease.v1", F = "reachy.sdkStalenessDismissed.v1", Q = 360 * 60 * 1e3, v = "reachy-sdk-outdated-overlay";
|
|
4
4
|
function X() {
|
|
5
5
|
try {
|