@johnmorrisdotca/taisen-brackets 0.2.1 → 0.4.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/dist/types.d.ts CHANGED
@@ -25,6 +25,11 @@ export interface Team {
25
25
  names?: Readonly<Record<string, string>>;
26
26
  /** An ISO 3166 region code (`DE`), for `countryName` and a `teamName` that uses it. */
27
27
  region?: string;
28
+ /**
29
+ * A country code (`ca`, `GB-ENG`) for a round flag drawn by the `flags` option's renderer (`@johnmorrisdotca/hata` has one). With no
30
+ * renderer, or one that has no flag for the code, the team's `mark` is drawn, or its initials: it never throws.
31
+ */
32
+ flag?: string;
28
33
  }
29
34
  /** One game of a tie: a match of a knockout, a game of a series, a leg of an aggregate, a replay. */
30
35
  export interface Game {
@@ -259,6 +264,33 @@ export interface Words {
259
264
  columnDate: string;
260
265
  /** The `<title>` of a drawing with no `title` option. */
261
266
  title: string;
267
+ /** The road-to-the-final chart (`roadToFinal`): its title, the "v" between two finalists, the group stage, FT, AET, `{a}`, `{b}` the shoot-out, and the results. */
268
+ roadTitle: string;
269
+ roadVs: string;
270
+ roadGroup: string;
271
+ roadFt: string;
272
+ roadAet: string;
273
+ roadPens: string;
274
+ roadWon: string;
275
+ roadLost: string;
276
+ roadDrew: string;
277
+ /** The names of the two rounds a road names one match of (the other rounds come from the round names of the language). */
278
+ roadQuarterFinal: string;
279
+ roadSemiFinal: string;
280
+ /** The road's table: the headings, the caption (`{a}`, `{b}`), the chart's name (`{a}`, `{b}`, `{title}`), the summary (`{a}`, `{b}`, `{an}`, `{bn}`) and its sentences. */
281
+ roadTableTeam: string;
282
+ roadTableOpponent: string;
283
+ roadTableScore: string;
284
+ roadTableDecided: string;
285
+ roadTableResult: string;
286
+ roadCaption: string;
287
+ roadName: string;
288
+ roadSummary: string;
289
+ /** `{a}`, `{b}`, `{score}`, `{how}`. */
290
+ roadFinal: string;
291
+ /** `{name}`. */
292
+ roadChampion: string;
293
+ roadToPlay: string;
262
294
  }
263
295
  /** A language: its words, the names of the rounds (by their English names), and the tag `Intl` formats numbers and dates for. */
264
296
  export interface Locale {
@@ -270,7 +302,7 @@ export interface Locale {
270
302
  rounds: Readonly<Record<string, string>>;
271
303
  }
272
304
  export type ThemeName = "auto" | "light" | "dark" | "poster" | "none";
273
- export type SizeName = "wide" | "square" | "phone";
305
+ export type SizeName = "wide" | "square" | "phone" | "card";
274
306
  export interface Size {
275
307
  /** The width of the drawing, in pixels. */
276
308
  width: number;
@@ -279,8 +311,40 @@ export interface Size {
279
311
  }
280
312
  /** How much a box shows: both names and scores, an abbreviation and the score, or only the marks. */
281
313
  export type Detail = "auto" | "full" | "compact" | "mark";
314
+ /** How a flag is framed: `round` in a circle, `square`, or `rect` in its own proportions. */
315
+ export type FlagShape = "round" | "square" | "rect";
316
+ /** What a drawing asks a `flags` renderer for. */
317
+ export interface FlagRequest {
318
+ shape: FlagShape;
319
+ /** Width and height in pixels (the diameter, for a round flag). */
320
+ size: number;
321
+ /** `light` or `dark` for a drawing in that look (`poster` is dark); `inherit` for `auto` and `none`. */
322
+ theme: "inherit" | "light" | "dark";
323
+ }
324
+ /**
325
+ * A function from a country code and a request to an SVG string, or `null` or `undefined` for a code it has no flag for. It must be
326
+ * synchronous: a drawing is a pure function of its options. `@johnmorrisdotca/hata`'s `flag()` is asynchronous, so load the flags first
327
+ * (`await flag(code, { shape: "round" })` for each code) and pass `(code) => loaded[code]`.
328
+ */
329
+ export type FlagRenderer = (code: string, request: FlagRequest) => string | null | undefined;
330
+ /** How a bracket is drawn: `classic` (the default) or `road`, with large round marks, big scores and a dotted path. */
331
+ export type Look = "classic" | "road";
332
+ /** How an emblem is drawn; the names are those of `@johnmorrisdotca/dougu-sports`. */
333
+ export type EmblemStyle = "metal" | "line" | "color";
334
+ /** What `drawBracket` asks an `emblems` renderer for. */
335
+ export interface EmblemRequest {
336
+ style: EmblemStyle;
337
+ /** Width and height in pixels. */
338
+ size: number;
339
+ /** The colour of the main part, when `emblemTint` is set. */
340
+ tint?: string;
341
+ /** `light` or `dark` for a bracket in that look (`poster` is dark); `inherit` for `auto` and `none`, where the drawing's stylesheet or the page sets the ink. */
342
+ theme: "inherit" | "light" | "dark";
343
+ }
344
+ /** A function from an emblem id and a request to an SVG string; `renderEmblem` of `@johnmorrisdotca/dougu-sports/emblems` is one. */
345
+ export type EmblemRenderer = (id: string, options: EmblemRequest) => string;
282
346
  export interface DrawOptions extends LayoutOptions {
283
- /** `wide` 1200 by 675, `square` 1080 by 1080, `phone` 390 wide and as tall as it needs; or a size of your own. Default `wide`. */
347
+ /** `wide` 1200 by 675, `square` 1080 by 1080, `card` 1080 by 1350 (a tall post), `phone` 390 wide and as tall as it needs; or a size of your own. Default `wide`. */
284
348
  size?: SizeName | {
285
349
  width: number;
286
350
  height?: number | null;
@@ -310,8 +374,39 @@ export interface DrawOptions extends LayoutOptions {
310
374
  markShape?: "round" | "square" | "none";
311
375
  /** Show the champion in the centre once the final is played. Default true. */
312
376
  champion?: boolean;
313
- /** A trophy for the centre: inline SVG or an image address. Drawn above the champion. */
377
+ /**
378
+ * A trophy for the centre, drawn above the champion: inline SVG, an image address, or (with `emblems`) an emblem id such as
379
+ * `"trophy:hockey-cup"`. An emblem id with no `emblems` renderer draws nothing and takes no room.
380
+ */
314
381
  trophy?: string;
382
+ /**
383
+ * Draws the emblem a `trophy` id names: any function from an id and a request to an SVG string, such as `renderEmblem` from
384
+ * `@johnmorrisdotca/dougu-sports/emblems`. Called once per champion, with the size the trophy has in the drawing. Its SVG is cleaned
385
+ * like any inline SVG; a renderer that throws, or returns something that is not an `<svg>`, draws no trophy.
386
+ */
387
+ emblems?: EmblemRenderer;
388
+ /** The style an emblem is drawn in: `metal` (the default), `line` or `color`. */
389
+ emblemStyle?: EmblemStyle;
390
+ /** A colour for the emblem's main part (a hex colour or `rgb()`), passed to the renderer as `tint`. */
391
+ emblemTint?: string;
392
+ /**
393
+ * Draws the flag a team's `flag` code names: a synchronous function from a code and `{ shape, size, theme }` to an SVG string, such as one
394
+ * made from `@johnmorrisdotca/hata`. With none, or when it returns nothing for a code, the team's `mark` or its initials are drawn.
395
+ */
396
+ flags?: FlagRenderer;
397
+ /**
398
+ * `classic` (the default) or `road`: the look of the road-to-the-final chart, with large round marks, big bold scores, the loser quiet, the
399
+ * rounds named on pills and a dotted path. Every other option works in both.
400
+ */
401
+ look?: Look;
402
+ /**
403
+ * A link for each tie's box, from the tie and, for a link on one team's row, its side (0 or 1). Called with the tie alone first: an address
404
+ * makes the whole box a link; when that gives none, each side is asked, and a row with an address is a link of its own. Each is a real
405
+ * `<a href>` in the SVG with an accessible name; an address that is not http(s), relative or a `#` fragment is refused. `undefined` is no link.
406
+ */
407
+ href?: (tie: Tie, side?: 0 | 1) => string | null | undefined;
408
+ /** The id of a team whose path to the final is drawn as a dotted line in the look's highlight, the rest quieter. */
409
+ highlightPath?: SideId;
315
410
  /** Where the third-place match goes: `below` the final (the default) or `hide`. */
316
411
  thirdPlace?: "below" | "hide";
317
412
  /** Highlight the side that went through. Default true. */
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.1";
1
+ export declare const VERSION = "0.4.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.2.1";
1
+ export const VERSION = "0.4.0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/taisen-brackets",
3
- "version": "0.2.1",
4
- "description": "Taisen Brackets 対戦, knockout brackets as SVG: from a list of ties (games, best-of series, two legs, replays, byes, a third-place match) it works out the rounds and halves and draws the bracket with the halves meeting at the final, or left to right, wide, square or for a phone, in light, dark or a gold-on-navy poster look, with each team's logo or round flag, the champion in the centre, and an accessible table. NHL, NBA, MLB, NFL, CFL, MLS and World Cup formats by era, in English, French, Japanese, Spanish and German. Zero dependencies.",
3
+ "version": "0.4.0",
4
+ "description": "Taisen Brackets 対戦, knockout brackets as SVG: from a list of ties (games, best-of series, two legs, replays, byes, a third-place match) it works out the rounds and halves and draws the bracket with the halves meeting at the final, or left to right, wide, square, as a tall card or for a phone, in a classic or a road look (large round flags, big scores, a team's dotted path, a link on every box), in light, dark or a gold-on-navy poster look, with each team's logo or round flag, the champion in the centre, and an accessible table; and the road to the final of either finalist. NHL, NBA, MLB, NFL, CFL, MLS and World Cup formats by era, in English, French, Japanese, Spanish and German. Zero dependencies.",
5
5
  "keywords": [
6
6
  "bracket",
7
7
  "tournament",
@@ -62,6 +62,11 @@
62
62
  "types": "./dist/presets-entry.d.ts",
63
63
  "import": "./dist/presets-entry.js",
64
64
  "default": "./dist/presets-entry.js"
65
+ },
66
+ "./road": {
67
+ "types": "./dist/road-entry.d.ts",
68
+ "import": "./dist/road-entry.js",
69
+ "default": "./dist/road-entry.js"
65
70
  }
66
71
  },
67
72
  "files": [
@@ -90,8 +95,21 @@
90
95
  "test:demo": "pnpm site && playwright test",
91
96
  "screenshots": "pnpm site && node scripts/screenshots.mjs"
92
97
  },
98
+ "peerDependencies": {
99
+ "@johnmorrisdotca/dougu-sports": ">=0.1.0 <1",
100
+ "@johnmorrisdotca/hata": ">=1.5.0 <2"
101
+ },
102
+ "peerDependenciesMeta": {
103
+ "@johnmorrisdotca/dougu-sports": {
104
+ "optional": true
105
+ },
106
+ "@johnmorrisdotca/hata": {
107
+ "optional": true
108
+ }
109
+ },
93
110
  "devDependencies": {
94
111
  "@eslint/js": "^9.0.0",
112
+ "@johnmorrisdotca/dougu-sports": "0.1.0",
95
113
  "@johnmorrisdotca/hata": "1.5.0",
96
114
  "@playwright/test": "^1.63.0",
97
115
  "@types/node": "^24.0.0",