@pollen-robotics/reachy-mini-sdk 1.8.0 → 1.8.1

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 (67) hide show
  1. package/APP_CREATION_GUIDE.md +1795 -0
  2. package/README.md +2 -5
  3. package/dist/animation/distance.d.ts +87 -0
  4. package/dist/animation/distance.d.ts.map +1 -0
  5. package/dist/animation/distance.js +140 -0
  6. package/dist/animation/distance.js.map +1 -0
  7. package/dist/animation/index.d.ts +34 -0
  8. package/dist/animation/index.d.ts.map +1 -0
  9. package/dist/animation/index.js +33 -0
  10. package/dist/animation/index.js.map +1 -0
  11. package/dist/animation/pose.d.ts +40 -0
  12. package/dist/animation/pose.d.ts.map +1 -0
  13. package/dist/animation/pose.js +15 -0
  14. package/dist/animation/pose.js.map +1 -0
  15. package/dist/animation/presets.d.ts +85 -0
  16. package/dist/animation/presets.d.ts.map +1 -0
  17. package/dist/animation/presets.js +82 -0
  18. package/dist/animation/presets.js.map +1 -0
  19. package/dist/animation/safe-return.d.ts +90 -0
  20. package/dist/animation/safe-return.d.ts.map +1 -0
  21. package/dist/animation/safe-return.js +123 -0
  22. package/dist/animation/safe-return.js.map +1 -0
  23. package/dist/lib/reachy-mini.d.ts +99 -0
  24. package/dist/lib/reachy-mini.d.ts.map +1 -1
  25. package/dist/lib/reachy-mini.js +314 -9
  26. package/dist/lib/reachy-mini.js.map +1 -1
  27. package/dist/lib/types.d.ts +27 -0
  28. package/dist/lib/types.d.ts.map +1 -1
  29. package/host/README.md +14 -12
  30. package/host/dist/ReachyHost.d.ts +2 -1
  31. package/host/dist/ReachyHost.d.ts.map +1 -1
  32. package/host/dist/chunks/index-lMs2sCXG.js +439 -0
  33. package/host/dist/chunks/{mountHost-D7cgkU9Q.js → mountHost-DjE5zE9R.js} +11142 -11014
  34. package/host/dist/chunks/{reachy-mini-B1hlBmDQ.js → reachy-mini-GHNS4GSp.js} +494 -307
  35. package/host/dist/components/PickerView.d.ts.map +1 -1
  36. package/host/dist/components/PostOAuthSplash.d.ts +25 -0
  37. package/host/dist/components/PostOAuthSplash.d.ts.map +1 -0
  38. package/host/dist/components/ReachyHostShell.d.ts.map +1 -1
  39. package/host/dist/components/TopBar.d.ts +8 -1
  40. package/host/dist/components/TopBar.d.ts.map +1 -1
  41. package/host/dist/components/WelcomeBackOverlay.d.ts.map +1 -1
  42. package/host/dist/embed/index.d.ts +3 -2
  43. package/host/dist/embed/index.d.ts.map +1 -1
  44. package/host/dist/entry/auto.js +2 -2
  45. package/host/dist/entry/embed.js +2 -2
  46. package/host/dist/hooks/useHostBridge.d.ts +6 -0
  47. package/host/dist/hooks/useHostBridge.d.ts.map +1 -1
  48. package/host/dist/hooks/useSdk.d.ts.map +1 -1
  49. package/host/dist/index.js +3 -3
  50. package/host/dist/lib/protocol.d.ts +17 -3
  51. package/host/dist/lib/protocol.d.ts.map +1 -1
  52. package/host/dist/lib/settings.d.ts +3 -2
  53. package/host/dist/lib/settings.d.ts.map +1 -1
  54. package/host/dist/mountHost.d.ts.map +1 -1
  55. package/host/dist/ui/design/IdentityChipBar.d.ts +46 -0
  56. package/host/dist/ui/design/IdentityChipBar.d.ts.map +1 -0
  57. package/host/dist/ui/design/LinkQualityBars.d.ts +32 -0
  58. package/host/dist/ui/design/LinkQualityBars.d.ts.map +1 -0
  59. package/host/dist/ui/design/MetaPill.d.ts +41 -0
  60. package/host/dist/ui/design/MetaPill.d.ts.map +1 -0
  61. package/host/dist/ui/design/TransportChip.d.ts +39 -0
  62. package/host/dist/ui/design/TransportChip.d.ts.map +1 -0
  63. package/package.json +7 -4
  64. package/CHANGELOG.md +0 -188
  65. package/host/APP_AUTHOR_GUIDE.md +0 -646
  66. package/host/SPEC.md +0 -618
  67. package/host/dist/chunks/index-CyLPysJS.js +0 -400
@@ -1,400 +0,0 @@
1
- import { decodeCredsFromHash as E, PROTOCOL_VERSION as w, PROTOCOL_SOURCE as y, isProtocolMessage as N } from "../lib/protocol.js";
2
- const _ = 8e3, P = 2e3, M = 900 * 1e3;
3
- let v = null, S = "*";
4
- function R() {
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 J(t = {}) {
13
- return v || (v = C(t)), await v;
14
- }
15
- async function C(t) {
16
- S = R();
17
- const o = t.expectedOrigin ?? S, s = E(window.location.hash);
18
- if (A(), !s)
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 = s.userName ?? s.username ?? null;
27
- s.hfToken && e && D(s.hfToken, e);
28
- const a = new window.ReachyMini({
29
- appName: s.appName,
30
- signalingUrl: s.signalingUrl,
31
- ...t.sdkOptions
32
- }), c = H(o);
33
- b({
34
- source: y,
35
- type: "embed:ready",
36
- version: w
37
- }), c.start();
38
- const l = await c.awaitHostInit(P, s);
39
- g("connecting", "link"), u("boot:link:start", { robotPeerId: l.robotPeerId }), await a.authenticate(), u("boot:authenticate:ok", { state: a.state }), await a.connect(), u("boot:connect:ok", {
40
- state: a.state,
41
- robots: (a.robots ?? []).length
42
- }), g("connecting", "session"), u("boot:session:start", { robotPeerId: l.robotPeerId }), F(a);
43
- try {
44
- await a.startSession(l.robotPeerId), u("boot:session:ok");
45
- } catch (d) {
46
- throw u("boot:session:error", {
47
- message: d?.message ?? String(d)
48
- }), d;
49
- }
50
- return g("connecting", "wake"), u("boot:wake:start"), await a.ensureAwake(), u("boot:wake:ok"), c.attachPageHide(a), g("live", null), c.buildHandle(a, l);
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 O(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 o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
74
- let e = null, a = !1, c = !1, l = null;
75
- function d(n) {
76
- switch (n.type) {
77
- case "host:init": {
78
- e = O(n), s.forEach((r) => r(e.theme)), f.forEach((r) => r(e.config));
79
- break;
80
- }
81
- case "host:theme-changed": {
82
- e && (e.theme = n.theme), s.forEach((r) => r(n.theme));
83
- break;
84
- }
85
- case "host:config-changed": {
86
- e && (e.config = n.config), f.forEach((r) => r(n.config));
87
- break;
88
- }
89
- case "host:leaving": {
90
- i();
91
- break;
92
- }
93
- }
94
- }
95
- function i() {
96
- a || (a = !0, o.forEach((n) => {
97
- try {
98
- n();
99
- } catch (r) {
100
- console.warn("[reachy-mini-sdk/host/embed] onLeave threw", r);
101
- }
102
- }));
103
- }
104
- return {
105
- start() {
106
- c || (c = !0, l = (n) => {
107
- t !== "*" && n.origin !== t || N(n.data) && d(n.data);
108
- }, window.addEventListener("message", l));
109
- },
110
- async awaitHostInit(n, r) {
111
- return window.parent !== window ? e || new Promise((h) => {
112
- const p = (I) => {
113
- if (t !== "*" && I.origin !== t || !N(I.data)) return;
114
- const T = I.data;
115
- T.type === "host:init" && (window.removeEventListener("message", p), window.clearTimeout(k), e = O(T), h(e));
116
- }, k = window.setTimeout(() => {
117
- window.removeEventListener("message", p), e || (e = L(r)), h(e);
118
- }, n);
119
- window.addEventListener("message", p);
120
- }) : (e = L(r), e);
121
- },
122
- attachPageHide(n) {
123
- const r = () => {
124
- i();
125
- try {
126
- n.stopSession();
127
- } catch {
128
- }
129
- };
130
- window.addEventListener("pagehide", r, { once: !0 });
131
- },
132
- buildHandle(n, r) {
133
- e = r;
134
- const m = j(n);
135
- return {
136
- reachy: n,
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 o.add(h), () => o.delete(h);
155
- },
156
- onThemeChange(h) {
157
- return s.add(h), () => s.delete(h);
158
- },
159
- onConfigChange(h) {
160
- const p = (k) => h(k);
161
- return f.add(p), () => f.delete(p);
162
- },
163
- setAppState(h) {
164
- g(
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: w
175
- });
176
- },
177
- reportError(h, p) {
178
- b({
179
- source: y,
180
- type: "embed:error",
181
- version: w,
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, o) {
199
- try {
200
- sessionStorage.setItem("hf_token", t), sessionStorage.setItem("hf_username", o), sessionStorage.setItem(
201
- "hf_token_expires",
202
- new Date(Date.now() + M).toISOString()
203
- );
204
- } catch {
205
- }
206
- }
207
- function U(t) {
208
- return new Promise((o) => {
209
- if (typeof window > "u") {
210
- o(!1);
211
- return;
212
- }
213
- if (window.ReachyMini) {
214
- o(!0);
215
- return;
216
- }
217
- let s = !1;
218
- const f = () => {
219
- s || (s = !0, window.removeEventListener("reachymini:ready", f), window.clearTimeout(e), o(!!window.ReachyMini));
220
- }, e = window.setTimeout(() => {
221
- s || (s = !0, window.removeEventListener("reachymini:ready", f), o(!1));
222
- }, t);
223
- window.addEventListener("reachymini:ready", f);
224
- });
225
- }
226
- function b(t) {
227
- if (!(typeof window > "u"))
228
- try {
229
- window.parent.postMessage(t, S);
230
- } catch (o) {
231
- console.warn("[reachy-mini-sdk/host/embed] postMessage to host failed", o);
232
- }
233
- }
234
- function g(t, o, s = null) {
235
- b({
236
- source: y,
237
- type: "embed:app-state",
238
- version: w,
239
- phase: t,
240
- connectingStep: o,
241
- message: s
242
- });
243
- }
244
- function u(t, o = {}) {
245
- if (!(typeof window > "u")) {
246
- try {
247
- window.parent.postMessage(
248
- {
249
- source: y,
250
- type: "embed:debug",
251
- version: w,
252
- tag: t,
253
- payload: o
254
- },
255
- S
256
- );
257
- } catch {
258
- }
259
- try {
260
- let s = "";
261
- try {
262
- s = JSON.stringify(o);
263
- } catch {
264
- s = "<unserializable>";
265
- }
266
- console.info(`[embed-debug] ${t} ${s}`);
267
- } catch {
268
- }
269
- }
270
- }
271
- function j(t) {
272
- let o = null;
273
- const s = t, f = () => {
274
- const c = s._pc;
275
- if (!c) return null;
276
- const l = c.getReceivers().map((d) => d.track).filter(
277
- (d) => d !== null && d.kind !== "" && d.readyState === "live"
278
- );
279
- return l.length === 0 ? null : new MediaStream(l);
280
- }, e = () => o || (o = f(), o && u("media:cache:init", {
281
- videoTracks: o.getVideoTracks().length,
282
- audioTracks: o.getAudioTracks().length
283
- }), o), a = () => {
284
- o && (o = null, u("media:cache:clear"));
285
- };
286
- return t.addEventListener("sessionStopped", a), {
287
- attachVideo(c) {
288
- const l = t.attachVideo(c), d = e();
289
- if (d && c.srcObject !== d)
290
- try {
291
- c.srcObject = d, c.play().catch(() => {
292
- }), u("media:attach:replay", {
293
- videoTracks: d.getVideoTracks().length,
294
- audioTracks: d.getAudioTracks().length
295
- });
296
- } catch (i) {
297
- u("media:attach:replay:error", {
298
- message: i?.message ?? String(i)
299
- });
300
- }
301
- return l;
302
- },
303
- get robotStream() {
304
- return e();
305
- },
306
- get micStream() {
307
- return s._micStream;
308
- }
309
- };
310
- }
311
- function F(t) {
312
- const o = [
313
- "connected",
314
- "disconnected",
315
- "streaming",
316
- "sessionStopped",
317
- "sessionRejected",
318
- "robotsChanged",
319
- "error",
320
- "state",
321
- "log",
322
- "message"
323
- ];
324
- for (const e of o)
325
- try {
326
- t.addEventListener(e, (a) => {
327
- let c = {};
328
- const l = a;
329
- if (l && typeof l == "object" && "detail" in l)
330
- try {
331
- c = JSON.parse(JSON.stringify(l.detail ?? null));
332
- } catch {
333
- c = { _unserializable: !0 };
334
- }
335
- u(`sdk:${e}`, c);
336
- });
337
- } catch {
338
- }
339
- try {
340
- const e = t, a = e._handleSignalingMessage;
341
- if (typeof a == "function") {
342
- const c = e._sendToServer;
343
- typeof c == "function" && (e._sendToServer = async function(d) {
344
- const i = d, n = { type: i?.type ?? "?" };
345
- if (i && "peerId" in i && (n.peerId = String(i.peerId)), i && "sessionId" in i && (n.sessionId = String(i.sessionId)), i && "sdp" in i) {
346
- const r = i.sdp;
347
- n.sdpType = r?.type ?? "?", n.sdpLen = r?.sdp?.length ?? 0;
348
- }
349
- if (i && "ice" in i) {
350
- const r = i.ice;
351
- n.iceCand = (r?.candidate ?? "").slice(0, 60) || "<end-of-candidates>";
352
- }
353
- u("sdk:send", n);
354
- try {
355
- const r = await c.call(this, d), m = r;
356
- return u("sdk:send:res", {
357
- inFor: n.type,
358
- resType: m?.type ?? null,
359
- keys: m ? Object.keys(m) : []
360
- }), r;
361
- } catch (r) {
362
- throw u("sdk:send:err", {
363
- inFor: n.type,
364
- msg: r?.message ?? String(r)
365
- }), r;
366
- }
367
- }), e._handleSignalingMessage = function(d) {
368
- const i = d, n = { type: i?.type ?? "?" };
369
- if ("sessionId" in i && (n.sessionId = String(i.sessionId)), "peerId" in i && (n.peerId = String(i.peerId)), "sdp" in i) {
370
- const r = i.sdp;
371
- n.sdpType = r?.type ?? "?", n.sdpLen = r?.sdp?.length ?? 0;
372
- }
373
- if ("ice" in i) {
374
- const r = i.ice;
375
- n.iceCand = (r?.candidate ?? "").slice(0, 60) || "<end-of-candidates>";
376
- }
377
- return "reason" in i && (n.reason = String(i.reason)), u("sdk:sse", n), a.call(this, d);
378
- };
379
- }
380
- } catch {
381
- }
382
- const s = Date.now(), f = window.setInterval(() => {
383
- const e = t, a = e._pc, c = e._dc;
384
- u("sdk:probe", {
385
- elapsedMs: Date.now() - s,
386
- myPeerId: e._peerId ?? null,
387
- state: e._state ?? null,
388
- sseAborted: e._sseAbortController?.signal?.aborted ?? null,
389
- pcState: a?.connectionState ?? null,
390
- iceState: a?.iceConnectionState ?? null,
391
- iceGather: a?.iceGatheringState ?? null,
392
- signalingState: a?.signalingState ?? null,
393
- dcState: c?.readyState ?? null,
394
- sessionId: e._sessionId ?? null
395
- }), Date.now() - s > 3e4 && window.clearInterval(f);
396
- }, 1500);
397
- }
398
- export {
399
- J as c
400
- };