@claudinho/core 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -385,9 +385,23 @@ declare function nextFixtureForTeam(code: string, opts?: {
385
385
  from?: Date;
386
386
  fixtures?: Match[];
387
387
  }): Match | undefined;
388
- /** A fixture is potentially live from kickoff until ~kickoff + 140 min. */
388
+ /**
389
+ * A group/regular fixture is potentially live from kickoff until ~kickoff + 140
390
+ * min (90' + half-time + stoppage).
391
+ */
389
392
  declare const LIVE_WINDOW_MS: number;
390
- /** Fixtures whose live window contains `now` (cheap, static — no network). */
393
+ /**
394
+ * Extra allowance for knockout matches, which can go to extra time (+30') and a
395
+ * penalty shootout, running to ~kickoff + 190 min — well past LIVE_WINDOW_MS.
396
+ * Without it the statusline refresher stops polling at kickoff+140min and the
397
+ * cache goes stale mid-match, so a knockout tie still level after 90' (in ET or
398
+ * penalties) silently drops off the statusline while it's still being played.
399
+ * Numerically matches the slack `marketFixtureForTeam` already applies (live.ts).
400
+ */
401
+ declare const KNOCKOUT_EXTRA_TIME_MS: number;
402
+ /** Live-window length for a fixture — longer for knockout (extra time + penalties). */
403
+ declare function liveWindowMsFor(m: Match): number;
404
+ /** Fixtures whose (stage-aware) live window contains `now` (cheap, static — no network). */
391
405
  declare function fixturesInLiveWindow(now?: number, fixtures?: Match[]): Match[];
392
406
  /**
393
407
  * The team's in-play fixture when one is inside its live window, else the next
@@ -1279,4 +1293,4 @@ declare function formatShareBracket(input: ShareBracketInput, options?: ShareBra
1279
1293
  /** Compact one-line-per-match bracket for narrow share contexts. */
1280
1294
  declare function formatBracketCompactLine(mv: BracketMatchView, opts?: BracketFormatOpts): string;
1281
1295
 
1282
- export { BRACKET_STAGE_ORDER, type BracketFormatOpts, type BracketMatchNode, type BracketMatchView, type BracketResult, type BracketTopology, type BracketView, type BuildSignalInput, DEFAULT_COMPETITION, DEFAULT_FLAVOR, DEFAULT_MAX_AGE_MS, EspnAdapter, type EspnAdapterOptions, FEED_TEXT_MAX, FLAVOR_LEVELS, FakeMarketProvider, type FakeMarketProviderOptions, type FavoriteStrength, type FlavorLevel, type FormatOpts, type GroupStandings, KNOWN_SOURCES, type KnockoutFixturesResult, LIVE_WINDOW_MS, type Lang, type LedgerRow, type LiveResult, type MapContext, type MarketFavorite, type MarketMapping, type MarketMappingTable, type MarketOutcome, type MarketOutcomeKind, type MarketProvider, type MarketSignal, type MarketSignalOptions, type MarketSignalsResult, type Match, type MatchByIdResult, type MatchEvent, type NextFixtureResult, type Outcome, PolymarketProvider, type PolymarketProviderOptions, type ProviderAdapter, type ProviderCapabilities, ProviderError, type ProviderErrorKind, type PunditPick, type ResolvedParticipant, SHARE_DISCLAIMER, SHARE_HASHTAG, type ShareBracketInput, type ShareBracketOptions, type ShareSnippetInput, type ShareSnippetOptions, type ShareStyle, type ShareTableInput, type SlotRef, type Stage, type StandingRow, type StandingsResult, type Status, type Team, type TeamInfo, type TeamLookup, allFixtures, allTeams, asFlavorLevel, buildBracketTopology, buildBracketView, buildMarketSignal, byKickoff, competitionBase, computeStandings, countdown, currentOrNextFixtureForTeam, deriveFavorite, displayWidth, favoriteStrength, fixturesByDate, fixturesByGroup, fixturesByTeam, fixturesInLiveWindow, flagEmoji, formatBracketCompactLine, formatBracketList, formatBracketMatchLine, formatBracketTree, formatDate, formatKickoff, formatShareBracket, formatShareSnippet, formatShareTable, formatTime, getBracket, getKnockoutFixtures, getLiveMatches, getMarketSignal, getMarketSignals, getMatchById, getMatchesForDate, getNextFixtureForTeam, getStandings, groups, hasSaneDistribution, isFinished, isFlavorLevel, isLive, isReliableMarketSignal, isResolvedNation, isStaleSignal, isValidDate, isValidTimeZone, knockoutWindow, liveSourceLabel, loadBracketTopology, localDate, lookupTeam, makeAdapter, makeMarketProvider, mapEspnEvent, mapsCleanly, marketAttributionText, marketBlock, marketFavoriteText, marketFixtureForTeam, marketLine, marketProbabilityText, marketRelevant, marketSignalRendersFor, marketSourceLabel, matchFlavor, matchKey, matchLocation, mergeLive, nationToFlag, nationToRegion, nextFixtureForTeam, normalizeLang, normalizeOutcomes, outcomeFromScore, padVisible, parseStandings, parseTeamSlot, resolveCompetition, resolveMarketSource, resolveTz, sanitizeBundledFixture, sanitizeFeedText, sanitizeMatchStrings, scoreline, stageLabel, stageLabelI18n, t };
1296
+ export { BRACKET_STAGE_ORDER, type BracketFormatOpts, type BracketMatchNode, type BracketMatchView, type BracketResult, type BracketTopology, type BracketView, type BuildSignalInput, DEFAULT_COMPETITION, DEFAULT_FLAVOR, DEFAULT_MAX_AGE_MS, EspnAdapter, type EspnAdapterOptions, FEED_TEXT_MAX, FLAVOR_LEVELS, FakeMarketProvider, type FakeMarketProviderOptions, type FavoriteStrength, type FlavorLevel, type FormatOpts, type GroupStandings, KNOCKOUT_EXTRA_TIME_MS, KNOWN_SOURCES, type KnockoutFixturesResult, LIVE_WINDOW_MS, type Lang, type LedgerRow, type LiveResult, type MapContext, type MarketFavorite, type MarketMapping, type MarketMappingTable, type MarketOutcome, type MarketOutcomeKind, type MarketProvider, type MarketSignal, type MarketSignalOptions, type MarketSignalsResult, type Match, type MatchByIdResult, type MatchEvent, type NextFixtureResult, type Outcome, PolymarketProvider, type PolymarketProviderOptions, type ProviderAdapter, type ProviderCapabilities, ProviderError, type ProviderErrorKind, type PunditPick, type ResolvedParticipant, SHARE_DISCLAIMER, SHARE_HASHTAG, type ShareBracketInput, type ShareBracketOptions, type ShareSnippetInput, type ShareSnippetOptions, type ShareStyle, type ShareTableInput, type SlotRef, type Stage, type StandingRow, type StandingsResult, type Status, type Team, type TeamInfo, type TeamLookup, allFixtures, allTeams, asFlavorLevel, buildBracketTopology, buildBracketView, buildMarketSignal, byKickoff, competitionBase, computeStandings, countdown, currentOrNextFixtureForTeam, deriveFavorite, displayWidth, favoriteStrength, fixturesByDate, fixturesByGroup, fixturesByTeam, fixturesInLiveWindow, flagEmoji, formatBracketCompactLine, formatBracketList, formatBracketMatchLine, formatBracketTree, formatDate, formatKickoff, formatShareBracket, formatShareSnippet, formatShareTable, formatTime, getBracket, getKnockoutFixtures, getLiveMatches, getMarketSignal, getMarketSignals, getMatchById, getMatchesForDate, getNextFixtureForTeam, getStandings, groups, hasSaneDistribution, isFinished, isFlavorLevel, isLive, isReliableMarketSignal, isResolvedNation, isStaleSignal, isValidDate, isValidTimeZone, knockoutWindow, liveSourceLabel, liveWindowMsFor, loadBracketTopology, localDate, lookupTeam, makeAdapter, makeMarketProvider, mapEspnEvent, mapsCleanly, marketAttributionText, marketBlock, marketFavoriteText, marketFixtureForTeam, marketLine, marketProbabilityText, marketRelevant, marketSignalRendersFor, marketSourceLabel, matchFlavor, matchKey, matchLocation, mergeLive, nationToFlag, nationToRegion, nextFixtureForTeam, normalizeLang, normalizeOutcomes, outcomeFromScore, padVisible, parseStandings, parseTeamSlot, resolveCompetition, resolveMarketSource, resolveTz, sanitizeBundledFixture, sanitizeFeedText, sanitizeMatchStrings, scoreline, stageLabel, stageLabelI18n, t };
package/dist/index.js CHANGED
@@ -2941,10 +2941,14 @@ function nextFixtureForTeam(code, opts = {}) {
2941
2941
  );
2942
2942
  }
2943
2943
  var LIVE_WINDOW_MS = 140 * 6e4;
2944
+ var KNOCKOUT_EXTRA_TIME_MS = 60 * 6e4;
2945
+ function liveWindowMsFor(m) {
2946
+ return m.stage === "GROUP" || m.stage === "FRIENDLY" ? LIVE_WINDOW_MS : LIVE_WINDOW_MS + KNOCKOUT_EXTRA_TIME_MS;
2947
+ }
2944
2948
  function fixturesInLiveWindow(now = Date.now(), fixtures = SCHEDULE) {
2945
2949
  return fixtures.filter((m) => {
2946
2950
  const k = Date.parse(m.kickoff);
2947
- return now >= k && now <= k + LIVE_WINDOW_MS;
2951
+ return now >= k && now <= k + liveWindowMsFor(m);
2948
2952
  }).sort(byKickoff);
2949
2953
  }
2950
2954
  function currentOrNextFixtureForTeam(code, opts = {}) {
@@ -2952,7 +2956,7 @@ function currentOrNextFixtureForTeam(code, opts = {}) {
2952
2956
  const nowMs = from.getTime();
2953
2957
  const inPlay = fixturesByTeam(code, opts.fixtures ?? SCHEDULE).find((m) => {
2954
2958
  const k = Date.parse(m.kickoff);
2955
- return nowMs >= k && nowMs <= k + LIVE_WINDOW_MS;
2959
+ return nowMs >= k && nowMs <= k + liveWindowMsFor(m);
2956
2960
  });
2957
2961
  return inPlay ?? nextFixtureForTeam(code, opts);
2958
2962
  }
@@ -3086,7 +3090,7 @@ function rosterAtZero(matches) {
3086
3090
  var ESPN_SOCCER = "https://site.api.espn.com/apis/site/v2/sports/soccer";
3087
3091
  var DEFAULT_COMPETITION = "fifa.world";
3088
3092
  var DEFAULT_BASE = `${ESPN_SOCCER}/${DEFAULT_COMPETITION}`;
3089
- var USER_AGENT = `claudinho/${"0.9.1"} (+https://github.com/arturogarrido/claudinho)`;
3093
+ var USER_AGENT = `claudinho/${"0.9.2"} (+https://github.com/arturogarrido/claudinho)`;
3090
3094
  var MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
3091
3095
  function competitionBase(slug) {
3092
3096
  return `${ESPN_SOCCER}/${slug}`;
@@ -5206,6 +5210,7 @@ export {
5206
5210
  FEED_TEXT_MAX,
5207
5211
  FLAVOR_LEVELS,
5208
5212
  FakeMarketProvider,
5213
+ KNOCKOUT_EXTRA_TIME_MS,
5209
5214
  KNOWN_SOURCES,
5210
5215
  LIVE_WINDOW_MS,
5211
5216
  PolymarketProvider,
@@ -5262,6 +5267,7 @@ export {
5262
5267
  isValidTimeZone,
5263
5268
  knockoutWindow,
5264
5269
  liveSourceLabel,
5270
+ liveWindowMsFor,
5265
5271
  loadBracketTopology,
5266
5272
  localDate,
5267
5273
  lookupTeam,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudinho/core",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Domain model, provider adapters (ESPN), standings, bundled schedule, and the read-only Polymarket market-signal sidecar powering Claudinho. Not affiliated with FIFA or Anthropic.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,12 +53,12 @@
53
53
  "agent"
54
54
  ],
55
55
  "devDependencies": {
56
- "@types/node": "^22.20.0",
57
- "@vitest/coverage-v8": "^4.1.9",
56
+ "@types/node": "^22.20.1",
57
+ "@vitest/coverage-v8": "^4.1.10",
58
58
  "tsup": "^8.0.0",
59
- "tsx": "^4.23.0",
59
+ "tsx": "^4.23.1",
60
60
  "typescript": "^5.7.0",
61
- "vitest": "^4.1.9"
61
+ "vitest": "^4.1.10"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "tsup",