mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
chore: rename blocks to groups
This commit is contained in:
committed by
Carlos Valente
parent
486d89ecf4
commit
e5d2457717
@@ -5,7 +5,7 @@ export type EntryId = string;
|
||||
export enum SupportedEntry {
|
||||
Event = 'event',
|
||||
Delay = 'delay',
|
||||
Block = 'block',
|
||||
Group = 'group',
|
||||
Milestone = 'milestone',
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ export type OntimeMilestone = OntimeBaseEvent & {
|
||||
revision: number;
|
||||
};
|
||||
|
||||
export type OntimeBlock = OntimeBaseEvent & {
|
||||
type: SupportedEntry.Block;
|
||||
export type OntimeGroup = OntimeBaseEvent & {
|
||||
type: SupportedEntry.Group;
|
||||
title: string;
|
||||
note: string;
|
||||
entries: EntryId[];
|
||||
@@ -78,7 +78,7 @@ export type OntimeEvent = OntimeBaseEvent & {
|
||||
|
||||
export type PlayableEvent = OntimeEvent & { skip: false };
|
||||
export type TimeField = 'timeStart' | 'timeEnd' | 'duration';
|
||||
export type OntimeEntry = OntimeDelay | OntimeBlock | OntimeEvent | OntimeMilestone;
|
||||
export type OntimeEntry = OntimeDelay | OntimeGroup | OntimeEvent | OntimeMilestone;
|
||||
|
||||
// we need to create a manual union type since keys cannot be used in type unions
|
||||
export type OntimeEntryCommonKeys = keyof OntimeEvent | keyof OntimeDelay | keyof OntimeBlock | keyof OntimeMilestone;
|
||||
export type OntimeEntryCommonKeys = keyof OntimeEvent | keyof OntimeDelay | keyof OntimeGroup | keyof OntimeMilestone;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type { MaybeNumber } from '../../utils/utils.type.js';
|
||||
import type { EntryId } from '../core/OntimeEntry.js';
|
||||
|
||||
export type CurrentBlockState = {
|
||||
export type CurrentGroupState = {
|
||||
id: EntryId;
|
||||
startedAt: MaybeNumber;
|
||||
expectedEnd: MaybeNumber;
|
||||
@@ -38,8 +38,8 @@ export const runtimeStorePlaceholder: Readonly<RuntimeStore> = {
|
||||
expectedEnd: null, // changes with runtime, based on offset, overflows over dayInMs
|
||||
offsetMode: OffsetMode.Absolute,
|
||||
},
|
||||
blockNow: null,
|
||||
blockNext: null,
|
||||
groupNow: null,
|
||||
groupNext: null,
|
||||
nextFlag: null,
|
||||
eventNow: null,
|
||||
eventNext: null,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { MaybeString } from '../../utils/utils.type.js';
|
||||
import type { OntimeEvent } from '../core/OntimeEntry.js';
|
||||
import type { SimpleTimerState } from './AuxTimer.type.js';
|
||||
import type { CurrentBlockState, EntryMetaData } from './CurrentBlockState.type.js';
|
||||
import type { CurrentGroupState, EntryMetaData } from './CurrentGroupState.type.js';
|
||||
import type { MessageState } from './MessageControl.type.js';
|
||||
import type { Runtime } from './Runtime.type.js';
|
||||
import type { TimerState } from './TimerState.type.js';
|
||||
@@ -19,8 +19,8 @@ export type RuntimeStore = {
|
||||
eventNow: OntimeEvent | null;
|
||||
eventNext: OntimeEvent | null;
|
||||
|
||||
blockNow: CurrentBlockState | null;
|
||||
blockNext: MaybeString;
|
||||
groupNow: CurrentGroupState | null;
|
||||
groupNext: MaybeString;
|
||||
nextFlag: EntryMetaData | null;
|
||||
|
||||
// extra timers
|
||||
|
||||
@@ -7,7 +7,7 @@ export {
|
||||
type EntryId,
|
||||
type OntimeBaseEvent,
|
||||
type OntimeDelay,
|
||||
type OntimeBlock,
|
||||
type OntimeGroup,
|
||||
type OntimeEntryCommonKeys,
|
||||
type OntimeEntry,
|
||||
type OntimeMilestone,
|
||||
@@ -101,7 +101,7 @@ export { OffsetMode } from './definitions/runtime/Runtime.type.js';
|
||||
export type { RuntimeStore } from './definitions/runtime/RuntimeStore.type.js';
|
||||
export { runtimeStorePlaceholder } from './definitions/runtime/RuntimeStore.js';
|
||||
export { type TimerState, TimerPhase } from './definitions/runtime/TimerState.type.js';
|
||||
export type { CurrentBlockState, UpcomingEntry, EntryMetaData } from './definitions/runtime/CurrentBlockState.type.js';
|
||||
export type { CurrentGroupState, UpcomingEntry, EntryMetaData } from './definitions/runtime/CurrentGroupState.type.js';
|
||||
|
||||
// ---> Extra Timer
|
||||
export { type SimpleTimerState, SimplePlayback, SimpleDirection } from './definitions/runtime/AuxTimer.type.js';
|
||||
@@ -111,7 +111,7 @@ export type { Client, ClientList, ClientType } from './definitions/Clients.type.
|
||||
|
||||
// TYPE UTILITIES
|
||||
export {
|
||||
isOntimeBlock,
|
||||
isOntimeGroup,
|
||||
isOntimeDelay,
|
||||
isOntimeEvent,
|
||||
isOntimeMilestone,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { AutomationOutput, HTTPOutput, OntimeAction, OSCOutput } from '../definitions/core/Automation.type.js';
|
||||
import type {
|
||||
OntimeBlock,
|
||||
OntimeDelay,
|
||||
OntimeEntry,
|
||||
OntimeEvent,
|
||||
OntimeGroup,
|
||||
OntimeMilestone,
|
||||
PlayableEvent,
|
||||
} from '../definitions/core/OntimeEntry.js';
|
||||
@@ -24,8 +24,8 @@ export function isOntimeDelay(event: MaybeEvent): event is OntimeDelay {
|
||||
return event?.type === SupportedEntry.Delay;
|
||||
}
|
||||
|
||||
export function isOntimeBlock(event: MaybeEvent): event is OntimeBlock {
|
||||
return event?.type === SupportedEntry.Block;
|
||||
export function isOntimeGroup(event: MaybeEvent): event is OntimeGroup {
|
||||
return event?.type === SupportedEntry.Group;
|
||||
}
|
||||
|
||||
export function isOntimeMilestone(event: MaybeEvent): event is OntimeMilestone {
|
||||
|
||||
@@ -16,7 +16,7 @@ export {
|
||||
getLastEventNormal,
|
||||
getLastNormal,
|
||||
getNext,
|
||||
getNextBlockNormal,
|
||||
getNextGroupNormal,
|
||||
getNextEvent,
|
||||
getNextEventNormal,
|
||||
getNextNormal,
|
||||
@@ -24,8 +24,8 @@ export {
|
||||
getPreviousEvent,
|
||||
getPreviousEventNormal,
|
||||
getPreviousNormal,
|
||||
getPreviousBlock,
|
||||
getPreviousBlockNormal,
|
||||
getPreviousGroup,
|
||||
getPreviousGroupNormal,
|
||||
swapEventData,
|
||||
} from './src/rundown-utils/rundownUtils.js';
|
||||
export { getFirstRundown } from './src/rundown/rundown.utils.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { OntimeBlock, OntimeDelay, OntimeEntry, OntimeEvent } from 'ontime-types';
|
||||
import type { OntimeDelay, OntimeEntry, OntimeEvent, OntimeGroup } from 'ontime-types';
|
||||
import { SupportedEntry } from 'ontime-types';
|
||||
|
||||
import {
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
getNext,
|
||||
getNextEvent,
|
||||
getPrevious,
|
||||
getPreviousBlock,
|
||||
getPreviousEvent,
|
||||
getPreviousGroup,
|
||||
swapEventData,
|
||||
} from './rundownUtils';
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('getNext()', () => {
|
||||
entries: {
|
||||
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
'3': { id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||
},
|
||||
order: ['1', '2', '3', '4'],
|
||||
@@ -76,7 +76,7 @@ describe('getNextEvent()', () => {
|
||||
const testRundown = [
|
||||
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
{ id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
{ id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
{ id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||
];
|
||||
|
||||
@@ -89,7 +89,7 @@ describe('getNextEvent()', () => {
|
||||
const testRundown = [
|
||||
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
{ id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
{ id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
];
|
||||
|
||||
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
||||
@@ -119,7 +119,7 @@ describe('getPrevious()', () => {
|
||||
entries: {
|
||||
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
'3': { id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||
},
|
||||
order: ['1', '2', '3', '4'],
|
||||
@@ -166,7 +166,7 @@ describe('getPreviousEvent()', () => {
|
||||
entries: {
|
||||
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
'3': { id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||
},
|
||||
order: ['1', '2', '3', '4'],
|
||||
@@ -181,7 +181,7 @@ describe('getPreviousEvent()', () => {
|
||||
const testRundown = {
|
||||
entries: {
|
||||
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||
'3': { id: '3', type: SupportedEntry.Group } as OntimeGroup,
|
||||
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||
},
|
||||
order: ['2', '3', '4'],
|
||||
@@ -247,7 +247,7 @@ describe('getLastEvent', () => {
|
||||
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
{ id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||
{ id: '4', type: SupportedEntry.Block } as OntimeBlock,
|
||||
{ id: '4', type: SupportedEntry.Group } as OntimeGroup,
|
||||
];
|
||||
|
||||
const { lastEvent } = getLastEvent(testRundown);
|
||||
@@ -263,7 +263,7 @@ describe('getLastEvent', () => {
|
||||
describe('getLastNormal', () => {
|
||||
it('returns the last entry', () => {
|
||||
const entries = {
|
||||
4: { id: '4', type: SupportedEntry.Block } as OntimeBlock,
|
||||
4: { id: '4', type: SupportedEntry.Group } as OntimeGroup,
|
||||
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
3: { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||
2: { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
@@ -300,16 +300,16 @@ describe('getLastEvent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPreviousBlock()', () => {
|
||||
describe('getPreviousGroup()', () => {
|
||||
const testRundown = {
|
||||
entries: {
|
||||
a: { id: 'a', type: SupportedEntry.Event } as OntimeEvent,
|
||||
b: { id: 'b', type: SupportedEntry.Event } as OntimeEvent,
|
||||
c: { id: 'c', type: SupportedEntry.Event } as OntimeEvent,
|
||||
d: { id: 'd', type: SupportedEntry.Delay } as OntimeDelay,
|
||||
e: { id: 'e', type: SupportedEntry.Block } as OntimeBlock,
|
||||
e: { id: 'e', type: SupportedEntry.Group } as OntimeGroup,
|
||||
f: { id: 'f', type: SupportedEntry.Event } as OntimeEvent,
|
||||
g: { id: 'g', type: SupportedEntry.Block } as OntimeBlock,
|
||||
g: { id: 'g', type: SupportedEntry.Group } as OntimeGroup,
|
||||
h: { id: 'h', type: SupportedEntry.Event } as OntimeEvent,
|
||||
},
|
||||
order: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
|
||||
@@ -318,37 +318,37 @@ describe('getLastEvent', () => {
|
||||
test.each([
|
||||
['h', 'g'],
|
||||
['f', 'e'],
|
||||
])('returns the relevant block', (id, expected) => {
|
||||
const block = getPreviousBlock(testRundown, id);
|
||||
expect(block?.id).toBe(expected);
|
||||
])('returns the relevant group', (id, expected) => {
|
||||
const group = getPreviousGroup(testRundown, id);
|
||||
expect(group?.id).toBe(expected);
|
||||
});
|
||||
|
||||
it('returns null if there is no parent block relevant block', () => {
|
||||
const block = getPreviousBlock(testRundown, 'a');
|
||||
expect(block).toBe(null);
|
||||
it('returns null if there is no parent group relevant group', () => {
|
||||
const group = getPreviousGroup(testRundown, 'a');
|
||||
expect(group).toBe(null);
|
||||
});
|
||||
|
||||
it('also works on index 0', () => {
|
||||
testRundown.order.unshift('0');
|
||||
// @ts-expect-error -- we are adding an event to the rundown
|
||||
testRundown.entries['0'] = { id: '0', type: SupportedEntry.Block } as OntimeBlock;
|
||||
const block = getPreviousBlock(testRundown, 'a');
|
||||
expect(block?.id).toBe('0');
|
||||
testRundown.entries['0'] = { id: '0', type: SupportedEntry.Group } as OntimeGroup;
|
||||
const group = getPreviousGroup(testRundown, 'a');
|
||||
expect(group?.id).toBe('0');
|
||||
});
|
||||
|
||||
it('returns the parent block if nested event', () => {
|
||||
it('returns the parent group if nested event', () => {
|
||||
const testRundown = {
|
||||
entries: {
|
||||
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||
block: { id: 'block', type: SupportedEntry.Block, entries: ['21', '22', '23'] } as OntimeBlock,
|
||||
21: { id: '21', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||
22: { id: '22', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||
23: { id: '23', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||
group: { id: 'group', type: SupportedEntry.Group, entries: ['21', '22', '23'] } as OntimeGroup,
|
||||
21: { id: '21', type: SupportedEntry.Event, parent: 'group' } as OntimeEvent,
|
||||
22: { id: '22', type: SupportedEntry.Event, parent: 'group' } as OntimeEvent,
|
||||
23: { id: '23', type: SupportedEntry.Event, parent: 'group' } as OntimeEvent,
|
||||
},
|
||||
order: ['1', 'block'],
|
||||
order: ['1', 'group'],
|
||||
};
|
||||
const block = getPreviousBlock(testRundown, '21');
|
||||
expect(block?.id).toBe('block');
|
||||
const group = getPreviousGroup(testRundown, '21');
|
||||
expect(group?.id).toBe('group');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type {
|
||||
EntryId,
|
||||
OntimeBlock,
|
||||
OntimeEntry,
|
||||
OntimeEvent,
|
||||
OntimeGroup,
|
||||
PlayableEvent,
|
||||
Rundown,
|
||||
RundownEntries,
|
||||
} from 'ontime-types';
|
||||
import { isOntimeBlock, isOntimeEvent, isPlayableEvent } from 'ontime-types';
|
||||
import { isOntimeEvent, isOntimeGroup, isPlayableEvent } from 'ontime-types';
|
||||
|
||||
type IndexAndEntry = { entry: OntimeEntry | null; index: number | null };
|
||||
|
||||
@@ -313,9 +313,9 @@ export function getEventWithId(rundown: OntimeEntry[], id: string): OntimeEntry
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets relevant block element for a given ID
|
||||
* Gets relevant group element for a given ID
|
||||
*/
|
||||
export function getPreviousBlockNormal(rundown: RundownEntries, order: string[], currentId: string): IndexAndEntry {
|
||||
export function getPreviousGroupNormal(rundown: RundownEntries, order: string[], currentId: string): IndexAndEntry {
|
||||
let foundCurrentEvent = false;
|
||||
// Iterate backwards through the rundown to find the current event
|
||||
for (let index = order.length - 1; index >= 0; index--) {
|
||||
@@ -325,20 +325,20 @@ export function getPreviousBlockNormal(rundown: RundownEntries, order: string[],
|
||||
foundCurrentEvent = true;
|
||||
continue;
|
||||
}
|
||||
// the first block before the current event is the relevant one
|
||||
// the first group before the current event is the relevant one
|
||||
const entry = rundown[id];
|
||||
if (foundCurrentEvent && isOntimeBlock(entry)) {
|
||||
if (foundCurrentEvent && isOntimeGroup(entry)) {
|
||||
return { entry, index };
|
||||
}
|
||||
}
|
||||
// no blocks exist before current event
|
||||
// no groups exist before current event
|
||||
return { entry: null, index: null };
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next block element for a given ID
|
||||
* Gets next group element for a given ID
|
||||
*/
|
||||
export function getNextBlockNormal(rundown: RundownEntries, order: string[], currentId: string): IndexAndEntry {
|
||||
export function getNextGroupNormal(rundown: RundownEntries, order: string[], currentId: string): IndexAndEntry {
|
||||
let foundCurrentEvent = false;
|
||||
// Iterate backwards through the rundown to find the current event
|
||||
for (let index = 0; index < order.length; index++) {
|
||||
@@ -348,25 +348,25 @@ export function getNextBlockNormal(rundown: RundownEntries, order: string[], cur
|
||||
foundCurrentEvent = true;
|
||||
continue;
|
||||
}
|
||||
// the first block before the current event is the relevant one
|
||||
// the first group before the current event is the relevant one
|
||||
const entry = rundown[id];
|
||||
if (foundCurrentEvent && isOntimeBlock(entry)) {
|
||||
if (foundCurrentEvent && isOntimeGroup(entry)) {
|
||||
return { entry, index };
|
||||
}
|
||||
}
|
||||
// no blocks exist before current event
|
||||
// no groups exist before current event
|
||||
return { entry: null, index: null };
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets relevant block element for a given ID
|
||||
* Gets relevant group element for a given ID
|
||||
*/
|
||||
export function getPreviousBlock(rundown: Pick<Rundown, 'entries' | 'order'>, currentId: EntryId): OntimeBlock | null {
|
||||
export function getPreviousGroup(rundown: Pick<Rundown, 'entries' | 'order'>, currentId: EntryId): OntimeGroup | null {
|
||||
const currentEvent = rundown.entries[currentId];
|
||||
|
||||
// check if event is inside a block
|
||||
// check if event is inside a group
|
||||
if (isOntimeEvent(currentEvent) && currentEvent.parent) {
|
||||
return rundown.entries[currentEvent.parent] as OntimeBlock;
|
||||
return rundown.entries[currentEvent.parent] as OntimeGroup;
|
||||
}
|
||||
|
||||
let foundCurrentEvent = false;
|
||||
@@ -379,11 +379,11 @@ export function getPreviousBlock(rundown: Pick<Rundown, 'entries' | 'order'>, cu
|
||||
foundCurrentEvent = true;
|
||||
continue;
|
||||
}
|
||||
// the first block before the current event is the relevant one
|
||||
if (foundCurrentEvent && isOntimeBlock(entry)) {
|
||||
// the first group before the current event is the relevant one
|
||||
if (foundCurrentEvent && isOntimeGroup(entry)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
// no blocks exist before null event
|
||||
// no groups exist before null event
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user