@pollen-robotics/reachy-mini-sdk 1.10.0-dev.0.main.b50d97e → 1.10.0-dev.0.main.c8367cd

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 (128) hide show
  1. package/APP_CREATION_GUIDE.md +98 -0
  2. package/dist/lib/central-listener.d.ts +71 -0
  3. package/dist/lib/central-listener.d.ts.map +1 -0
  4. package/dist/lib/central-listener.js +277 -0
  5. package/dist/lib/central-listener.js.map +1 -0
  6. package/dist/lib/central-listener.test.d.ts +2 -0
  7. package/dist/lib/central-listener.test.d.ts.map +1 -0
  8. package/dist/lib/central-listener.test.js +378 -0
  9. package/dist/lib/central-listener.test.js.map +1 -0
  10. package/dist/lib/dc-watchdog.test.d.ts +2 -0
  11. package/dist/lib/dc-watchdog.test.d.ts.map +1 -0
  12. package/dist/lib/dc-watchdog.test.js +154 -0
  13. package/dist/lib/dc-watchdog.test.js.map +1 -0
  14. package/dist/lib/ensure-awake.test.d.ts +2 -0
  15. package/dist/lib/ensure-awake.test.d.ts.map +1 -0
  16. package/dist/lib/ensure-awake.test.js +117 -0
  17. package/dist/lib/ensure-awake.test.js.map +1 -0
  18. package/dist/lib/ice-grace.test.d.ts +2 -0
  19. package/dist/lib/ice-grace.test.d.ts.map +1 -0
  20. package/dist/lib/ice-grace.test.js +211 -0
  21. package/dist/lib/ice-grace.test.js.map +1 -0
  22. package/dist/lib/imu.test.d.ts +2 -0
  23. package/dist/lib/imu.test.d.ts.map +1 -0
  24. package/dist/lib/imu.test.js +78 -0
  25. package/dist/lib/imu.test.js.map +1 -0
  26. package/dist/lib/logger.d.ts +38 -0
  27. package/dist/lib/logger.d.ts.map +1 -0
  28. package/dist/lib/logger.js +81 -0
  29. package/dist/lib/logger.js.map +1 -0
  30. package/dist/lib/pending-replies.d.ts +127 -0
  31. package/dist/lib/pending-replies.d.ts.map +1 -0
  32. package/dist/lib/pending-replies.js +255 -0
  33. package/dist/lib/pending-replies.js.map +1 -0
  34. package/dist/lib/pending-replies.test.d.ts +2 -0
  35. package/dist/lib/pending-replies.test.d.ts.map +1 -0
  36. package/dist/lib/pending-replies.test.js +217 -0
  37. package/dist/lib/pending-replies.test.js.map +1 -0
  38. package/dist/lib/reachy-mini.d.ts +202 -88
  39. package/dist/lib/reachy-mini.d.ts.map +1 -1
  40. package/dist/lib/reachy-mini.js +651 -566
  41. package/dist/lib/reachy-mini.js.map +1 -1
  42. package/dist/lib/redial.test.d.ts +2 -0
  43. package/dist/lib/redial.test.d.ts.map +1 -0
  44. package/dist/lib/redial.test.js +206 -0
  45. package/dist/lib/redial.test.js.map +1 -0
  46. package/dist/lib/request.test.d.ts +2 -0
  47. package/dist/lib/request.test.d.ts.map +1 -0
  48. package/dist/lib/request.test.js +90 -0
  49. package/dist/lib/request.test.js.map +1 -0
  50. package/dist/lib/session-supervisor.d.ts +201 -0
  51. package/dist/lib/session-supervisor.d.ts.map +1 -0
  52. package/dist/lib/session-supervisor.js +520 -0
  53. package/dist/lib/session-supervisor.js.map +1 -0
  54. package/dist/lib/token-store.d.ts +50 -0
  55. package/dist/lib/token-store.d.ts.map +1 -0
  56. package/dist/lib/token-store.js +120 -0
  57. package/dist/lib/token-store.js.map +1 -0
  58. package/dist/lib/token-store.test.d.ts +2 -0
  59. package/dist/lib/token-store.test.d.ts.map +1 -0
  60. package/dist/lib/token-store.test.js +82 -0
  61. package/dist/lib/token-store.test.js.map +1 -0
  62. package/dist/lib/types.d.ts +280 -6
  63. package/dist/lib/types.d.ts.map +1 -1
  64. package/dist/lib/url-helpers.d.ts.map +1 -1
  65. package/dist/lib/url-helpers.js +3 -1
  66. package/dist/lib/url-helpers.js.map +1 -1
  67. package/dist/lib/version.d.ts +2 -0
  68. package/dist/lib/version.d.ts.map +1 -0
  69. package/dist/lib/version.js +5 -0
  70. package/dist/lib/version.js.map +1 -0
  71. package/dist/reachy-mini-sdk.d.ts +15 -1
  72. package/dist/reachy-mini-sdk.d.ts.map +1 -1
  73. package/dist/reachy-mini-sdk.js +12 -0
  74. package/dist/reachy-mini-sdk.js.map +1 -1
  75. package/host/dist/ReachyHost.d.ts.map +1 -1
  76. package/host/dist/chunks/centralRest-uXNMidlL.js +2315 -0
  77. package/host/dist/chunks/index-Beu4GNzi.js +821 -0
  78. package/host/dist/chunks/{mountHost-DjE5zE9R.js → mountHost-BTTF4Uu9.js} +24933 -27488
  79. package/host/dist/components/ConnectingView.d.ts.map +1 -1
  80. package/host/dist/components/DaemonUpdateGate.d.ts +65 -0
  81. package/host/dist/components/DaemonUpdateGate.d.ts.map +1 -0
  82. package/host/dist/components/ErrorView.d.ts.map +1 -1
  83. package/host/dist/components/HostErrorBoundary.d.ts +30 -0
  84. package/host/dist/components/HostErrorBoundary.d.ts.map +1 -0
  85. package/host/dist/components/LeavingView.d.ts.map +1 -1
  86. package/host/dist/components/PickerView.d.ts +16 -14
  87. package/host/dist/components/PickerView.d.ts.map +1 -1
  88. package/host/dist/components/PostOAuthSplash.d.ts +14 -9
  89. package/host/dist/components/PostOAuthSplash.d.ts.map +1 -1
  90. package/host/dist/components/ReachyHostShell.d.ts.map +1 -1
  91. package/host/dist/components/SignInView.d.ts.map +1 -1
  92. package/host/dist/components/TopBar.d.ts +5 -6
  93. package/host/dist/components/TopBar.d.ts.map +1 -1
  94. package/host/dist/components/WelcomeBackOverlay.d.ts.map +1 -1
  95. package/host/dist/embed/index.d.ts +68 -5
  96. package/host/dist/embed/index.d.ts.map +1 -1
  97. package/host/dist/entry/auto.js +2 -2
  98. package/host/dist/entry/embed.d.ts +5 -4
  99. package/host/dist/entry/embed.d.ts.map +1 -1
  100. package/host/dist/entry/embed.js +5 -4
  101. package/host/dist/hooks/useHostBridge.d.ts +35 -1
  102. package/host/dist/hooks/useHostBridge.d.ts.map +1 -1
  103. package/host/dist/hooks/useLatestDaemonVersion.d.ts +7 -0
  104. package/host/dist/hooks/useLatestDaemonVersion.d.ts.map +1 -0
  105. package/host/dist/hooks/useOAuth.d.ts +18 -0
  106. package/host/dist/hooks/useOAuth.d.ts.map +1 -1
  107. package/host/dist/hooks/useRobots.d.ts +0 -2
  108. package/host/dist/hooks/useRobots.d.ts.map +1 -1
  109. package/host/dist/index.d.ts +2 -2
  110. package/host/dist/index.d.ts.map +1 -1
  111. package/host/dist/index.js +11 -10
  112. package/host/dist/lib/daemonRelease.d.ts +84 -0
  113. package/host/dist/lib/daemonRelease.d.ts.map +1 -0
  114. package/host/dist/lib/protocol.d.ts +141 -7
  115. package/host/dist/lib/protocol.d.ts.map +1 -1
  116. package/host/dist/lib/rebootWatch.d.ts +51 -0
  117. package/host/dist/lib/rebootWatch.d.ts.map +1 -0
  118. package/host/dist/lib/sdk-types.d.ts +1 -1
  119. package/host/dist/lib/sdk-types.d.ts.map +1 -1
  120. package/host/dist/lib/sdkStaleness.d.ts +78 -0
  121. package/host/dist/lib/sdkStaleness.d.ts.map +1 -0
  122. package/host/dist/lib/settings.d.ts +16 -5
  123. package/host/dist/lib/settings.d.ts.map +1 -1
  124. package/package.json +11 -4
  125. package/host/dist/chunks/index-lMs2sCXG.js +0 -439
  126. package/host/dist/chunks/reachy-mini-CdsdQLIU.js +0 -1523
  127. package/host/dist/lib/centralListener.d.ts +0 -73
  128. package/host/dist/lib/centralListener.d.ts.map +0 -1
@@ -1,439 +0,0 @@
1
- import { decodeCredsFromHash as O, PROTOCOL_VERSION as g, PROTOCOL_SOURCE as y, isProtocolMessage as N } from "../lib/protocol.js";
2
- const _ = 8e3, M = 2e3, R = 900 * 1e3;
3
- let k = null, S = "*";
4
- function P() {
5
- try {
6
- if (typeof document < "u" && document.referrer)
7
- return new URL(document.referrer).origin;
8
- } catch {
9
- }
10
- return "*";
11
- }
12
- async function q(t = {}) {
13
- return k || (k = C(t)), await k;
14
- }
15
- async function C(t) {
16
- S = P();
17
- const r = t.expectedOrigin ?? S, n = O(window.location.hash);
18
- if (A(), !n)
19
- throw new Error(
20
- "[reachy-mini-sdk/host/embed] no creds bundle found in URL hash. Was the embed mounted directly without ?embedded=1#creds=...?"
21
- );
22
- if (!await U(_))
23
- throw new Error(
24
- `[reachy-mini-sdk/host/embed] window.ReachyMini did not become available within ${_}ms - check the SDK CDN tag.`
25
- );
26
- const e = n.userName ?? n.username ?? null;
27
- n.hfToken && e && D(n.hfToken, e);
28
- const a = new window.ReachyMini({
29
- appName: n.appName,
30
- signalingUrl: n.signalingUrl,
31
- ...t.sdkOptions
32
- }), c = H(r);
33
- b({
34
- source: y,
35
- type: "embed:ready",
36
- version: g
37
- }), c.start();
38
- const u = await c.awaitHostInit(M, n);
39
- w("connecting", "link"), f("boot:link:start", { robotPeerId: u.robotPeerId }), await a.authenticate(), f("boot:authenticate:ok", { state: a.state }), await a.connect(), f("boot:connect:ok", {
40
- state: a.state,
41
- robots: (a.robots ?? []).length
42
- }), w("connecting", "session"), f("boot:session:start", { robotPeerId: u.robotPeerId }), $(a);
43
- try {
44
- await a.startSession(u.robotPeerId), f("boot:session:ok");
45
- } catch (d) {
46
- throw f("boot:session:error", {
47
- message: d?.message ?? String(d)
48
- }), d;
49
- }
50
- return w("connecting", "wake"), f("boot:wake:start"), await a.ensureAwake(), f("boot:wake:ok"), c.attachPageHide(a), w("live", null), J(a), c.buildHandle(a, u);
51
- }
52
- function L(t) {
53
- return {
54
- theme: t.theme,
55
- config: t.config,
56
- appName: t.appName,
57
- hostName: t.hostName,
58
- userName: t.userName ?? null,
59
- robotPeerId: t.robotPeerId
60
- };
61
- }
62
- function E(t) {
63
- return {
64
- theme: t.theme,
65
- config: t.config,
66
- appName: t.appName,
67
- hostName: t.hostName,
68
- userName: t.userName ?? null,
69
- robotPeerId: t.robotPeerId
70
- };
71
- }
72
- function H(t) {
73
- const r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
74
- let e = null, a = !1, c = !1, u = null;
75
- function d(o) {
76
- switch (o.type) {
77
- case "host:init": {
78
- e = E(o), n.forEach((i) => i(e.theme)), l.forEach((i) => i(e.config));
79
- break;
80
- }
81
- case "host:theme-changed": {
82
- e && (e.theme = o.theme), n.forEach((i) => i(o.theme));
83
- break;
84
- }
85
- case "host:config-changed": {
86
- e && (e.config = o.config), l.forEach((i) => i(o.config));
87
- break;
88
- }
89
- case "host:leaving": {
90
- s();
91
- break;
92
- }
93
- }
94
- }
95
- function s() {
96
- a || (a = !0, r.forEach((o) => {
97
- try {
98
- o();
99
- } catch (i) {
100
- console.warn("[reachy-mini-sdk/host/embed] onLeave threw", i);
101
- }
102
- }));
103
- }
104
- return {
105
- start() {
106
- c || (c = !0, u = (o) => {
107
- t !== "*" && o.origin !== t || N(o.data) && d(o.data);
108
- }, window.addEventListener("message", u));
109
- },
110
- async awaitHostInit(o, i) {
111
- return window.parent !== window ? e || new Promise((h) => {
112
- const p = (v) => {
113
- if (t !== "*" && v.origin !== t || !N(v.data)) return;
114
- const T = v.data;
115
- T.type === "host:init" && (window.removeEventListener("message", p), window.clearTimeout(I), e = E(T), h(e));
116
- }, I = window.setTimeout(() => {
117
- window.removeEventListener("message", p), e || (e = L(i)), h(e);
118
- }, o);
119
- window.addEventListener("message", p);
120
- }) : (e = L(i), e);
121
- },
122
- attachPageHide(o) {
123
- const i = () => {
124
- s();
125
- try {
126
- o.stopSession();
127
- } catch {
128
- }
129
- };
130
- window.addEventListener("pagehide", i, { once: !0 });
131
- },
132
- buildHandle(o, i) {
133
- e = i;
134
- const m = K(o);
135
- return {
136
- reachy: o,
137
- media: m,
138
- get theme() {
139
- return e.theme;
140
- },
141
- get config() {
142
- return e.config;
143
- },
144
- get appName() {
145
- return e.appName;
146
- },
147
- get hostName() {
148
- return e.hostName;
149
- },
150
- get userName() {
151
- return e.userName;
152
- },
153
- onLeave(h) {
154
- return r.add(h), () => r.delete(h);
155
- },
156
- onThemeChange(h) {
157
- return n.add(h), () => n.delete(h);
158
- },
159
- onConfigChange(h) {
160
- const p = (I) => h(I);
161
- return l.add(p), () => l.delete(p);
162
- },
163
- setAppState(h) {
164
- w(
165
- h.phase,
166
- h.connectingStep ?? null,
167
- h.message ?? null
168
- );
169
- },
170
- requestLeave() {
171
- b({
172
- source: y,
173
- type: "embed:request-leave",
174
- version: g
175
- });
176
- },
177
- reportError(h, p) {
178
- b({
179
- source: y,
180
- type: "embed:error",
181
- version: g,
182
- message: h,
183
- fatal: p?.fatal === !0,
184
- detail: p?.detail
185
- });
186
- }
187
- };
188
- }
189
- };
190
- }
191
- function A() {
192
- try {
193
- const t = window.location.pathname + window.location.search;
194
- history.replaceState(history.state, document.title, t);
195
- } catch {
196
- }
197
- }
198
- function D(t, r) {
199
- try {
200
- sessionStorage.setItem("hf_token", t), sessionStorage.setItem("hf_username", r), sessionStorage.setItem(
201
- "hf_token_expires",
202
- new Date(Date.now() + R).toISOString()
203
- );
204
- } catch {
205
- }
206
- }
207
- function U(t) {
208
- return new Promise((r) => {
209
- if (typeof window > "u") {
210
- r(!1);
211
- return;
212
- }
213
- if (window.ReachyMini) {
214
- r(!0);
215
- return;
216
- }
217
- let n = !1;
218
- const l = () => {
219
- n || (n = !0, window.removeEventListener("reachymini:ready", l), window.clearTimeout(e), r(!!window.ReachyMini));
220
- }, e = window.setTimeout(() => {
221
- n || (n = !0, window.removeEventListener("reachymini:ready", l), r(!1));
222
- }, t);
223
- window.addEventListener("reachymini:ready", l);
224
- });
225
- }
226
- function b(t) {
227
- if (!(typeof window > "u"))
228
- try {
229
- window.parent.postMessage(t, S);
230
- } catch (r) {
231
- console.warn("[reachy-mini-sdk/host/embed] postMessage to host failed", r);
232
- }
233
- }
234
- function w(t, r, n = null, l = null) {
235
- b({
236
- source: y,
237
- type: "embed:app-state",
238
- version: g,
239
- phase: t,
240
- connectingStep: r,
241
- message: n,
242
- rttMs: l
243
- });
244
- }
245
- const j = 1500, F = 6;
246
- async function V(t) {
247
- try {
248
- const r = await t.getStats();
249
- let n = null;
250
- return r.forEach((l) => {
251
- const e = l;
252
- e.type !== "candidate-pair" || !(e.selected === !0 || e.nominated === !0 && e.state === "succeeded") || typeof e.currentRoundTripTime == "number" && (n = e.currentRoundTripTime * 1e3);
253
- }), n;
254
- } catch {
255
- return null;
256
- }
257
- }
258
- function J(t) {
259
- if (typeof window > "u") return;
260
- const r = t._pc;
261
- if (!r) return;
262
- const n = [];
263
- let l = !1;
264
- const e = async () => {
265
- if (l) return;
266
- const u = await V(r);
267
- u !== null && (n.push(u), n.length > F && n.shift(), w("live", null, null, Math.min(...n)));
268
- }, a = window.setInterval(() => {
269
- e();
270
- }, j);
271
- window.setTimeout(() => {
272
- e();
273
- }, 600);
274
- const c = () => {
275
- l || (l = !0, window.clearInterval(a));
276
- };
277
- try {
278
- t.addEventListener("sessionStopped", c);
279
- } catch {
280
- }
281
- window.addEventListener("pagehide", c, { once: !0 });
282
- }
283
- function f(t, r = {}) {
284
- if (!(typeof window > "u")) {
285
- try {
286
- window.parent.postMessage(
287
- {
288
- source: y,
289
- type: "embed:debug",
290
- version: g,
291
- tag: t,
292
- payload: r
293
- },
294
- S
295
- );
296
- } catch {
297
- }
298
- try {
299
- let n = "";
300
- try {
301
- n = JSON.stringify(r);
302
- } catch {
303
- n = "<unserializable>";
304
- }
305
- console.info(`[embed-debug] ${t} ${n}`);
306
- } catch {
307
- }
308
- }
309
- }
310
- function K(t) {
311
- let r = null;
312
- const n = t, l = () => {
313
- const c = n._pc;
314
- if (!c) return null;
315
- const u = c.getReceivers().map((d) => d.track).filter(
316
- (d) => d !== null && d.kind !== "" && d.readyState === "live"
317
- );
318
- return u.length === 0 ? null : new MediaStream(u);
319
- }, e = () => r || (r = l(), r && f("media:cache:init", {
320
- videoTracks: r.getVideoTracks().length,
321
- audioTracks: r.getAudioTracks().length
322
- }), r), a = () => {
323
- r && (r = null, f("media:cache:clear"));
324
- };
325
- return t.addEventListener("sessionStopped", a), {
326
- attachVideo(c) {
327
- const u = t.attachVideo(c), d = e();
328
- if (d && c.srcObject !== d)
329
- try {
330
- c.srcObject = d, c.play().catch(() => {
331
- }), f("media:attach:replay", {
332
- videoTracks: d.getVideoTracks().length,
333
- audioTracks: d.getAudioTracks().length
334
- });
335
- } catch (s) {
336
- f("media:attach:replay:error", {
337
- message: s?.message ?? String(s)
338
- });
339
- }
340
- return u;
341
- },
342
- get robotStream() {
343
- return e();
344
- },
345
- get micStream() {
346
- return n._micStream;
347
- }
348
- };
349
- }
350
- function $(t) {
351
- const r = [
352
- "connected",
353
- "disconnected",
354
- "streaming",
355
- "sessionStopped",
356
- "sessionRejected",
357
- "robotsChanged",
358
- "error",
359
- "state",
360
- "log",
361
- "message"
362
- ];
363
- for (const e of r)
364
- try {
365
- t.addEventListener(e, (a) => {
366
- let c = {};
367
- const u = a;
368
- if (u && typeof u == "object" && "detail" in u)
369
- try {
370
- c = JSON.parse(JSON.stringify(u.detail ?? null));
371
- } catch {
372
- c = { _unserializable: !0 };
373
- }
374
- f(`sdk:${e}`, c);
375
- });
376
- } catch {
377
- }
378
- try {
379
- const e = t, a = e._handleSignalingMessage;
380
- if (typeof a == "function") {
381
- const c = e._sendToServer;
382
- typeof c == "function" && (e._sendToServer = async function(d) {
383
- const s = d, o = { type: s?.type ?? "?" };
384
- if (s && "peerId" in s && (o.peerId = String(s.peerId)), s && "sessionId" in s && (o.sessionId = String(s.sessionId)), s && "sdp" in s) {
385
- const i = s.sdp;
386
- o.sdpType = i?.type ?? "?", o.sdpLen = i?.sdp?.length ?? 0;
387
- }
388
- if (s && "ice" in s) {
389
- const i = s.ice;
390
- o.iceCand = (i?.candidate ?? "").slice(0, 60) || "<end-of-candidates>";
391
- }
392
- f("sdk:send", o);
393
- try {
394
- const i = await c.call(this, d), m = i;
395
- return f("sdk:send:res", {
396
- inFor: o.type,
397
- resType: m?.type ?? null,
398
- keys: m ? Object.keys(m) : []
399
- }), i;
400
- } catch (i) {
401
- throw f("sdk:send:err", {
402
- inFor: o.type,
403
- msg: i?.message ?? String(i)
404
- }), i;
405
- }
406
- }), e._handleSignalingMessage = function(d) {
407
- const s = d, o = { type: s?.type ?? "?" };
408
- if ("sessionId" in s && (o.sessionId = String(s.sessionId)), "peerId" in s && (o.peerId = String(s.peerId)), "sdp" in s) {
409
- const i = s.sdp;
410
- o.sdpType = i?.type ?? "?", o.sdpLen = i?.sdp?.length ?? 0;
411
- }
412
- if ("ice" in s) {
413
- const i = s.ice;
414
- o.iceCand = (i?.candidate ?? "").slice(0, 60) || "<end-of-candidates>";
415
- }
416
- return "reason" in s && (o.reason = String(s.reason)), f("sdk:sse", o), a.call(this, d);
417
- };
418
- }
419
- } catch {
420
- }
421
- const n = Date.now(), l = window.setInterval(() => {
422
- const e = t, a = e._pc, c = e._dc;
423
- f("sdk:probe", {
424
- elapsedMs: Date.now() - n,
425
- myPeerId: e._peerId ?? null,
426
- state: e._state ?? null,
427
- sseAborted: e._sseAbortController?.signal?.aborted ?? null,
428
- pcState: a?.connectionState ?? null,
429
- iceState: a?.iceConnectionState ?? null,
430
- iceGather: a?.iceGatheringState ?? null,
431
- signalingState: a?.signalingState ?? null,
432
- dcState: c?.readyState ?? null,
433
- sessionId: e._sessionId ?? null
434
- }), Date.now() - n > 3e4 && window.clearInterval(l);
435
- }, 1500);
436
- }
437
- export {
438
- q as c
439
- };