@wral/hsot-data 0.1.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/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @wral/hsot-data
2
+
3
+ Lit web components for the HighSchoolOT public data pages, rendered from
4
+ [api-hsot](https://bitbucket.org/cbcnm/api-hsot) v1 read payloads. One
5
+ component per page function; the sport arrives as an attribute, so the
6
+ sport-first site hierarchy (`/football/` → standings) is a publishing concern,
7
+ not a code one. Each published `templates.hsot-web.data-page` document carries
8
+ exactly one of these elements.
9
+
10
+ | Component | Page | Key attributes |
11
+ |---|---|---|
12
+ | `<hsot-scores>` | Scores/Schedules (the scoreboard; future dates are schedules) | `sport`, `date` (YYYY-MM-DD, default today, deep-linkable via `?date=`), `season`, `refresh-interval` |
13
+ | `<hsot-standings>` | Standings, every conference for a sport | `sport`, `season` |
14
+ | `<hsot-rankings>` | The weekly Top 25 with movement + rank history | `sport`, `gender` (poll family), `season`, deep link `?poll=YYYY-MM-DD` |
15
+ | `<hsot-school>` | School hub: hero, team tabs, schedule, roster, honors | `school-id`, `sport` (initial tab, deep link `?sport=`), `season` |
16
+ | `<hsot-boxscore>` | Game detail: line score, coverage, season context | `game-id`, `refresh-interval` |
17
+
18
+ Shared attributes on every component:
19
+
20
+ - `api` — base URL of api-hsot v1 (e.g. `https://api.highschoolot.com/v1`).
21
+ Alternatively set the `.client` **property** to any object with the client
22
+ method surface (see `src/lib/client.mjs`) — the demo client, a test double,
23
+ or the future `@wral/sdk-hsot`. The property wins over the attribute.
24
+ - `game-href`, `school-href`, `section-href` — link templates with `{sport}`,
25
+ `{id}` and `{view}` tokens for cross-page links. Defaults follow the
26
+ sport-first hierarchy: `/{sport}/game/{id}/`, `/school/{id}/`,
27
+ `/{sport}/{view}/`. The site's URL space belongs to Studio publications, so
28
+ these are overridable per mount.
29
+ - `refresh-interval` — milliseconds between reloads (live surfaces). 0 = off.
30
+
31
+ ## Derivation lives here, for now
32
+
33
+ Standings, records, streaks and rank badges are **derived client-side** from
34
+ Game and Ranking payloads:
35
+
36
+ - Winner rule: forfeit (names the awarded side) → score → tiebreakWinner.
37
+ - gameType semantics: scrimmage counts toward nothing; conference counts
38
+ toward overall **and** conference records; nonconference/playoff toward
39
+ overall only.
40
+ - Poll resolution (behavioral contract §8): the poll in effect for a date is
41
+ the latest one on or before it, per gender family — so past box scores keep
42
+ the ranks they were played under.
43
+
44
+ That logic is `src/lib/records.mjs` and `src/lib/polls.mjs`, unit-tested with
45
+ `node --test`. If api-hsot ever grows derived read endpoints, those two files
46
+ are what they replace.
47
+
48
+ ## Development
49
+
50
+ Requires Node 18+.
51
+
52
+ ```bash
53
+ npm install
54
+ npm run dev # demo harness on the vite dev server
55
+ npm test # node --test over src/lib
56
+ npm run lint
57
+ npm run build # dist/index.mjs + dist/define.mjs (lit external)
58
+ # and dist/define.standalone.js (self-contained, for <script src> on pages)
59
+ ```
60
+
61
+ The demo harness (`index.html`) runs the components against a seeded
62
+ in-memory client (`src/demo/demo-client.mjs`): a full football season with
63
+ live, overtime, forfeit and postponed games, nine weekly polls, and three
64
+ rosters. **Player names in the demo data are pseudonyms** — real rosters stay
65
+ out of this repo pending the minors-data review. No live api-hsot call is
66
+ made by the harness.
67
+
68
+ ## Consuming
69
+
70
+ From a page template (the data-page pattern):
71
+
72
+ ```html
73
+ <script type="module" src="https://d2sxodt54h49c7.cloudfront.net/@wral/hsot-data/v0/define.standalone.js"></script>
74
+ <hsot-standings sport="football" api="https://api.highschoolot.com/v1"></hsot-standings>
75
+ ```
76
+
77
+ From an app:
78
+
79
+ ```js
80
+ import '@wral/hsot-data/define'; // defines all five elements
81
+ // or
82
+ import { HsotStandings } from '@wral/hsot-data';
83
+ ```
@@ -0,0 +1,18 @@
1
+ import { H as e, b as n, a as c, d as i, c as a } from "./hsot-boxscore-BYV62gYv.js";
2
+ const r = {
3
+ "hsot-scores": a,
4
+ "hsot-standings": i,
5
+ "hsot-rankings": c,
6
+ "hsot-school": n,
7
+ "hsot-boxscore": e
8
+ };
9
+ function f() {
10
+ const s = globalThis?.customElements;
11
+ if (s)
12
+ for (const [o, t] of Object.entries(r))
13
+ s.get(o) || s.define(o, t);
14
+ }
15
+ typeof window < "u" && globalThis.customElements && f();
16
+ export {
17
+ f as defineAll
18
+ };