import type { CircuitRace } from "./circuits.race.ts"; /** A car of a feed: an id the rest of the feed uses, and what the board shows of it. Everything but `id` is optional. */ export interface RaceFeedCar { id: string; /** A short code, as a timing board shows one: three letters. Missing, the id is used. */ code?: string; name?: string; team?: string; /** The team's colour, `#rrggbb`. Missing, one of the package's is used. */ colour?: string; /** Its place on the grid, 1 for pole. Missing, the order of `cars`. */ grid?: number; } /** kyogijo's open race timeline: any feed, file or program can write it. Times are seconds from the start (the lights going out). */ export interface RaceFeed { kind: "kyogijo-race"; version: 1; /** The circuit's key (`las-vegas`). A page may draw a feed on another circuit; the lap's shape is then the page's. */ circuit?: string; /** The laps of the race, if the feed knows them; else the most any car has done. */ laps?: number; /** A line about where the race comes from, shown with it. */ title?: string; cars: RaceFeedCar[]; /** When each car completed each lap: lap 1 is the first time it crossed the line after the start. */ crossings: { car: string; lap: number; t: number; }[]; /** When a car left the track for the pit lane and joined it again, and how long it stood still. */ pits?: { car: string; in: number; out: number; stop?: number; }[]; /** When a car retired. */ out?: { car: string; t: number; }[]; /** Where a car was, in the feed's own frame (any unit, any way up): laid on the circuit's line by how far round the lap it is. */ positions?: { car: string; t: number; x: number; y: number; }[]; /** True while the race is going on: the last lap seen is not the end. */ live?: boolean; } /** What reading a feed gives: the feed, or why it is not one, in words. */ export type FeedResult = { ok: true; feed: RaceFeed; } | { ok: false; error: string; }; /** The most a feed may hold: cars, and rows of each list. */ export declare const FEED_LIMITS: Readonly<{ cars: 40; rows: 200000; laps: 200; }>; /** * Read a feed strictly: anything that is not the open race timeline is refused with a sentence that says why, and anything a feed carries that the format does not name is left behind. Text is kept as text (never markup). * @example * ```ts * import { readRaceFeed } from "@johnmorrisdotca/kyogijo-stadiums/circuits"; * const read = readRaceFeed({ kind: "kyogijo-race", version: 1, cars: [{ id: "a" }], crossings: [{ car: "a", lap: 1, t: 101 }] }); * console.log(read.ok, readRaceFeed({ kind: "something" }).ok); * // true false * ``` */ export declare function readRaceFeed(input: unknown): FeedResult; /** * A feed as a race (`CircuitRace`): the same shape a simulation gives, so that `raceAt`, `drawRace`, `raceBoard` and `mountCircuitRace` play it. The circuit is the feed's, or the one named here (a page draws a feed on the * circuit it shows). Between the moments a feed gives, the cars run at the lap's own speeds. * @example * ```ts * import { raceAt, raceFromFeed } from "@johnmorrisdotca/kyogijo-stadiums/circuits"; * const race = raceFromFeed({ kind: "kyogijo-race", version: 1, cars: [{ id: "a", code: "AAA" }, { id: "b", code: "BBB" }], crossings: [{ car: "a", lap: 1, t: 101 }, { car: "b", lap: 1, t: 102.5 }, { car: "a", lap: 2, t: 198 }, { car: "b", lap: 2, t: 200 }] }, "las-vegas"); * const end = raceAt(race, race.duration); * console.log(race.laps, end.standings[0].car.driver.code, end.standings[1].gap); * // 2 AAA 2 * ``` */ export declare function raceFromFeed(feed: RaceFeed, circuitId?: string): CircuitRace; /** * A race as the open race timeline: what a simulated race is, written as a feed (the demo's sample feed is one). Lap times are rounded to thousandths. * @example * ```ts * import { raceToFeed, simulateRace } from "@johnmorrisdotca/kyogijo-stadiums/circuits"; * const feed = raceToFeed(simulateRace({ circuit: "las-vegas", laps: 3, cars: 4 })); * console.log(feed.kind, feed.cars.length, feed.crossings.length); * // kyogijo-race 4 12 * ``` */ export declare function raceToFeed(race: CircuitRace, title?: string): RaceFeed;