Open janecakemaster opened 1 month ago
Hi Jane nice to meet you! I'm traveling rn but I will def try to look into this shortly. Thanks for filing and say hi to the team for me!
@janecakemaster could I get you to paste the definition of EventsRecordToMartok
as well as any notable or unusual fields that might be in SketchyGame
? Even better if you can get a reduced repro that can be dropped into this thread in its entirety.
Once I know what's in EventsRecordToMartok
I should be able to dig in and see what's going on.
/**
* @ignore
* Convert backend update types to Martok compatible types
*/
export type EventsRecordToMartok<
T extends FaceoffRouteRecord<any, any, any, any>,
> = {
[K in keyof T]: {
type: K;
data: T[K]['inputType'] extends undefined
? object
: NonNullable<T[K]['inputType']>;
};
}[keyof T];
/**
* @ignore
*/
import { SketchyGame } from '..';
/**
* @ignore
*/
import { EventsRecordToMartok } from '../../../sdk/GamesTypeFactory';
import { StrokeData } from './GameState';
export type DrawingDataEvent = {
drawData: StrokeData;
/** @precision int */
drawRoundIndex: number;
};
export type ReplaceDrawingEvent = {
drawData: StrokeData[];
/** @precision int */
drawRoundIndex: number;
};
export type SpeechTextEvent = {
speechText?: string;
speechData?: string[] | null;
/** @precision int */
drawRoundIndex: number;
};
export type UndoStrokeEvent = {
strokeId: string;
/** @precision int */
drawRoundIndex: number;
};
/**
* @expand
*/
export type SketchyEvents = EventsRecordToMartok<
(typeof SketchyGame)['routes']
>;
nothing has changed in the code it's just the upgrade to node 20 that's the difference
Sounds good-- I'll try to reconstruct what I can to get a repro working. I no longer have access to any of the code and I'm a little foggy on my recollection.
I'm still missing FaceoffRouteRecord
and SketchyGame
if you're able to post here or email to aaron@sarazan.net it would definitely speed things up <3
* @ignore
*/
export type FaceoffRouteRecord<
GameState extends StateExtension,
Updates extends UpdatesExtension,
Storage extends StorageExtension,
Inputs extends InputExtension,
> = {
[K in keyof Inputs]: RouteConfig<GameState, Updates, Storage, Inputs[K]>;
} & {
startGame: RouteConfig<GameState, Updates, Storage, undefined>;
stateUpdate?: RouteConfig<GameState, Updates, Storage, undefined>;
};
export const SketchyGame = SketchySdk.createGame(
'sketchy',
'Sketchy AF',
createInitialGameState,
endGameHandler,
{
startGame: startGameRoute,
speechText: speechTextRoute,
drawingData: drawingDataRoute,
undoStroke: undoStrokeRoute,
replaceDrawing: replaceDrawingRoute,
readyUp: readyUpRoute,
stateUpdate: stateUpdateRoute,
}
);
GameState extends StateExtension,
Storage extends StorageExtension,
Updates extends UpdatesExtension,
> {
createGame<
R extends FaceoffRouteRecord<GameState, Updates, Storage, any>,
N extends string,
>(
id: N,
name: string,
createInitialGameState: (
participants: PlayerObject<Storage>[],
initiator: string
) => Promise<GameState>,
handleEndGame: (state: GameState) => Promise<EndGameInfo>,
routes: R
) {
return {
state: {} as GameState,
storage: {} as Storage,
updates: {} as Updates,
id,
name,
createInitialGameState,
handleEndGame,
routes,
};
}
createRoute<Input extends InputExtension | undefined = undefined>() {
return new RouteBuilder<GameState, Updates, Storage, Input>();
}
}
our martok script stopped working when converting our project from node 16 to node 20
here seems like its not able to resolve
(typeof SketchyGame)['routes']