restream-sdk 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core.js +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "restream-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.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
@@ -402,6 +402,15 @@ export class RestreamStudio extends EventTarget {
402
402
  */
403
403
  async goLive({ publisherSessionId, destinations, overlay, recording, trackNames, restreamChannels, streamMeta, destinationMeta, streamingProvider, layout, screenSessionId, participantOnly } = {}) {
404
404
  if (!publisherSessionId) throw new Error("publisherSessionId is required (from your existing stream session)");
405
+ // Idempotency guard: refuse a second goLive while a job is already live. Re-publishing a fresh
406
+ // session and calling goLive() again on reconnect / screen toggle / collaborator change is the #1
407
+ // cause of duplicate + stale jobs — those are LIVE changes, so use setStreamState() /
408
+ // startScreenShare() / acceptCollab(), NOT a new goLive. Keep ONE publisher session for the whole
409
+ // stream; call stopLive() first to intentionally start over. Only live states block, so after the
410
+ // job stops (status becomes stopping/stopped/failed/ended) a genuine restart works normally.
411
+ if (this.job?.id && ["queued", "starting", "connecting", "running"].includes(this.job.status)) {
412
+ throw new Error(`goLive blocked: a stream is already live (job ${this.job.id}, status ${this.job.status}). Use setStreamState()/startScreenShare()/acceptCollab() for live changes, and call stopLive() before starting a new stream — do not re-publish or re-goLive on reconnect/screen/collab changes.`);
413
+ }
405
414
  const body = {
406
415
  publisherSessionId,
407
416
  destinations: destinations || this._armed?.destinations || [],