restream-sdk 0.7.0 → 0.8.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.
- package/package.json +1 -1
- package/src/core.js +9 -6
- package/types/index.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "restream-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Plug-and-play headless React hooks to add multi-platform restreaming (connect socials, go live, live chat + viewers, collaborative split-screen) with zero client backend.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/core.js
CHANGED
|
@@ -73,7 +73,7 @@ export class RestreamStudio extends EventTarget {
|
|
|
73
73
|
|
|
74
74
|
_emit(type, detail) { this.dispatchEvent(new CustomEvent(type, { detail })); }
|
|
75
75
|
|
|
76
|
-
/** Subscribe to an event ("connections" | "job" | "viewers" | "comment" | "comments" | "error" | "collab" | "collab-invite" | "collab-accepted" | "collab-declined" | "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-snapshot"). Returns an unsubscribe fn. */
|
|
76
|
+
/** Subscribe to an event ("connections" | "job" | "viewers" | "comment" | "comments" | "error" | "collab" | "collab-invite" | "collab-accepted" | "collab-declined" | "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-reassigned" | "collab-snapshot"). Returns an unsubscribe fn. */
|
|
77
77
|
on(type, cb) {
|
|
78
78
|
const handler = (e) => cb(e.detail);
|
|
79
79
|
this.addEventListener(type, handler);
|
|
@@ -802,11 +802,14 @@ export class RestreamStudio extends EventTarget {
|
|
|
802
802
|
let evt;
|
|
803
803
|
try { evt = JSON.parse(e.data); } catch { return; } // heartbeat / non-JSON
|
|
804
804
|
if (!evt || !evt.type) return;
|
|
805
|
-
//
|
|
806
|
-
// critical for the HOST,
|
|
807
|
-
//
|
|
808
|
-
// this
|
|
809
|
-
|
|
805
|
+
// Follow a job-id change. Two events carry a new job to adopt:
|
|
806
|
+
// • collab-composite — this client joined the composite (critical for the HOST, still tracking
|
|
807
|
+
// its now-superseded solo; the guest already attached via the accept response).
|
|
808
|
+
// • collab-reassigned — this creator was moved to a FRESH solo job (collab ended, host took
|
|
809
|
+
// over, or this guest was swapped out). Without adopting it, the UI is orphaned on a stopped
|
|
810
|
+
// composite id while actually re-broadcasting under a job it can't see.
|
|
811
|
+
// The id guard keeps it idempotent (won't restart realtime twice).
|
|
812
|
+
if ((evt.type === "collab-composite" || evt.type === "collab-reassigned") && evt.job?.id && this.job?.id !== evt.job.id) {
|
|
810
813
|
this.job = evt.job;
|
|
811
814
|
this._emit("job", evt.job);
|
|
812
815
|
this.startRealtime(evt.job.id);
|
package/types/index.d.ts
CHANGED
|
@@ -161,7 +161,7 @@ export interface OverlayUpdate {
|
|
|
161
161
|
export type RestreamEvent =
|
|
162
162
|
| "connections" | "job" | "viewers" | "comment" | "comments" | "error"
|
|
163
163
|
| "collab" | "collab-invite" | "collab-accepted" | "collab-declined"
|
|
164
|
-
| "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-snapshot";
|
|
164
|
+
| "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-reassigned" | "collab-snapshot";
|
|
165
165
|
|
|
166
166
|
/** A collaborative split-screen invite (A invites B; the composite starts on accept). */
|
|
167
167
|
export interface CollabInvite {
|
|
@@ -230,7 +230,7 @@ export class RestreamStudio extends EventTarget {
|
|
|
230
230
|
on(type: "error", cb: (e: Error) => void): () => void;
|
|
231
231
|
on(type: "state", cb: (s: StreamState) => void): () => void;
|
|
232
232
|
on(type: "screenshare", cb: (e: { active: boolean; sessionId?: string; trackName?: string }) => void): () => void;
|
|
233
|
-
on(type: "collab" | "collab-invite" | "collab-accepted" | "collab-declined" | "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-snapshot", cb: (e: CollabEvent) => void): () => void;
|
|
233
|
+
on(type: "collab" | "collab-invite" | "collab-accepted" | "collab-declined" | "collab-revoked" | "collab-ended" | "collab-expired" | "collab-composite" | "collab-reassigned" | "collab-snapshot", cb: (e: CollabEvent) => void): () => void;
|
|
234
234
|
listConnections(): Promise<Connection[]>;
|
|
235
235
|
listOAuthPlatforms(): Promise<OAuthPlatformsResponse>;
|
|
236
236
|
listRestreamChannels(): Promise<RestreamChannel[]>;
|