@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.
- package/LICENSE +21 -0
- package/NOTICE.md +109 -0
- package/README.md +984 -2
- package/dist/_web-D7Aa5Rd8.d.ts +69 -0
- package/dist/aaf-GJ3SH34T.js +13 -0
- package/dist/aaf-HCYN5T6Y.js +37 -0
- package/dist/aaf-ZAE5KS2Y.js +13 -0
- package/dist/ahl-E66MDVCU.js +66 -0
- package/dist/ahl-NPQQWZEV.js +249 -0
- package/dist/ahl-QRDU73XX.js +309 -0
- package/dist/axis-CraWQRUJ.d.ts +49 -0
- package/dist/bins.d.ts +174 -0
- package/dist/bins.js +4 -0
- package/dist/bins.js.map +1 -0
- package/dist/cfb-F42SVS4X.js +5000 -0
- package/dist/cfb-P3SHEYRZ.js +692 -0
- package/dist/cfb-WXRZANLP.js +10226 -0
- package/dist/chartjs-surface.d.ts +42 -0
- package/dist/chartjs-surface.js +65 -0
- package/dist/chartjs-surface.js.map +1 -0
- package/dist/chartjs.d.ts +162 -0
- package/dist/chartjs.js +342 -0
- package/dist/chartjs.js.map +1 -0
- package/dist/chunk-4C3GX6QO.js +92 -0
- package/dist/chunk-4C3GX6QO.js.map +1 -0
- package/dist/chunk-57WFSI4Q.js +128 -0
- package/dist/chunk-57WFSI4Q.js.map +1 -0
- package/dist/chunk-7ULOCCFL.js +313 -0
- package/dist/chunk-7ULOCCFL.js.map +1 -0
- package/dist/chunk-AMXASQHT.js +120 -0
- package/dist/chunk-AMXASQHT.js.map +1 -0
- package/dist/chunk-B2MP37SR.js +175 -0
- package/dist/chunk-B2MP37SR.js.map +1 -0
- package/dist/chunk-C2CDY5OG.js +137 -0
- package/dist/chunk-C2CDY5OG.js.map +1 -0
- package/dist/chunk-DYMUVE6K.js +127 -0
- package/dist/chunk-DYMUVE6K.js.map +1 -0
- package/dist/chunk-E7G7VSLV.js +43 -0
- package/dist/chunk-E7G7VSLV.js.map +1 -0
- package/dist/chunk-H2C3FMMA.js +300 -0
- package/dist/chunk-H2C3FMMA.js.map +1 -0
- package/dist/chunk-J4P4HDBF.js +175 -0
- package/dist/chunk-J4P4HDBF.js.map +1 -0
- package/dist/chunk-J6R2LEJ7.js +58 -0
- package/dist/chunk-J6R2LEJ7.js.map +1 -0
- package/dist/chunk-M3XD2OSN.js +132 -0
- package/dist/chunk-M3XD2OSN.js.map +1 -0
- package/dist/chunk-OIILARXI.js +30 -0
- package/dist/chunk-OIILARXI.js.map +1 -0
- package/dist/chunk-RPVVJY74.js +170 -0
- package/dist/chunk-RPVVJY74.js.map +1 -0
- package/dist/chunk-UL5M6KDE.js +205 -0
- package/dist/chunk-UL5M6KDE.js.map +1 -0
- package/dist/chunk-WQT4IVLX.js +10 -0
- package/dist/chunk-WQT4IVLX.js.map +1 -0
- package/dist/chunk-ZAEQXFJM.js +556 -0
- package/dist/chunk-ZAEQXFJM.js.map +1 -0
- package/dist/cricket-KPCYG2HL.js +493 -0
- package/dist/cricket-NDXLE25B.js +116 -0
- package/dist/cricket-YUUF7P6M.js +160 -0
- package/dist/cytoscape.d.ts +188 -0
- package/dist/cytoscape.js +219 -0
- package/dist/cytoscape.js.map +1 -0
- package/dist/d3.d.ts +234 -0
- package/dist/d3.js +198 -0
- package/dist/d3.js.map +1 -0
- package/dist/deckgl.d.ts +232 -0
- package/dist/deckgl.js +197 -0
- package/dist/deckgl.js.map +1 -0
- package/dist/echarts.d.ts +121 -0
- package/dist/echarts.js +228 -0
- package/dist/echarts.js.map +1 -0
- package/dist/echl-3CR4RGFC.js +241 -0
- package/dist/echl-NPC32C23.js +107 -0
- package/dist/echl-PI33DGJC.js +64 -0
- package/dist/export.d.ts +130 -0
- package/dist/export.js +258 -0
- package/dist/export.js.map +1 -0
- package/dist/g2.d.ts +251 -0
- package/dist/g2.js +102 -0
- package/dist/g2.js.map +1 -0
- package/dist/headshots-B2J_LOO8.d.ts +40 -0
- package/dist/index.d.ts +183 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/interact.d.ts +567 -0
- package/dist/interact.js +809 -0
- package/dist/interact.js.map +1 -0
- package/dist/lightweight-charts.d.ts +217 -0
- package/dist/lightweight-charts.js +155 -0
- package/dist/lightweight-charts.js.map +1 -0
- package/dist/maplibre.d.ts +271 -0
- package/dist/maplibre.js +175 -0
- package/dist/maplibre.js.map +1 -0
- package/dist/marks-DH-tQIP-.d.ts +75 -0
- package/dist/mbb-3TRLVW3H.js +3619 -0
- package/dist/mbb-DQUHCHZP.js +5111 -0
- package/dist/mbb-PRAIO2P5.js +371 -0
- package/dist/milb-6IQ6NCEW.js +291 -0
- package/dist/milb-EYY5MD4T.js +1752 -0
- package/dist/milb-EYZ4SZLI.js +797 -0
- package/dist/mlb-4PBUJSVQ.js +35 -0
- package/dist/mlb-FHPY3GQJ.js +701 -0
- package/dist/mlb-REVGL3N2.js +665 -0
- package/dist/mui.d.ts +338 -0
- package/dist/mui.js +184 -0
- package/dist/mui.js.map +1 -0
- package/dist/nba-ATT775GS.js +485 -0
- package/dist/nba-LKM4UHVU.js +482 -0
- package/dist/nba-YX7PXM3R.js +35 -0
- package/dist/nbagl-3WGZCZ4S.js +37 -0
- package/dist/nbagl-LP4XJRAL.js +229 -0
- package/dist/nbagl-VTTOU7LN.js +499 -0
- package/dist/ncaa_baseball-UV75LNVR.js +2670 -0
- package/dist/ncaa_baseball-VD5J5C72.js +419 -0
- package/dist/ncaa_baseball-YRBS32D6.js +4592 -0
- package/dist/ncaa_mhockey-IMYHS7QS.js +1033 -0
- package/dist/ncaa_mhockey-TXTKWHE3.js +115 -0
- package/dist/ncaa_mhockey-U3MFW5VT.js +663 -0
- package/dist/ncaa_softball-6WR6KS64.js +420 -0
- package/dist/ncaa_softball-RZCTIE56.js +2654 -0
- package/dist/ncaa_softball-VOD4PVGY.js +4599 -0
- package/dist/ncaa_whockey-6XXGUTBK.js +607 -0
- package/dist/ncaa_whockey-AKKYKY67.js +53 -0
- package/dist/ncaa_whockey-KBEKXFBB.js +293 -0
- package/dist/nfl-BDB2HYAR.js +625 -0
- package/dist/nfl-EHYHDLJD.js +37 -0
- package/dist/nfl-VF4NJCHY.js +514 -0
- package/dist/nfl_gsis-UY64JO37.js +4 -0
- package/dist/nhl-6WPHME7H.js +511 -0
- package/dist/nhl-EMIJFZHY.js +884 -0
- package/dist/nhl-ISFUKRFU.js +37 -0
- package/dist/nivo.d.ts +193 -0
- package/dist/nivo.js +8 -0
- package/dist/nivo.js.map +1 -0
- package/dist/ohl-2FEM554G.js +113 -0
- package/dist/ohl-C5Q4W6JB.js +32 -0
- package/dist/ohl-TQ4J46VC.js +66 -0
- package/dist/perspective.d.ts +198 -0
- package/dist/perspective.js +171 -0
- package/dist/perspective.js.map +1 -0
- package/dist/phf-H7POU2KW.js +32 -0
- package/dist/phf-K5IFMZUM.js +13 -0
- package/dist/phf-TWJI3BOW.js +20 -0
- package/dist/placement-UWkqUzpa.d.ts +32 -0
- package/dist/plot.d.ts +451 -0
- package/dist/plot.js +712 -0
- package/dist/plot.js.map +1 -0
- package/dist/plotly.d.ts +129 -0
- package/dist/plotly.js +360 -0
- package/dist/plotly.js.map +1 -0
- package/dist/pwhl-OX3BO4JI.js +53 -0
- package/dist/pwhl-W44OC3C6.js +17 -0
- package/dist/pwhl-ZJGG3H7W.js +23 -0
- package/dist/qmjhl-5HISEHLL.js +35 -0
- package/dist/qmjhl-DA3UHKE5.js +125 -0
- package/dist/qmjhl-YG4BOQPF.js +614 -0
- package/dist/react.d.ts +377 -0
- package/dist/react.js +522 -0
- package/dist/react.js.map +1 -0
- package/dist/recharts.d.ts +162 -0
- package/dist/recharts.js +8 -0
- package/dist/recharts.js.map +1 -0
- package/dist/resolve-CQW-jzvr.d.ts +28 -0
- package/dist/selection-D4T3PkRt.d.ts +140 -0
- package/dist/shadcn.d.ts +83 -0
- package/dist/shadcn.js +88 -0
- package/dist/shadcn.js.map +1 -0
- package/dist/shots.d.ts +364 -0
- package/dist/shots.js +86 -0
- package/dist/shots.js.map +1 -0
- package/dist/soccer-7BH3ZLVL.js +7898 -0
- package/dist/soccer-MRU25OGE.js +2636 -0
- package/dist/soccer-PF4IPPVA.js +12342 -0
- package/dist/surface-TR7YFJW3.js +4 -0
- package/dist/surface-TR7YFJW3.js.map +1 -0
- package/dist/surfaces-MIG7HOFU.js +6 -0
- package/dist/surfaces-MIG7HOFU.js.map +1 -0
- package/dist/surfaces-W-odWLpT.d.ts +47 -0
- package/dist/svelte/HeadshotMark.svelte +25 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts +10 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts.map +1 -0
- package/dist/svelte/LogoMark.svelte +25 -0
- package/dist/svelte/LogoMark.svelte.d.ts +10 -0
- package/dist/svelte/LogoMark.svelte.d.ts.map +1 -0
- package/dist/svelte/Marks.svelte +25 -0
- package/dist/svelte/Marks.svelte.d.ts +10 -0
- package/dist/svelte/Marks.svelte.d.ts.map +1 -0
- package/dist/svelte/Surface.svelte +29 -0
- package/dist/svelte/Surface.svelte.d.ts +9 -0
- package/dist/svelte/Surface.svelte.d.ts.map +1 -0
- package/dist/svelte/SurfaceBackdrop.svelte +26 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts +11 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts.map +1 -0
- package/dist/svelte/index.d.ts +13 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +11 -0
- package/dist/svelte-core.d.ts +139 -0
- package/dist/svelte-core.js +123 -0
- package/dist/svelte-core.js.map +1 -0
- package/dist/tanstack.d.ts +240 -0
- package/dist/tanstack.js +110 -0
- package/dist/tanstack.js.map +1 -0
- package/dist/testing.d.ts +75 -0
- package/dist/testing.js +239 -0
- package/dist/testing.js.map +1 -0
- package/dist/three.d.ts +223 -0
- package/dist/three.js +50 -0
- package/dist/three.js.map +1 -0
- package/dist/tiers-BN4md-GB.d.ts +65 -0
- package/dist/types-C7n6gJF3.d.ts +62 -0
- package/dist/ufl-7VLZTLTT.js +143 -0
- package/dist/ufl-CCMBLPSW.js +100 -0
- package/dist/ufl-F2BJRXME.js +16 -0
- package/dist/unovis.d.ts +127 -0
- package/dist/unovis.js +108 -0
- package/dist/unovis.js.map +1 -0
- package/dist/uplot.d.ts +120 -0
- package/dist/uplot.js +110 -0
- package/dist/uplot.js.map +1 -0
- package/dist/usfl-4CR5RMZJ.js +32 -0
- package/dist/usfl-LD7HP2YK.js +14 -0
- package/dist/usfl-VU4YSJQD.js +19 -0
- package/dist/ushl-CPG2LB4L.js +73 -0
- package/dist/ushl-PQL6HJAD.js +88 -0
- package/dist/ushl-ZT2ATPHK.js +22 -0
- package/dist/vega.d.ts +85 -0
- package/dist/vega.js +362 -0
- package/dist/vega.js.map +1 -0
- package/dist/victory.d.ts +107 -0
- package/dist/victory.js +38 -0
- package/dist/victory.js.map +1 -0
- package/dist/wbb-3KHCDYTK.js +5087 -0
- package/dist/wbb-BMX53Q3Q.js +369 -0
- package/dist/wbb-QNRN2CJJ.js +3620 -0
- package/dist/whl-4ATYZWUB.js +97 -0
- package/dist/whl-RVFPL6MH.js +79 -0
- package/dist/whl-Y7ASKYMM.js +28 -0
- package/dist/wnba-FWX5SFVI.js +232 -0
- package/dist/wnba-GX6HZR4B.js +220 -0
- package/dist/wnba-NTMWIPP6.js +20 -0
- package/dist/xfl-43R2JMJK.js +30 -0
- package/dist/xfl-H3BXQPZZ.js +16 -0
- package/dist/xfl-XON7A7FI.js +69 -0
- package/package.json +366 -3
package/dist/react.js
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { logoLayer, teamColors } from './chunk-RPVVJY74.js';
|
|
3
|
+
import { trajectoryTube } from './chunk-AMXASQHT.js';
|
|
4
|
+
import { aspect, seasons, imageSource } from './chunk-UL5M6KDE.js';
|
|
5
|
+
import { checkAlpha, logoUrlSync, placeSync, placedName } from './chunk-7ULOCCFL.js';
|
|
6
|
+
import { loadLeague, resolveSync, getLeagueSync, loadGsis, headshotUrl, palette, HEADSHOT_ASPECT, checkLeague } from './chunk-ZAEQXFJM.js';
|
|
7
|
+
import './chunk-J6R2LEJ7.js';
|
|
8
|
+
import { OptionalDependencyError, warn, UnsupportedTargetError, InputError } from './chunk-E7G7VSLV.js';
|
|
9
|
+
import { lazy, useId, useMemo, createElement, useEffect, Suspense, useState, useRef, useSyncExternalStore, useLayoutEffect } from 'react';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
var missing = (peer, e) => new OptionalDependencyError(
|
|
13
|
+
`SurfaceBackdrop needs the optional peer ${peer}, which could not be loaded: pnpm add ${peer}`,
|
|
14
|
+
{ cause: e }
|
|
15
|
+
);
|
|
16
|
+
var numeric = (d) => d !== void 0 && d.length === 2 && d.every((v) => typeof v === "number" && Number.isFinite(v)) && d[1] !== d[0];
|
|
17
|
+
function linear(scale, d0, d1, dir) {
|
|
18
|
+
if (scale === void 0) return true;
|
|
19
|
+
const [a, m, b] = [d0, (d0 + d1) / 2, d1].map((v) => Number(scale(v)));
|
|
20
|
+
if (![a, m, b].every((v) => Number.isFinite(v))) return true;
|
|
21
|
+
return dir * (b - a) > 0 && Math.abs(m - (a + b) / 2) < 0.5;
|
|
22
|
+
}
|
|
23
|
+
var Backdrop = lazy(async () => {
|
|
24
|
+
const [rc, surfaces, svg] = await Promise.all([
|
|
25
|
+
import('recharts').catch((e) => {
|
|
26
|
+
throw missing("recharts", e);
|
|
27
|
+
}),
|
|
28
|
+
import('./surfaces-MIG7HOFU.js').catch((e) => {
|
|
29
|
+
throw missing("@sportsdataverse/sporty", e);
|
|
30
|
+
}),
|
|
31
|
+
import('@sportsdataverse/sporty/svg').catch((e) => {
|
|
32
|
+
throw missing("@sportsdataverse/sporty", e);
|
|
33
|
+
})
|
|
34
|
+
]);
|
|
35
|
+
const noScale = () => void 0;
|
|
36
|
+
const useXScale = rc.useXAxisScale ?? noScale;
|
|
37
|
+
const useYScale = rc.useYAxisScale ?? noScale;
|
|
38
|
+
function Drawn({ league, xAxisId, yAxisId, ...o }) {
|
|
39
|
+
const area = rc.usePlotArea();
|
|
40
|
+
const xd = rc.useXAxisDomain(xAxisId);
|
|
41
|
+
const yd = rc.useYAxisDomain(yAxisId);
|
|
42
|
+
const sx = useXScale(xAxisId);
|
|
43
|
+
const sy = useYScale(yAxisId);
|
|
44
|
+
const clip = `sdv-surface-${useId().replace(/[^\w-]/g, "")}`;
|
|
45
|
+
const key = JSON.stringify(o, (_k, v) => typeof v === "bigint" ? `${v}n` : v);
|
|
46
|
+
const scene = useMemo(() => surfaces.surfaceScene(league, o), [league, key]);
|
|
47
|
+
if (area === void 0 || xd === void 0 || yd === void 0) return null;
|
|
48
|
+
if (!numeric(xd) || !numeric(yd)) {
|
|
49
|
+
warn(
|
|
50
|
+
"react:SurfaceBackdrop:domain",
|
|
51
|
+
`SurfaceBackdrop draws nothing: both axes must be type="number" with a numeric domain in the surface's units (got x ${JSON.stringify(xd)}, y ${JSON.stringify(yd)})`
|
|
52
|
+
);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const [dx0, dx1] = xd;
|
|
56
|
+
const [dy0, dy1] = yd;
|
|
57
|
+
if (!linear(sx, dx0, dx1, 1) || !linear(sy, dy0, dy1, -1)) {
|
|
58
|
+
warn(
|
|
59
|
+
"react:SurfaceBackdrop:scale",
|
|
60
|
+
"SurfaceBackdrop draws nothing on a reversed or log axis: use linear, unreversed number axes"
|
|
61
|
+
);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const fx = (v) => area.x + (v - dx0) / (dx1 - dx0) * area.width;
|
|
65
|
+
const fy = (v) => area.y + (dy1 - v) / (dy1 - dy0) * area.height;
|
|
66
|
+
const [x0, y0, x1, y1] = scene.bbox;
|
|
67
|
+
const width = fx(x1) - fx(x0);
|
|
68
|
+
const height = fy(y0) - fy(y1);
|
|
69
|
+
if (!(width > 0 && height > 0)) {
|
|
70
|
+
warn(
|
|
71
|
+
"react:SurfaceBackdrop:empty",
|
|
72
|
+
`SurfaceBackdrop draws nothing: the surface spans ${width} x ${height} px`
|
|
73
|
+
);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const drawn = svg.toSVG(scene, { width, height }).replace("<svg ", `<svg x="${fx(x0)}" y="${fy(y1)}" preserveAspectRatio="none" `);
|
|
77
|
+
return /* @__PURE__ */ jsxs("g", { "data-sdv-surface": "", className: "sdv-surface", children: [
|
|
78
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: clip, children: /* @__PURE__ */ jsx("rect", { x: area.x, y: area.y, width: area.width, height: area.height }) }) }),
|
|
79
|
+
/* @__PURE__ */ jsx("g", { clipPath: `url(#${clip})`, dangerouslySetInnerHTML: { __html: drawn } })
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
return { default: Drawn };
|
|
83
|
+
});
|
|
84
|
+
function SurfaceBackdrop(props) {
|
|
85
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Backdrop, { ...props }) });
|
|
86
|
+
}
|
|
87
|
+
var LAYERS = ["grid", "axes", "labels", "lines", "points"];
|
|
88
|
+
var Chart = lazy(async () => {
|
|
89
|
+
const m = await import('@nivo/bump').catch((e) => {
|
|
90
|
+
throw new OptionalDependencyError(
|
|
91
|
+
"LogoBump needs the optional peer @nivo/bump, which could not be loaded: pnpm add @nivo/bump @nivo/core",
|
|
92
|
+
{ cause: e }
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
const Drawn = (p) => createElement(
|
|
96
|
+
p.width === void 0 || p.height === void 0 ? m.ResponsiveBump : m.Bump,
|
|
97
|
+
p
|
|
98
|
+
);
|
|
99
|
+
return { default: Drawn };
|
|
100
|
+
});
|
|
101
|
+
function LogoBump({
|
|
102
|
+
league,
|
|
103
|
+
season,
|
|
104
|
+
idSystem,
|
|
105
|
+
background,
|
|
106
|
+
logoHeight,
|
|
107
|
+
at,
|
|
108
|
+
variant,
|
|
109
|
+
markType,
|
|
110
|
+
layers,
|
|
111
|
+
...rest
|
|
112
|
+
}) {
|
|
113
|
+
const teams = rest.data.map((s) => s.id);
|
|
114
|
+
const key = JSON.stringify([
|
|
115
|
+
league,
|
|
116
|
+
season,
|
|
117
|
+
idSystem,
|
|
118
|
+
background,
|
|
119
|
+
logoHeight,
|
|
120
|
+
at,
|
|
121
|
+
variant,
|
|
122
|
+
markType,
|
|
123
|
+
teams
|
|
124
|
+
]);
|
|
125
|
+
const drawn = useMemo(() => {
|
|
126
|
+
const o = {
|
|
127
|
+
league,
|
|
128
|
+
...season === void 0 ? {} : { season },
|
|
129
|
+
...idSystem === void 0 ? {} : { idSystem }
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
colors: teamColors({ ...o, ...background === void 0 ? {} : { teams, background } }),
|
|
133
|
+
logos: logoLayer({
|
|
134
|
+
...o,
|
|
135
|
+
...logoHeight === void 0 ? {} : { height: logoHeight },
|
|
136
|
+
...at === void 0 ? {} : { at },
|
|
137
|
+
...variant === void 0 ? {} : { variant },
|
|
138
|
+
...markType === void 0 ? {} : { markType }
|
|
139
|
+
})
|
|
140
|
+
};
|
|
141
|
+
}, [key]);
|
|
142
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
143
|
+
Chart,
|
|
144
|
+
{
|
|
145
|
+
colors: drawn.colors,
|
|
146
|
+
...rest,
|
|
147
|
+
layers: layers === void 0 ? [...LAYERS, drawn.logos, "mesh"] : [...layers, drawn.logos]
|
|
148
|
+
}
|
|
149
|
+
) });
|
|
150
|
+
}
|
|
151
|
+
var isNum = (v) => typeof v === "number" && Number.isFinite(v);
|
|
152
|
+
function checkSize(size) {
|
|
153
|
+
if (!(isNum(size) && size > 0))
|
|
154
|
+
throw new InputError(`size is an image height in px > 0, got ${String(size)}`);
|
|
155
|
+
if (size < 1)
|
|
156
|
+
throw new InputError(
|
|
157
|
+
`size is a height in px, not a fraction of the plot (echarts' \`height\`): got ${size}, which draws a sub-pixel image`
|
|
158
|
+
);
|
|
159
|
+
return size;
|
|
160
|
+
}
|
|
161
|
+
function placed(x, y, raw, rows, o) {
|
|
162
|
+
const season = seasons(rows, o.season);
|
|
163
|
+
return placeSync([x], [y], [raw], {
|
|
164
|
+
league: o.league,
|
|
165
|
+
kind: o.markType ?? "logo",
|
|
166
|
+
...season === void 0 ? {} : { season },
|
|
167
|
+
...o.variant === void 0 ? {} : { variant: o.variant },
|
|
168
|
+
...o.idSystem === void 0 ? {} : { idSystem: o.idSystem }
|
|
169
|
+
})[0];
|
|
170
|
+
}
|
|
171
|
+
function image(p, o, raw, box, at, extra) {
|
|
172
|
+
const kind = o.markType ?? "logo";
|
|
173
|
+
return createElement("image", {
|
|
174
|
+
...extra,
|
|
175
|
+
href: imageSource(p, o.embed),
|
|
176
|
+
x: box.left,
|
|
177
|
+
y: box.top,
|
|
178
|
+
width: box.h * aspect(p),
|
|
179
|
+
height: box.h,
|
|
180
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
181
|
+
role: "img",
|
|
182
|
+
"aria-label": `${placedName(p, o.league, raw)} ${kind}`,
|
|
183
|
+
"data-sdv-id": p.id,
|
|
184
|
+
"data-sdv-kind": kind,
|
|
185
|
+
"data-sdv-x": String(at.x),
|
|
186
|
+
"data-sdv-y": String(at.y),
|
|
187
|
+
"data-sdv-frame": "1"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function noBox(props, name, how) {
|
|
191
|
+
for (const k of ["height", "width"]) if (k in props) throw new InputError(`${name} takes no ${k}: ${how}`);
|
|
192
|
+
}
|
|
193
|
+
function LogoPoint(props) {
|
|
194
|
+
noBox(
|
|
195
|
+
props,
|
|
196
|
+
"LogoPoint",
|
|
197
|
+
"each logo is as tall as Victory drew the point (twice the scatter's size, in px)"
|
|
198
|
+
);
|
|
199
|
+
const alpha = checkAlpha(props.alpha ?? 1);
|
|
200
|
+
const { x, y, size } = props;
|
|
201
|
+
if (!(isNum(x) && isNum(y) && isNum(size)))
|
|
202
|
+
throw new UnsupportedTargetError(
|
|
203
|
+
"LogoPoint is a VictoryScatter dataComponent: it needs the point's x, y and size, which the scatter hands it"
|
|
204
|
+
);
|
|
205
|
+
const row = props.datum ?? {};
|
|
206
|
+
const raw = row[props.team];
|
|
207
|
+
if (raw === void 0 || raw === null) {
|
|
208
|
+
warn(
|
|
209
|
+
`victory:LogoPoint:no-team:${props.team}`,
|
|
210
|
+
`LogoPoint: a datum has no ${props.team} field: nothing drawn`
|
|
211
|
+
);
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
if (!(size > 0)) {
|
|
215
|
+
warn(
|
|
216
|
+
`victory:LogoPoint:size:${size}`,
|
|
217
|
+
`LogoPoint: Victory drew a point of size ${size} (px): nothing drawn`
|
|
218
|
+
);
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const p = placed(x, y, raw, [row], props);
|
|
222
|
+
if (p === void 0) return null;
|
|
223
|
+
const h = 2 * size;
|
|
224
|
+
const w = h * aspect(p);
|
|
225
|
+
return image(
|
|
226
|
+
p,
|
|
227
|
+
props,
|
|
228
|
+
raw,
|
|
229
|
+
{ left: x - w / 2, top: y - h / 2, h },
|
|
230
|
+
{ x, y },
|
|
231
|
+
{ ...props.events, ...alpha === 1 ? {} : { opacity: alpha } }
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
var Label = lazy(async () => {
|
|
235
|
+
const m = await import('victory').catch((e) => {
|
|
236
|
+
throw new OptionalDependencyError(
|
|
237
|
+
"LogoTick needs the optional peer victory to draw a label as text, and it could not be loaded: pnpm add victory",
|
|
238
|
+
{ cause: e }
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
return { default: m.VictoryLabel };
|
|
242
|
+
});
|
|
243
|
+
function LogoTick(props) {
|
|
244
|
+
noBox(props, "LogoTick", "size is the logo's height in px (Victory hands a tick label no plot height)");
|
|
245
|
+
const h = checkSize(props.size ?? 24);
|
|
246
|
+
const { league, season, variant, idSystem, markType, embed, size, ...label } = props;
|
|
247
|
+
const x = isNum(props.x) ? props.x : 0;
|
|
248
|
+
const y = isNum(props.y) ? props.y : 0;
|
|
249
|
+
const raw = typeof props.text === "string" || typeof props.text === "number" ? props.text : void 0;
|
|
250
|
+
const p = raw === void 0 ? void 0 : placed(x, y, raw, [], props);
|
|
251
|
+
if (p === void 0)
|
|
252
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Label, { ...label }) });
|
|
253
|
+
const w = h * aspect(p);
|
|
254
|
+
const anchor = props.textAnchor ?? "start";
|
|
255
|
+
const vertical = props.verticalAnchor ?? "middle";
|
|
256
|
+
const left = anchor === "end" ? x - w : anchor === "middle" ? x - w / 2 : x;
|
|
257
|
+
const top = vertical === "end" ? y - h : vertical === "middle" ? y - h / 2 : y;
|
|
258
|
+
return image(p, props, raw, { left, top, h }, { x, y }, {});
|
|
259
|
+
}
|
|
260
|
+
async function peers(who) {
|
|
261
|
+
try {
|
|
262
|
+
return await Promise.all([import('three'), import('@react-three/fiber')]);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
throw new OptionalDependencyError(
|
|
265
|
+
`${who} needs the optional peers three and @react-three/fiber, which could not be loaded: pnpm add three @react-three/fiber`,
|
|
266
|
+
{ cause: e }
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function meshOf(THREE, fiber) {
|
|
271
|
+
return function Drawn({ buffers, material, renderOrder }) {
|
|
272
|
+
const invalidate = fiber.useThree((s) => s.invalidate);
|
|
273
|
+
const geometry = useMemo(() => {
|
|
274
|
+
const g = new THREE.BufferGeometry();
|
|
275
|
+
g.setAttribute("position", new THREE.BufferAttribute(buffers.positions, 3));
|
|
276
|
+
if (buffers.colors !== void 0) g.setAttribute("color", new THREE.BufferAttribute(buffers.colors, 4));
|
|
277
|
+
if (buffers.normals !== void 0)
|
|
278
|
+
g.setAttribute("normal", new THREE.BufferAttribute(buffers.normals, 3));
|
|
279
|
+
g.setIndex(new THREE.BufferAttribute(buffers.indices, 1));
|
|
280
|
+
g.computeBoundingSphere();
|
|
281
|
+
return g;
|
|
282
|
+
}, [buffers]);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
invalidate();
|
|
285
|
+
return () => geometry.dispose();
|
|
286
|
+
}, [geometry, invalidate]);
|
|
287
|
+
return createElement("mesh", { geometry, renderOrder }, createElement("meshBasicMaterial", material));
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function loaded(league) {
|
|
291
|
+
checkLeague(league);
|
|
292
|
+
try {
|
|
293
|
+
getLeagueSync(league);
|
|
294
|
+
return true;
|
|
295
|
+
} catch {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
var SurfaceBody = lazy(async () => {
|
|
300
|
+
const [[THREE, fiber], { surfaceMesh }] = await Promise.all([
|
|
301
|
+
peers("Surface3D"),
|
|
302
|
+
import('./surface-TR7YFJW3.js').catch((e) => {
|
|
303
|
+
throw new OptionalDependencyError(
|
|
304
|
+
"Surface3D needs the optional peer @sportsdataverse/sporty, which could not be loaded: pnpm add @sportsdataverse/sporty",
|
|
305
|
+
{ cause: e }
|
|
306
|
+
);
|
|
307
|
+
})
|
|
308
|
+
]);
|
|
309
|
+
const Drawn = meshOf(THREE, fiber);
|
|
310
|
+
const material = {
|
|
311
|
+
vertexColors: true,
|
|
312
|
+
transparent: true,
|
|
313
|
+
depthWrite: false,
|
|
314
|
+
toneMapped: false,
|
|
315
|
+
side: THREE.DoubleSide
|
|
316
|
+
};
|
|
317
|
+
function Body({ sport, league, options, renderOrder = -1 }) {
|
|
318
|
+
const key = JSON.stringify([sport, league, options]);
|
|
319
|
+
const buffers = useMemo(() => surfaceMesh(sport, league, options), [key]);
|
|
320
|
+
return createElement(Drawn, { buffers, material, renderOrder });
|
|
321
|
+
}
|
|
322
|
+
return { default: Body };
|
|
323
|
+
});
|
|
324
|
+
function Surface3D(props) {
|
|
325
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(SurfaceBody, { ...props }) });
|
|
326
|
+
}
|
|
327
|
+
var TubeBody = lazy(
|
|
328
|
+
async () => {
|
|
329
|
+
const [THREE, fiber] = await peers("Trajectory");
|
|
330
|
+
const Drawn = meshOf(THREE, fiber);
|
|
331
|
+
function Body({ tube, renderOrder }) {
|
|
332
|
+
const material = useMemo(() => ({ color: tube.color, toneMapped: false }), [tube.color]);
|
|
333
|
+
return createElement(Drawn, { buffers: tube, material, renderOrder });
|
|
334
|
+
}
|
|
335
|
+
return { default: Body };
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
function Trajectory({ points, renderOrder = 0, ...o }) {
|
|
339
|
+
const league = o.color === void 0 ? o.league : void 0;
|
|
340
|
+
const ready = league === void 0 || loaded(league);
|
|
341
|
+
const [, loadedNow] = useState(0);
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
if (ready || league === void 0) return;
|
|
344
|
+
let live = true;
|
|
345
|
+
loadLeague(league).then(
|
|
346
|
+
() => live && loadedNow((n) => n + 1),
|
|
347
|
+
() => {
|
|
348
|
+
}
|
|
349
|
+
// a league that cannot load leaves the tube undrawn, as it is now
|
|
350
|
+
);
|
|
351
|
+
return () => {
|
|
352
|
+
live = false;
|
|
353
|
+
};
|
|
354
|
+
}, [league, ready]);
|
|
355
|
+
const key = JSON.stringify([points, o, ready]);
|
|
356
|
+
const tube = useMemo(() => ready ? trajectoryTube(points, o) : null, [key]);
|
|
357
|
+
if (tube === null) {
|
|
358
|
+
warn(
|
|
359
|
+
`three:Trajectory:unloaded:${league}`,
|
|
360
|
+
`<Trajectory team> draws nothing until league ${league} is loaded: await loadLeague("${league}") first (on a server, before rendering)`
|
|
361
|
+
);
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(TubeBody, { tube, renderOrder }) });
|
|
365
|
+
}
|
|
366
|
+
function TeamLogo({
|
|
367
|
+
team,
|
|
368
|
+
league,
|
|
369
|
+
season,
|
|
370
|
+
variant,
|
|
371
|
+
markType,
|
|
372
|
+
size,
|
|
373
|
+
alt,
|
|
374
|
+
...imgProps
|
|
375
|
+
}) {
|
|
376
|
+
const [mark, setMark] = useState();
|
|
377
|
+
useEffect(() => {
|
|
378
|
+
let live = true;
|
|
379
|
+
(async () => {
|
|
380
|
+
await loadLeague(league);
|
|
381
|
+
if (!live) return;
|
|
382
|
+
const o = {};
|
|
383
|
+
if (season !== void 0) o.season = season;
|
|
384
|
+
if (variant !== void 0) o.variant = variant;
|
|
385
|
+
if (markType !== void 0) o.markType = markType;
|
|
386
|
+
const src = logoUrlSync(team, league, o);
|
|
387
|
+
const id = resolveSync(team, league, { season });
|
|
388
|
+
const name = getLeagueSync(league).teams.find((t) => t.team_id === id)?.name ?? "";
|
|
389
|
+
setMark(src === void 0 ? void 0 : { src, name });
|
|
390
|
+
})().catch(() => {
|
|
391
|
+
if (live) setMark(void 0);
|
|
392
|
+
});
|
|
393
|
+
return () => {
|
|
394
|
+
live = false;
|
|
395
|
+
};
|
|
396
|
+
}, [team, league, season, variant, markType]);
|
|
397
|
+
if (mark === void 0) return null;
|
|
398
|
+
return /* @__PURE__ */ jsx("img", { src: mark.src, alt: alt ?? mark.name, height: size, ...imgProps });
|
|
399
|
+
}
|
|
400
|
+
function Wordmark(props) {
|
|
401
|
+
return /* @__PURE__ */ jsx(TeamLogo, { ...props, markType: "wordmark" });
|
|
402
|
+
}
|
|
403
|
+
var initialsOf = (name) => name.split(" ").map((w) => Array.from(w)[0] ?? "").join("").slice(0, 3);
|
|
404
|
+
var useClientLayoutEffect = typeof document === "undefined" ? useEffect : useLayoutEffect;
|
|
405
|
+
function Headshot({
|
|
406
|
+
playerId,
|
|
407
|
+
league,
|
|
408
|
+
idSystem,
|
|
409
|
+
height = 60,
|
|
410
|
+
alt,
|
|
411
|
+
fallback = "none",
|
|
412
|
+
name,
|
|
413
|
+
...imgProps
|
|
414
|
+
}) {
|
|
415
|
+
const [, setGsisReady] = useState(false);
|
|
416
|
+
const [failed, setFailed] = useState();
|
|
417
|
+
const img = useRef(null);
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
if (idSystem !== "gsis") return;
|
|
420
|
+
let live = true;
|
|
421
|
+
loadGsis().then(
|
|
422
|
+
() => {
|
|
423
|
+
if (live) setGsisReady(true);
|
|
424
|
+
},
|
|
425
|
+
() => {
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
return () => {
|
|
429
|
+
live = false;
|
|
430
|
+
};
|
|
431
|
+
}, [idSystem]);
|
|
432
|
+
let src;
|
|
433
|
+
try {
|
|
434
|
+
src = headshotUrl(playerId, league, idSystem === void 0 ? {} : { idSystem });
|
|
435
|
+
} catch {
|
|
436
|
+
src = void 0;
|
|
437
|
+
}
|
|
438
|
+
const label = alt ?? (name || void 0) ?? "Player headshot";
|
|
439
|
+
const width = Math.round(height * HEADSHOT_ASPECT);
|
|
440
|
+
useClientLayoutEffect(() => {
|
|
441
|
+
if (img.current?.complete && img.current.naturalWidth === 0) setFailed(src);
|
|
442
|
+
}, [src]);
|
|
443
|
+
if (src === void 0 || fallback === "initials" && src === failed) {
|
|
444
|
+
if (fallback !== "initials" || name === void 0) return null;
|
|
445
|
+
return /* @__PURE__ */ jsx(
|
|
446
|
+
"span",
|
|
447
|
+
{
|
|
448
|
+
...label === "" ? { "aria-hidden": true } : { role: "img", "aria-label": label },
|
|
449
|
+
className: imgProps.className,
|
|
450
|
+
style: {
|
|
451
|
+
display: "inline-flex",
|
|
452
|
+
alignItems: "center",
|
|
453
|
+
justifyContent: "center",
|
|
454
|
+
width,
|
|
455
|
+
height,
|
|
456
|
+
background: "var(--sdv-line, #e2e2e2)",
|
|
457
|
+
color: "var(--sdv-muted, #525252)",
|
|
458
|
+
...imgProps.style
|
|
459
|
+
},
|
|
460
|
+
children: initialsOf(name)
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
const shown = src;
|
|
465
|
+
return (
|
|
466
|
+
// biome-ignore lint/a11y/useAltText: alt always defaults to a string; imgProps cannot carry it
|
|
467
|
+
/* @__PURE__ */ jsx(
|
|
468
|
+
"img",
|
|
469
|
+
{
|
|
470
|
+
ref: img,
|
|
471
|
+
src: shown,
|
|
472
|
+
alt: label,
|
|
473
|
+
height,
|
|
474
|
+
width,
|
|
475
|
+
...imgProps,
|
|
476
|
+
onError: (e) => {
|
|
477
|
+
setFailed(shown);
|
|
478
|
+
imgProps.onError?.(e);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
function useTeamColors(league, { which } = {}) {
|
|
485
|
+
const [colors, setColors] = useState();
|
|
486
|
+
useEffect(() => {
|
|
487
|
+
let live = true;
|
|
488
|
+
setColors(void 0);
|
|
489
|
+
palette(league, void 0, which === void 0 ? {} : { which }).then((c) => {
|
|
490
|
+
if (live) setColors(c);
|
|
491
|
+
}).catch(() => {
|
|
492
|
+
if (live) setColors(void 0);
|
|
493
|
+
});
|
|
494
|
+
return () => {
|
|
495
|
+
live = false;
|
|
496
|
+
};
|
|
497
|
+
}, [league, which]);
|
|
498
|
+
return colors;
|
|
499
|
+
}
|
|
500
|
+
function useResolve(league) {
|
|
501
|
+
const [ready, setReady] = useState();
|
|
502
|
+
useEffect(() => {
|
|
503
|
+
let live = true;
|
|
504
|
+
setReady(void 0);
|
|
505
|
+
loadLeague(league).then(() => {
|
|
506
|
+
if (live) setReady(league);
|
|
507
|
+
}).catch(() => {
|
|
508
|
+
if (live) setReady(void 0);
|
|
509
|
+
});
|
|
510
|
+
return () => {
|
|
511
|
+
live = false;
|
|
512
|
+
};
|
|
513
|
+
}, [league]);
|
|
514
|
+
return ready === void 0 ? void 0 : (value, opts) => resolveSync(value, ready, opts);
|
|
515
|
+
}
|
|
516
|
+
function useSelection(store) {
|
|
517
|
+
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export { Headshot, LogoBump, LogoPoint, LogoTick, Surface3D, SurfaceBackdrop, TeamLogo, Trajectory, Wordmark, useResolve, useSelection, useTeamColors };
|
|
521
|
+
//# sourceMappingURL=react.js.map
|
|
522
|
+
//# sourceMappingURL=react.js.map
|