@johnmorrisdotca/taisen-brackets 0.1.0 → 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/CHANGELOG.md +24 -2
- package/NOTICE.md +6 -1
- package/README.md +106 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/layout-entry.d.ts +3 -1
- package/dist/layout-entry.js +2 -1
- package/dist/locales.d.ts +42 -0
- package/dist/locales.js +176 -0
- package/dist/matchup.d.ts +9 -6
- package/dist/matchup.js +51 -22
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -1
- package/dist/render.d.ts +6 -6
- package/dist/render.js +61 -56
- package/dist/rounds.d.ts +2 -2
- package/dist/rounds.js +4 -4
- package/dist/table.d.ts +4 -5
- package/dist/table.js +17 -13
- package/dist/theme.js +1 -1
- package/dist/types.d.ts +60 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -3
- package/dist/words.d.ts +0 -7
- package/dist/words.js +0 -33
package/dist/types.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface Team {
|
|
|
21
21
|
group?: string;
|
|
22
22
|
/** A colour for the team's initials when it has no mark, any CSS colour. */
|
|
23
23
|
color?: string;
|
|
24
|
+
/** The name in other languages, by locale code: `{ fr: "Allemagne", ja: "ドイツ" }`. The language of a drawing picks its own, else `name`. */
|
|
25
|
+
names?: Readonly<Record<string, string>>;
|
|
26
|
+
/** An ISO 3166 region code (`DE`), for `countryName` and a `teamName` that uses it. */
|
|
27
|
+
region?: string;
|
|
24
28
|
}
|
|
25
29
|
/** One game of a tie: a match of a knockout, a game of a series, a leg of an aggregate, a replay. */
|
|
26
30
|
export interface Game {
|
|
@@ -86,6 +90,8 @@ export interface Matchup {
|
|
|
86
90
|
pens?: readonly [number, number];
|
|
87
91
|
/** The game with no `games` list went to extra time. */
|
|
88
92
|
extraTime?: boolean;
|
|
93
|
+
/** The tie was settled without a game (a side withdrew): the note says so. */
|
|
94
|
+
walkover?: boolean;
|
|
89
95
|
/** This is the third-place match: it leads nowhere and is drawn apart. */
|
|
90
96
|
third?: boolean;
|
|
91
97
|
note?: string;
|
|
@@ -121,6 +127,7 @@ export interface Tie {
|
|
|
121
127
|
date: string;
|
|
122
128
|
no: number | null;
|
|
123
129
|
third: boolean;
|
|
130
|
+
walkover: boolean;
|
|
124
131
|
note: string | null;
|
|
125
132
|
}
|
|
126
133
|
/** Where the layout put a tie. */
|
|
@@ -193,38 +200,73 @@ export interface LayoutOptions {
|
|
|
193
200
|
/** The order of the halves' groups, first on the left: `["West", "East"]`. Left out, a name with "west" goes left and one with "east" right. */
|
|
194
201
|
groupOrder?: readonly string[];
|
|
195
202
|
}
|
|
196
|
-
/** The words a drawing and a table use. Every one can be replaced (`words`). */
|
|
203
|
+
/** The words a drawing and a table use, in one language. Every one can be replaced (`words`), and a language can be added (`defineLocale`). Phrases take `{name}`-style holes. */
|
|
197
204
|
export interface Words {
|
|
205
|
+
/** A side not known yet. */
|
|
198
206
|
tbd: string;
|
|
207
|
+
/** The word beside the score of a side that had a bye. */
|
|
199
208
|
bye: string;
|
|
209
|
+
/** A tie decided without a game (`Matchup.walkover`). */
|
|
210
|
+
walkover: string;
|
|
211
|
+
/** The label under the champion. */
|
|
200
212
|
champion: string;
|
|
201
213
|
thirdPlace: string;
|
|
202
214
|
/** The heading over ties that lead nowhere near the final. */
|
|
203
215
|
other: string;
|
|
204
|
-
|
|
216
|
+
/** Short notes in a box: after extra time, penalties, aggregate, replay. */
|
|
205
217
|
aet: string;
|
|
206
218
|
pens: string;
|
|
207
219
|
aggregate: string;
|
|
208
220
|
replay: string;
|
|
209
|
-
/**
|
|
221
|
+
/** The same in a sentence (tooltip, table, description). */
|
|
222
|
+
aetLong: string;
|
|
223
|
+
/** `{a}`, `{b}`: the shoot-out's score. */
|
|
224
|
+
pensScore: string;
|
|
225
|
+
aggregateLong: string;
|
|
226
|
+
/** `{n}`: "in 7" (games). */
|
|
210
227
|
inGames: string;
|
|
211
|
-
/** `{n}
|
|
228
|
+
/** `{n}` games, `{w}` wins that settle it: "best of 7". */
|
|
212
229
|
bestOf: string;
|
|
213
|
-
/** `{n}`:
|
|
230
|
+
/** `{n}`: a round with no name. */
|
|
214
231
|
round: string;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
232
|
+
/** `{n}`: "Round of 64", for a round the language has no word of its own for. */
|
|
233
|
+
roundOf: string;
|
|
234
|
+
/** `{a}`, `{b}`: an undecided tie. */
|
|
235
|
+
tieVs: string;
|
|
236
|
+
/** `{a}`, `{b}` the names, `{sa}`, `{sb}` the scores. */
|
|
237
|
+
tieScore: string;
|
|
238
|
+
/** `{a}`, `{b}`: a score as written ("3–1"). */
|
|
239
|
+
scoreText: string;
|
|
240
|
+
/** `{name}`. */
|
|
241
|
+
winnerIs: string;
|
|
242
|
+
championIs: string;
|
|
243
|
+
/** `{round}`, `{tie}`. */
|
|
244
|
+
finalLine: string;
|
|
222
245
|
/** `{n}` teams, `{r}` rounds. */
|
|
223
246
|
summary: string;
|
|
224
|
-
/** The same for a bracket of one round. */
|
|
225
247
|
summaryOne: string;
|
|
248
|
+
/** Joins the sentences of a description, and ends it. */
|
|
249
|
+
sep: string;
|
|
250
|
+
end: string;
|
|
251
|
+
/** `{notes}`: the notes after a tie in a sentence; and what joins several notes. */
|
|
252
|
+
note: string;
|
|
253
|
+
noteJoin: string;
|
|
254
|
+
columnRound: string;
|
|
255
|
+
columnTie: string;
|
|
256
|
+
columnNote: string;
|
|
257
|
+
columnDate: string;
|
|
258
|
+
/** The `<title>` of a drawing with no `title` option. */
|
|
226
259
|
title: string;
|
|
227
260
|
}
|
|
261
|
+
/** A language: its words, the names of the rounds (by their English names), and the tag `Intl` formats numbers and dates for. */
|
|
262
|
+
export interface Locale {
|
|
263
|
+
/** The code (`fr`) and the tag (`fr-CA`, `ja-JP`) used for numbers, dates and capitals. */
|
|
264
|
+
code: string;
|
|
265
|
+
tag: string;
|
|
266
|
+
words: Words;
|
|
267
|
+
/** Round names by their English name: `{ "Round of 16": "Huitièmes de finale" }`. A round with no entry keeps its name (or `roundOf`). */
|
|
268
|
+
rounds: Readonly<Record<string, string>>;
|
|
269
|
+
}
|
|
228
270
|
export type ThemeName = "auto" | "light" | "dark" | "poster" | "none";
|
|
229
271
|
export type SizeName = "wide" | "square" | "phone";
|
|
230
272
|
export interface Size {
|
|
@@ -272,8 +314,12 @@ export interface DrawOptions extends LayoutOptions {
|
|
|
272
314
|
thirdPlace?: "below" | "hide";
|
|
273
315
|
/** Highlight the side that went through. Default true. */
|
|
274
316
|
winnerHighlight?: boolean;
|
|
275
|
-
/** The
|
|
317
|
+
/** The language: `en` (the default), `fr`, `ja`, `es`, `de`, or a `Locale` you made with `defineLocale`. Sets the words, the round names, the number and date formats and the `lang` of the drawing. */
|
|
318
|
+
locale?: string | Locale;
|
|
319
|
+
/** Replace any of the language's words. */
|
|
276
320
|
words?: Partial<Words>;
|
|
321
|
+
/** The name to draw for a team in this language: `undefined` keeps `Team.names[locale]` or `Team.name`. `countryName(team.region, locale)` makes a country's name from Intl, with no list of your own. */
|
|
322
|
+
teamName?: (team: Team, locale: Locale) => string | undefined;
|
|
277
323
|
/** Prefix for the drawing's ids. Default: a hash of the bracket and the options. */
|
|
278
324
|
id?: string;
|
|
279
325
|
/** Extra class names for the root `<svg>`. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.2.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.2.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/taisen-brackets",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Taisen
|
|
3
|
+
"version": "0.2.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 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 and World Cup formats by era, in English, French, Japanese, Spanish and German. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bracket",
|
|
7
7
|
"tournament",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"cfl",
|
|
20
20
|
"soccer",
|
|
21
21
|
"sports",
|
|
22
|
+
"multilingual",
|
|
23
|
+
"i18n",
|
|
22
24
|
"visualization",
|
|
23
25
|
"accessible",
|
|
24
26
|
"dark-mode",
|
|
@@ -77,9 +79,10 @@
|
|
|
77
79
|
"typecheck": "tsc -p tsconfig.check.json",
|
|
78
80
|
"test": "node --test test/*.test.ts",
|
|
79
81
|
"test:package": "pnpm build && node scripts/check-package.mjs",
|
|
80
|
-
"test:readme": "pnpm build && node scripts/make-formats-doc.mjs --check && node scripts/check-readme-examples.mjs",
|
|
82
|
+
"test:readme": "pnpm build && node scripts/make-formats-doc.mjs --check && node scripts/make-languages-doc.mjs --check && node scripts/check-readme-examples.mjs",
|
|
81
83
|
"check": "pnpm lint && pnpm typecheck && pnpm test && pnpm build && node scripts/check-package.mjs",
|
|
82
84
|
"prepublishOnly": "pnpm check",
|
|
85
|
+
"family:readme": "node scripts/family-readme.mjs",
|
|
83
86
|
"dev": "pnpm build && node scripts/dev.mjs",
|
|
84
87
|
"flags": "node scripts/make-flags.mjs",
|
|
85
88
|
"site": "pnpm build && node scripts/site.mjs",
|
package/dist/words.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Words } from "./types.ts";
|
|
2
|
-
/** The English words of a drawing and a table. Pass `words` to replace any of them. */
|
|
3
|
-
export declare const WORDS: Readonly<Words>;
|
|
4
|
-
/** The words with any replacements applied. */
|
|
5
|
-
export declare function wordsWith(over?: Partial<Words>): Words;
|
|
6
|
-
/** Fills `{n}`-style holes in a phrase. */
|
|
7
|
-
export declare function fill(phrase: string, values: Record<string, string | number>): string;
|
package/dist/words.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** The English words of a drawing and a table. Pass `words` to replace any of them. */
|
|
2
|
-
export const WORDS = Object.freeze({
|
|
3
|
-
tbd: "TBD",
|
|
4
|
-
bye: "bye",
|
|
5
|
-
champion: "Champion",
|
|
6
|
-
thirdPlace: "Third place",
|
|
7
|
-
other: "Other ties",
|
|
8
|
-
final: "Final",
|
|
9
|
-
aet: "a.e.t.",
|
|
10
|
-
pens: "pens",
|
|
11
|
-
aggregate: "agg.",
|
|
12
|
-
replay: "replay",
|
|
13
|
-
inGames: "in {n}",
|
|
14
|
-
bestOf: "best of {n}",
|
|
15
|
-
round: "Round {n}",
|
|
16
|
-
winner: "Winner",
|
|
17
|
-
versus: "v",
|
|
18
|
-
columnRound: "Round",
|
|
19
|
-
columnTie: "Tie",
|
|
20
|
-
columnResult: "Result",
|
|
21
|
-
columnNote: "Note",
|
|
22
|
-
summary: "{n} teams, {r} rounds",
|
|
23
|
-
summaryOne: "{n} teams, 1 round",
|
|
24
|
-
title: "Knockout bracket",
|
|
25
|
-
});
|
|
26
|
-
/** The words with any replacements applied. */
|
|
27
|
-
export function wordsWith(over) {
|
|
28
|
-
return { ...WORDS, ...over };
|
|
29
|
-
}
|
|
30
|
-
/** Fills `{n}`-style holes in a phrase. */
|
|
31
|
-
export function fill(phrase, values) {
|
|
32
|
-
return phrase.replace(/\{(\w+)\}/g, (hole, key) => (key in values ? String(values[key]) : hole));
|
|
33
|
-
}
|