mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
refactor: limit runtimeState core exports to consumed seams
Only the cores exercised by tests remain exported (startCore, addTimeCore, updateCore, getExpectedTimesCore, loadGroupFlagAndEndCore). The rest stay parameterized but module private until a consumer needs them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVTnCfesGNGwPQJwJ9FwoD
This commit is contained in:
@@ -130,7 +130,7 @@ export function clearEventData() {
|
|||||||
/* clear data related to the current event, but leave in place data about the global run state
|
/* clear data related to the current event, but leave in place data about the global run state
|
||||||
* used when loading a new event but the playback is not interrupted
|
* used when loading a new event but the playback is not interrupted
|
||||||
*/
|
*/
|
||||||
export function clearEventDataCore(state: RuntimeState) {
|
function clearEventDataCore(state: RuntimeState) {
|
||||||
state.eventNow = null;
|
state.eventNow = null;
|
||||||
state.eventNext = null;
|
state.eventNext = null;
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ export function clearState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clear all necessary data when doing a full stop and the event is unloaded
|
// clear all necessary data when doing a full stop and the event is unloaded
|
||||||
export function clearStateCore(state: RuntimeState) {
|
function clearStateCore(state: RuntimeState) {
|
||||||
state.eventNow = null;
|
state.eventNow = null;
|
||||||
state.eventNext = null;
|
state.eventNext = null;
|
||||||
state.eventFlag = null;
|
state.eventFlag = null;
|
||||||
@@ -227,7 +227,7 @@ export function updateRundownData(rundownData: RundownData) {
|
|||||||
* Utility, allows updating data derived from the rundown
|
* Utility, allows updating data derived from the rundown
|
||||||
* @param playableRundown
|
* @param playableRundown
|
||||||
*/
|
*/
|
||||||
export function updateRundownDataCore(state: RuntimeState, rundownData: RundownData) {
|
function updateRundownDataCore(state: RuntimeState, rundownData: RundownData) {
|
||||||
// we keep this in private state since there is no UI use case for it
|
// we keep this in private state since there is no UI use case for it
|
||||||
state._rundown.totalDelay = rundownData.totalDelay;
|
state._rundown.totalDelay = rundownData.totalDelay;
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ export function load(
|
|||||||
/**
|
/**
|
||||||
* Loads a given event into state
|
* Loads a given event into state
|
||||||
*/
|
*/
|
||||||
export function loadCore(
|
function loadCore(
|
||||||
state: RuntimeState,
|
state: RuntimeState,
|
||||||
event: PlayableEvent,
|
event: PlayableEvent,
|
||||||
rundown: Rundown,
|
rundown: Rundown,
|
||||||
@@ -317,12 +317,7 @@ export function loadNow(rundown: Rundown, metadata: RundownMetadata, eventIndex?
|
|||||||
* Loads current event and its public counterpart
|
* Loads current event and its public counterpart
|
||||||
* @param eventIndex the index to load, defaults to the currently selected index
|
* @param eventIndex the index to load, defaults to the currently selected index
|
||||||
*/
|
*/
|
||||||
export function loadNowCore(
|
function loadNowCore(state: RuntimeState, rundown: Rundown, metadata: RundownMetadata, eventIndex?: MaybeNumber) {
|
||||||
state: RuntimeState,
|
|
||||||
rundown: Rundown,
|
|
||||||
metadata: RundownMetadata,
|
|
||||||
eventIndex?: MaybeNumber,
|
|
||||||
) {
|
|
||||||
const index = eventIndex === undefined ? state.rundown.selectedEventIndex : eventIndex;
|
const index = eventIndex === undefined ? state.rundown.selectedEventIndex : eventIndex;
|
||||||
if (index === null) {
|
if (index === null) {
|
||||||
// reset the state to indicate there is no selection
|
// reset the state to indicate there is no selection
|
||||||
@@ -349,12 +344,7 @@ export function loadNext(rundown: Rundown, metadata: RundownMetadata, eventIndex
|
|||||||
* Loads the next event and its public counterpart
|
* Loads the next event and its public counterpart
|
||||||
* @param eventIndex the index to load from, defaults to the currently selected index
|
* @param eventIndex the index to load from, defaults to the currently selected index
|
||||||
*/
|
*/
|
||||||
export function loadNextCore(
|
function loadNextCore(state: RuntimeState, rundown: Rundown, metadata: RundownMetadata, eventIndex?: MaybeNumber) {
|
||||||
state: RuntimeState,
|
|
||||||
rundown: Rundown,
|
|
||||||
metadata: RundownMetadata,
|
|
||||||
eventIndex?: MaybeNumber,
|
|
||||||
) {
|
|
||||||
const index = eventIndex === undefined ? state.rundown.selectedEventIndex : eventIndex;
|
const index = eventIndex === undefined ? state.rundown.selectedEventIndex : eventIndex;
|
||||||
if (index === null) {
|
if (index === null) {
|
||||||
// reset the state to indicate there is no future event
|
// reset the state to indicate there is no future event
|
||||||
@@ -383,7 +373,7 @@ export function resume(restorePoint: RestorePoint, event: PlayableEvent, rundown
|
|||||||
/**
|
/**
|
||||||
* Resume from restore point
|
* Resume from restore point
|
||||||
*/
|
*/
|
||||||
export function resumeCore(
|
function resumeCore(
|
||||||
state: RuntimeState,
|
state: RuntimeState,
|
||||||
restorePoint: RestorePoint,
|
restorePoint: RestorePoint,
|
||||||
event: PlayableEvent,
|
event: PlayableEvent,
|
||||||
@@ -401,7 +391,7 @@ export function updateLoaded(event?: PlayableEvent): string | undefined {
|
|||||||
* We only pass an event if we are hot reloading
|
* We only pass an event if we are hot reloading
|
||||||
* @param {PlayableEvent} event only passed if we are changing the data if a playing timer
|
* @param {PlayableEvent} event only passed if we are changing the data if a playing timer
|
||||||
*/
|
*/
|
||||||
export function updateLoadedCore(state: RuntimeState, event?: PlayableEvent): string | undefined {
|
function updateLoadedCore(state: RuntimeState, event?: PlayableEvent): string | undefined {
|
||||||
// if there is no event loaded, nothing to do
|
// if there is no event loaded, nothing to do
|
||||||
if (state.eventNow === null) {
|
if (state.eventNow === null) {
|
||||||
return;
|
return;
|
||||||
@@ -458,7 +448,7 @@ export function updateAll(rundown: Rundown, metadata: RundownMetadata) {
|
|||||||
/**
|
/**
|
||||||
* Used in situations when we want to hot-reload all events without interrupting timer
|
* Used in situations when we want to hot-reload all events without interrupting timer
|
||||||
*/
|
*/
|
||||||
export function updateAllCore(state: RuntimeState, rundown: Rundown, metadata: RundownMetadata) {
|
function updateAllCore(state: RuntimeState, rundown: Rundown, metadata: RundownMetadata) {
|
||||||
// event now might have moved so we find the event now id and recalculate the the index again
|
// event now might have moved so we find the event now id and recalculate the the index again
|
||||||
const eventNowIndex = metadata.timedEventOrder.findIndex((id) => id === state.eventNow?.id);
|
const eventNowIndex = metadata.timedEventOrder.findIndex((id) => id === state.eventNow?.id);
|
||||||
|
|
||||||
@@ -536,7 +526,7 @@ export function pause(): boolean {
|
|||||||
return pauseCore(runtimeState);
|
return pauseCore(runtimeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pauseCore(state: RuntimeState): boolean {
|
function pauseCore(state: RuntimeState): boolean {
|
||||||
if (state.timer.playback !== Playback.Play) {
|
if (state.timer.playback !== Playback.Play) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -551,7 +541,7 @@ export function stop(): boolean {
|
|||||||
return stopCore(runtimeState);
|
return stopCore(runtimeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopCore(state: RuntimeState): boolean {
|
function stopCore(state: RuntimeState): boolean {
|
||||||
if (state.timer.playback === Playback.Stop) {
|
if (state.timer.playback === Playback.Stop) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -716,7 +706,7 @@ export function roll(
|
|||||||
return rollCore(runtimeState, rundown, metadata, offset);
|
return rollCore(runtimeState, rundown, metadata, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rollCore(
|
function rollCore(
|
||||||
state: RuntimeState,
|
state: RuntimeState,
|
||||||
rundown: Rundown,
|
rundown: Rundown,
|
||||||
metadata: RundownMetadata,
|
metadata: RundownMetadata,
|
||||||
@@ -1037,7 +1027,7 @@ export function setOffsetMode(mode: OffsetMode) {
|
|||||||
setOffsetModeCore(runtimeState, mode);
|
setOffsetModeCore(runtimeState, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setOffsetModeCore(state: RuntimeState, mode: OffsetMode) {
|
function setOffsetModeCore(state: RuntimeState, mode: OffsetMode) {
|
||||||
state.offset.mode = mode;
|
state.offset.mode = mode;
|
||||||
if (isPlaybackActive(state.timer.playback)) getExpectedTimesCore(state);
|
if (isPlaybackActive(state.timer.playback)) getExpectedTimesCore(state);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user