Match Timeline Adapter (Mr. Doge SDK)
mrdoge-ui/mrdoge-match-timeline-adapterFreeUtility
Maps a real match's timeline events onto Match Timeline's entries prop.
Install it
npx shadcn@latest add https://mrdoge.co/r/mrdoge-match-timeline-adapter.jsonSource
1import type { MatchDetail, TimelineEvent } from "@mrdoge/protocol"2import type { MatchTimelineEntry, MatchTimelineProps } from "@/registry/mrdoge-ui/match-timeline/match-timeline"34// Soccer only. classify() and the phase labels below use soccer's own5// event/phase sysnames. Other sports just get zero entries for now.67// Matched by prefix. Lower-tier competitions report goals/cards without8// a named player ("GoalWithoutScorer" vs "GoalWithScorer"). "GoalWith"9// specifically, not "GoalKick" (a real, different event).10function classify(type: string): "goal" | "own-goal" | "yellow-card" | "red-card" | "penalty" | null {11 if (type === "OwnGoal") return "own-goal"12 if (type.startsWith("GoalWith")) return "goal"13 if (type.startsWith("YellowCard")) return "yellow-card"14 if (type.startsWith("RedCard")) return "red-card"15 if (type === "PenaltyKick") return "penalty"16 return null17}1819function toTimeLabel(event: TimelineEvent): string | undefined {20 return event.captions[0] ? `${event.captions[0]}'` : undefined21}2223// clock.phase/display/displayLong only update on backend event triggers24// and can go stale. StartOfSecondHalf (tracked below) is the reliable25// "2nd half started" signal; elapsedSeconds is only a last-resort26// fallback for matches with no events to check at all.27const SOCCER_PHASE_LABEL: Record<string, string> = {28 SOCCER_MATCH_FIRST_HALF: "1st Half",29 SOCCER_MATCH_SECOND_HALF: "2nd Half",30 SOCCER_MATCH_EXTRA_FIRST_HALF: "Extra Time - 1st Half",31 SOCCER_MATCH_EXTRA_SECOND_HALF: "Extra Time - 2nd Half",32 SOCCER_MATCH_PENALTIES: "Penalties",33}34// Only reached when there's no StartOfSecondHalf event to trust.35// Deliberately wide, since real 1st-half stoppage rarely approaches it.36const FIRST_HALF_ELAPSED_CUTOFF_SECONDS = 70 * 6037const SECOND_HALF_ELAPSED_CEILING_SECONDS = 115 * 603839function phaseLabelFromElapsedSeconds(elapsedSeconds: number | null | undefined): string | undefined {40 if (elapsedSeconds == null) return undefined41 if (elapsedSeconds <= FIRST_HALF_ELAPSED_CUTOFF_SECONDS) return "1st Half"42 if (elapsedSeconds <= SECOND_HALF_ELAPSED_CEILING_SECONDS) return "2nd Half"43 return undefined44}4546type ClockLike = {47 phase: string | null48 state?: string | null49 display: string | null50 displayLong: string | null51 elapsedSeconds?: number | null52} | null | undefined5354function toLivePhaseLabel(clock: ClockLike, secondHalfStarted: boolean): string {55 // elapsedSeconds is null during intermission. Trust the backend's56// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from mrdoge-ui
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Bet Slip Adapter (Mr. Doge SDK)mrdoge-bet-slip-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Mr. Doge Clientmrdoge-client | mrdoge-ui | Utilities | Free | 1 dep | |
| Conflict Adapter (Mr. Doge SDK)mrdoge-conflict-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Card Adapter (Mr. Doge SDK)mrdoge-match-card-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Highlight Adapter (Mr. Doge SDK)mrdoge-match-highlight-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Odds Selector Adapter (Mr. Doge SDK)mrdoge-odds-selector-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Stats List Adapter (Mr. Doge SDK)mrdoge-stats-list-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Rate Limitrate-limit | mrdoge-ui | Utilities | Free | no deps |
