@johnmorrisdotca/kyogijo-stadiums 0.4.0 → 0.6.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 (361) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/NOTICE.md +182 -2
  3. package/README.md +106 -19
  4. package/dist/annotate.js +1 -1
  5. package/dist/arenas-entry.d.ts +4 -0
  6. package/dist/arenas-entry.js +3 -0
  7. package/dist/arenas.d.ts +125 -0
  8. package/dist/arenas.data.d.ts +2 -0
  9. package/dist/arenas.data.js +3763 -0
  10. package/dist/arenas.js +72 -0
  11. package/dist/athletics/describe.d.ts +8 -0
  12. package/dist/athletics/describe.js +41 -0
  13. package/dist/athletics/events.d.ts +17 -0
  14. package/dist/athletics/events.js +48 -0
  15. package/dist/athletics/facilities.d.ts +80 -0
  16. package/dist/athletics/facilities.js +176 -0
  17. package/dist/athletics/infield.d.ts +79 -0
  18. package/dist/athletics/infield.js +166 -0
  19. package/dist/athletics/layout.d.ts +13 -0
  20. package/dist/athletics/layout.js +98 -0
  21. package/dist/athletics/oval.d.ts +57 -0
  22. package/dist/athletics/oval.js +116 -0
  23. package/dist/athletics/plan.d.ts +97 -0
  24. package/dist/athletics/plan.js +355 -0
  25. package/dist/athletics/races.d.ts +102 -0
  26. package/dist/athletics/races.js +355 -0
  27. package/dist/athletics/steeplechase.d.ts +72 -0
  28. package/dist/athletics/steeplechase.js +196 -0
  29. package/dist/athletics/stencil.d.ts +13 -0
  30. package/dist/athletics/stencil.js +85 -0
  31. package/dist/athletics/track.d.ts +54 -0
  32. package/dist/athletics/track.js +105 -0
  33. package/dist/athletics/types.d.ts +77 -0
  34. package/dist/athletics/types.js +1 -0
  35. package/dist/athletics-entry.d.ts +17 -0
  36. package/dist/athletics-entry.js +11 -0
  37. package/dist/athletics.style.d.ts +16 -0
  38. package/dist/athletics.style.js +51 -0
  39. package/dist/atlas-entry.d.ts +6 -2
  40. package/dist/atlas-entry.js +4 -2
  41. package/dist/atlas.d.ts +117 -23
  42. package/dist/atlas.js +197 -12
  43. package/dist/background.js +2 -1
  44. package/dist/budo/describe.d.ts +13 -0
  45. package/dist/budo/describe.js +120 -0
  46. package/dist/budo/dojo.api.d.ts +64 -0
  47. package/dist/budo/dojo.api.js +46 -0
  48. package/dist/budo/dojo.d.ts +72 -0
  49. package/dist/budo/dojo.js +300 -0
  50. package/dist/budo/judo.d.ts +61 -0
  51. package/dist/budo/judo.js +109 -0
  52. package/dist/budo/karate.d.ts +29 -0
  53. package/dist/budo/karate.js +80 -0
  54. package/dist/budo/kendo.d.ts +18 -0
  55. package/dist/budo/kendo.js +44 -0
  56. package/dist/budo/kimarite.d.ts +19 -0
  57. package/dist/budo/kimarite.js +33 -0
  58. package/dist/budo/kit.d.ts +16 -0
  59. package/dist/budo/kit.js +24 -0
  60. package/dist/budo/kyudo.d.ts +28 -0
  61. package/dist/budo/kyudo.js +66 -0
  62. package/dist/budo/looks.d.ts +28 -0
  63. package/dist/budo/looks.js +58 -0
  64. package/dist/budo/parts.d.ts +32 -0
  65. package/dist/budo/parts.js +10 -0
  66. package/dist/budo/plan.d.ts +64 -0
  67. package/dist/budo/plan.js +139 -0
  68. package/dist/budo/room.d.ts +133 -0
  69. package/dist/budo/room.js +111 -0
  70. package/dist/budo/sumo.d.ts +31 -0
  71. package/dist/budo/sumo.js +71 -0
  72. package/dist/budo/tatami.d.ts +55 -0
  73. package/dist/budo/tatami.js +156 -0
  74. package/dist/budo/types.d.ts +192 -0
  75. package/dist/budo/types.js +2 -0
  76. package/dist/budo-entry.d.ts +22 -0
  77. package/dist/budo-entry.js +13 -0
  78. package/dist/budo.board.d.ts +28 -0
  79. package/dist/budo.board.js +81 -0
  80. package/dist/budo.score.d.ts +18 -0
  81. package/dist/budo.score.js +52 -0
  82. package/dist/budo.style.d.ts +6 -0
  83. package/dist/budo.style.js +67 -0
  84. package/dist/charts-entry.d.ts +6 -1
  85. package/dist/charts-entry.js +3 -0
  86. package/dist/charts.athletics.d.ts +183 -0
  87. package/dist/charts.athletics.js +455 -0
  88. package/dist/charts.baseball.js +1 -1
  89. package/dist/charts.curling.heat.d.ts +24 -0
  90. package/dist/charts.curling.heat.js +116 -0
  91. package/dist/charts.curling.js +14 -3
  92. package/dist/charts.js +4 -4
  93. package/dist/charts.pool.d.ts +67 -0
  94. package/dist/charts.pool.js +76 -0
  95. package/dist/charts.skating.d.ts +204 -0
  96. package/dist/charts.skating.js +426 -0
  97. package/dist/charts.soccer.js +3 -3
  98. package/dist/charts.types.d.ts +63 -1
  99. package/dist/colour.d.ts +4 -4
  100. package/dist/colour.js +4 -4
  101. package/dist/court.d.ts +85 -2
  102. package/dist/court.js +102 -7
  103. package/dist/court.more.d.ts +46 -0
  104. package/dist/court.more.js +219 -0
  105. package/dist/courts.style.d.ts +14 -2
  106. package/dist/courts.style.js +51 -4
  107. package/dist/crowd.d.ts +164 -0
  108. package/dist/crowd.draw.d.ts +17 -0
  109. package/dist/crowd.draw.js +204 -0
  110. package/dist/crowd.js +480 -0
  111. package/dist/crowd.park.d.ts +19 -0
  112. package/dist/crowd.park.js +153 -0
  113. package/dist/curling.stats.d.ts +271 -0
  114. package/dist/curling.stats.js +301 -0
  115. package/dist/draw.d.ts +16 -0
  116. package/dist/draw.js +462 -54
  117. package/dist/element-entry.d.ts +3 -1
  118. package/dist/element-entry.js +2 -1
  119. package/dist/element.d.ts +13 -2
  120. package/dist/element.js +79 -4
  121. package/dist/emblems-source.d.ts +50 -0
  122. package/dist/emblems-source.js +56 -0
  123. package/dist/eras.d.ts +3 -1
  124. package/dist/eras.js +8 -3
  125. package/dist/features.js +204 -0
  126. package/dist/field.data.d.ts +16 -0
  127. package/dist/field.data.js +50 -0
  128. package/dist/fields.kit.d.ts +2 -2
  129. package/dist/fields.types.d.ts +24 -4
  130. package/dist/formations.js +18 -7
  131. package/dist/formations.sports.d.ts +8 -0
  132. package/dist/formations.sports.js +251 -0
  133. package/dist/frames.providers.js +71 -8
  134. package/dist/geojson.js +3 -0
  135. package/dist/geometry-entry.d.ts +2 -1
  136. package/dist/geometry-entry.js +2 -1
  137. package/dist/geometry.d.ts +20 -0
  138. package/dist/geometry.js +78 -1
  139. package/dist/grounds.d.ts +4 -0
  140. package/dist/grounds.data.js +12 -0
  141. package/dist/halls.d.ts +65 -0
  142. package/dist/halls.js +122 -0
  143. package/dist/hardwood.d.ts +31 -0
  144. package/dist/hardwood.js +157 -0
  145. package/dist/heat.js +21 -13
  146. package/dist/heat.types.d.ts +5 -0
  147. package/dist/heat.zones.d.ts +4 -2
  148. package/dist/heat.zones.js +207 -7
  149. package/dist/homeside.js +24 -0
  150. package/dist/index.d.ts +30 -4
  151. package/dist/index.js +18 -2
  152. package/dist/layers-entry.d.ts +2 -1
  153. package/dist/layers-entry.js +1 -0
  154. package/dist/layers.d.ts +2 -1
  155. package/dist/layers.env.d.ts +12 -1
  156. package/dist/layers.env.js +36 -4
  157. package/dist/layers.js +32 -13
  158. package/dist/layers.types.d.ts +9 -2
  159. package/dist/leagues/athletics.d.ts +63 -0
  160. package/dist/leagues/athletics.js +87 -0
  161. package/dist/leagues/budo.d.ts +196 -0
  162. package/dist/leagues/budo.js +105 -0
  163. package/dist/leagues/courts.d.ts +269 -4
  164. package/dist/leagues/courts.js +155 -1
  165. package/dist/leagues/hockey.js +41 -19
  166. package/dist/leagues/skating.d.ts +145 -0
  167. package/dist/leagues/skating.js +73 -0
  168. package/dist/leagues/sources.js +41 -0
  169. package/dist/leagues/types.d.ts +1 -1
  170. package/dist/leagues-entry.d.ts +4 -2
  171. package/dist/leagues-entry.js +2 -1
  172. package/dist/leagues.d.ts +17 -4
  173. package/dist/leagues.js +246 -5
  174. package/dist/lineup.codes.d.ts +23 -0
  175. package/dist/lineup.codes.js +122 -0
  176. package/dist/logo.d.ts +25 -0
  177. package/dist/logo.js +47 -0
  178. package/dist/look.d.ts +3 -3
  179. package/dist/look.js +39 -6
  180. package/dist/outline.d.ts +1 -1
  181. package/dist/outline.js +46 -4
  182. package/dist/pageant.d.ts +120 -0
  183. package/dist/pageant.draw.d.ts +21 -0
  184. package/dist/pageant.draw.js +171 -0
  185. package/dist/pageant.js +211 -0
  186. package/dist/pageant.style.d.ts +8 -0
  187. package/dist/pageant.style.js +42 -0
  188. package/dist/png.d.ts +8 -1
  189. package/dist/png.js +21 -1
  190. package/dist/pointer-entry.d.ts +2 -0
  191. package/dist/pointer-entry.js +2 -0
  192. package/dist/pointer.d.ts +113 -0
  193. package/dist/pointer.js +151 -0
  194. package/dist/pool.d.ts +176 -0
  195. package/dist/pool.figures.d.ts +306 -0
  196. package/dist/pool.figures.js +148 -0
  197. package/dist/pool.js +304 -0
  198. package/dist/pool.kit.d.ts +48 -0
  199. package/dist/pool.kit.js +141 -0
  200. package/dist/pool.labels.d.ts +20 -0
  201. package/dist/pool.labels.js +258 -0
  202. package/dist/pool.race.d.ts +65 -0
  203. package/dist/pool.race.js +140 -0
  204. package/dist/pool.replay.d.ts +46 -0
  205. package/dist/pool.replay.js +127 -0
  206. package/dist/pool.section.d.ts +13 -0
  207. package/dist/pool.section.js +83 -0
  208. package/dist/pool.style.d.ts +20 -0
  209. package/dist/pool.style.js +169 -0
  210. package/dist/pool.types.d.ts +145 -0
  211. package/dist/pool.types.js +3 -0
  212. package/dist/pool.words.d.ts +13 -0
  213. package/dist/pool.words.js +101 -0
  214. package/dist/ranges.names.js +53 -3
  215. package/dist/replay-entry.d.ts +3 -0
  216. package/dist/replay-entry.js +2 -0
  217. package/dist/restyle.js +1 -1
  218. package/dist/road.draw.js +3 -2
  219. package/dist/road.js +2 -1
  220. package/dist/road.types.d.ts +3 -0
  221. package/dist/rules.d.ts +138 -0
  222. package/dist/rules.js +511 -0
  223. package/dist/rules.types.d.ts +4 -0
  224. package/dist/rules.types.js +64 -0
  225. package/dist/score.d.ts +3 -0
  226. package/dist/score.js +93 -6
  227. package/dist/sheet.d.ts +3 -0
  228. package/dist/sheet.js +7 -3
  229. package/dist/situation.d.ts +135 -0
  230. package/dist/situation.draw.d.ts +34 -0
  231. package/dist/situation.draw.js +202 -0
  232. package/dist/situation.js +337 -0
  233. package/dist/situation.style.d.ts +2 -0
  234. package/dist/situation.style.js +45 -0
  235. package/dist/situation.types.d.ts +77 -0
  236. package/dist/situation.types.js +3 -0
  237. package/dist/situation.widgets.d.ts +39 -0
  238. package/dist/situation.widgets.js +129 -0
  239. package/dist/skating/describe.d.ts +7 -0
  240. package/dist/skating/describe.js +44 -0
  241. package/dist/skating/events.d.ts +24 -0
  242. package/dist/skating/events.js +47 -0
  243. package/dist/skating/figure.d.ts +24 -0
  244. package/dist/skating/figure.js +37 -0
  245. package/dist/skating/long.d.ts +54 -0
  246. package/dist/skating/long.js +111 -0
  247. package/dist/skating/parts.d.ts +43 -0
  248. package/dist/skating/parts.js +40 -0
  249. package/dist/skating/plan.d.ts +55 -0
  250. package/dist/skating/plan.js +197 -0
  251. package/dist/skating/short.d.ts +47 -0
  252. package/dist/skating/short.js +89 -0
  253. package/dist/skating/track.d.ts +66 -0
  254. package/dist/skating/track.js +94 -0
  255. package/dist/skating/types.d.ts +57 -0
  256. package/dist/skating/types.js +3 -0
  257. package/dist/skating-entry.d.ts +17 -0
  258. package/dist/skating-entry.js +11 -0
  259. package/dist/skating.style.d.ts +4 -0
  260. package/dist/skating.style.js +24 -0
  261. package/dist/strings.d.ts +470 -0
  262. package/dist/strings.js +674 -13
  263. package/dist/style.d.ts +2 -0
  264. package/dist/style.js +19 -2
  265. package/dist/surfaces/artistic.d.ts +9 -0
  266. package/dist/surfaces/artistic.js +94 -0
  267. package/dist/surfaces/athletics.d.ts +16 -0
  268. package/dist/surfaces/athletics.js +132 -0
  269. package/dist/surfaces/baseball.js +17 -0
  270. package/dist/surfaces/basketball.floor.d.ts +27 -0
  271. package/dist/surfaces/basketball.floor.js +83 -0
  272. package/dist/surfaces/basketball.gear.d.ts +27 -0
  273. package/dist/surfaces/basketball.gear.js +90 -0
  274. package/dist/surfaces/basketball.js +44 -22
  275. package/dist/surfaces/budo.d.ts +6 -0
  276. package/dist/surfaces/budo.js +104 -0
  277. package/dist/surfaces/curling.d.ts +16 -0
  278. package/dist/surfaces/curling.fold.d.ts +67 -0
  279. package/dist/surfaces/curling.fold.js +107 -0
  280. package/dist/surfaces/curling.js +37 -3
  281. package/dist/surfaces/dive.d.ts +9 -0
  282. package/dist/surfaces/dive.js +128 -0
  283. package/dist/surfaces/field.d.ts +7 -2
  284. package/dist/surfaces/field.js +15 -9
  285. package/dist/surfaces/football.js +7 -0
  286. package/dist/surfaces/hockey.js +4 -2
  287. package/dist/surfaces/net.d.ts +2 -1
  288. package/dist/surfaces/net.js +160 -15
  289. package/dist/surfaces/polo.d.ts +12 -0
  290. package/dist/surfaces/polo.js +159 -0
  291. package/dist/surfaces/pool.d.ts +27 -0
  292. package/dist/surfaces/pool.js +198 -0
  293. package/dist/surfaces/skating.d.ts +6 -0
  294. package/dist/surfaces/skating.js +62 -0
  295. package/dist/surfaces/soccer.js +2 -1
  296. package/dist/surfaces/surface.d.ts +76 -0
  297. package/dist/surfaces/venue.d.ts +15 -0
  298. package/dist/surfaces/venue.js +95 -0
  299. package/dist/target-entry.d.ts +2 -0
  300. package/dist/target-entry.js +2 -0
  301. package/dist/target.d.ts +200 -0
  302. package/dist/target.js +525 -0
  303. package/dist/team.common.d.ts +1 -1
  304. package/dist/team.common.js +3 -3
  305. package/dist/team.formation.d.ts +3 -1
  306. package/dist/team.formation.js +3 -3
  307. package/dist/team.layers.d.ts +2 -2
  308. package/dist/team.layers.js +4 -1
  309. package/dist/team.lineup.d.ts +27 -0
  310. package/dist/team.lineup.js +207 -0
  311. package/dist/team.network.js +6 -5
  312. package/dist/team.shape.js +5 -5
  313. package/dist/team.types.d.ts +40 -1
  314. package/dist/tenants.d.ts +77 -0
  315. package/dist/tenants.data.d.ts +8 -0
  316. package/dist/tenants.data.js +1793 -0
  317. package/dist/tenants.js +46 -0
  318. package/dist/turn-entry.d.ts +12 -0
  319. package/dist/turn-entry.js +7 -0
  320. package/dist/turn.camera.d.ts +116 -0
  321. package/dist/turn.camera.js +184 -0
  322. package/dist/turn.dom.d.ts +40 -0
  323. package/dist/turn.dom.js +353 -0
  324. package/dist/turn.kit.d.ts +86 -0
  325. package/dist/turn.kit.js +110 -0
  326. package/dist/turn.markup.d.ts +48 -0
  327. package/dist/turn.markup.js +108 -0
  328. package/dist/turn.model.d.ts +78 -0
  329. package/dist/turn.model.js +91 -0
  330. package/dist/turn.style.d.ts +5 -0
  331. package/dist/turn.style.js +56 -0
  332. package/dist/types.d.ts +221 -20
  333. package/dist/units.d.ts +1 -1
  334. package/dist/units.js +22 -1
  335. package/dist/uprights.board.d.ts +17 -0
  336. package/dist/uprights.board.js +59 -0
  337. package/dist/uprights.budo.d.ts +17 -0
  338. package/dist/uprights.budo.js +87 -0
  339. package/dist/uprights.d.ts +37 -0
  340. package/dist/uprights.fields.d.ts +32 -0
  341. package/dist/uprights.fields.js +172 -0
  342. package/dist/uprights.goal.d.ts +49 -0
  343. package/dist/uprights.goal.js +69 -0
  344. package/dist/uprights.js +169 -0
  345. package/dist/uprights.more.d.ts +7 -0
  346. package/dist/uprights.more.js +183 -0
  347. package/dist/uprights.net.d.ts +12 -0
  348. package/dist/uprights.net.js +109 -0
  349. package/dist/uprights.netkit.d.ts +28 -0
  350. package/dist/uprights.netkit.js +67 -0
  351. package/dist/uprights.pools.d.ts +8 -0
  352. package/dist/uprights.pools.js +190 -0
  353. package/dist/uprights.rinks.d.ts +27 -0
  354. package/dist/uprights.rinks.js +106 -0
  355. package/dist/uprights.track.d.ts +50 -0
  356. package/dist/uprights.track.js +246 -0
  357. package/dist/version.d.ts +1 -1
  358. package/dist/version.js +1 -1
  359. package/dist/zones-entry.d.ts +2 -0
  360. package/dist/zones-entry.js +2 -0
  361. package/package.json +56 -3
@@ -1,4 +1,6 @@
1
1
  // Replay: tracking data over time on a surface. The frame, the clock and the pure functions between them; the controls and the animation
2
2
  // are in the mount (`mountKyogijo(...).replay(...)`) and in `<kyogijo-field>`.
3
3
  export { activeEvents, describeEvent, drawFrame, eventsBetween, interpolate, possession, replayClock, replayEvents, replayInfo, replayLayers, replaySnapshot, replaySummary, replayTable, replayTimes, trails } from "./replay.js";
4
+ export { alongPool, distanceAt, progressOf, raceTimeline } from "./pool.replay.js";
5
+ export { formatTime, parseTime } from "./pool.race.js";
4
6
  export { REPLAY_SPEEDS, REPLAY_SPEED_RANGE, createReplay } from "./replay.control.js";
package/dist/restyle.js CHANGED
@@ -8,7 +8,7 @@ const LINES = new Set(["ky-line", "ky-red", "ky-blue", "ky-band", "ky-crease"]);
8
8
  /** The dashes in the centre line of a rink are lines too, but they are dashes already. */
9
9
  const WIDTH = new Set([...LINES, "ky-dash"]);
10
10
  /** The classes of marks painted as a fill, which take an opacity. */
11
- const FILLS = new Set(["ky-fill-line", "ky-red-fill", "ky-blue-fill", "ky-num"]);
11
+ const FILLS = new Set(["ky-fill-line", "ky-wall-line", "ky-red-fill", "ky-blue-fill", "ky-num"]);
12
12
  const finitePositive = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
13
13
  /**
14
14
  * The look of the lines the options ask for, or `undefined` when they ask for none of it. A width is a multiple of the width the lines are drawn at (`2`,
package/dist/road.draw.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // The road chart, drawn: the two finalists' big round marks with their names, the round names down the middle on a dotted road, each finalist's matches on its side as
2
2
  // the round marks of both teams with the score between them, and the group stage as a compact row at the foot. Each size has its own arrangement: `card`, `square` and
3
3
  // `phone` stack the finalists over the rounds; `wide` puts them at the two ends. Nothing is measured in a browser: type is set by estimates (`textWidth`).
4
- import { safeColour, safeLogo } from "./colour.js";
4
+ import { safeColour } from "./colour.js";
5
+ import { safeLogo } from "./logo.js";
5
6
  import { safeClass } from "./common.js";
6
7
  import { el, esc, num } from "./format.js";
7
8
  import { KYOGIJO_MARK_STYLE, roundMarkup } from "./mark.js";
@@ -45,7 +46,7 @@ export function drawRoad(model, o, gid) {
45
46
  cx,
46
47
  cy,
47
48
  r,
48
- href: safeLogo(team.logo),
49
+ href: safeLogo(team.logo, { color: team.color, accent: team.textColor, initials: codeOf(team).slice(0, 3), theme }),
49
50
  fit: team.markFit === "contain" ? "contain" : undefined,
50
51
  initials: codeOf(team).slice(0, 3),
51
52
  color: safeColour(team.color),
package/dist/road.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // them, the rounds named down the middle, and the group stage as a compact row at the foot. The idea is that of the "road to the final" graphics that sports sites post
3
3
  // for a World Cup or a Stanley Cup; the arrangement, the type and the code are this package's own, and no one's artwork is used: the marks are the caller's flags and
4
4
  // logos, or the team's initials on its colour.
5
+ import { withEmblems } from "./emblems-source.js";
5
6
  import { hash } from "./format.js";
6
7
  import { safeClass } from "./common.js";
7
8
  import { drawRoad } from "./road.draw.js";
@@ -46,7 +47,7 @@ export function roadToFinal(finalists, options = {}) {
46
47
  check(merged);
47
48
  const m = readModel(finalists, merged);
48
49
  const gid = safeClass(merged.id).replace(/ /g, "-") || `kr-${hash(JSON.stringify([finalists, merged, VERSION]))}`;
49
- return drawRoad(m, merged, gid);
50
+ return withEmblems(merged.emblems, () => drawRoad(m, merged, gid));
50
51
  };
51
52
  return {
52
53
  options: { ...options },
@@ -1,3 +1,4 @@
1
+ import type { EmblemRenderer } from "./emblems-source.ts";
1
2
  import type { Language, Team } from "./types.ts";
2
3
  /** A match's score from the finalist's side: `[for, against]` (numbers, or text such as a series' `4`), or one text, `"4-2"`, that is split at its dash. */
3
4
  export type RoadScore = readonly [number | string, number | string] | string;
@@ -48,6 +49,8 @@ export interface RoadOptions {
48
49
  language?: Language;
49
50
  /** A prefix for the ids inside the drawing. Made from the chart when missing, so that two charts on a page do not share ids. */
50
51
  id?: string;
52
+ /** A renderer of ready-made emblems for this chart alone, so that a finalist's `logo` may be an emblem's id. Over the one the page plugged in with `useEmblems`. */
53
+ emblems?: EmblemRenderer;
51
54
  /** The tournament, set large at the top. "Road to the final" when missing. */
52
55
  title?: string;
53
56
  /** The line under it. "Road to the final" when a `title` is given. */
@@ -0,0 +1,138 @@
1
+ import { type Attacking, type Frame, type SurfaceSize } from "./frames.ts";
2
+ import "./frames.providers.ts";
3
+ import "./surfaces/soccer-providers.ts";
4
+ import { type Park } from "./parks.ts";
5
+ import type { Language, Sport, SurfaceOptions } from "./types.ts";
6
+ export { RULE_IDS } from "./rules.types.ts";
7
+ export type { RuleId } from "./rules.types.ts";
8
+ /** A place: `[x, y]` or `{ x, y }`. */
9
+ export type PlaceLike = readonly [number, number] | {
10
+ readonly x: number;
11
+ readonly y: number;
12
+ };
13
+ /** What `zoneAt` and the predicates take besides the point: the surface's own options (the league, the season, the park, the pitch) and the frame the point is in. */
14
+ export interface ZoneOptions extends Partial<Pick<SurfaceOptions, "league" | "year" | "pitch" | "park" | "fence" | "units" | "sheet" | "net" | "field" | "pool" | "athletics" | "skating" | "language">> {
15
+ /** The frame the point is in: the name of a frame (`nhl-api`, `opta`), a frame, or nothing for the drawing's own (feet, or `units`). */
16
+ frame?: Frame | string;
17
+ /** The size of the surface when the frame is a variable one, in place of the drawing's own. */
18
+ size?: SurfaceSize;
19
+ /** The end the point's team attacks, as the surface is drawn wide; `left` turns the numbers a half turn so that the team attacks right. */
20
+ attacking?: Attacking;
21
+ }
22
+ /** What the rules say of a point. */
23
+ export interface ZoneAnswer {
24
+ sport: Sport;
25
+ /** The point on the surface, in feet in the drawing's wide frame, the team attacking the right. */
26
+ at: [number, number];
27
+ /** True when the point is on the surface, or on its edge. Off it, `zone`, `subzone` and `zones` are empty (a ballpark is the exception: its foul ground and the stands beyond the fence are zones). */
28
+ inBounds: boolean;
29
+ /** The zone the point is in: one of a partition of the surface, such as `offensive-zone`. */
30
+ zone: string | undefined;
31
+ /** The finer area in the zone, when there is one: `crease`, `paint`, `six-yard-box`, `warning-track`. */
32
+ subzone: string | undefined;
33
+ /** Every id that holds, the zone and the subzone first. */
34
+ zones: string[];
35
+ /** The zone of each of the package's zone sets for the sport (`ZONE_SETS`) that the point is in. */
36
+ sets: Record<string, string>;
37
+ /** The name of each id in `zones`, in the language asked for. */
38
+ names: Record<string, string>;
39
+ }
40
+ /** The wall height at a bearing: the stretch of the park's fence that covers it in the season, in feet, or `null` where the park's data holds none. */
41
+ export declare function wallHeightAt(park: Park, angle: number, year?: number): number | null;
42
+ /**
43
+ * Where a point lies by the rules of a sport: the zone, the area in it and every other area that holds, each by id and name. Hockey answers in the
44
+ * offensive, neutral and defensive zones with the crease, the trapezoid, the slot, the face-off circles and behind the goal line; basketball in the
45
+ * frontcourt and backcourt with the restricted area, the paint, the mid-range, the corner threes and the arc; soccer in thirds with the six-yard box,
46
+ * the penalty area, the D, the half-spaces and the wings; baseball in the infield, the outfield, foul territory, the warning track and over the
47
+ * wall by the park's own fence; football in the end zones, the halves, the red zone and between the hashes. Every other sport answers in its zone sets.
48
+ * @example
49
+ * ```ts
50
+ * import { zoneAt } from "@johnmorrisdotca/kyogijo-stadiums/zones";
51
+ * // The NHL API's (69, 22) is the face-off dot in the right end zone: the offensive zone, inside a face-off circle.
52
+ * const dot = zoneAt("nhl", [69, 22], { frame: "nhl-api" });
53
+ * console.log(dot.zone, dot.subzone, dot.zones.includes("faceoff-circle"));
54
+ * // offensive-zone faceoff-circle true
55
+ * ```
56
+ */
57
+ export declare function zoneAt(sport: Sport, point: PlaceLike, options?: ZoneOptions): ZoneAnswer;
58
+ /** `zoneAt` for a place already on the surface: feet in the drawing's wide frame, the team attacking the right. What a drawing's click is asked with (pointer.ts). */
59
+ export declare function zoneAtSurface(sport: Sport, at: readonly [number, number], options?: ZoneOptions): ZoneAnswer;
60
+ /**
61
+ * A function from a place on the surface (feet, the drawing's wide frame, the team attacking the right) to the id of the finest zone it lies in: what a data
62
+ * layer's marks carry as `data-zone`. Built once for the options of a drawing; `undefined` where the sport has no zone there.
63
+ */
64
+ export declare function zoneResolver(sport: Sport, options?: ZoneOptions): (x: number, y: number) => string | undefined;
65
+ /**
66
+ * The name of a zone id in a language: the rules engine's own ids have words in both; any other id (a zone set's) comes back as it is. A court of `league: "fiba"` has the words of FIBA's rule book, which the
67
+ * Japan Basketball Association follows: the restricted area is the no-charge semicircle (ノーチャージセミサークル); in the NBA and the leagues that follow its words it is the restricted area (リストリクテッドエリア).
68
+ */
69
+ export declare const zoneName: (id: string, language?: Language, league?: string) => string;
70
+ /** True when a shot from the place would count three: beyond the three-point line (the arc, or past the straight lines at the sidelines), at the basket the team attacks. */
71
+ export declare const isThreePointer: (point: PlaceLike, options?: ZoneOptions) => boolean;
72
+ /** True when the place is in the paint (the free-throw lane, the key), outside the restricted area. */
73
+ export declare const inPaint: (point: PlaceLike, options?: ZoneOptions) => boolean;
74
+ /** True when the place is in the restricted area under the basket. */
75
+ export declare const inRestrictedArea: (point: PlaceLike, options?: ZoneOptions) => boolean;
76
+ /** True when the place is in the slot (the package's definition: the inner and outer slot in front of the net, between the face-off circles), at either end. */
77
+ export declare const inSlot: (point: PlaceLike, options?: ZoneOptions) => boolean;
78
+ /** True when the place is in a goal crease. */
79
+ export declare const inCrease: (point: PlaceLike, options?: ZoneOptions) => boolean;
80
+ /** True when the place is in a penalty area, at the end the team attacks or the one it defends. */
81
+ export declare const inPenaltyArea: (point: PlaceLike, options?: ZoneOptions) => boolean;
82
+ /** True when the place is in a goal area (the six-yard box), at either end. */
83
+ export declare const inSixYardBox: (point: PlaceLike, options?: ZoneOptions) => boolean;
84
+ /** True when the place is in the red zone: inside the opponent's 20-yard line. */
85
+ export declare const inRedZone: (point: PlaceLike, options?: ZoneOptions) => boolean;
86
+ /** True when the place is between the hash marks. */
87
+ export declare const betweenHashes: (point: PlaceLike, options?: ZoneOptions) => boolean;
88
+ /** True when the place is in fair territory: between the foul lines, which are fair themselves. */
89
+ export declare const isFair: (point: PlaceLike, options?: ZoneOptions) => boolean;
90
+ /** True when the place, in fair territory, lies beyond the park's fence: where a ball came down over the wall. `park` is a key of `PARKS`. */
91
+ export declare const overWall: (point: PlaceLike, options?: ZoneOptions) => boolean;
92
+ /** True when the place is on the warning track. */
93
+ export declare const onWarningTrack: (point: PlaceLike, options?: ZoneOptions) => boolean;
94
+ /** What a home-run decision rests on. */
95
+ export interface HomeRunVerdict {
96
+ /** True: a home run. False: in play or foul. `undefined`: it cannot be told, because the ball was over the fence and its height was given but the park holds no wall height there. */
97
+ homeRun: boolean | undefined;
98
+ /** The place is in fair territory. */
99
+ fair: boolean;
100
+ /** How far from home plate, and the fence's distance in that direction (at the bearing), in feet. */
101
+ distance: number;
102
+ fence: number;
103
+ /** The bearing from dead centre, in degrees (negative to left field). */
104
+ angle: number;
105
+ /** The wall's height at the bearing in feet, or `null` where the park's data holds none. */
106
+ wall: number | null;
107
+ /** True when the park has wall heights at all; `isHomeRun` reports it so that a caller can say the data is missing. */
108
+ wallData: boolean;
109
+ /** Why, in a word: `foul`, `short` (the ball came down inside the fence), `over` (beyond the fence), `cleared` or `struck-wall` (the given height did not clear the wall), `unknown-wall`. */
110
+ reason: "foul" | "short" | "over" | "cleared" | "struck-wall" | "unknown-wall";
111
+ }
112
+ /** What a caller can give about the ball. */
113
+ export interface HomeRunOptions extends ZoneOptions {
114
+ /** The height of the ball in feet as it crossed the fence's line. Without it, a ball that came down beyond the fence in fair territory is a home run. */
115
+ height?: number;
116
+ }
117
+ /**
118
+ * The ballparks whose wall heights the package holds nowhere in their fence: of the 94 parks, the 35 whose article gives heights have them for some stretch,
119
+ * and for the rest the height is not known here, so a decision that needs it is undecided (`homeRun: undefined`), never guessed.
120
+ */
121
+ export declare const PARKS_WITHOUT_WALL_HEIGHTS: readonly string[];
122
+ /**
123
+ * Whether a ball is a home run, from the park's own fence: the fence's distance at the bearing and, when the height of the ball is given, the wall's height there
124
+ * (`wall` data of the park: the stretches of fence with their heights). A ball in fair territory that came down beyond the fence is a home run; one that was
125
+ * lower than the wall where it crossed struck the wall and is in play. Where the park holds no height for the bearing the answer to a question that needs it
126
+ * is `homeRun: undefined`, and `wallData` says whether the park has any heights at all. `park` is a key of `PARKS` (or a park); the place is in the frame of `options.frame`
127
+ * (`retrosheet` and `mlbam` are the usual) or the drawing's own.
128
+ * @example
129
+ * ```ts
130
+ * import { homeRun } from "@johnmorrisdotca/kyogijo-stadiums/zones";
131
+ * // Fenway Park's Green Monster is 37 feet 2 inches high, 310 feet down the line in left.
132
+ * console.log(homeRun("fenway-park", [-250, 250], { frame: "retrosheet", height: 30 }).reason, homeRun("fenway-park", [-250, 250], { frame: "retrosheet", height: 40 }).reason);
133
+ * // struck-wall cleared
134
+ * ```
135
+ */
136
+ export declare function homeRun(park: string | Park, point: PlaceLike, options?: HomeRunOptions): HomeRunVerdict;
137
+ /** `homeRun` as a yes or no: `true` for a home run, `false` for foul, in play or the wall struck, `undefined` where the park's wall height is missing and the decision needs it. */
138
+ export declare const isHomeRun: (park: string | Park, point: PlaceLike, options?: HomeRunOptions) => boolean | undefined;