@tivio/sdk-react 10.2.1 → 11.0.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.
@@ -675,15 +675,53 @@ export declare interface BaseInteractiveWidget<TAnswer extends BaseQuestionAnswe
675
675
  readonly type: InteractiveWidgetType;
676
676
  readonly status: InteractiveWidgetStatus;
677
677
  readonly questionsCount: number;
678
+ /**
679
+ * Id of the answer option the current user picked for {@link currentQuestion}.
680
+ *
681
+ * @remarks
682
+ * This is **optimistic local state**, not a server-confirmed value. It is set
683
+ * immediately when `submitAnswer` is called (before the backend responds) so the
684
+ * UI can reflect the choice without delay. For quizzes it is reverted to its
685
+ * previous value if the submission fails; for **polls** it is intentionally kept
686
+ * on failure (polls favor a smooth voting experience over per-vote precision), so
687
+ * the user keeps seeing their pick for this session. It is scoped to this
688
+ * device/session and resets when the question changes — it does not reflect a vote
689
+ * made by the same user elsewhere.
690
+ */
678
691
  readonly currentAnswerId?: string;
692
+ /**
693
+ * The state to render **right now** for the audience. Render your scene off this.
694
+ *
695
+ * @remarks
696
+ * It is kept in sync with the viewer's delayed video stream: it switches to the
697
+ * next state exactly when that state becomes active, not before. To show a preview
698
+ * of what's coming (e.g. a "voting opens in N s" screen), read
699
+ * {@link currentStateWithDelay}'s `state` together with {@link secondsUntilStateChange}.
700
+ */
679
701
  readonly currentState: TState;
680
702
  /**
681
- * State delayed for end users, used to toggle scenes just like in OBS / host view.
703
+ * The **upcoming** state and the absolute time it becomes active (`enteredAt`).
704
+ *
705
+ * @remarks
706
+ * While a transition is pending, `state` is already the next state whereas
707
+ * {@link currentState} still reports what's on screen. Use this together with
708
+ * {@link secondsUntilStateChange} to render a countdown / preview of the next state.
682
709
  */
683
710
  readonly currentStateWithDelay: InteractiveWidgetCurrentStateWithDelay<TState>;
684
711
  readonly currentQuestion: CurrentQuestion<TAnswer> | null;
685
712
  readonly answers?: TAnswer[];
686
713
  readonly questionIndex?: number;
714
+ /**
715
+ * Whether the current user has submitted an answer for {@link currentQuestion}.
716
+ *
717
+ * @remarks
718
+ * This is **optimistic local state**, not a server-confirmed value. It flips to
719
+ * `true` the moment `submitAnswer` is called (before the backend responds). For
720
+ * quizzes it is reverted to `false` if the submission fails; for **polls** it is
721
+ * intentionally kept `true` on failure, so the user keeps seeing their vote as
722
+ * submitted for this session. It is scoped to this device/session and resets when
723
+ * the question changes.
724
+ */
687
725
  readonly isSubmitted?: boolean;
688
726
  readonly userRole: InteractiveWidgetRole;
689
727
  readonly scenes: TScene[];
@@ -694,6 +732,27 @@ export declare interface BaseInteractiveWidget<TAnswer extends BaseQuestionAnswe
694
732
  * disruption to existing consumers.
695
733
  */
696
734
  readonly isWaitingForStart: boolean;
735
+ /**
736
+ * Delay (in seconds) applied to the audience-facing
737
+ * state relative to the live state, so end users see widget transitions in sync
738
+ * with their delayed video stream.
739
+ */
740
+ readonly audienceDelayInSeconds: number;
741
+ /**
742
+ * Number of users currently active on the video this widget belongs to.
743
+ * Sourced live from the video document (`activeUsers.value`).
744
+ */
745
+ readonly activeUsers?: number;
746
+ /**
747
+ * Whole seconds until the {@link currentStateWithDelay} state becomes active for
748
+ * the audience; `0` when no transition is pending.
749
+ *
750
+ * @remarks
751
+ * Use this for countdown UIs instead of computing time yourself — it is already
752
+ * synced to server time. Reading it in render is safe (it updates at most once per
753
+ * second). Derive "is a transition pending?" as `secondsUntilStateChange > 0`.
754
+ */
755
+ readonly secondsUntilStateChange: number;
697
756
  answerQuestion(answerId: string): void;
698
757
  submitAnswer(request: Pick<SubmitAnswerRequest, 'answerOptionId' | 'answerText'>): Promise<void>;
699
758
  verifyJoinCode(joinCode: string, shouldJoinPlayer?: boolean): Promise<boolean>;
@@ -1515,7 +1574,12 @@ export declare enum CustomerId {
1515
1574
  MYSTICO = "MYSTICO",
1516
1575
  MORAVEC = "MORAVEC",
1517
1576
  JAN_TUNA = "JAN_TUNA",
1518
- PODNIKATELSKY_MINDSET = "PODNIKATELSKY_MINDSET"
1577
+ PODNIKATELSKY_MINDSET = "PODNIKATELSKY_MINDSET",
1578
+ PETR_HOFMAN = "PETR_HOFMAN",
1579
+ NCSLM = "NCSLM",
1580
+ DOUCKO_S_ROBINEM = "DOUCKO_S_ROBINEM",
1581
+ KVIZ_PLEASE = "KVIZ_PLEASE",
1582
+ TALKSHOW_KOTAK_LIVE = "TALKSHOW_KOTAK_LIVE"
1519
1583
  }
1520
1584
 
1521
1585
  /**
@@ -4879,7 +4943,7 @@ export declare interface PollWidget<TScene extends InteractiveWidgetScene = Inte
4879
4943
  readonly type: InteractiveWidgetType.POLL;
4880
4944
  }
4881
4945
 
4882
- export declare type PollWidgetState = InteractiveWidgetState.IDLE | InteractiveWidgetState.CURRENT_QUESTION | InteractiveWidgetState.LEADERBOARD | InteractiveWidgetState.RESET_GAME | InteractiveWidgetState.NEXT_STATE;
4946
+ export declare type PollWidgetState = InteractiveWidgetState.IDLE | InteractiveWidgetState.CURRENT_QUESTION | InteractiveWidgetState.RESOLVED_QUESTION | InteractiveWidgetState.RESET_GAME | InteractiveWidgetState.NEXT_STATE;
4883
4947
 
4884
4948
  /**
4885
4949
  * @public
@@ -5569,7 +5633,9 @@ export declare interface QuestionRepository {
5569
5633
  readonly selectedAnswerId: string | undefined;
5570
5634
  isSubmitted: boolean;
5571
5635
  isSubmitting: boolean;
5572
- setCurrentQuestion: (question: CurrentQuestion | null, role: InteractiveWidgetRole, secondsToAnswer: number, shouldEnterAtTimestampMs?: number, shouldAdjustEndTimestampMs?: boolean) => void;
5636
+ setCurrentQuestion: (question: CurrentQuestion | null, role: InteractiveWidgetRole,
5637
+ /** Time limit for the question. Omit/undefined means no timer (e.g. polls). */
5638
+ secondsToAnswer: number | undefined, shouldEnterAtTimestampMs?: number, shouldAdjustEndTimestampMs?: boolean) => void;
5573
5639
  selectAnswer: (answerId: string | undefined) => void;
5574
5640
  setShowCountdown: (showCountdown: boolean) => void;
5575
5641
  reset: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-react",
3
- "version": "10.2.1",
3
+ "version": "11.0.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -41,7 +41,7 @@
41
41
  "@material-ui/core": "^4.11.2",
42
42
  "@material-ui/icons": "^4.11.2",
43
43
  "@sentry/browser": "^6.1.0",
44
- "@tivio/common": "1.1.138",
44
+ "@tivio/common": "1.1.140",
45
45
  "dayjs": "^1.11.0",
46
46
  "es7-object-polyfill": "^1.0.1",
47
47
  "firebase": "8.10.1",