restream-sdk 0.1.7 → 0.1.9
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 +16 -1
- package/types/index.d.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "restream-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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
|
@@ -299,7 +299,7 @@ export class RestreamStudio extends EventTarget {
|
|
|
299
299
|
* Restream channels. Any field omitted falls back to the
|
|
300
300
|
* default pre-set for this creator on the platform.
|
|
301
301
|
*/
|
|
302
|
-
async goLive({ publisherSessionId, destinations, overlay, recording, trackNames, restreamChannels, streamMeta } = {}) {
|
|
302
|
+
async goLive({ publisherSessionId, destinations, overlay, recording, trackNames, restreamChannels, streamMeta, destinationMeta } = {}) {
|
|
303
303
|
if (!publisherSessionId) throw new Error("publisherSessionId is required (from your existing stream session)");
|
|
304
304
|
const body = {
|
|
305
305
|
publisherSessionId,
|
|
@@ -315,6 +315,12 @@ export class RestreamStudio extends EventTarget {
|
|
|
315
315
|
if (streamMeta && (streamMeta.title || streamMeta.description || (streamMeta.tags && streamMeta.tags.length))) {
|
|
316
316
|
body.streamMeta = streamMeta;
|
|
317
317
|
}
|
|
318
|
+
// Per-destination overrides, keyed by platform name (e.g. { youtube: {title},
|
|
319
|
+
// twitch: {title, tags} }). Each field falls back to streamMeta, then the
|
|
320
|
+
// creator's pre-set per-destination / global default on the platform.
|
|
321
|
+
if (destinationMeta && typeof destinationMeta === "object" && Object.keys(destinationMeta).length) {
|
|
322
|
+
body.destinationMeta = destinationMeta;
|
|
323
|
+
}
|
|
318
324
|
if (this.publishableKey && this.userId) body.clientUserId = this.userId; // token mode binds server-side
|
|
319
325
|
const job = await this._req("POST", "/api/v1/jobs", body);
|
|
320
326
|
this.job = job;
|
|
@@ -526,6 +532,15 @@ export class RestreamStudio extends EventTarget {
|
|
|
526
532
|
let evt;
|
|
527
533
|
try { evt = JSON.parse(e.data); } catch { return; } // heartbeat / non-JSON
|
|
528
534
|
if (!evt || !evt.type) return;
|
|
535
|
+
// When the composite starts, transition this client onto the composite job —
|
|
536
|
+
// critical for the HOST, who was still tracking their (now-superseded) solo
|
|
537
|
+
// job. The guest already attached via the accept response; the id guard makes
|
|
538
|
+
// this idempotent so it doesn't restart realtime twice.
|
|
539
|
+
if (evt.type === "collab-composite" && evt.job?.id && this.job?.id !== evt.job.id) {
|
|
540
|
+
this.job = evt.job;
|
|
541
|
+
this._emit("job", evt.job);
|
|
542
|
+
this.startRealtime(evt.job.id);
|
|
543
|
+
}
|
|
529
544
|
this._emit(evt.type, evt);
|
|
530
545
|
this._emit("collab", evt);
|
|
531
546
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -81,6 +81,13 @@ export interface GoLiveParams {
|
|
|
81
81
|
* this creator on the platform. Omit entirely to use the pre-set defaults.
|
|
82
82
|
*/
|
|
83
83
|
streamMeta?: StreamMeta;
|
|
84
|
+
/**
|
|
85
|
+
* Per-destination overrides, keyed by platform name (e.g.
|
|
86
|
+
* `{ youtube: { title }, twitch: { title, tags } }`). Each field falls back, in
|
|
87
|
+
* order, to: this map → `streamMeta` → the creator's pre-set per-destination
|
|
88
|
+
* default → the creator's pre-set global default → the platform's existing value.
|
|
89
|
+
*/
|
|
90
|
+
destinationMeta?: DestinationMeta;
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
export interface StreamMeta {
|
|
@@ -89,6 +96,9 @@ export interface StreamMeta {
|
|
|
89
96
|
tags?: string[];
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
/** Per-platform stream metadata overrides, keyed by platform name. */
|
|
100
|
+
export type DestinationMeta = Partial<Record<Platform, StreamMeta>> & Record<string, StreamMeta>;
|
|
101
|
+
|
|
92
102
|
export interface OverlayUpdate {
|
|
93
103
|
topBanner?: string;
|
|
94
104
|
bottomBanner?: string;
|