@sportsdataverse/sdvplot 0.0.0-stage → 0.2.0

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.
Files changed (245) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +109 -0
  3. package/README.md +984 -2
  4. package/dist/_web-D7Aa5Rd8.d.ts +69 -0
  5. package/dist/aaf-GJ3SH34T.js +13 -0
  6. package/dist/aaf-HCYN5T6Y.js +37 -0
  7. package/dist/aaf-ZAE5KS2Y.js +13 -0
  8. package/dist/ahl-E66MDVCU.js +66 -0
  9. package/dist/ahl-NPQQWZEV.js +249 -0
  10. package/dist/ahl-QRDU73XX.js +309 -0
  11. package/dist/axis-CraWQRUJ.d.ts +49 -0
  12. package/dist/bins.d.ts +174 -0
  13. package/dist/bins.js +4 -0
  14. package/dist/bins.js.map +1 -0
  15. package/dist/cfb-F42SVS4X.js +5000 -0
  16. package/dist/cfb-P3SHEYRZ.js +692 -0
  17. package/dist/cfb-WXRZANLP.js +10226 -0
  18. package/dist/chartjs-surface.d.ts +42 -0
  19. package/dist/chartjs-surface.js +65 -0
  20. package/dist/chartjs-surface.js.map +1 -0
  21. package/dist/chartjs.d.ts +162 -0
  22. package/dist/chartjs.js +342 -0
  23. package/dist/chartjs.js.map +1 -0
  24. package/dist/chunk-4C3GX6QO.js +92 -0
  25. package/dist/chunk-4C3GX6QO.js.map +1 -0
  26. package/dist/chunk-57WFSI4Q.js +128 -0
  27. package/dist/chunk-57WFSI4Q.js.map +1 -0
  28. package/dist/chunk-7ULOCCFL.js +313 -0
  29. package/dist/chunk-7ULOCCFL.js.map +1 -0
  30. package/dist/chunk-AMXASQHT.js +120 -0
  31. package/dist/chunk-AMXASQHT.js.map +1 -0
  32. package/dist/chunk-B2MP37SR.js +175 -0
  33. package/dist/chunk-B2MP37SR.js.map +1 -0
  34. package/dist/chunk-C2CDY5OG.js +137 -0
  35. package/dist/chunk-C2CDY5OG.js.map +1 -0
  36. package/dist/chunk-DYMUVE6K.js +127 -0
  37. package/dist/chunk-DYMUVE6K.js.map +1 -0
  38. package/dist/chunk-E7G7VSLV.js +43 -0
  39. package/dist/chunk-E7G7VSLV.js.map +1 -0
  40. package/dist/chunk-H2C3FMMA.js +300 -0
  41. package/dist/chunk-H2C3FMMA.js.map +1 -0
  42. package/dist/chunk-J4P4HDBF.js +175 -0
  43. package/dist/chunk-J4P4HDBF.js.map +1 -0
  44. package/dist/chunk-J6R2LEJ7.js +58 -0
  45. package/dist/chunk-J6R2LEJ7.js.map +1 -0
  46. package/dist/chunk-M3XD2OSN.js +132 -0
  47. package/dist/chunk-M3XD2OSN.js.map +1 -0
  48. package/dist/chunk-OIILARXI.js +30 -0
  49. package/dist/chunk-OIILARXI.js.map +1 -0
  50. package/dist/chunk-RPVVJY74.js +170 -0
  51. package/dist/chunk-RPVVJY74.js.map +1 -0
  52. package/dist/chunk-UL5M6KDE.js +205 -0
  53. package/dist/chunk-UL5M6KDE.js.map +1 -0
  54. package/dist/chunk-WQT4IVLX.js +10 -0
  55. package/dist/chunk-WQT4IVLX.js.map +1 -0
  56. package/dist/chunk-ZAEQXFJM.js +556 -0
  57. package/dist/chunk-ZAEQXFJM.js.map +1 -0
  58. package/dist/cricket-KPCYG2HL.js +493 -0
  59. package/dist/cricket-NDXLE25B.js +116 -0
  60. package/dist/cricket-YUUF7P6M.js +160 -0
  61. package/dist/cytoscape.d.ts +188 -0
  62. package/dist/cytoscape.js +219 -0
  63. package/dist/cytoscape.js.map +1 -0
  64. package/dist/d3.d.ts +234 -0
  65. package/dist/d3.js +198 -0
  66. package/dist/d3.js.map +1 -0
  67. package/dist/deckgl.d.ts +232 -0
  68. package/dist/deckgl.js +197 -0
  69. package/dist/deckgl.js.map +1 -0
  70. package/dist/echarts.d.ts +121 -0
  71. package/dist/echarts.js +228 -0
  72. package/dist/echarts.js.map +1 -0
  73. package/dist/echl-3CR4RGFC.js +241 -0
  74. package/dist/echl-NPC32C23.js +107 -0
  75. package/dist/echl-PI33DGJC.js +64 -0
  76. package/dist/export.d.ts +130 -0
  77. package/dist/export.js +258 -0
  78. package/dist/export.js.map +1 -0
  79. package/dist/g2.d.ts +251 -0
  80. package/dist/g2.js +102 -0
  81. package/dist/g2.js.map +1 -0
  82. package/dist/headshots-B2J_LOO8.d.ts +40 -0
  83. package/dist/index.d.ts +183 -0
  84. package/dist/index.js +9 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/interact.d.ts +567 -0
  87. package/dist/interact.js +809 -0
  88. package/dist/interact.js.map +1 -0
  89. package/dist/lightweight-charts.d.ts +217 -0
  90. package/dist/lightweight-charts.js +155 -0
  91. package/dist/lightweight-charts.js.map +1 -0
  92. package/dist/maplibre.d.ts +271 -0
  93. package/dist/maplibre.js +175 -0
  94. package/dist/maplibre.js.map +1 -0
  95. package/dist/marks-DH-tQIP-.d.ts +75 -0
  96. package/dist/mbb-3TRLVW3H.js +3619 -0
  97. package/dist/mbb-DQUHCHZP.js +5111 -0
  98. package/dist/mbb-PRAIO2P5.js +371 -0
  99. package/dist/milb-6IQ6NCEW.js +291 -0
  100. package/dist/milb-EYY5MD4T.js +1752 -0
  101. package/dist/milb-EYZ4SZLI.js +797 -0
  102. package/dist/mlb-4PBUJSVQ.js +35 -0
  103. package/dist/mlb-FHPY3GQJ.js +701 -0
  104. package/dist/mlb-REVGL3N2.js +665 -0
  105. package/dist/mui.d.ts +338 -0
  106. package/dist/mui.js +184 -0
  107. package/dist/mui.js.map +1 -0
  108. package/dist/nba-ATT775GS.js +485 -0
  109. package/dist/nba-LKM4UHVU.js +482 -0
  110. package/dist/nba-YX7PXM3R.js +35 -0
  111. package/dist/nbagl-3WGZCZ4S.js +37 -0
  112. package/dist/nbagl-LP4XJRAL.js +229 -0
  113. package/dist/nbagl-VTTOU7LN.js +499 -0
  114. package/dist/ncaa_baseball-UV75LNVR.js +2670 -0
  115. package/dist/ncaa_baseball-VD5J5C72.js +419 -0
  116. package/dist/ncaa_baseball-YRBS32D6.js +4592 -0
  117. package/dist/ncaa_mhockey-IMYHS7QS.js +1033 -0
  118. package/dist/ncaa_mhockey-TXTKWHE3.js +115 -0
  119. package/dist/ncaa_mhockey-U3MFW5VT.js +663 -0
  120. package/dist/ncaa_softball-6WR6KS64.js +420 -0
  121. package/dist/ncaa_softball-RZCTIE56.js +2654 -0
  122. package/dist/ncaa_softball-VOD4PVGY.js +4599 -0
  123. package/dist/ncaa_whockey-6XXGUTBK.js +607 -0
  124. package/dist/ncaa_whockey-AKKYKY67.js +53 -0
  125. package/dist/ncaa_whockey-KBEKXFBB.js +293 -0
  126. package/dist/nfl-BDB2HYAR.js +625 -0
  127. package/dist/nfl-EHYHDLJD.js +37 -0
  128. package/dist/nfl-VF4NJCHY.js +514 -0
  129. package/dist/nfl_gsis-UY64JO37.js +4 -0
  130. package/dist/nhl-6WPHME7H.js +511 -0
  131. package/dist/nhl-EMIJFZHY.js +884 -0
  132. package/dist/nhl-ISFUKRFU.js +37 -0
  133. package/dist/nivo.d.ts +193 -0
  134. package/dist/nivo.js +8 -0
  135. package/dist/nivo.js.map +1 -0
  136. package/dist/ohl-2FEM554G.js +113 -0
  137. package/dist/ohl-C5Q4W6JB.js +32 -0
  138. package/dist/ohl-TQ4J46VC.js +66 -0
  139. package/dist/perspective.d.ts +198 -0
  140. package/dist/perspective.js +171 -0
  141. package/dist/perspective.js.map +1 -0
  142. package/dist/phf-H7POU2KW.js +32 -0
  143. package/dist/phf-K5IFMZUM.js +13 -0
  144. package/dist/phf-TWJI3BOW.js +20 -0
  145. package/dist/placement-UWkqUzpa.d.ts +32 -0
  146. package/dist/plot.d.ts +451 -0
  147. package/dist/plot.js +712 -0
  148. package/dist/plot.js.map +1 -0
  149. package/dist/plotly.d.ts +129 -0
  150. package/dist/plotly.js +360 -0
  151. package/dist/plotly.js.map +1 -0
  152. package/dist/pwhl-OX3BO4JI.js +53 -0
  153. package/dist/pwhl-W44OC3C6.js +17 -0
  154. package/dist/pwhl-ZJGG3H7W.js +23 -0
  155. package/dist/qmjhl-5HISEHLL.js +35 -0
  156. package/dist/qmjhl-DA3UHKE5.js +125 -0
  157. package/dist/qmjhl-YG4BOQPF.js +614 -0
  158. package/dist/react.d.ts +377 -0
  159. package/dist/react.js +522 -0
  160. package/dist/react.js.map +1 -0
  161. package/dist/recharts.d.ts +162 -0
  162. package/dist/recharts.js +8 -0
  163. package/dist/recharts.js.map +1 -0
  164. package/dist/resolve-CQW-jzvr.d.ts +28 -0
  165. package/dist/selection-D4T3PkRt.d.ts +140 -0
  166. package/dist/shadcn.d.ts +83 -0
  167. package/dist/shadcn.js +88 -0
  168. package/dist/shadcn.js.map +1 -0
  169. package/dist/shots.d.ts +364 -0
  170. package/dist/shots.js +86 -0
  171. package/dist/shots.js.map +1 -0
  172. package/dist/soccer-7BH3ZLVL.js +7898 -0
  173. package/dist/soccer-MRU25OGE.js +2636 -0
  174. package/dist/soccer-PF4IPPVA.js +12342 -0
  175. package/dist/surface-TR7YFJW3.js +4 -0
  176. package/dist/surface-TR7YFJW3.js.map +1 -0
  177. package/dist/surfaces-MIG7HOFU.js +6 -0
  178. package/dist/surfaces-MIG7HOFU.js.map +1 -0
  179. package/dist/surfaces-W-odWLpT.d.ts +47 -0
  180. package/dist/svelte/HeadshotMark.svelte +25 -0
  181. package/dist/svelte/HeadshotMark.svelte.d.ts +10 -0
  182. package/dist/svelte/HeadshotMark.svelte.d.ts.map +1 -0
  183. package/dist/svelte/LogoMark.svelte +25 -0
  184. package/dist/svelte/LogoMark.svelte.d.ts +10 -0
  185. package/dist/svelte/LogoMark.svelte.d.ts.map +1 -0
  186. package/dist/svelte/Marks.svelte +25 -0
  187. package/dist/svelte/Marks.svelte.d.ts +10 -0
  188. package/dist/svelte/Marks.svelte.d.ts.map +1 -0
  189. package/dist/svelte/Surface.svelte +29 -0
  190. package/dist/svelte/Surface.svelte.d.ts +9 -0
  191. package/dist/svelte/Surface.svelte.d.ts.map +1 -0
  192. package/dist/svelte/SurfaceBackdrop.svelte +26 -0
  193. package/dist/svelte/SurfaceBackdrop.svelte.d.ts +11 -0
  194. package/dist/svelte/SurfaceBackdrop.svelte.d.ts.map +1 -0
  195. package/dist/svelte/index.d.ts +13 -0
  196. package/dist/svelte/index.d.ts.map +1 -0
  197. package/dist/svelte/index.js +11 -0
  198. package/dist/svelte-core.d.ts +139 -0
  199. package/dist/svelte-core.js +123 -0
  200. package/dist/svelte-core.js.map +1 -0
  201. package/dist/tanstack.d.ts +240 -0
  202. package/dist/tanstack.js +110 -0
  203. package/dist/tanstack.js.map +1 -0
  204. package/dist/testing.d.ts +75 -0
  205. package/dist/testing.js +239 -0
  206. package/dist/testing.js.map +1 -0
  207. package/dist/three.d.ts +223 -0
  208. package/dist/three.js +50 -0
  209. package/dist/three.js.map +1 -0
  210. package/dist/tiers-BN4md-GB.d.ts +65 -0
  211. package/dist/types-C7n6gJF3.d.ts +62 -0
  212. package/dist/ufl-7VLZTLTT.js +143 -0
  213. package/dist/ufl-CCMBLPSW.js +100 -0
  214. package/dist/ufl-F2BJRXME.js +16 -0
  215. package/dist/unovis.d.ts +127 -0
  216. package/dist/unovis.js +108 -0
  217. package/dist/unovis.js.map +1 -0
  218. package/dist/uplot.d.ts +120 -0
  219. package/dist/uplot.js +110 -0
  220. package/dist/uplot.js.map +1 -0
  221. package/dist/usfl-4CR5RMZJ.js +32 -0
  222. package/dist/usfl-LD7HP2YK.js +14 -0
  223. package/dist/usfl-VU4YSJQD.js +19 -0
  224. package/dist/ushl-CPG2LB4L.js +73 -0
  225. package/dist/ushl-PQL6HJAD.js +88 -0
  226. package/dist/ushl-ZT2ATPHK.js +22 -0
  227. package/dist/vega.d.ts +85 -0
  228. package/dist/vega.js +362 -0
  229. package/dist/vega.js.map +1 -0
  230. package/dist/victory.d.ts +107 -0
  231. package/dist/victory.js +38 -0
  232. package/dist/victory.js.map +1 -0
  233. package/dist/wbb-3KHCDYTK.js +5087 -0
  234. package/dist/wbb-BMX53Q3Q.js +369 -0
  235. package/dist/wbb-QNRN2CJJ.js +3620 -0
  236. package/dist/whl-4ATYZWUB.js +97 -0
  237. package/dist/whl-RVFPL6MH.js +79 -0
  238. package/dist/whl-Y7ASKYMM.js +28 -0
  239. package/dist/wnba-FWX5SFVI.js +232 -0
  240. package/dist/wnba-GX6HZR4B.js +220 -0
  241. package/dist/wnba-NTMWIPP6.js +20 -0
  242. package/dist/xfl-43R2JMJK.js +30 -0
  243. package/dist/xfl-H3BXQPZZ.js +16 -0
  244. package/dist/xfl-XON7A7FI.js +69 -0
  245. package/package.json +366 -3
package/dist/g2.js ADDED
@@ -0,0 +1,102 @@
1
+ import { colorPalette, aspect, imageSource, markPlacements } from './chunk-UL5M6KDE.js';
2
+ export { embedSources } from './chunk-UL5M6KDE.js';
3
+ import { placeSync, placedName, checkAlpha } from './chunk-7ULOCCFL.js';
4
+ import './chunk-ZAEQXFJM.js';
5
+ import './chunk-J6R2LEJ7.js';
6
+ import { InputError } from './chunk-E7G7VSLV.js';
7
+
8
+ // src/g2.ts
9
+ function teamColorPalette(league, teams, o = {}) {
10
+ return colorPalette(league, teams, o);
11
+ }
12
+ function teamColorScale(league, teams, o = {}) {
13
+ const seen = /* @__PURE__ */ new Map();
14
+ for (const t of teams) if (!seen.has(String(t))) seen.set(String(t), t);
15
+ return { type: "ordinal", domain: [...seen.values()], range: colorPalette(league, [...seen.keys()], o) };
16
+ }
17
+ function checkSize(size) {
18
+ if (!(typeof size === "number" && Number.isFinite(size) && size > 0))
19
+ throw new InputError(`size is an image height in px > 0, got ${String(size)}`);
20
+ if (size < 1)
21
+ throw new InputError(
22
+ `size is a height in px, not a fraction of the plot (echarts' \`height\`): got ${size}, which draws a sub-pixel image`
23
+ );
24
+ return size;
25
+ }
26
+ var width = (d) => d.sdv_width;
27
+ var height = (d) => d.sdv_height;
28
+ function imageMark(rows, kind, o) {
29
+ const h = checkSize(o.size ?? 24);
30
+ const opacity = checkAlpha(o.alpha ?? 1);
31
+ const ps = markPlacements(rows, kind, o);
32
+ return {
33
+ type: "image",
34
+ // the whole row, not only x and y: a view's encode (say color: "team") reaches this mark too, and a caller's own
35
+ // style callback on it (opacity by wins, say) reads the row's fields
36
+ data: ps.map((p) => ({
37
+ ...rows[p.index],
38
+ sdv_id: p.id,
39
+ sdv_src: imageSource(p, o.embed),
40
+ sdv_width: h * aspect(p),
41
+ sdv_height: h
42
+ })),
43
+ encode: { x: o.x, y: o.y, src: "sdv_src" },
44
+ style: { width, height, opacity },
45
+ tooltip: false,
46
+ legend: false
47
+ };
48
+ }
49
+ function logoMark(rows, o) {
50
+ return imageMark(rows, "logo", o);
51
+ }
52
+ function wordmarkMark(rows, o) {
53
+ return imageMark(rows, "wordmark", o);
54
+ }
55
+ function headshotMark(rows, o) {
56
+ return imageMark(rows, "headshot", o);
57
+ }
58
+ var escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
59
+ function axisLogos(o) {
60
+ const h = checkSize(o.size ?? 24);
61
+ const kind = o.markType ?? "logo";
62
+ return {
63
+ labelRender: (datum) => {
64
+ const value = datum.label;
65
+ const p = placeSync([0], [0], [value], {
66
+ league: o.league,
67
+ kind,
68
+ ...o.season === void 0 ? {} : { season: o.season },
69
+ ...o.variant === void 0 ? {} : { variant: o.variant },
70
+ ...o.idSystem === void 0 ? {} : { idSystem: o.idSystem }
71
+ })[0];
72
+ if (p === void 0)
73
+ return `<span style="display:block;width:max-content;transform:translateX(-50%)">${escapeHtml(String(value ?? ""))}</span>`;
74
+ const alt = escapeHtml(`${placedName(p, o.league, value)} ${kind}`);
75
+ const w = h * aspect(p);
76
+ return `<img src="${imageSource(p, o.embed)}" alt="${alt}" data-sdv-id="${escapeHtml(p.id)}" style="display:block;margin-left:${-w / 2}px;width:${w}px;height:${h}px">`;
77
+ },
78
+ labelOpacity: 1,
79
+ labelAutoHide: false,
80
+ labelAutoRotate: false,
81
+ transform: []
82
+ };
83
+ }
84
+ var isImageMark = (v) => typeof v === "object" && v !== null && v.type === "image" && Array.isArray(v.data) && v.encode?.src === "sdv_src";
85
+ function drawnMarks(spec) {
86
+ if (Array.isArray(spec)) return spec.flatMap(drawnMarks);
87
+ if (typeof spec !== "object" || spec === null) return [];
88
+ if (isImageMark(spec))
89
+ return spec.data.map((d) => [
90
+ d.sdv_id,
91
+ d[spec.encode.x],
92
+ d[spec.encode.y],
93
+ spec.style.height(d),
94
+ d.sdv_src
95
+ ]);
96
+ const { children, annotations } = spec;
97
+ return [...drawnMarks(children), ...drawnMarks(annotations)];
98
+ }
99
+
100
+ export { axisLogos, drawnMarks, headshotMark, logoMark, teamColorPalette, teamColorScale, wordmarkMark };
101
+ //# sourceMappingURL=g2.js.map
102
+ //# sourceMappingURL=g2.js.map
package/dist/g2.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/g2.ts"],"names":[],"mappings":";;;;;;;;AA0DO,SAAS,gBAAA,CACd,MAAA,EACA,KAAA,EACA,CAAA,GAAoB,EAAC,EACX;AACV,EAAA,OAAO,YAAA,CAAa,MAAA,EAAQ,KAAA,EAAO,CAAC,CAAA;AACtC;AA2BO,SAAS,cAAA,CACd,MAAA,EACA,KAAA,EACA,CAAA,GAAoB,EAAC,EACJ;AACjB,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAe;AAChC,EAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,IAAI,CAAC,KAAK,GAAA,CAAI,MAAA,CAAO,CAAC,CAAC,GAAG,IAAA,CAAK,GAAA,CAAI,MAAA,CAAO,CAAC,GAAG,CAAC,CAAA;AACtE,EAAA,OAAO,EAAE,MAAM,SAAA,EAAW,MAAA,EAAQ,CAAC,GAAG,IAAA,CAAK,QAAQ,CAAA,EAAG,OAAO,YAAA,CAAa,MAAA,EAAQ,CAAC,GAAG,IAAA,CAAK,MAAM,CAAA,EAAG,CAAC,CAAA,EAAE;AACzG;AAoEA,SAAS,UAAU,IAAA,EAAuB;AACxC,EAAA,IAAI,EAAE,OAAO,IAAA,KAAS,QAAA,IAAY,OAA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,OAAO,IAAA,CAAK,QAAQ,UAAU,CAAA;AACvD,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,IAAA,SAAa,EAAC;AACvD,EAAA,IAAI,YAAY,IAAI,CAAA;AAClB,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,KAAM;AAAA,MAC1B,CAAA,CAAE,MAAA;AAAA,MACF,CAAA,CAAE,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA;AAAA,MACf,CAAA,CAAE,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA;AAAA,MACf,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA;AAAA,MACnB,CAAA,CAAE;AAAA,KACH,CAAA;AACH,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAY,GAAI,IAAA;AAClC,EAAA,OAAO,CAAC,GAAG,UAAA,CAAW,QAAQ,GAAG,GAAG,UAAA,CAAW,WAAW,CAAC,CAAA;AAC7D","file":"g2.js","sourcesContent":["/**\n * The G2 5 adapter, and so Ant Design Charts (`@ant-design/plots`), whose configs are G2 specs underneath: team colours\n * as a `scale.color` (`teamColorScale`) or a list (`teamColorPalette`), logos / wordmarks / headshots as G2 `image`\n * marks (`logoMark`, `wordmarkMark`, `headshotMark`), and logos as a band axis' labels (`axisLogos`). Each returns\n * plain spec pieces: a mark goes in a view's `children` (`chart.options(...)`) or an Ant Design Charts config's\n * `annotations`, a scale in `scale.color`, the axis labels in `axis.x`. Pure: @antv/g2 is never imported (the types\n * are structural, checked against G2 5.4's own). Call after `loadLeague(league)` / `preloadAll()`.\n */\nimport {\n type DrawnMark,\n type Row,\n aspect,\n checkAlpha,\n colorPalette,\n imageSource,\n markPlacements,\n place,\n} from \"./_web.js\";\nimport { InputError } from \"./errors.js\";\nimport type { EspnHeadshotLeague } from \"./headshots.js\";\nimport { type Placement, placedName } from \"./placement.js\";\nimport type { Value } from \"./resolve.js\";\nimport type { HeadshotIdSystem, IdSystem, League, MarkType, SeasonInput, Variant, Which } from \"./types.js\";\nexport type { DrawnMark, Row } from \"./_web.js\";\nexport { embedSources } from \"./_web.js\"; // public: build `embed` with it, as for the other adapters\n\n/** `teamColorPalette` / `teamColorScale` options. */\nexport interface G2ColorOptions {\n /** \"primary\" (default) or \"secondary\" colour. */\n which?: Which;\n /** The season the teams are resolved for (a number or string). */\n season?: SeasonInput;\n /** How the team values are read. Default \"auto\". */\n idSystem?: IdSystem;\n /** The colour of an unresolved team. Default \"#808080\". */\n fallback?: string;\n /**\n * The chart's background. Given, a team colour under 3:1 contrast against it is swapped for the team's other\n * colour, else moved towards white (on a dark background) or black (a light one) until it reads: dark mode. A\n * colour that would then sit too close to an earlier team's (CIE76 ΔE under 20) takes the team's other colour, or\n * the nearest colour to its own that is distinct and still reads; failing that it is kept, with one warning.\n */\n background?: string;\n}\n/**\n * One colour per team, in order, for anything that takes colours by position. With `background`, every colour keeps\n * 3:1 contrast against it (dark mode) and aims to stay distinct from the others. `teamColorScale` puts the same\n * colours on a G2 `scale.color`, keyed by team.\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { teamColorPalette } from \"@sportsdataverse/sdvplot/g2\";\n *\n * await loadLeague(\"nfl\");\n * teamColorPalette(\"nfl\", [\"KC\", \"LAC\", \"DEN\", \"LV\"], { background: \"#141414\" });\n * ```\n */\nexport function teamColorPalette(\n league: League,\n teams: readonly unknown[],\n o: G2ColorOptions = {},\n): string[] {\n return colorPalette(league, teams, o);\n}\n\n/** A G2 `scale.color`: an ordinal scale from each team value to its colour. */\nexport interface G2ColorScale<T = unknown> {\n /** Ordinal: a numeric team column (ESPN ids, say) keeps one colour per id, never a gradient. */\n type: \"ordinal\";\n /** The team values exactly as the data holds them (numbers stay numbers), each once and in order. */\n domain: T[];\n /** Their colours, in the same order. */\n range: string[];\n}\n/**\n * Team colours as a G2 `scale.color` (`{ type: \"ordinal\", domain, range }`): the mark's `encode.color` field holds the\n * team values, and each draws in its own colour; the legend lists the teams in this order. With `background` the\n * colours read on it (dark mode). Pass the teams as the data holds them: G2 matches the domain to the data by exact\n * value, so a numeric id stays a number here (12, not \"12\"); a value given twice (also 12 and \"12\") is kept once.\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { teamColorScale } from \"@sportsdataverse/sdvplot/g2\";\n *\n * await loadLeague(\"nfl\");\n * // { type: \"interval\", encode: { x: \"team\", y: \"wins\", color: \"team\" }, scale: { color: <this> } }\n * teamColorScale(\"nfl\", [\"KC\", \"LAC\", \"DEN\", \"LV\"]);\n * ```\n */\nexport function teamColorScale<T>(\n league: League,\n teams: readonly T[],\n o: G2ColorOptions = {},\n): G2ColorScale<T> {\n const seen = new Map<string, T>(); // keyed by String(v): the first of 12 and \"12\" wins\n for (const t of teams) if (!seen.has(String(t))) seen.set(String(t), t);\n return { type: \"ordinal\", domain: [...seen.values()], range: colorPalette(league, [...seen.keys()], o) };\n}\n\ninterface Shared {\n /** Image height in px, 1 or more (G2 sizes an image mark in px). Default 24. */\n size?: number;\n /** Opacity in [0, 1]. Default 1. */\n alpha?: number;\n /** url → data URI map from `embedSources`, to inline the images. */\n embed?: ReadonlyMap<string, string>;\n}\n/** `logoMark` / `wordmarkMark` options. */\nexport interface G2MarkOptions extends Shared {\n /** Name of the row field holding each mark's x position (the field the chart's x channel encodes). */\n x: string;\n /** Name of the row field holding each mark's y position. */\n y: string;\n /** Name of the row field holding the team (abbreviation, name or id; see `idSystem`). */\n team: string;\n /** The league the teams belong to, e.g. \"nfl\". */\n league: League;\n /** A season (number or string) for every row, or the name of a row field holding each row's season. */\n season?: SeasonInput;\n /** Logo variant, e.g. \"dark\". Default \"default\". */\n variant?: Variant;\n /** How the `team` values are read. Default \"auto\". */\n idSystem?: IdSystem;\n}\n/** `headshotMark` options. */\nexport interface G2HeadshotOptions extends Shared {\n /** Name of the row field holding each headshot's x position. */\n x: string;\n /** Name of the row field holding each headshot's y position. */\n y: string;\n /** Name of the row field holding the player id. */\n player: string;\n /** The league the players belong to, e.g. \"nfl\". */\n league: EspnHeadshotLeague;\n /** ESPN athlete ids, or nflverse gsis ids (needs `loadGsis()` first). Default \"espn\". */\n idSystem?: HeadshotIdSystem;\n}\n\n/** One datum of an sdvplot image mark: the caller's row and what it draws. */\nexport type G2ImageDatum = Row & {\n /** The resolved team id or player id. */\n sdv_id: string;\n /** The image's URL (or data URI). */\n sdv_src: string;\n /** Its size in px. */\n sdv_width: number;\n sdv_height: number;\n};\n/**\n * A G2 `image` mark (G2 5's `ImageMark`, structurally): one image per drawable row, centred on the row's (x, y) in\n * the view's own scales. Out of the tooltip and the legend.\n */\nexport interface G2ImageMark {\n type: \"image\";\n data: G2ImageDatum[];\n encode: { x: string; y: string; src: \"sdv_src\" };\n style: {\n width: (d: G2ImageDatum) => number;\n height: (d: G2ImageDatum) => number;\n opacity: number;\n };\n tooltip: false;\n legend: false;\n}\n\nfunction checkSize(size: unknown): number {\n if (!(typeof size === \"number\" && Number.isFinite(size) && size > 0))\n throw new InputError(`size is an image height in px > 0, got ${String(size)}`);\n if (size < 1)\n throw new InputError(\n `size is a height in px, not a fraction of the plot (echarts' \\`height\\`): got ${size}, which draws a sub-pixel image`,\n );\n return size;\n}\nconst width = (d: G2ImageDatum): number => d.sdv_width;\nconst height = (d: G2ImageDatum): number => d.sdv_height;\n\nfunction imageMark(\n rows: readonly Row[],\n kind: \"logo\" | \"wordmark\" | \"headshot\",\n o: G2MarkOptions | G2HeadshotOptions,\n): G2ImageMark {\n const h = checkSize(o.size ?? 24);\n const opacity = checkAlpha(o.alpha ?? 1);\n // markPlacements reads the x/y fields only to drop rows with a missing one; G2 reads them itself, by field name\n const ps: Placement[] = markPlacements(rows, kind, o);\n return {\n type: \"image\",\n // the whole row, not only x and y: a view's encode (say color: \"team\") reaches this mark too, and a caller's own\n // style callback on it (opacity by wins, say) reads the row's fields\n data: ps.map((p) => ({\n ...rows[p.index],\n sdv_id: p.id,\n sdv_src: imageSource(p, o.embed),\n sdv_width: h * aspect(p),\n sdv_height: h,\n })),\n encode: { x: o.x, y: o.y, src: \"sdv_src\" },\n style: { width, height, opacity },\n tooltip: false,\n legend: false,\n };\n}\n\n/**\n * Team logos as a G2 `image` mark: one logo per row, `size` px tall, centred on the row's (`x`, `y`) fields in the\n * view's scales. Put it last in a view's `children` (G2: `chart.options({ type: \"view\", children: [..., mark] })`), or\n * in an Ant Design Charts config's `annotations`, which reach G2 as they are. A team with no logo draws nothing and\n * warns once.\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { logoMark } from \"@sportsdataverse/sdvplot/g2\";\n *\n * await loadLeague(\"nfl\");\n * const rows = [\n * { team: \"KC\", pf: 385, pa: 326 },\n * { team: \"LAC\", pf: 402, pa: 301 },\n * ];\n * // chart.options({ type: \"view\", data: rows, children: [{ type: \"point\", encode: { x: \"pf\", y: \"pa\" } }, <this>] })\n * logoMark(rows, { x: \"pf\", y: \"pa\", team: \"team\", league: \"nfl\", size: 32 });\n * ```\n */\nexport function logoMark(rows: readonly Row[], o: G2MarkOptions): G2ImageMark {\n return imageMark(rows, \"logo\", o);\n}\n/**\n * Team wordmarks as a G2 `image` mark, `size` px tall at their own aspect ratio; as `logoMark` otherwise.\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { drawnMarks, wordmarkMark } from \"@sportsdataverse/sdvplot/g2\";\n *\n * await loadLeague(\"nfl\");\n * // [team id, x, y, height in px, wordmark URL]: each wordmark 20 px tall, as wide as its own shape\n * drawnMarks(wordmarkMark([{ team: \"LV\", wins: 4, week: 18 }], { x: \"week\", y: \"wins\", team: \"team\", league: \"nfl\", size: 20 }));\n * ```\n */\nexport function wordmarkMark(rows: readonly Row[], o: G2MarkOptions): G2ImageMark {\n return imageMark(rows, \"wordmark\", o);\n}\n/**\n * ESPN player headshots as a G2 `image` mark, from the row's `player` field; an id with no headshot draws nothing and\n * warns once. `idSystem: \"gsis\"` needs `loadGsis()` first.\n *\n * @example\n * ```ts\n * import { headshotMark } from \"@sportsdataverse/sdvplot/g2\";\n *\n * // Patrick Mahomes (ESPN id 3139477) at his 2024 passing yards and touchdowns, 40 px tall\n * const rows = [{ qb: \"3139477\", yards: 3928, tds: 26 }];\n * headshotMark(rows, { x: \"yards\", y: \"tds\", player: \"qb\", league: \"nfl\", size: 40 }).data;\n * ```\n */\nexport function headshotMark(rows: readonly Row[], o: G2HeadshotOptions): G2ImageMark {\n return imageMark(rows, \"headshot\", o);\n}\n\n/** `axisLogos` options: the axis' categories are the teams. */\nexport interface G2AxisOptions {\n /** The league the teams belong to, e.g. \"nfl\". */\n league: League;\n /** The season the axis' teams are resolved for. */\n season?: SeasonInput;\n /** Image height in px, 1 or more. Default 24. */\n size?: number;\n /** Logo variant, e.g. \"dark\". Default \"default\". */\n variant?: Variant;\n /** \"logo\" (default) or \"wordmark\". */\n markType?: MarkType;\n /** How the axis categories are read. Default \"auto\". */\n idSystem?: IdSystem;\n /** url → data URI map from `embedSources`, to inline the images. */\n embed?: ReadonlyMap<string, string>;\n}\n/** What G2 hands an axis' `labelRender`: the subset read here. */\nexport interface G2AxisDatum {\n /** The tick's label: the category, as the axis' `labelFormatter` shows it. */\n label?: unknown;\n}\n/** Axis options for a G2 band axis whose categories are teams: spread them into `axis.x`. */\nexport interface G2AxisLabels {\n /** HTML for each label: the team's logo, or the category's own text where it has none. */\n labelRender: (datum: G2AxisDatum) => string;\n /** G2's theme draws labels at 0.45 opacity: a logo is drawn whole. */\n labelOpacity: 1;\n /** No label is hidden or rotated: each logo box is one band wide, so they never overlap. */\n labelAutoHide: false;\n labelAutoRotate: false;\n transform: [];\n}\n\nconst escapeHtml = (s: string): string => s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n\n/**\n * Team logos as a horizontal band axis' labels (a column chart's `axis.x`), through G2's `labelRender`: each label is\n * HTML, the logo `size` px tall and centred on its tick. Needs `@antv/component` 2.1.12 or later (G2's axis package,\n * an optional peer): 2.1.11 and earlier lay an HTML label out differently, and each logo would sit half a band left. A category with no logo keeps its text and warns once. G2\n * lays an HTML label out one band wide along a horizontal axis only; for a vertical axis (a bar chart's, or under\n * `transpose`) draw a `logoMark` at the axis' position instead. HTML labels are page elements over the chart, not\n * pixels on its canvas: a `toDataURL` export leaves them out.\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { axisLogos } from \"@sportsdataverse/sdvplot/g2\";\n *\n * await loadLeague(\"nfl\");\n * // { type: \"interval\", encode: { x: \"team\", y: \"wins\" }, axis: { x: { ...<this>, title: false } } }\n * axisLogos({ league: \"nfl\", size: 28 }).labelRender({ label: \"KC\" });\n * ```\n */\nexport function axisLogos(o: G2AxisOptions): G2AxisLabels {\n const h = checkSize(o.size ?? 24);\n const kind = o.markType ?? \"logo\";\n return {\n labelRender: (datum) => {\n const value = datum.label as Value;\n const p = place([0], [0], [value], {\n league: o.league,\n kind,\n ...(o.season === undefined ? {} : { season: o.season }),\n ...(o.variant === undefined ? {} : { variant: o.variant }),\n ...(o.idSystem === undefined ? {} : { idSystem: o.idSystem }),\n })[0];\n // G2's axis (@antv/component 2.1.12) puts an HTML label's box with its left edge on the tick: each label shifts\n // itself left by half its own width to centre there. (2.1.11 and earlier centred the box: see the guide.)\n if (p === undefined)\n return `<span style=\"display:block;width:max-content;transform:translateX(-50%)\">${escapeHtml(String(value ?? \"\"))}</span>`;\n const alt = escapeHtml(`${placedName(p, o.league, value)} ${kind}`);\n const w = h * aspect(p);\n // G2 reads the label's height from its inline style; imageSource escapes quotes and angle brackets\n return `<img src=\"${imageSource(p, o.embed)}\" alt=\"${alt}\" data-sdv-id=\"${escapeHtml(p.id)}\" style=\"display:block;margin-left:${-w / 2}px;width:${w}px;height:${h}px\">`;\n },\n labelOpacity: 1,\n labelAutoHide: false,\n labelAutoRotate: false,\n transform: [],\n };\n}\n\nconst isImageMark = (v: unknown): v is G2ImageMark =>\n typeof v === \"object\" &&\n v !== null &&\n (v as { type?: unknown }).type === \"image\" &&\n Array.isArray((v as { data?: unknown }).data) &&\n (v as { encode?: { src?: unknown } }).encode?.src === \"sdv_src\";\n/**\n * Test hook: [id, x, y, height in px, url] per image of every sdvplot mark in `spec`: a mark, a list of them, a G2\n * spec (its `children`, at any depth) or an Ant Design Charts config (its `children` and `annotations`). The height is\n * what the mark's own style hands G2.\n */\nexport function drawnMarks(spec: unknown): DrawnMark[] {\n if (Array.isArray(spec)) return spec.flatMap(drawnMarks);\n if (typeof spec !== \"object\" || spec === null) return [];\n if (isImageMark(spec))\n return spec.data.map((d) => [\n d.sdv_id,\n d[spec.encode.x],\n d[spec.encode.y],\n spec.style.height(d),\n d.sdv_src,\n ]);\n const { children, annotations } = spec as { children?: unknown; annotations?: unknown };\n return [...drawnMarks(children), ...drawnMarks(annotations)];\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import { V as Value } from './resolve-CQW-jzvr.js';
2
+ import { H as HeadshotIdSystem } from './types-C7n6gJF3.js';
3
+
4
+ /** Port of `_headshots.ESPN_HEADSHOT_LEAGUES`. */
5
+ declare const ESPN_HEADSHOT_LEAGUES: {
6
+ readonly nfl: "nfl";
7
+ readonly nba: "nba";
8
+ readonly wnba: "wnba";
9
+ readonly mlb: "mlb";
10
+ readonly nhl: "nhl";
11
+ readonly cfb: "college-football";
12
+ readonly mbb: "mens-college-basketball";
13
+ readonly wbb: "womens-college-basketball";
14
+ };
15
+ /** Leagues with ESPN headshots (gsis ids are nfl-only, and nfl is one of these). */
16
+ type EspnHeadshotLeague = keyof typeof ESPN_HEADSHOT_LEAGUES;
17
+ /** Width / height of a headshot image box (the ESPN combiner crop). */
18
+ declare const HEADSHOT_ASPECT: number;
19
+ declare function nbaHeadshotUrl(id: string | number): string;
20
+ declare function wnbaHeadshotUrl(id: string | number): string;
21
+ declare function mlbHeadshotUrl(id: string | number): string;
22
+ declare function nhlHeadshotUrl(id: string | number): string;
23
+ /** Loads the bundled nflverse gsis map (its own ~3 MB chunk, imported only on demand); required before `headshotUrl(…, { idSystem: "gsis" })`. Nothing is downloaded. */
24
+ declare function loadGsis(): Promise<void>;
25
+ /**
26
+ * Sync port of `_headshots.headshot_url`. ESPN ids need no data; gsis ids need `await loadGsis()` (or `preloadAll()`)
27
+ * first.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { headshotUrl } from "@sportsdataverse/sdvplot";
32
+ *
33
+ * headshotUrl("3139477", "nfl"); // Patrick Mahomes, by ESPN athlete id
34
+ * ```
35
+ */
36
+ declare function headshotUrl(playerId: Value, league: EspnHeadshotLeague, { idSystem }?: {
37
+ idSystem?: HeadshotIdSystem;
38
+ }): string | undefined;
39
+
40
+ export { type EspnHeadshotLeague as E, HEADSHOT_ASPECT as H, ESPN_HEADSHOT_LEAGUES as a, nhlHeadshotUrl as b, headshotUrl as h, loadGsis as l, mlbHeadshotUrl as m, nbaHeadshotUrl as n, wnbaHeadshotUrl as w };
@@ -0,0 +1,183 @@
1
+ import { A as Alias, a as MarkRow, S as SeasonInput, L as League, b as LeagueData, c as Team } from './types-C7n6gJF3.js';
2
+ export { E as EXPLICIT_ONLY, H as HeadshotIdSystem, d as INDEX_VERSION, I as IdSystem, e as LEAGUES, M as MarkType, P as PRIORITY, T as TeamId, f as VARIANTS, V as Variant, W as Which } from './types-C7n6gJF3.js';
3
+ import { R as ResolveOptions, V as Value } from './resolve-CQW-jzvr.js';
4
+ export { a as Resolved, r as resolve, b as resolveSync, s as suggest } from './resolve-CQW-jzvr.js';
5
+ export { C as ColorOptions, a as ColorResult, L as LogoUrlOptions, S as SelectOptions, l as logoUrl, b as logoUrlSync, m as marks, p as palette, s as selectMark, c as selectMarkSync, t as teamColors, d as teamColorsSync } from './marks-DH-tQIP-.js';
6
+ export { K as Kind, a as PlaceOptions, P as Placement, c as checkAlpha, b as checkHeight, p as place, d as placeSync } from './placement-UWkqUzpa.js';
7
+ export { a as ESPN_HEADSHOT_LEAGUES, E as EspnHeadshotLeague, H as HEADSHOT_ASPECT, h as headshotUrl, l as loadGsis, m as mlbHeadshotUrl, n as nbaHeadshotUrl, b as nhlHeadshotUrl, w as wnbaHeadshotUrl } from './headshots-B2J_LOO8.js';
8
+ export { C as Cursor, R as RowFilter, b as SelectionPatch, a as SelectionState, S as SelectionStore, c as createSelection, f as focusIds, s as sameCursor, d as sameIds, t as toId } from './selection-D4T3PkRt.js';
9
+ export { b as TIERS_SUBTITLE, c as TIER_DESC, d as TIER_THEMES, a as TierRow, e as Tiers, T as TiersOptions, p as prepareTiers, w as wrapLabel } from './tiers-BN4md-GB.js';
10
+
11
+ declare const MANIFEST_URL = "https://sdv.nyc3.cdn.digitaloceanspaces.com/assets/public/manifest/marks.csv";
12
+ interface ManifestRow {
13
+ level: string;
14
+ league: string;
15
+ entity_id: string;
16
+ mark_type: string;
17
+ variant: string;
18
+ valid_from: string;
19
+ valid_to: string;
20
+ source: string;
21
+ sha256: string;
22
+ ext: string;
23
+ width: string;
24
+ height: string;
25
+ archive_url: string;
26
+ first_seen: string;
27
+ }
28
+ /** RFC 4180 over the whole text (quoted commas, doubled quotes, embedded newlines; CRLF or LF); rows keyed by header name. */
29
+ declare function parseManifestCsv(text: string): ManifestRow[];
30
+ /** Alias-mapped, safe-URL-filtered, ranked marks of one league; `archive_url` is derived, never copied. Not deduped. */
31
+ declare function manifestMarks(league: string, rows: readonly ManifestRow[], aliases: readonly Alias[]): MarkRow[];
32
+ declare function resetManifestCache(): void;
33
+ /** The CDN manifest, fetched once per process (a failure is not cached). */
34
+ declare function fetchManifest(o?: {
35
+ fetch?: typeof fetch;
36
+ }): Promise<ManifestRow[]>;
37
+
38
+ interface Rankable {
39
+ source_rank: number;
40
+ valid_from: number | null;
41
+ valid_to: number | null;
42
+ first_seen: string;
43
+ sha256: string;
44
+ }
45
+ /** Python `_ranked`: source_rank asc, open-ended (valid_to null) first, valid_to desc, first_seen desc, valid_from desc, sha256 asc; nulls last. */
46
+ declare function compareMarks(a: Rankable, b: Rankable): number;
47
+
48
+ declare class SdvplotError extends Error {
49
+ constructor(message: string, options?: ErrorOptions);
50
+ }
51
+ declare class InputError extends SdvplotError {
52
+ }
53
+ declare class UnresolvedTeamError extends SdvplotError {
54
+ }
55
+ declare class UnsupportedTargetError extends SdvplotError {
56
+ }
57
+ /** An optional peer dependency (resvg, playwright, react) is not installed. */
58
+ declare class OptionalDependencyError extends SdvplotError {
59
+ }
60
+ declare class OfflineError extends SdvplotError {
61
+ }
62
+ declare class DownloadError extends OfflineError {
63
+ readonly url: string;
64
+ readonly status?: number | undefined;
65
+ constructor(message: string, url: string, status?: number | undefined);
66
+ }
67
+ type WarningHandler = (message: string) => void;
68
+ declare function setWarningHandler(fn: WarningHandler | null): void;
69
+ declare function resetWarnings(): void;
70
+ /** One warning per `key` per process (spec §4.3): a 10k-row join must not print 10k lines. */
71
+ declare function warn(key: string, message: string): void;
72
+
73
+ /** Port of `_normalize.norm_value`: trimmed, accents + typographic punctuation folded, case-folded, integral numbers without ".0". */
74
+ declare function normValue(value: unknown): string | null;
75
+ declare function normSeason(value: SeasonInput, league?: League): number | null;
76
+
77
+ /**
78
+ * Load a league's bundled teams, aliases and marks (one code-split chunk; nothing is downloaded). Every `*Sync`
79
+ * function needs it first. Async throughout: an unknown league rejects (never throws synchronously); a failed chunk
80
+ * load can be retried.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { loadLeague } from "@sportsdataverse/sdvplot";
85
+ *
86
+ * const nfl = await loadLeague("nfl");
87
+ * nfl.teams.find((t) => t.abbr === "KC");
88
+ * ```
89
+ */
90
+ declare function loadLeague(league: League): Promise<LeagueData>;
91
+ /** Every league shard plus the gsis map, so every *Sync variant works afterwards. */
92
+ declare function preloadAll(): Promise<void>;
93
+ /** Port of `_index.season_bounds`: [first, last]; last = max(latest alias season, next year). */
94
+ declare function seasonBounds(league?: League): readonly [number, number] | null;
95
+ /**
96
+ * The latest season any dated alias of `league` names (the last relocation or rename the index records), or `null`
97
+ * when no alias is dated. It is not the current season: the NHL's is 1997. A value resolved without a season is
98
+ * matched at this season first.
99
+ */
100
+ declare const latestSeason: (league: League) => number | null;
101
+
102
+ /** All teams for one league, or every league (in `LEAGUES` order) when omitted. */
103
+ declare function teams(league?: League): Promise<readonly Team[]>;
104
+
105
+ /** Column form → `Row[]` (flat objects, one per index). Columns must be equal length; `{}` → `[]`. */
106
+ declare function rowsFrom(columns: Record<string, readonly unknown[]>): Record<string, unknown>[];
107
+
108
+ /** Options for {@link matchupColors}: the league, how to resolve the two teams, and the backgrounds. */
109
+ interface MatchupColorOptions extends ResolveOptions {
110
+ /** The league both teams belong to. */
111
+ league: League;
112
+ /** The background each theme's pair must read on; default `{ light: "#ffffff", dark: "#181a1b" }` (Game on Paper's pages). */
113
+ theme?: {
114
+ light?: string;
115
+ dark?: string;
116
+ };
117
+ }
118
+ /** One `[teamA, teamB]` colour pair per theme, as lowercase `#rrggbb`. */
119
+ interface MatchupColors {
120
+ /** The pair for a light background. */
121
+ light: [string, string];
122
+ /** The pair for a dark background. */
123
+ dark: [string, string];
124
+ }
125
+ /**
126
+ * {@link matchupColors} once the league is loaded (`loadLeague` or `preloadAll`).
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { loadLeague, matchupColorsSync } from "@sportsdataverse/sdvplot";
131
+ *
132
+ * await loadLeague("cfb");
133
+ * matchupColorsSync("Alabama", "Georgia", { league: "cfb" });
134
+ * ```
135
+ */
136
+ declare function matchupColorsSync(teamA: Value, teamB: Value, opts: MatchupColorOptions): MatchupColors;
137
+ /**
138
+ * Two team colours that tell the teams apart on a chart: Game on Paper's "game colours" picker.
139
+ *
140
+ * @remarks
141
+ * One pair per theme, each the first candidate whose colours are at least 20 apart in CIEDE2000 and each
142
+ * at least 2.5:1 (WCAG) against that theme's background. Candidates, in order: both primaries, teamB's
143
+ * secondary, teamA's secondary, both secondaries; so a team keeps its primary whenever it works, and teamA
144
+ * (Game on Paper's home team) keeps it first. When no candidate works, an unreadable colour's L* moves just
145
+ * far enough to read; then both colours' L* move, least total movement first, until they separate; failing
146
+ * that, the widest readable separation found. A team with no colour gets `#2394fd`. Deterministic.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { matchupColors } from "@sportsdataverse/sdvplot";
151
+ *
152
+ * // two crimson teams; light: ["#9e1b32", "#2c2a29"] (Georgia's secondary), dark: ["#ffffff", "#ba0c2f"]
153
+ * // in a page, pick the pair for the theme:
154
+ * // const [alabama, georgia] = window.matchMedia("(prefers-color-scheme: dark)").matches ? dark : light;
155
+ * await matchupColors("Alabama", "Georgia", { league: "cfb" });
156
+ * ```
157
+ */
158
+ declare function matchupColors(teamA: Value, teamB: Value, opts: MatchupColorOptions): Promise<MatchupColors>;
159
+
160
+ /** A color as lowercase `#rrggbb`: accepts `#rgb`, `#rrggbb`, `#rgba`, `#rrggbbaa` (`#` optional). Transparency throws unless `dropAlpha`. */
161
+ declare function hex6(color: string, opts?: {
162
+ dropAlpha?: boolean;
163
+ }): string;
164
+ /** WCAG relative luminance, 0 (black) to 1 (white). */
165
+ declare function luminance(color: string): number;
166
+ /** WCAG contrast ratio, 1 (same) to 21 (black on white). */
167
+ declare function contrast(a: string, b: string): number;
168
+ /** Black or white, whichever reads better on `background`. */
169
+ declare function onColor(background: string): string;
170
+ /** The color `t` of the way from `a` to `b` in sRGB (`t` in [0, 1]). */
171
+ declare function mix(a: string, b: string, t: number): string;
172
+ /** The opaque `#rrggbb` a hex color shows as over `background`: a translucent color is alpha-composited onto it. */
173
+ declare function solid(color: string, background?: string): string;
174
+
175
+ declare function versions(): {
176
+ sdvplot: string;
177
+ index: string;
178
+ manifestLastModified: string;
179
+ };
180
+
181
+ declare const VERSION: string;
182
+
183
+ export { Alias, DownloadError, InputError, League, LeagueData, MANIFEST_URL, type ManifestRow, MarkRow, type MatchupColorOptions, type MatchupColors, OfflineError, OptionalDependencyError, type Rankable, ResolveOptions, SdvplotError, SeasonInput, Team, UnresolvedTeamError, UnsupportedTargetError, VERSION, Value, type WarningHandler, compareMarks, contrast, fetchManifest, hex6, latestSeason, loadLeague, luminance, manifestMarks, matchupColors, matchupColorsSync, mix, normSeason, normValue, onColor, parseManifestCsv, preloadAll, resetManifestCache, resetWarnings, rowsFrom, seasonBounds, setWarningHandler, solid, teams, versions, warn };
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { VERSION, matchupColors, matchupColorsSync, rowsFrom, teams, versions } from './chunk-J4P4HDBF.js';
2
+ export { TIERS_SUBTITLE, TIER_DESC, TIER_THEMES, prepareTiers, wrapLabel } from './chunk-DYMUVE6K.js';
3
+ export { createSelection, focusIds, sameCursor, sameIds, toId } from './chunk-4C3GX6QO.js';
4
+ export { MANIFEST_URL, checkAlpha, checkHeight, compareMarks, fetchManifest, logoUrl, logoUrlSync, manifestMarks, marks, parseManifestCsv, place, placeSync, resetManifestCache, selectMark, selectMarkSync } from './chunk-7ULOCCFL.js';
5
+ export { ESPN_HEADSHOT_LEAGUES, EXPLICIT_ONLY, HEADSHOT_ASPECT, INDEX_VERSION, LEAGUES, PRIORITY, VARIANTS, headshotUrl, latestSeason, loadGsis, loadLeague, mlbHeadshotUrl, nbaHeadshotUrl, nhlHeadshotUrl, normSeason, normValue, palette, preloadAll, resolve, resolveSync, seasonBounds, suggest, teamColors, teamColorsSync, wnbaHeadshotUrl } from './chunk-ZAEQXFJM.js';
6
+ export { contrast, hex6, luminance, mix, onColor, solid } from './chunk-J6R2LEJ7.js';
7
+ export { DownloadError, InputError, OfflineError, OptionalDependencyError, SdvplotError, UnresolvedTeamError, UnsupportedTargetError, resetWarnings, setWarningHandler, warn } from './chunk-E7G7VSLV.js';
8
+ //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}