@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
@@ -0,0 +1,4 @@
1
+ export { surfaceMesh } from './chunk-B2MP37SR.js';
2
+ import './chunk-E7G7VSLV.js';
3
+ //# sourceMappingURL=surface-TR7YFJW3.js.map
4
+ //# sourceMappingURL=surface-TR7YFJW3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"surface-TR7YFJW3.js"}
@@ -0,0 +1,6 @@
1
+ export { SURFACES, SURFACE_BASE, colorUpdates, surfaceScene } from './chunk-57WFSI4Q.js';
2
+ import './chunk-ZAEQXFJM.js';
3
+ import './chunk-J6R2LEJ7.js';
4
+ import './chunk-E7G7VSLV.js';
5
+ //# sourceMappingURL=surfaces-MIG7HOFU.js.map
6
+ //# sourceMappingURL=surfaces-MIG7HOFU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"surfaces-MIG7HOFU.js"}
@@ -0,0 +1,47 @@
1
+ import { BaseballColorKey, BasketballColorKey, CurlingColorKey, FootballColorKey, HockeyColorKey, LacrosseColorKey, SoccerColorKey, SoftballColorKey, TennisColorKey, VolleyballColorKey, BaseballDisplayRange, BasketballDisplayRange, CurlingDisplayRange, FootballDisplayRange, HockeyDisplayRange, LacrosseDisplayRange, SoccerDisplayRange, SoftballDisplayRange, TennisDisplayRange, VolleyballDisplayRange, BaseballParamUpdates, BasketballParamUpdates, CurlingParamUpdates, FootballParamUpdates, HockeyParamUpdates, LacrosseParamUpdates, SoccerParamUpdates, SoftballParamUpdates, TennisParamUpdates, VolleyballParamUpdates, Sport } from '@sportsdataverse/sporty';
2
+ import { V as Value } from './resolve-CQW-jzvr.js';
3
+ import { S as SeasonInput } from './types-C7n6gJF3.js';
4
+
5
+ type SurfaceSport = Sport;
6
+ /**
7
+ * Maps an sdv surface key to `[sporty sport, sporty league key]`: the SDV surface-key table shared with sdvplot (Python
8
+ * `SURFACES`) and sdvplotR (`surface_map`). Keys that are also sdv team leagues (`nfl`, `ncaa_softball`, ...) take a `team`;
9
+ * the rest (`atp`, `fiba`, `nll`, ...) draw the plain surface.
10
+ */
11
+ declare const SURFACES: Readonly<Record<string, readonly [SurfaceSport, string]>>;
12
+ declare const SURFACE_BASE: {
13
+ readonly basketball: "#d2ab6f";
14
+ readonly football: "#196f0c";
15
+ readonly hockey: "#ffffff";
16
+ };
17
+ type Paint<K extends string> = Partial<Record<K, string>>;
18
+ type AnyColorKey = BaseballColorKey | BasketballColorKey | CurlingColorKey | FootballColorKey | HockeyColorKey | LacrosseColorKey | SoccerColorKey | SoftballColorKey | TennisColorKey | VolleyballColorKey;
19
+ /**
20
+ * Port of `_surface.color_updates`: the team colours a sport's surface takes, keyed by sporty colour key. Sports without a
21
+ * team painting (baseball, softball, soccer and the team-less surfaces) take none, as in sdvplotR.
22
+ */
23
+ declare function colorUpdates(sport: "basketball", primary: string, secondary?: string): Paint<BasketballColorKey>;
24
+ declare function colorUpdates(sport: "football", primary: string, secondary?: string): Paint<FootballColorKey>;
25
+ declare function colorUpdates(sport: "hockey", primary: string, secondary?: string): Paint<HockeyColorKey>;
26
+ declare function colorUpdates(sport: SurfaceSport, primary: string, secondary?: string): Record<string, string>;
27
+ type AnyRange = BaseballDisplayRange | BasketballDisplayRange | CurlingDisplayRange | FootballDisplayRange | HockeyDisplayRange | LacrosseDisplayRange | SoccerDisplayRange | SoftballDisplayRange | TennisDisplayRange | VolleyballDisplayRange;
28
+ interface SurfaceSceneOptions {
29
+ /** A team of the league, painting the surface; only for keys that are sdv team leagues (otherwise `InputError`). */
30
+ team?: Value;
31
+ season?: SeasonInput;
32
+ /** Overrides on top of the team painting, keyed by sporty colour key. */
33
+ colorUpdates?: Paint<AnyColorKey>;
34
+ rotation?: number;
35
+ /** A sporty display range for the league's sport; one the sport does not know throws sporty's UnknownDisplayRangeError. */
36
+ displayRange?: AnyRange;
37
+ xlim?: readonly [number, number];
38
+ ylim?: readonly [number, number];
39
+ units?: "ft" | "m" | "yd" | "in" | "cm" | "mm";
40
+ /** Sporty parameter overrides (intersected across sports so each sport's own keys type-check). */
41
+ updates?: BaseballParamUpdates & BasketballParamUpdates & CurlingParamUpdates & FootballParamUpdates & HockeyParamUpdates & LacrosseParamUpdates & SoccerParamUpdates & SoftballParamUpdates & TennisParamUpdates & VolleyballParamUpdates;
42
+ arcResolution?: number;
43
+ xTrans?: number;
44
+ yTrans?: number;
45
+ }
46
+
47
+ export { type SurfaceSceneOptions as S, SURFACES as a, SURFACE_BASE as b, colorUpdates as c };
@@ -0,0 +1,25 @@
1
+ <!--
2
+ @component
3
+ ESPN player headshots as marks in a LayerChart chart: a child of its `<Svg>` layer. Each row draws its `player`'s
4
+ headshot centred on its scaled (`x`, `y`), `height` (a fraction of the plot area's height) tall. An id with no
5
+ headshot draws nothing and warns once. layerchart loads on first render; missing, it throws an install error then.
6
+ -->
7
+ <script lang="ts">
8
+ import { type HeadshotMarkProps, type LayerChart, loadLayerChart, raise } from "../svelte-core.js";
9
+ import Marks from "./Marks.svelte";
10
+
11
+ let props: HeadshotMarkProps = $props();
12
+ let lc = $state<LayerChart>();
13
+ let failed = $state<{ error: unknown }>();
14
+ // a failed import is rethrown from the template (an effect), where a <svelte:boundary> catches it
15
+ loadLayerChart("HeadshotMark").then(
16
+ (m) => (lc = m),
17
+ (error: unknown) => (failed = { error }),
18
+ );
19
+ </script>
20
+
21
+ {#if failed}
22
+ {raise(failed.error)}
23
+ {:else if lc}
24
+ <Marks {lc} kind="headshot" options={props} />
25
+ {/if}
@@ -0,0 +1,10 @@
1
+ import { type HeadshotMarkProps } from "../svelte-core.js";
2
+ /**
3
+ * ESPN player headshots as marks in a LayerChart chart: a child of its `<Svg>` layer. Each row draws its `player`'s
4
+ * headshot centred on its scaled (`x`, `y`), `height` (a fraction of the plot area's height) tall. An id with no
5
+ * headshot draws nothing and warns once. layerchart loads on first render; missing, it throws an install error then.
6
+ */
7
+ declare const HeadshotMark: import("svelte").Component<HeadshotMarkProps, {}, "">;
8
+ type HeadshotMark = ReturnType<typeof HeadshotMark>;
9
+ export default HeadshotMark;
10
+ //# sourceMappingURL=HeadshotMark.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeadshotMark.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/HeadshotMark.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,iBAAiB,EAA0C,MAAM,mBAAmB,CAAC;AA0BnG;;;;GAIG;AACH,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ <!--
2
+ @component
3
+ Team logos (or wordmarks) as marks in a LayerChart chart: a child of its `<Svg>` layer. Each row draws its
4
+ `team`'s logo centred on its scaled (`x`, `y`), `height` (a fraction of the plot area's height) tall. A team with no
5
+ logo draws nothing and warns once. layerchart loads on first render; missing, it throws an install error then.
6
+ -->
7
+ <script lang="ts">
8
+ import { type LayerChart, type LogoMarkProps, loadLayerChart, raise } from "../svelte-core.js";
9
+ import Marks from "./Marks.svelte";
10
+
11
+ let props: LogoMarkProps = $props();
12
+ let lc = $state<LayerChart>();
13
+ let failed = $state<{ error: unknown }>();
14
+ // a failed import is rethrown from the template (an effect), where a <svelte:boundary> catches it
15
+ loadLayerChart("LogoMark").then(
16
+ (m) => (lc = m),
17
+ (error: unknown) => (failed = { error }),
18
+ );
19
+ </script>
20
+
21
+ {#if failed}
22
+ {raise(failed.error)}
23
+ {:else if lc}
24
+ <Marks {lc} kind={props.markType ?? "logo"} options={props} />
25
+ {/if}
@@ -0,0 +1,10 @@
1
+ import { type LogoMarkProps } from "../svelte-core.js";
2
+ /**
3
+ * Team logos (or wordmarks) as marks in a LayerChart chart: a child of its `<Svg>` layer. Each row draws its
4
+ * `team`'s logo centred on its scaled (`x`, `y`), `height` (a fraction of the plot area's height) tall. A team with no
5
+ * logo draws nothing and warns once. layerchart loads on first render; missing, it throws an install error then.
6
+ */
7
+ declare const LogoMark: import("svelte").Component<LogoMarkProps, {}, "">;
8
+ type LogoMark = ReturnType<typeof LogoMark>;
9
+ export default LogoMark;
10
+ //# sourceMappingURL=LogoMark.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogoMark.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/LogoMark.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,aAAa,EAAyB,MAAM,mBAAmB,CAAC;AA0B/F;;;;GAIG;AACH,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,25 @@
1
+ <svelte:options namespace="svg" />
2
+
3
+ <script lang="ts">
4
+ // Internal: the images of a LogoMark or HeadshotMark, drawn once layerchart has loaded (its chart context is read
5
+ // here, during this component's setup inside the chart).
6
+ import {
7
+ type HeadshotMarkProps,
8
+ type LayerChart,
9
+ type LogoMarkProps,
10
+ markImages,
11
+ } from "../svelte-core.js";
12
+
13
+ let {
14
+ lc,
15
+ kind,
16
+ options,
17
+ }: { lc: LayerChart; kind: "logo" | "wordmark" | "headshot"; options: LogoMarkProps | HeadshotMarkProps } = $props();
18
+ // svelte-ignore state_referenced_locally
19
+ const ctx = lc.getChartContext(); // once, at setup: a context is only readable then (lc never changes)
20
+ const images = $derived(markImages(ctx, kind, options));
21
+ </script>
22
+
23
+ {#each images as m (m.key)}
24
+ <image {...m.attrs} />
25
+ {/each}
@@ -0,0 +1,10 @@
1
+ import { type HeadshotMarkProps, type LayerChart, type LogoMarkProps } from "../svelte-core.js";
2
+ type $$ComponentProps = {
3
+ lc: LayerChart;
4
+ kind: "logo" | "wordmark" | "headshot";
5
+ options: LogoMarkProps | HeadshotMarkProps;
6
+ };
7
+ declare const Marks: import("svelte").Component<$$ComponentProps, {}, "">;
8
+ type Marks = ReturnType<typeof Marks>;
9
+ export default Marks;
10
+ //# sourceMappingURL=Marks.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Marks.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/Marks.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAE5B,KAAK,gBAAgB,GAAI;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAAC,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAwBjI,QAAA,MAAM,KAAK,sDAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
@@ -0,0 +1,29 @@
1
+ <svelte:options namespace="svg" />
2
+
3
+ <script lang="ts">
4
+ // Internal: the backdrop once its code has loaded (the chart context is read here, during setup inside the chart).
5
+ import { type SurfaceBackdropProps, type SurfaceKit, surfaceMarkup } from "../svelte-core.js";
6
+
7
+ let { kit, options }: { kit: SurfaceKit; options: SurfaceBackdropProps } = $props();
8
+ // svelte-ignore state_referenced_locally
9
+ const ctx = kit.lc.getChartContext(); // once, at setup: a context is only readable then (kit never changes)
10
+ const uid = $props.id();
11
+ const clip = `sdv-surface-${uid.replace(/[^\w-]/g, "")}`;
12
+ const scene = $derived.by(() => {
13
+ const { league, ...o } = options;
14
+ return kit.scene(league, o as never);
15
+ });
16
+ const markup = $derived(surfaceMarkup(ctx, kit, scene));
17
+ </script>
18
+
19
+ {#if markup !== null}
20
+ <g data-sdv-surface="" class="sdv-surface">
21
+ <defs>
22
+ <clipPath id={clip}>
23
+ <rect x="0" y="0" width={ctx.width} height={ctx.height} />
24
+ </clipPath>
25
+ </defs>
26
+ <!-- sporty's own SVG, its text and colours escaped by toSVG -->
27
+ <g clip-path="url(#{clip})">{@html markup}</g>
28
+ </g>
29
+ {/if}
@@ -0,0 +1,9 @@
1
+ import { type SurfaceBackdropProps, type SurfaceKit } from "../svelte-core.js";
2
+ type $$ComponentProps = {
3
+ kit: SurfaceKit;
4
+ options: SurfaceBackdropProps;
5
+ };
6
+ declare const Surface: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type Surface = ReturnType<typeof Surface>;
8
+ export default Surface;
9
+ //# sourceMappingURL=Surface.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Surface.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/Surface.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAE7F,KAAK,gBAAgB,GAAI;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAiC7E,QAAA,MAAM,OAAO,sDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -0,0 +1,26 @@
1
+ <!--
2
+ @component
3
+ A team-painted court, field or rink under a LayerChart chart's marks: a child of its `<Svg>` layer, before the
4
+ marks. It is drawn in the chart's x/y units: set `xDomain` / `yDomain` to the surface's bbox (sporty's
5
+ `surface(...).bbox`) to fill the plot area. Both scales must be linear and unreversed (otherwise nothing is drawn,
6
+ with one warning). layerchart and `@sportsdataverse/sporty` load on first render; either missing throws then.
7
+ -->
8
+ <script lang="ts">
9
+ import { type SurfaceBackdropProps, type SurfaceKit, loadSurfaceKit, raise } from "../svelte-core.js";
10
+ import Surface from "./Surface.svelte";
11
+
12
+ let props: SurfaceBackdropProps = $props();
13
+ let kit = $state<SurfaceKit>();
14
+ let failed = $state<{ error: unknown }>();
15
+ // a failed import is rethrown from the template (an effect), where a <svelte:boundary> catches it
16
+ loadSurfaceKit().then(
17
+ (k) => (kit = k),
18
+ (error: unknown) => (failed = { error }),
19
+ );
20
+ </script>
21
+
22
+ {#if failed}
23
+ {raise(failed.error)}
24
+ {:else if kit}
25
+ <Surface {kit} options={props} />
26
+ {/if}
@@ -0,0 +1,11 @@
1
+ import { type SurfaceBackdropProps } from "../svelte-core.js";
2
+ /**
3
+ * A team-painted court, field or rink under a LayerChart chart's marks: a child of its `<Svg>` layer, before the
4
+ * marks. It is drawn in the chart's x/y units: set `xDomain` / `yDomain` to the surface's bbox (sporty's
5
+ * `surface(...).bbox`) to fill the plot area. Both scales must be linear and unreversed (otherwise nothing is drawn,
6
+ * with one warning). layerchart and `@sportsdataverse/sporty` load on first render; either missing throws then.
7
+ */
8
+ declare const SurfaceBackdrop: import("svelte").Component<SurfaceBackdropProps, {}, "">;
9
+ type SurfaceBackdrop = ReturnType<typeof SurfaceBackdrop>;
10
+ export default SurfaceBackdrop;
11
+ //# sourceMappingURL=SurfaceBackdrop.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceBackdrop.svelte.d.ts","sourceRoot":"","sources":["../../src/svelte/SurfaceBackdrop.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,EAA0C,MAAM,mBAAmB,CAAC;AA0BtG;;;;;GAKG;AACH,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Svelte 5 components for LayerChart: team logos and player headshots as marks, a team-painted surface as a
3
+ * backdrop, and team colours for the series. Each component is a child of a LayerChart chart's `<Svg>` layer; it
4
+ * loads layerchart (an optional peer) when it first renders, never on import. Call `loadLeague(league)` /
5
+ * `preloadAll()` first, as for the other adapters.
6
+ * @packageDocumentation
7
+ */
8
+ export { default as HeadshotMark } from "./HeadshotMark.svelte.js";
9
+ export { default as LogoMark } from "./LogoMark.svelte.js";
10
+ export { default as SurfaceBackdrop } from "./SurfaceBackdrop.svelte.js";
11
+ export { embedSources, teamColorPalette } from "../svelte-core.js";
12
+ export type { HeadshotMarkProps, LogoMarkProps, Row, SurfaceBackdropProps, TeamColorPaletteOptions, } from "../svelte-core.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,GAAG,EACH,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Svelte 5 components for LayerChart: team logos and player headshots as marks, a team-painted surface as a
3
+ * backdrop, and team colours for the series. Each component is a child of a LayerChart chart's `<Svg>` layer; it
4
+ * loads layerchart (an optional peer) when it first renders, never on import. Call `loadLeague(league)` /
5
+ * `preloadAll()` first, as for the other adapters.
6
+ * @packageDocumentation
7
+ */
8
+ export { default as HeadshotMark } from "./HeadshotMark.svelte";
9
+ export { default as LogoMark } from "./LogoMark.svelte";
10
+ export { default as SurfaceBackdrop } from "./SurfaceBackdrop.svelte";
11
+ export { embedSources, teamColorPalette } from "../svelte-core.js";
@@ -0,0 +1,139 @@
1
+ import { H as HeadshotOptions, R as Row, M as MarkOptions } from './_web-D7Aa5Rd8.js';
2
+ export { e as embedSources } from './_web-D7Aa5Rd8.js';
3
+ import { K as Kind } from './placement-UWkqUzpa.js';
4
+ import { S as SurfaceSceneOptions } from './surfaces-W-odWLpT.js';
5
+ import { M as MarkType, L as League, S as SeasonInput, W as Which, I as IdSystem } from './types-C7n6gJF3.js';
6
+ import './resolve-CQW-jzvr.js';
7
+ import '@sportsdataverse/sporty';
8
+
9
+ /**
10
+ * What the `sdvplot/svelte` components compute, as plain TypeScript (tsup builds it to dist/svelte-core.js, which the
11
+ * components built by svelte-package import as ../svelte-core.js). Internal: not a package subpath; `sdvplot/svelte`
12
+ * re-exports the public part. layerchart, sporty and the surface code are imported here only, and only lazily.
13
+ */
14
+
15
+ /** `<LogoMark>` props: the shared mark options (`x`, `y`, `team`, `league`, `height` a fraction of the plot height,
16
+ * ...) plus the rows to mark and the mark type. */
17
+ interface LogoMarkProps extends MarkOptions {
18
+ /** The rows to mark. Default: the chart's own `data`. */
19
+ data?: readonly Row[];
20
+ /** "logo" (default) or "wordmark". */
21
+ markType?: MarkType;
22
+ }
23
+ /** `<HeadshotMark>` props: the shared headshot options (`x`, `y`, `player`, `league`, `height`, ...) plus the rows. */
24
+ interface HeadshotMarkProps extends HeadshotOptions {
25
+ /** The rows to mark. Default: the chart's own `data`. */
26
+ data?: readonly Row[];
27
+ }
28
+ /**
29
+ * `<SurfaceBackdrop>` props: the league whose surface to draw and how to paint it (the options of sdvplot's other
30
+ * `surface` functions). The sporty-specific options are typed loosely, so these types never name
31
+ * `@sportsdataverse/sporty` (an optional peer); sporty checks them when the surface is built.
32
+ */
33
+ interface SurfaceBackdropProps {
34
+ /** The league whose court, field or rink to draw, e.g. "nba". */
35
+ league: League;
36
+ /** The team whose colours paint the surface. */
37
+ team?: string | number;
38
+ /** The season the team's colours are taken from. */
39
+ season?: SeasonInput;
40
+ /** Overrides on top of the team painting, keyed by sporty colour key (e.g. `{ painted_area: "#0e2240" }`). */
41
+ colorUpdates?: Readonly<Record<string, string>>;
42
+ /** Degrees to rotate the surface by. */
43
+ rotation?: number;
44
+ /** A sporty display range for the league's sport, e.g. "defense"; one the sport does not know throws. */
45
+ displayRange?: string;
46
+ xlim?: readonly [number, number];
47
+ ylim?: readonly [number, number];
48
+ units?: "ft" | "m" | "yd" | "in" | "cm" | "mm";
49
+ /** Sporty parameter overrides for the league's surface. */
50
+ updates?: Readonly<Record<string, unknown>>;
51
+ arcResolution?: number;
52
+ xTrans?: number;
53
+ yTrans?: number;
54
+ }
55
+ /** A LayerChart scale: what the marks call (a d3 scale; a band scale has a bandwidth). */
56
+ interface ChartScale {
57
+ (v: unknown): unknown;
58
+ domain(): unknown[];
59
+ bandwidth?: () => number;
60
+ }
61
+ /** The part of LayerChart's chart context the components read: the scales, the plot area's size and the data. */
62
+ interface ChartContext {
63
+ xScale: ChartScale;
64
+ yScale: ChartScale;
65
+ width: number;
66
+ height: number;
67
+ data?: unknown;
68
+ }
69
+ /** The part of the layerchart module the components use. */
70
+ interface LayerChart {
71
+ getChartContext(): ChartContext;
72
+ }
73
+ /** layerchart, imported on first use (never with `sdvplot/svelte`); a missing peer rejects with an install message. */
74
+ declare function loadLayerChart(component: string): Promise<LayerChart>;
75
+ /** Throws `e`: a component rethrows a failed import from its template (an effect), so a `<svelte:boundary>` catches
76
+ * it (an error thrown from a promise callback would bypass the boundary). */
77
+ declare function raise(e: unknown): never;
78
+ /** An `<image>` to draw: its attributes, including the `data-sdv-*` stamps `sdvplot/testing`'s `drawnMarks` reads. */
79
+ interface MarkImage {
80
+ key: string;
81
+ attrs: Record<string, string | number>;
82
+ }
83
+ /**
84
+ * The images a mark component draws in the chart `ctx`: one per row whose team (or player) has an image, centred on
85
+ * the row's scaled (x, y), `height` of the plot area tall. A row with no image is skipped with one warning (placeSync),
86
+ * as `sdvplot/echarts` does. Nothing is drawn before the chart has a size.
87
+ */
88
+ declare function markImages(ctx: ChartContext, kind: Kind, o: LogoMarkProps | HeadshotMarkProps): MarkImage[];
89
+ /** The surface code (sdvplot's surfaces, sporty's SVG writer) and layerchart, imported when a backdrop first renders. */
90
+ interface SurfaceKit {
91
+ lc: LayerChart;
92
+ scene(league: League, o: SurfaceSceneOptions): {
93
+ bbox: readonly [number, number, number, number];
94
+ };
95
+ toSVG(scene: never, o: {
96
+ width: number;
97
+ height: number;
98
+ }): string;
99
+ }
100
+ declare function loadSurfaceKit(): Promise<SurfaceKit>;
101
+ /**
102
+ * The backdrop's SVG over the plot area: the scene's bbox mapped through the chart's scales, so the surface's units
103
+ * land on the axes'. A scale that is not numeric, reversed or not linear draws nothing (one warning): a mirrored or
104
+ * stretched court would mislead.
105
+ */
106
+ declare function surfaceMarkup(ctx: ChartContext, kit: SurfaceKit, scene: ReturnType<SurfaceKit["scene"]>): string | null;
107
+ /** `teamColorPalette` options. */
108
+ interface TeamColorPaletteOptions {
109
+ which?: Which;
110
+ season?: SeasonInput;
111
+ idSystem?: IdSystem;
112
+ /** The colour of an unresolved team. Default "#808080". */
113
+ fallback?: string;
114
+ /**
115
+ * The chart's background. Given, a team colour under 3:1 contrast against it is swapped for the team's other
116
+ * colour, else moved towards white (on a dark background) or black (a light one) until it reads: dark mode. A
117
+ * colour that would then sit too close to an earlier team's (CIE76 ΔE under 20) takes the team's other colour, or
118
+ * the nearest colour to its own (lightness, hue or chroma stepped) that is distinct and still reads; failing that it
119
+ * is kept, with one warning.
120
+ */
121
+ background?: string;
122
+ }
123
+ /**
124
+ * One colour per team, in order: a LayerChart series' `color`, a `<Spline stroke>`, or the chart's `cRange`. With
125
+ * `background`, every colour keeps 3:1 contrast against it (dark mode) and aims to stay distinct from the others (when
126
+ * it cannot, it keeps the readable colour and warns once).
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { loadLeague } from "@sportsdataverse/sdvplot";
131
+ * import { teamColorPalette } from "@sportsdataverse/sdvplot/svelte";
132
+ *
133
+ * await loadLeague("nfl");
134
+ * teamColorPalette("nfl", ["KC", "LAC", "DEN", "LV"], { background: "#181a1b" });
135
+ * ```
136
+ */
137
+ declare function teamColorPalette(league: League, teams: readonly unknown[], o?: TeamColorPaletteOptions): string[];
138
+
139
+ export { type ChartContext, type ChartScale, type HeadshotMarkProps, type LayerChart, type LogoMarkProps, type MarkImage, Row, type SurfaceBackdropProps, type SurfaceKit, type TeamColorPaletteOptions, loadLayerChart, loadSurfaceKit, markImages, raise, surfaceMarkup, teamColorPalette };
@@ -0,0 +1,123 @@
1
+ import { markPlacements, aspect, imageSource, colorPalette } from './chunk-UL5M6KDE.js';
2
+ export { embedSources } from './chunk-UL5M6KDE.js';
3
+ import { checkHeight, checkAlpha, placedName } from './chunk-7ULOCCFL.js';
4
+ import './chunk-ZAEQXFJM.js';
5
+ import './chunk-J6R2LEJ7.js';
6
+ import { warn, OptionalDependencyError } from './chunk-E7G7VSLV.js';
7
+
8
+ // src/svelte-core.ts
9
+ var missing = (component, peer, e) => new OptionalDependencyError(
10
+ `${component} needs the optional peer ${peer}, which could not be loaded: pnpm add ${peer}`,
11
+ { cause: e }
12
+ );
13
+ var layerchart;
14
+ function loadLayerChart(component) {
15
+ layerchart ??= import('layerchart');
16
+ return layerchart.catch((e) => {
17
+ layerchart = void 0;
18
+ throw missing(component, "layerchart", e);
19
+ });
20
+ }
21
+ function raise(e) {
22
+ throw e;
23
+ }
24
+ var finite = (v) => typeof v === "number" && Number.isFinite(v);
25
+ function pixel(scale, v) {
26
+ const at = scale(v);
27
+ return finite(at) ? at + (scale.bandwidth?.() ?? 0) / 2 : void 0;
28
+ }
29
+ var stamp = (v) => String(v instanceof Date ? v.getTime() : v);
30
+ function markImages(ctx, kind, o) {
31
+ const h = checkHeight(o.height ?? 0.1);
32
+ const alpha = checkAlpha(o.alpha ?? 1);
33
+ const rows = o.data ?? (Array.isArray(ctx.data) ? ctx.data : []);
34
+ if (!(ctx.height > 0)) return [];
35
+ const size = h * ctx.height;
36
+ const ps = markPlacements(rows, kind, o);
37
+ const raw = kind === "headshot" ? o.player : o.team;
38
+ return ps.flatMap((p) => {
39
+ const cx = pixel(ctx.xScale, p.x);
40
+ const cy = pixel(ctx.yScale, p.y);
41
+ if (cx === void 0 || cy === void 0) return [];
42
+ const w = size * aspect(p);
43
+ return [
44
+ {
45
+ key: `${p.index}:${p.id}`,
46
+ attrs: {
47
+ href: imageSource(p, o.embed),
48
+ x: cx - w / 2,
49
+ y: cy - size / 2,
50
+ width: w,
51
+ height: size,
52
+ preserveAspectRatio: "xMidYMid meet",
53
+ ...alpha === 1 ? {} : { opacity: alpha },
54
+ role: "img",
55
+ "aria-label": `${placedName(p, o.league, rows[p.index]?.[raw])} ${kind}`,
56
+ "data-sdv-id": p.id,
57
+ "data-sdv-kind": kind,
58
+ "data-sdv-x": stamp(p.x),
59
+ "data-sdv-y": stamp(p.y),
60
+ "data-sdv-frame": ctx.height
61
+ }
62
+ }
63
+ ];
64
+ });
65
+ }
66
+ async function loadSurfaceKit() {
67
+ const [lc, surfaces, svg] = await Promise.all([
68
+ loadLayerChart("SurfaceBackdrop"),
69
+ import('./surfaces-MIG7HOFU.js').catch((e) => {
70
+ throw missing("SurfaceBackdrop", "@sportsdataverse/sporty", e);
71
+ }),
72
+ import('@sportsdataverse/sporty/svg').catch((e) => {
73
+ throw missing("SurfaceBackdrop", "@sportsdataverse/sporty", e);
74
+ })
75
+ ]);
76
+ return {
77
+ lc,
78
+ scene: surfaces.surfaceScene,
79
+ toSVG: svg.toSVG
80
+ };
81
+ }
82
+ function surfaceMarkup(ctx, kit, scene) {
83
+ if (!(ctx.width > 0 && ctx.height > 0)) return null;
84
+ const [sx, sy] = [ctx.xScale, ctx.yScale];
85
+ const numeric = (s) => s.bandwidth === void 0 && s.domain().every(finite);
86
+ if (!numeric(sx) || !numeric(sy)) {
87
+ warn(
88
+ "svelte:SurfaceBackdrop:domain",
89
+ "SurfaceBackdrop draws nothing: both scales must be numeric (linear), in the surface's units"
90
+ );
91
+ return null;
92
+ }
93
+ const linear = (s, dir) => {
94
+ const [d0, d1] = s.domain();
95
+ const [a, m, b] = [d0, (d0 + d1) / 2, d1].map((v) => Number(s(v)));
96
+ return dir * (b - a) * Math.sign(d1 - d0) > 0 && Math.abs(m - (a + b) / 2) < 0.5;
97
+ };
98
+ if (!linear(sx, 1) || !linear(sy, -1)) {
99
+ warn(
100
+ "svelte:SurfaceBackdrop:scale",
101
+ "SurfaceBackdrop draws nothing on a reversed or log scale: use linear, unreversed scales"
102
+ );
103
+ return null;
104
+ }
105
+ const [x0, y0, x1, y1] = scene.bbox;
106
+ const [left, right, top, bottom] = [sx(x0), sx(x1), sy(y1), sy(y0)].map(Number);
107
+ const [width, height] = [right - left, bottom - top];
108
+ if (!(width > 0 && height > 0)) {
109
+ warn(
110
+ "svelte:SurfaceBackdrop:empty",
111
+ `SurfaceBackdrop draws nothing: the surface spans ${width} x ${height} px`
112
+ );
113
+ return null;
114
+ }
115
+ return kit.toSVG(scene, { width, height }).replace("<svg ", `<svg x="${left}" y="${top}" preserveAspectRatio="none" `);
116
+ }
117
+ function teamColorPalette(league, teams, o = {}) {
118
+ return colorPalette(league, teams, o);
119
+ }
120
+
121
+ export { loadLayerChart, loadSurfaceKit, markImages, raise, surfaceMarkup, teamColorPalette };
122
+ //# sourceMappingURL=svelte-core.js.map
123
+ //# sourceMappingURL=svelte-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/svelte-core.ts"],"names":[],"mappings":";;;;;;;;AAiFA,IAAM,OAAA,GAAU,CAAC,SAAA,EAAmB,IAAA,EAAc,MAChD,IAAI,uBAAA;AAAA,EACF,CAAA,EAAG,SAAS,CAAA,yBAAA,EAA4B,IAAI,yCAAyC,IAAI,CAAA,CAAA;AAAA,EACz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G,GAAG,EAAE,CAAC,CAAA,CAAE,GAAA,CAAI,MAAM,CAAA;AAM9E,EAAA,MAAM,CAAC,OAAO,MAAM,CAAA,GAAI,CAAC,KAAA,GAAQ,IAAA,EAAM,SAAS,GAAG,CAAA;AACnD,EAAA,IAAI,EAAE,KAAA,GAAQ,CAAA,IAAK,MAAA,GAAS,CAAA,CAAA,EAAI;AAC9B,IAAA,IAAA;AAAA,MACE,8BAAA;AAAA,MACA,CAAA,iDAAA,EAAoD,KAAK,CAAA,GAAA,EAAM,MAAM,CAAA,GAAA;AAAA,KACvE;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,OAAO,GAAA,CACJ,KAAA,CAAM,KAAA,EAAgB,EAAE,OAAO,MAAA,EAAQ,CAAA,CACvC,OAAA,CAAQ,OAAA,EAAS,CAAA,QAAA,EAAW,IAAI,CAAA,KAAA,EAAQ,GAAG,CAAA,6BAAA,CAA+B,CAAA;AAC/E;AAgCO,SAAS,gBAAA,CACd,MAAA,EACA,KAAA,EACA,CAAA,GAA6B,EAAC,EACpB;AACV,EAAA,OAAO,YAAA,CAAa,MAAA,EAAQ,KAAA,EAAO,CAAC,CAAA;AACtC","file":"svelte-core.js","sourcesContent":["/**\n * What the `sdvplot/svelte` components compute, as plain TypeScript (tsup builds it to dist/svelte-core.js, which the\n * components built by svelte-package import as ../svelte-core.js). Internal: not a package subpath; `sdvplot/svelte`\n * re-exports the public part. layerchart, sporty and the surface code are imported here only, and only lazily.\n */\nimport {\n type HeadshotOptions,\n type MarkOptions,\n type Row,\n aspect,\n colorPalette,\n imageSource,\n markPlacements,\n} from \"./_web.js\";\nimport { OptionalDependencyError, warn } from \"./errors.js\";\nimport { type Kind, type Placement, checkAlpha, checkHeight, placedName } from \"./placement.js\";\nimport type { SurfaceSceneOptions } from \"./surfaces.js\";\nimport type { IdSystem, League, MarkType, SeasonInput, Which } from \"./types.js\";\nexport type { Row } from \"./_web.js\";\nexport { embedSources } from \"./_web.js\"; // public via sdvplot/svelte: build `embed` with it, as for the other adapters\n\n/** `<LogoMark>` props: the shared mark options (`x`, `y`, `team`, `league`, `height` a fraction of the plot height,\n * ...) plus the rows to mark and the mark type. */\nexport interface LogoMarkProps extends MarkOptions {\n /** The rows to mark. Default: the chart's own `data`. */\n data?: readonly Row[];\n /** \"logo\" (default) or \"wordmark\". */\n markType?: MarkType;\n}\n/** `<HeadshotMark>` props: the shared headshot options (`x`, `y`, `player`, `league`, `height`, ...) plus the rows. */\nexport interface HeadshotMarkProps extends HeadshotOptions {\n /** The rows to mark. Default: the chart's own `data`. */\n data?: readonly Row[];\n}\n/**\n * `<SurfaceBackdrop>` props: the league whose surface to draw and how to paint it (the options of sdvplot's other\n * `surface` functions). The sporty-specific options are typed loosely, so these types never name\n * `@sportsdataverse/sporty` (an optional peer); sporty checks them when the surface is built.\n */\nexport interface SurfaceBackdropProps {\n /** The league whose court, field or rink to draw, e.g. \"nba\". */\n league: League;\n /** The team whose colours paint the surface. */\n team?: string | number;\n /** The season the team's colours are taken from. */\n season?: SeasonInput;\n /** Overrides on top of the team painting, keyed by sporty colour key (e.g. `{ painted_area: \"#0e2240\" }`). */\n colorUpdates?: Readonly<Record<string, string>>;\n /** Degrees to rotate the surface by. */\n rotation?: number;\n /** A sporty display range for the league's sport, e.g. \"defense\"; one the sport does not know throws. */\n displayRange?: string;\n xlim?: readonly [number, number];\n ylim?: readonly [number, number];\n units?: \"ft\" | \"m\" | \"yd\" | \"in\" | \"cm\" | \"mm\";\n /** Sporty parameter overrides for the league's surface. */\n updates?: Readonly<Record<string, unknown>>;\n arcResolution?: number;\n xTrans?: number;\n yTrans?: number;\n}\n\n/** A LayerChart scale: what the marks call (a d3 scale; a band scale has a bandwidth). */\nexport interface ChartScale {\n (v: unknown): unknown;\n domain(): unknown[];\n bandwidth?: () => number;\n}\n/** The part of LayerChart's chart context the components read: the scales, the plot area's size and the data. */\nexport interface ChartContext {\n xScale: ChartScale;\n yScale: ChartScale;\n width: number;\n height: number;\n data?: unknown;\n}\n/** The part of the layerchart module the components use. */\nexport interface LayerChart {\n getChartContext(): ChartContext;\n}\n\nconst missing = (component: string, peer: string, e: unknown): OptionalDependencyError =>\n new OptionalDependencyError(\n `${component} needs the optional peer ${peer}, which could not be loaded: pnpm add ${peer}`,\n { cause: e },\n );\nlet layerchart: Promise<LayerChart> | undefined;\n/** layerchart, imported on first use (never with `sdvplot/svelte`); a missing peer rejects with an install message. */\nexport function loadLayerChart(component: string): Promise<LayerChart> {\n layerchart ??= import(\"layerchart\") as Promise<LayerChart>;\n return layerchart.catch((e: unknown) => {\n layerchart = undefined; // installed later (a dev server): the next render tries again\n throw missing(component, \"layerchart\", e);\n });\n}\n/** Throws `e`: a component rethrows a failed import from its template (an effect), so a `<svelte:boundary>` catches\n * it (an error thrown from a promise callback would bypass the boundary). */\nexport function raise(e: unknown): never {\n throw e;\n}\n\n/** An `<image>` to draw: its attributes, including the `data-sdv-*` stamps `sdvplot/testing`'s `drawnMarks` reads. */\nexport interface MarkImage {\n key: string;\n attrs: Record<string, string | number>;\n}\nconst finite = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v);\n/** A value's pixel on a scale: the middle of its band on a band scale. undefined off the scale. */\nfunction pixel(scale: ChartScale, v: unknown): number | undefined {\n const at = scale(v);\n return finite(at) ? at + (scale.bandwidth?.() ?? 0) / 2 : undefined;\n}\n/** A data value as the `data-sdv-x/y` text drawnMarks reads back: a Date as its time in ms (as sdvplot/plot). */\nconst stamp = (v: unknown): string => String(v instanceof Date ? v.getTime() : v);\n\n/**\n * The images a mark component draws in the chart `ctx`: one per row whose team (or player) has an image, centred on\n * the row's scaled (x, y), `height` of the plot area tall. A row with no image is skipped with one warning (placeSync),\n * as `sdvplot/echarts` does. Nothing is drawn before the chart has a size.\n */\nexport function markImages(ctx: ChartContext, kind: Kind, o: LogoMarkProps | HeadshotMarkProps): MarkImage[] {\n const h = checkHeight(o.height ?? 0.1);\n const alpha = checkAlpha(o.alpha ?? 1);\n const rows = o.data ?? (Array.isArray(ctx.data) ? (ctx.data as Row[]) : []);\n if (!(ctx.height > 0)) return [];\n const size = h * ctx.height;\n const ps: Placement[] = markPlacements(rows, kind, o);\n const raw = kind === \"headshot\" ? (o as HeadshotMarkProps).player : (o as LogoMarkProps).team;\n return ps.flatMap((p) => {\n const cx = pixel(ctx.xScale, p.x);\n const cy = pixel(ctx.yScale, p.y);\n if (cx === undefined || cy === undefined) return [];\n const w = size * aspect(p);\n return [\n {\n key: `${p.index}:${p.id}`,\n attrs: {\n href: imageSource(p, o.embed),\n x: cx - w / 2,\n y: cy - size / 2,\n width: w,\n height: size,\n preserveAspectRatio: \"xMidYMid meet\",\n ...(alpha === 1 ? {} : { opacity: alpha }),\n role: \"img\",\n \"aria-label\": `${placedName(p, o.league, rows[p.index]?.[raw])} ${kind}`,\n \"data-sdv-id\": p.id,\n \"data-sdv-kind\": kind,\n \"data-sdv-x\": stamp(p.x),\n \"data-sdv-y\": stamp(p.y),\n \"data-sdv-frame\": ctx.height,\n },\n },\n ];\n });\n}\n\n/** The surface code (sdvplot's surfaces, sporty's SVG writer) and layerchart, imported when a backdrop first renders. */\nexport interface SurfaceKit {\n lc: LayerChart;\n scene(league: League, o: SurfaceSceneOptions): { bbox: readonly [number, number, number, number] };\n toSVG(scene: never, o: { width: number; height: number }): string;\n}\nexport async function loadSurfaceKit(): Promise<SurfaceKit> {\n const [lc, surfaces, svg] = await Promise.all([\n loadLayerChart(\"SurfaceBackdrop\"),\n import(\"./surfaces.js\").catch((e: unknown) => {\n throw missing(\"SurfaceBackdrop\", \"@sportsdataverse/sporty\", e);\n }),\n import(\"@sportsdataverse/sporty/svg\").catch((e: unknown) => {\n throw missing(\"SurfaceBackdrop\", \"@sportsdataverse/sporty\", e);\n }),\n ]);\n return {\n lc,\n scene: surfaces.surfaceScene,\n toSVG: svg.toSVG as unknown as SurfaceKit[\"toSVG\"],\n };\n}\n\n/**\n * The backdrop's SVG over the plot area: the scene's bbox mapped through the chart's scales, so the surface's units\n * land on the axes'. A scale that is not numeric, reversed or not linear draws nothing (one warning): a mirrored or\n * stretched court would mislead.\n */\nexport function surfaceMarkup(\n ctx: ChartContext,\n kit: SurfaceKit,\n scene: ReturnType<SurfaceKit[\"scene\"]>,\n): string | null {\n if (!(ctx.width > 0 && ctx.height > 0)) return null;\n const [sx, sy] = [ctx.xScale, ctx.yScale];\n const numeric = (s: ChartScale): boolean => s.bandwidth === undefined && s.domain().every(finite);\n if (!numeric(sx) || !numeric(sy)) {\n warn(\n \"svelte:SurfaceBackdrop:domain\",\n \"SurfaceBackdrop draws nothing: both scales must be numeric (linear), in the surface's units\",\n );\n return null;\n }\n // x grows left to right and y bottom to top in pixels, each linearly: its midpoint lands half way\n const linear = (s: ChartScale, dir: 1 | -1): boolean => {\n const [d0, d1] = s.domain() as [number, number];\n const [a, m, b] = [d0, (d0 + d1) / 2, d1].map((v) => Number(s(v))) as [number, number, number];\n return dir * (b - a) * Math.sign(d1 - d0) > 0 && Math.abs(m - (a + b) / 2) < 0.5;\n };\n if (!linear(sx, 1) || !linear(sy, -1)) {\n warn(\n \"svelte:SurfaceBackdrop:scale\",\n \"SurfaceBackdrop draws nothing on a reversed or log scale: use linear, unreversed scales\",\n );\n return null;\n }\n const [x0, y0, x1, y1] = scene.bbox;\n const [left, right, top, bottom] = [sx(x0), sx(x1), sy(y1), sy(y0)].map(Number) as [\n number,\n number,\n number,\n number,\n ];\n const [width, height] = [right - left, bottom - top];\n if (!(width > 0 && height > 0)) {\n warn(\n \"svelte:SurfaceBackdrop:empty\",\n `SurfaceBackdrop draws nothing: the surface spans ${width} x ${height} px`,\n );\n return null;\n }\n // toSVG maps the scene's bbox onto its own viewport; placed and stretched over the bbox's pixel rectangle, the\n // surface's units land on the scales' (strokes stay 1 px: non-scaling)\n return kit\n .toSVG(scene as never, { width, height })\n .replace(\"<svg \", `<svg x=\"${left}\" y=\"${top}\" preserveAspectRatio=\"none\" `);\n}\n\n/** `teamColorPalette` options. */\nexport interface TeamColorPaletteOptions {\n which?: Which;\n season?: SeasonInput;\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 (lightness, hue or chroma stepped) that is distinct and still reads; failing that it\n * is kept, with one warning.\n */\n background?: string;\n}\n/**\n * One colour per team, in order: a LayerChart series' `color`, a `<Spline stroke>`, or the chart's `cRange`. With\n * `background`, every colour keeps 3:1 contrast against it (dark mode) and aims to stay distinct from the others (when\n * it cannot, it keeps the readable colour and warns once).\n *\n * @example\n * ```ts\n * import { loadLeague } from \"@sportsdataverse/sdvplot\";\n * import { teamColorPalette } from \"@sportsdataverse/sdvplot/svelte\";\n *\n * await loadLeague(\"nfl\");\n * teamColorPalette(\"nfl\", [\"KC\", \"LAC\", \"DEN\", \"LV\"], { background: \"#181a1b\" });\n * ```\n */\nexport function teamColorPalette(\n league: League,\n teams: readonly unknown[],\n o: TeamColorPaletteOptions = {},\n): string[] {\n return colorPalette(league, teams, o);\n}\n"]}