Skip to content

Broadcast cast · Modules

8 modules · 18 exports · 1 repository · 0 e2e tests · 9 routes

Who imports who · hover a node
Depends onBroadcast cast modulesUsed byEliminationLayouttourna…BroadcastSnapshot.serverTournament.servertourna…ProducerbroadcastSetProgressbroadcastInkColorbroadcastBracketFocus6 exportsCastChannel3 exportsCastSnapshot.server1 ex…CastStreamDeck2 exportsDesignScenario2 exportsGameResult1 exportGroupFocus2 exportsTeamSpotlight1 exportRoutes3 filesLoaders1 fileActions2 filesOther4 filesComponents1 file

BracketFocus

app/features/broadcast-cast/core/BracketFocus.ts

No overview comment at the top of the file.

Imports
EliminationLayout
Used by
1 route3 modules

Types

interface

FeaturedMatch

:29

The featured match as far as a view shows it.

export interface FeaturedMatch {
	id: number;
	progress: Pick<MatchProgress, "resultCount" | "scores" | "isOver">;
}

Functions & values

function

layout

:49

Lays out an elimination bracket for the bracket scene: of double elimination the sides in focus, compactified to the rounds still being played unless the whole bracket is in focus. The featured match is shown as far as the view shows it, so a result not on air yet doesn't spoil it, neither does its winner advancing in the bracket.

export function layout({
	idx,
	name,
	type,
	data,
	groupId,
	focus,
	featured,
	teamById,
}: {
	idx: number;
	name: string;
	type: "single_elimination" | "double_elimination";
	data: BracketData;
	/** Group shown of a bracket split into groups. */
	groupId: number | undefined;
	focus: BroadcastBracketFocus;
	featured: FeaturedMatch | null;
	teamById: (id: number) => BroadcastBracketTeam | null;
}): BroadcastEliminationBracket
Unit tests (7)
function

resolveBracketIdx

:108

Index of the bracket the bracket scene shows: the producer's pick, the featured match's bracket or else the last one, of the brackets it can show. null when there is none.

export function resolveBracketIdx({
	pickedIdx,
	featuredMatchBracketIdx,
	showableIdxs,
}: {
	pickedIdx: number | null;
	featuredMatchBracketIdx: number | null;
	/** See {@link showableBracketIdxs}. */
	showableIdxs: number[];
})
Unit tests (2)
function

showableBracketIdxs

:126

Brackets the bracket scene can show: the elimination, round robin and Swiss ones that have started.

export function showableBracketIdxs(
	tournament: Pick<Tournament, "bracketsMeta">,
)
function

toBroadcastMatch

:221

The match as the bracket scene shows it, see {@link asOnAir} for the featured match's.

export function toBroadcastMatch({
	match,
	isFeatured,
	isFed,
	teamById,
}: {
	match: MatchData;
	isFeatured: boolean;
	isFed: boolean;
	teamById: (id: number) => BroadcastBracketTeam | null;
}): BroadcastBracketMatch
function

asOnAir

:259

The bracket with the featured match at the view's progress. While the view has its set going, its teams are taken out of the elimination matches they advanced to.

export function asOnAir(
	data: BracketData,
	featured: FeaturedMatch | null,
): BracketData

CastChannel

app/features/broadcast-cast/core/CastChannel.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 loader2 actions2 routes1 module2 other

Functions & values

function

list

:6

The tournament's broadcast channels, one per cast account.

export function list(castAccounts: CastAccount[] | null): BroadcastChannel[]
function

findBySlug

:16

The broadcast channel the URL key points to, undefined when the tournament has no such cast account.

export function findBySlug(
	castAccounts: CastAccount[] | null,
	channelSlug: string,
): BroadcastChannel | undefined
Unit tests (1)
function

featuredMatchId

:25

Id of the match the channel features: the one being cast on it, or else the first one locked to be cast on it next.

export function featuredMatchId({
	castedMatchesInfo,
	channel,
}: {
	castedMatchesInfo: CastedMatchesInfo | null;
	channel: Pick<BroadcastChannel, "platform" | "account">;
}): number | null
Unit tests (1)

CastSnapshot

serverapp/features/broadcast-cast/core/CastSnapshot.server.ts

No overview comment at the top of the file.

Imports
BroadcastSnapshot.serverTournament.serverBracketFocusCastChannelGroupFocusTeamSpotlight
Used by
1 other

Functions & values

function

build

:46

Builds the state the channel's cast overlays render from fresh (uncached) data, along with the event channels whose events change it. null when the tournament has no cast channel by the slug.

export async function build({
	tournamentId,
	slug,
}: {
	tournamentId: number;
	slug: string;
}): Promise<BroadcastSnapshot.Built<CastBroadcastState> | null>

CastStreamDeck

app/features/broadcast-cast/core/CastStreamDeck.ts

No overview comment at the top of the file.

Imports
Producer
Used by
1 route1 other

Types

type

Key

no JSDoc:27
export type Key =
	| {
			type: "scene";
			scene: CastScene;
			/** The scene on air. */
			isLive: boolean;
			/** The scene of the queue item the dashboard edits, the one pressing a scene key changes. */
			isSelected: boolean;
			isDisabled: boolean;
	  }
	| {
			type: "queueItem";
			/** Of the queue item edited, 0 for next. */
			position: number;
			/** Items in the queue. */
			count: number;
			scene: CastScene;
			/** The item pressing the key edits instead, the first again after the last. `null` while next is the only item: pressing it queues a new one. */
			nextItemId: number | null;
			isDisabled: false;
	  }
	| {
			type: "advance";
			/** The queue item edited. */
			itemId: number;
			/** How it goes on air besides a Take. */
			advance: BroadcastAdvance;
			/** Which game event `game` waits for, `null` for the other advances. */
			gameCue: "start" | "end" | null;
			/** What pressing the key sets it to, the next of the advances it can have. */
			nextAdvance: BroadcastAdvance;
			/** Only a Take can put it on air. */
			isDisabled: boolean;
	  }
	| {
			type: "take";
			isDisabled: boolean;
			/** Time until next goes on air by itself, `null` when it doesn't by a timer. */
			remainingMs: number | null;
			/** Next goes on air as the scanner sees this, `null` when it doesn't wait for a game. */
			gameCue: "start" | "end" | null;
			/** Next goes on air by itself in a moment. */
			isImminent: boolean;
	  };

Functions & values

function

keys

:80

What each key of a 15 key Stream Deck shows, from the top left row by row ({@link StreamDeck.COLUMNS} per row). A scene key sets the scene of selected (the queue item the dashboard edits, as the number keys do). The queue item key moves the editing on to the next item in the queue (queues a new one while next is the only item), the advance key cycles how the item edited goes on air (on a Take, by a timer, at a game start or end) through the ones it can have there, and Take does what the dashboard's button does. Keys that can't do anything right now are disabled, e.g. the match scenes while no match is cast.

export function keys({
	state,
	selected,
	now,
}: {
	state: CastBroadcastState;
	selected: CastProducerState;
	/** Server time, `null` before the clock is synced. */
	now: number | null;
}): Key[]
Unit tests (9)

DesignScenario

app/features/broadcast-cast/core/DesignScenario.ts

No overview comment at the top of the file.

Imports
SetProgress
Used by
1 route

Types

type

Scenario

:35

The designer's mock scenario, see broadcastDesignSearchParams.

export type Scenario = Omit<
	SearchParamsValues<typeof broadcastDesignSearchParams.shape>,
	"footage"
>;

Functions & values

function

build

:449

A broadcast's whole state made up for the designer: the scene on air in the scenario's situation, with mock teams, players, casters, brackets and other matches.

export function build({
	scenario,
	tournament: realTournament,
	settings,
	takenAt,
}: {
	scenario: Scenario;
	/** The real tournament, the In The Zone logo standing in for its own if it has none (an empty `logoUrl`). */
	tournament: CastBroadcastState["tournament"];
	settings: CastBroadcastSettings;
	/** When the scene went on air, what starting soon counts down from. */
	takenAt: number;
}): CastBroadcastState
Unit tests (15)

GameResult

app/features/broadcast-cast/core/GameResult.ts

No overview comment at the top of the file.

Imports
InkColor
Used by
1 component

Functions & values

function

resolve

:34

The game the results scene shows in the view: the featured match's last game the scanner read (scannedGame), whichever of the set's games it was, else the last one reported with the teams' rosters. A scanned game is the set's game with its map and mode, the one played last when several have them. Its teams are put in bracket order by the game's ink colors (the pair's first color going to the team the producer gave it, see BroadcastInk.isFlipped), else by the names read matching the rosters. Names not read are filled in from the roster players no read name matched. Its winner is the scanner's, from a results screen or the counter, else the reported one of the set's game it was. null when the match has no game to show.

export function resolve({
	match,
	view,
	scannedGame,
	ink,
}: {
	match: BroadcastMatch;
	view: BroadcastView;
	scannedGame: BroadcastStoredState["scannedGame"];
	ink: BroadcastStoredState["ink"];
}): BroadcastGameResult | null
Unit tests (14)

GroupFocus

app/features/broadcast-cast/core/GroupFocus.ts

No overview comment at the top of the file.

Imports
BracketFocus
Used by
1 module

Functions & values

function

roundRobin

:41

Lays out a round robin group for the bracket scene: its standings and rounds. A big group's are cut to the standings around the featured match's teams and the rounds around the one being played.

export function roundRobin(args: GroupArgs): BroadcastRoundRobinBracket
Unit tests (5)
function

swiss

:75

Lays out a Swiss group for the bracket scene: its standings, of a big group the ones around the featured match's teams, and the round being played with its matches pooled by the record their teams went into it with.

export function swiss(args: GroupArgs): BroadcastSwissBracket
Unit tests (3)
Unit tests not about one export (1)

Not shown, only used by tests: windowsAround

TeamSpotlight

app/features/broadcast-cast/core/TeamSpotlight.ts

No overview comment at the top of the file.

Imports
BracketFocus
Used by
1 module

Functions & values

function

build

:28

The team's tournament so far for the team scene: its sets in the order it played them up to the one being played (or the next one once its opponent or round is known), its record and how it did per mode. The featured match is shown as far as the view shows it, so a result not on air yet doesn't spoil it, neither does its winner advancing.

export function build({
	teamId,
	brackets,
	games,
	featured,
	teamById,
	roundLabelOf,
}: {
	teamId: number;
	/** The tournament's started brackets in the order they were played. */
	brackets: Array<{ data: BracketData }>;
	/** Reported games of the team's sets, in playing order. */
	games: GameResult[];
	featured: BracketFocus.FeaturedMatch | null;
	teamById: (id: number) => BroadcastBracketTeam | null;
	roundLabelOf: (matchId: number) => string;
}): Pick<BroadcastTeamSpotlight, "sets" | "record" | "modes">
Unit tests (5)