Initial commit

This commit is contained in:
2026-04-08 10:01:19 -07:00
commit 6657125a1e
68 changed files with 15886 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
{
"name": "@goodgrief/cue-engine",
"version": "0.1.0",
"type": "module",
"main": "./src/index.ts",
"exports": {
".": "./src/index.ts"
},
"dependencies": {
"@goodgrief/shared-types": "file:../shared-types"
}
}
+62
View File
@@ -0,0 +1,62 @@
import type { Cue } from "@goodgrief/shared-types";
export interface CueRuntimeState {
cueStack: Cue[];
currentCueId: string | null;
armedCueId: string | null;
previewCueId: string | null;
blackout: boolean;
safeSceneActive: boolean;
}
export const createCueRuntimeState = (cueStack: Cue[]): CueRuntimeState => ({
cueStack: [...cueStack].sort((left, right) => left.orderIndex - right.orderIndex),
currentCueId: null,
armedCueId: cueStack[0]?.id ?? null,
previewCueId: cueStack[0]?.id ?? null,
blackout: false,
safeSceneActive: false
});
export const armCue = (state: CueRuntimeState, cueId: string): CueRuntimeState => ({
...state,
armedCueId: cueId,
previewCueId: cueId
});
export const takeCue = (state: CueRuntimeState): CueRuntimeState => {
if (!state.armedCueId) {
return state;
}
const currentIndex = state.cueStack.findIndex((cue) => cue.id === state.armedCueId);
const nextCue = state.cueStack[currentIndex + 1] ?? null;
return {
...state,
currentCueId: state.armedCueId,
armedCueId: nextCue?.id ?? null,
previewCueId: nextCue?.id ?? null,
blackout: false,
safeSceneActive: false
};
};
export const triggerBlackout = (state: CueRuntimeState): CueRuntimeState => ({
...state,
blackout: true
});
export const triggerSafeScene = (state: CueRuntimeState, cueId: string): CueRuntimeState => ({
...state,
currentCueId: cueId,
previewCueId: cueId,
safeSceneActive: true,
blackout: false
});
export const skipToCue = (state: CueRuntimeState, cueId: string): CueRuntimeState => ({
...state,
armedCueId: cueId,
previewCueId: cueId
});
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"include": [
"src"
]
}