@johnmorrisdotca/sugoroku 1.1.0 → 1.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 +20 -0
- package/README.md +6 -4
- package/dist/board.js +1 -1
- package/dist/colours.js +6 -1
- package/dist/computer.d.ts +1 -1
- package/dist/computer.js +9 -4
- package/dist/draw-entry.d.ts +3 -3
- package/dist/draw-entry.js +2 -2
- package/dist/draw.js +30 -11
- package/dist/element.d.ts +3 -122
- package/dist/element.js +327 -405
- package/dist/elementFrame.d.ts +21 -0
- package/dist/elementFrame.js +110 -0
- package/dist/evaluate.js +5 -2
- package/dist/game.js +16 -2
- package/dist/geometry.js +44 -27
- package/dist/index.d.ts +11 -11
- package/dist/index.js +9 -9
- package/dist/match.js +14 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +80 -354
- package/dist/mountView.d.ts +58 -0
- package/dist/mountView.js +459 -0
- package/dist/notation.js +6 -2
- package/dist/play-entry.d.ts +4 -4
- package/dist/play-entry.js +1 -1
- package/dist/positionElement.d.ts +107 -0
- package/dist/positionElement.js +303 -0
- package/dist/positionId.js +4 -1
- package/dist/record.d.ts +1 -1
- package/dist/record.js +27 -31
- package/dist/rules.js +34 -5
- package/dist/strings-fr.data.d.ts +2 -0
- package/dist/strings-fr.data.js +60 -0
- package/dist/strings.d.ts +4 -4
- package/dist/strings.js +10 -5
- package/dist/variants.js +19 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,26 @@ All notable changes to this project are written here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.0] - 2026-12-06
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- French: the board's words (`SUGOROKU_STRINGS.fr`, in `src/strings-fr.data.ts`), chosen by `lang="fr"` (or any `fr-*` tag) on the board or the page, or `language: "fr"`; the position element's default label too. The builder and embed page offer French. Every French string is listed beside its English in `docs/strings-fr.md`, made and held by a test like `docs/strings-ja.md`.
|
|
14
|
+
|
|
15
|
+
- The README opens with the package's thumbnail, and the demo carries it as its link preview (og:image) and publishes the card, a dark card and an icon on Pages at `thumbnail.png`, `thumbnail-dark.png` and `icon.png`.
|
|
16
|
+
|
|
17
|
+
## [1.1.1] - 2026-10-31
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Biome replaces ESLint as the formatter and linter, with the family's shared settings in `scripts/biome-family.json`; `pnpm lint` checks formatting too, and `pnpm format` applies it. The code is formatted once to 120 columns. Nothing a user of the package sees has changed.
|
|
22
|
+
- TypeScript targets ES2022, treats an indexed read as possibly missing, and refuses switch fallthrough and unmarked overrides.
|
|
23
|
+
- `pnpm check` also holds every source file to at most 500 lines of code (`scripts/check-size.mjs`; blank lines, comments, tests and data files are not counted). The board is split across `src/elementFrame.ts` and `src/positionElement.ts`, and the play view lives in `src/mountView.ts`, so those files stay within that.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- The issue chooser's security link shows again: an unquoted colon had made `.github/ISSUE_TEMPLATE/config.yml` invalid YAML.
|
|
28
|
+
|
|
9
29
|
## [1.1.0] - 2026-10-14
|
|
10
30
|
|
|
11
31
|
The board and the position are custom elements with the family's standard embed attributes and a shared builder, and the package has an English and Japanese documentation site with a checked example for every export. The rules, dice, records and computer players are unchanged.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<p align="center"><a href="https://johnmorrisdotca.github.io/sugoroku/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/thumbnail-dark.png"><img src="https://raw.githubusercontent.com/johnmorrisdotca/sugoroku/main/docs/images/thumbnail.png" alt="Sugoroku: a backgammon board drawn as SVG in the middle of a match, the doubling cube at 2 and two dice just rolled." width="1200"></picture></a></p>
|
|
2
|
+
|
|
1
3
|
<h1 align="center">Sugoroku <sub>双六</sub> — Backgammon and its variants</h1>
|
|
2
4
|
|
|
3
5
|
<p align="center"><strong>Backgammon and its variants for JavaScript and TypeScript.</strong><br>
|
|
@@ -85,7 +87,7 @@ And in a page, a game to play against the computer, by touch and mouse, with not
|
|
|
85
87
|
- **Drawn as SVG text**, in an entry of its own: five boards, four sets of checkers, and either way up for a phone.
|
|
86
88
|
- **Played in any page** by touch and mouse (tap a checker then a point, or drag), as one function call (`mountSugoroku`) or one tag (`<sugoroku-board>`), with a match, a cube, undo and a record kept for you.
|
|
87
89
|
- **Optional sounds**: short CC0 clips for a checker set down, a hit, the dice and the cube.
|
|
88
|
-
- **English and
|
|
90
|
+
- **English, Japanese and French** in the board's words; English and Japanese in the demo.
|
|
89
91
|
- **No dependencies**, no network requests, and nothing stored outside the page it is in.
|
|
90
92
|
|
|
91
93
|
### What's in it
|
|
@@ -685,7 +687,7 @@ element.addEventListener("sugoroku-turn", (event) => console.log(event.detail.no
|
|
|
685
687
|
|
|
686
688
|
Tap a checker and then a point (the places it may go light up), or drag it there. A turn may
|
|
687
689
|
be undone move by move until Done. The doubling cube is offered, taken and dropped with
|
|
688
|
-
buttons. The computer plays either side. Words are in English and
|
|
690
|
+
buttons. The computer plays either side. Words are in English, Japanese and French and follow the
|
|
689
691
|
page's `lang`.
|
|
690
692
|
|
|
691
693
|
- **Dice** are rolled by a button, or (`dice: "host"`) given by the page: it hears
|
|
@@ -838,7 +840,7 @@ Any browser with ES2020 modules, custom elements, Pointer Events, `ResizeObserve
|
|
|
838
840
|
|
|
839
841
|
## Languages
|
|
840
842
|
|
|
841
|
-
English and
|
|
843
|
+
English, Japanese and French, chosen by the `lang` of the board's element or the page's (any `fr-*` tag is French), and followed when it changes. The demo has a chooser of its own for English and Japanese and takes the browser's language on a first visit; its builder and embed page also offer French. The board's words (`SUGOROKU_STRINGS`) are in all three. **Japanese and French: included; not yet reviewed by a native reader. Corrections welcome.** Every string of the board is listed beside its English in [docs/strings-ja.md](./docs/strings-ja.md) and [docs/strings-fr.md](./docs/strings-fr.md), and there is an [issue template](https://github.com/johnmorrisdotca/sugoroku/issues/new?template=fix-a-translation.md) for fixing one. Any other language is a table of your own. The rules' notation is the standard one (`24/18 13/11`) in each.
|
|
842
844
|
|
|
843
845
|
## Roadmap
|
|
844
846
|
|
|
@@ -971,7 +973,7 @@ Please follow the [code of conduct](./CODE_OF_CONDUCT.md). A record or a positio
|
|
|
971
973
|
|
|
972
974
|
See [CHANGELOG.md](./CHANGELOG.md).
|
|
973
975
|
|
|
974
|
-
The latest release
|
|
976
|
+
The latest release, 1.2.0, adds French to the board's words.
|
|
975
977
|
|
|
976
978
|
## Licence
|
|
977
979
|
|
package/dist/board.js
CHANGED
package/dist/colours.js
CHANGED
|
@@ -86,4 +86,9 @@ export const SUGOROKU_CHECKER_SETS = {
|
|
|
86
86
|
* console.log(SUGOROKU_CHECKER_SET_NAMES);
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
export const SUGOROKU_CHECKER_SET_NAMES = [
|
|
89
|
+
export const SUGOROKU_CHECKER_SET_NAMES = [
|
|
90
|
+
"classic",
|
|
91
|
+
"red-and-white",
|
|
92
|
+
"gold-and-blue",
|
|
93
|
+
"contrast",
|
|
94
|
+
];
|
package/dist/computer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DiceSource } from "./dice.ts";
|
|
2
|
-
import { type GameState } from "./game.ts";
|
|
3
2
|
import { type EvaluationWeights } from "./evaluate.ts";
|
|
3
|
+
import { type GameState } from "./game.ts";
|
|
4
4
|
import { type Play } from "./plays.ts";
|
|
5
5
|
import type { Random } from "./random.ts";
|
|
6
6
|
import { type Side } from "./side.ts";
|
package/dist/computer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inContact } from "./board.js";
|
|
2
2
|
import { rollFrom } from "./dice.js";
|
|
3
|
-
import { canDouble, endTurn, legalPlaysOf, offerDouble, playTurn, rollDice, rollOpening, takeDouble, dropDouble } from "./game.js";
|
|
4
3
|
import { EVALUATION_WEIGHTS, evaluateFor, keithCount, winChance } from "./evaluate.js";
|
|
4
|
+
import { canDouble, dropDouble, endTurn, legalPlaysOf, offerDouble, playTurn, rollDice, rollOpening, takeDouble, } from "./game.js";
|
|
5
5
|
import { legalPlays } from "./plays.js";
|
|
6
6
|
import { otherSide } from "./side.js";
|
|
7
7
|
/** The strengths, weakest first.
|
|
@@ -34,7 +34,9 @@ const ROLLS_OF_THREE = (() => {
|
|
|
34
34
|
})();
|
|
35
35
|
/** The plays best first by what they leave, each with its score. */
|
|
36
36
|
function ranked(spec, plays, side, weights) {
|
|
37
|
-
return plays
|
|
37
|
+
return plays
|
|
38
|
+
.map((play) => ({ play, score: evaluateFor(spec, play.position, side, weights) }))
|
|
39
|
+
.sort((a, b) => b.score - a.score);
|
|
38
40
|
}
|
|
39
41
|
/** The value, for `side`, of a position that the other side is about to move from: the average over its rolls of what its best reply leaves. */
|
|
40
42
|
function lookedAhead(spec, position, side, weights) {
|
|
@@ -43,7 +45,9 @@ function lookedAhead(spec, position, side, weights) {
|
|
|
43
45
|
let weight = 0;
|
|
44
46
|
const rolls = spec.dice === 2 ? ROLLS : ROLLS_OF_THREE;
|
|
45
47
|
for (const roll of rolls) {
|
|
46
|
-
const dice = spec.dice === 2
|
|
48
|
+
const dice = spec.dice === 2
|
|
49
|
+
? [roll[0], roll[1]]
|
|
50
|
+
: [roll[0], roll[1], roll[2]];
|
|
47
51
|
const chance = roll[spec.dice];
|
|
48
52
|
const replies = legalPlays(spec, position, opp, dice);
|
|
49
53
|
// The other side picks the reply it likes best; we judge what that leaves us.
|
|
@@ -170,7 +174,8 @@ export function wantsToDouble(game, options = {}) {
|
|
|
170
174
|
if (!inContact(spec, game.position)) {
|
|
171
175
|
const race = raceCube(game, side, holds);
|
|
172
176
|
// Not when the race is so lopsided that the other side must drop and the gammon is the only prize: keep it simple and double.
|
|
173
|
-
return race.double &&
|
|
177
|
+
return (race.double &&
|
|
178
|
+
keithCount(game.position, side, true) < keithCount(game.position, otherSide(side), false) + (holds ? 4 : 5));
|
|
174
179
|
}
|
|
175
180
|
if (strength === "greedy")
|
|
176
181
|
return false;
|
package/dist/draw-entry.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* (`@johnmorrisdotca/sugoroku/draw`), so a server that only checks a game never
|
|
5
5
|
* loads any of it.
|
|
6
6
|
*/
|
|
7
|
-
export { colourProperty, SUGOROKU_BOARD_NAMES, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SET_NAMES, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES } from "./colours.ts";
|
|
8
7
|
export type { SugorokuBoardName, SugorokuCheckerSetName, SugorokuColours } from "./colours.ts";
|
|
9
|
-
export {
|
|
8
|
+
export { colourProperty, SUGOROKU_BOARD_NAMES, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SET_NAMES, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES, } from "./colours.ts";
|
|
10
9
|
export type { SugorokuDrawOptions } from "./draw.ts";
|
|
11
|
-
export {
|
|
10
|
+
export { colourStyle, drawSugoroku, MOST_DRAWN } from "./draw.ts";
|
|
12
11
|
export type { BoardOptions, Box, Orientation } from "./geometry.ts";
|
|
12
|
+
export { BoardLayout, boardSize } from "./geometry.ts";
|
|
13
13
|
export { SUGOROKU_STYLE } from "./style.ts";
|
package/dist/draw-entry.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* (`@johnmorrisdotca/sugoroku/draw`), so a server that only checks a game never
|
|
5
5
|
* loads any of it.
|
|
6
6
|
*/
|
|
7
|
-
export { colourProperty, SUGOROKU_BOARD_NAMES, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SET_NAMES, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES } from "./colours.js";
|
|
7
|
+
export { colourProperty, SUGOROKU_BOARD_NAMES, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SET_NAMES, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES, } from "./colours.js";
|
|
8
8
|
export { colourStyle, drawSugoroku, MOST_DRAWN } from "./draw.js";
|
|
9
|
-
export {
|
|
9
|
+
export { BoardLayout, boardSize } from "./geometry.js";
|
|
10
10
|
export { SUGOROKU_STYLE } from "./style.js";
|
package/dist/draw.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { colourProperty, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES } from "./colours.js";
|
|
3
|
-
import { BAR_WIDTH, BoardLayout, boardSize, CHECKER, DIE, PAD, POINT_WIDTH, STACK_STEP, TRAY_WIDTH } from "./geometry.js";
|
|
4
|
-
import {
|
|
1
|
+
import { BAR, boardPoint, POINTS } from "./board.js";
|
|
2
|
+
import { colourProperty, SUGOROKU_BOARDS, SUGOROKU_CHECKER_SETS, SUGOROKU_COLOUR_NAMES, } from "./colours.js";
|
|
3
|
+
import { BAR_WIDTH, BoardLayout, boardSize, CHECKER, DIE, PAD, POINT_WIDTH, STACK_STEP, TRAY_WIDTH, } from "./geometry.js";
|
|
4
|
+
import { SIDES, sideIndex } from "./side.js";
|
|
5
5
|
import { SUGOROKU_STYLE } from "./style.js";
|
|
6
6
|
import { VARIANTS } from "./variants.js";
|
|
7
|
-
const
|
|
7
|
+
const escapeXml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
8
8
|
const n = (value) => String(Math.round(value * 100) / 100);
|
|
9
9
|
/** How many checkers are drawn on a stack before the last one carries the count.
|
|
10
10
|
*
|
|
@@ -16,7 +16,15 @@ const n = (value) => String(Math.round(value * 100) / 100);
|
|
|
16
16
|
*/
|
|
17
17
|
export const MOST_DRAWN = 5;
|
|
18
18
|
/** The pips of each die face, as places on a three by three grid, 0 to 8 reading across and down. */
|
|
19
|
-
const PIPS = [
|
|
19
|
+
const PIPS = [
|
|
20
|
+
[],
|
|
21
|
+
[4],
|
|
22
|
+
[0, 8],
|
|
23
|
+
[0, 4, 8],
|
|
24
|
+
[0, 2, 6, 8],
|
|
25
|
+
[0, 2, 4, 6, 8],
|
|
26
|
+
[0, 2, 3, 5, 6, 8],
|
|
27
|
+
];
|
|
20
28
|
/** The inline custom properties of a drawing: the named board and checkers, then any colour given.
|
|
21
29
|
*
|
|
22
30
|
* @param options - Native drawing, geometry, mounting or computer choices specified by the signature.
|
|
@@ -29,8 +37,14 @@ const PIPS = [[], [4], [0, 8], [0, 4, 8], [0, 2, 6, 8], [0, 2, 4, 6, 8], [0, 2,
|
|
|
29
37
|
* ```
|
|
30
38
|
*/
|
|
31
39
|
export function colourStyle(options) {
|
|
32
|
-
const colours = {
|
|
33
|
-
|
|
40
|
+
const colours = {
|
|
41
|
+
...(options.board === undefined ? {} : SUGOROKU_BOARDS[options.board]),
|
|
42
|
+
...(options.checkers === undefined ? {} : SUGOROKU_CHECKER_SETS[options.checkers]),
|
|
43
|
+
...options.colours,
|
|
44
|
+
};
|
|
45
|
+
return SUGOROKU_COLOUR_NAMES.filter((name) => colours[name] !== undefined)
|
|
46
|
+
.map((name) => `${colourProperty(name)}:${escapeXml(String(colours[name]))}`)
|
|
47
|
+
.join(";");
|
|
34
48
|
}
|
|
35
49
|
/** The words a screen reader hears of a drawing when none is given. */
|
|
36
50
|
function describe(position) {
|
|
@@ -70,7 +84,7 @@ export function drawSugoroku(position, options = {}) {
|
|
|
70
84
|
const mx = (x, w = 0) => layout.mx(x, w);
|
|
71
85
|
const out = [];
|
|
72
86
|
/** Text drawn upright whichever way the board is turned. */
|
|
73
|
-
const text = (x, y, content, className, extra = "") => `<text class="${className}" x="${n(x)}" y="${n(y)}" text-anchor="middle" dominant-baseline="central"${portrait ? ` transform="rotate(-90 ${n(x)} ${n(y)})"` : ""}${extra}>${
|
|
87
|
+
const text = (x, y, content, className, extra = "") => `<text class="${className}" x="${n(x)}" y="${n(y)}" text-anchor="middle" dominant-baseline="central"${portrait ? ` transform="rotate(-90 ${n(x)} ${n(y)})"` : ""}${extra}>${escapeXml(content)}</text>`;
|
|
74
88
|
// The frame, the field of play, the bar, and the trays' wells.
|
|
75
89
|
const field = { x: layout.fieldLeft, y: layout.fieldTop, w: 2 * POINT_WIDTH * 6 + BAR_WIDTH, h: layout.fieldHeight };
|
|
76
90
|
out.push(`<rect class="sg-frame" x="0" y="0" width="${n(layout.width)}" height="${n(layout.height)}" rx="16"/>`);
|
|
@@ -80,7 +94,12 @@ export function drawSugoroku(position, options = {}) {
|
|
|
80
94
|
out.push(`<rect class="sg-tray-well" x="${n(mx(layout.trayLeft, TRAY_WIDTH))}" y="${n(field.y)}" width="${TRAY_WIDTH}" height="${n(field.h)}" rx="4"/>`);
|
|
81
95
|
// The points, with the highlight on the one picked up and on those it may go to.
|
|
82
96
|
const mover = options.highlight?.side;
|
|
83
|
-
const fromBoard = mover !== undefined &&
|
|
97
|
+
const fromBoard = mover !== undefined &&
|
|
98
|
+
options.highlight?.from != null &&
|
|
99
|
+
options.highlight.from !== BAR &&
|
|
100
|
+
options.highlight.from > 0
|
|
101
|
+
? boardPoint(spec, mover, options.highlight.from)
|
|
102
|
+
: null;
|
|
84
103
|
const targetBoard = new Set();
|
|
85
104
|
let offTarget = false;
|
|
86
105
|
const movableBoard = new Set();
|
|
@@ -200,7 +219,7 @@ export function drawSugoroku(position, options = {}) {
|
|
|
200
219
|
const colours = colourStyle(options);
|
|
201
220
|
const theme = options.theme === undefined || options.theme === "auto" ? "" : ` data-theme="${options.theme}"`;
|
|
202
221
|
const inline = options.style === true ? `<style>${SUGOROKU_STYLE}</style>` : "";
|
|
203
|
-
return (`<svg xmlns="http://www.w3.org/2000/svg" class="sugoroku" viewBox="0 0 ${n(width)} ${n(height)}" role="img" aria-label="${
|
|
222
|
+
return (`<svg xmlns="http://www.w3.org/2000/svg" class="sugoroku" viewBox="0 0 ${n(width)} ${n(height)}" role="img" aria-label="${escapeXml(options.label ?? describe(position))}"` +
|
|
204
223
|
` data-orientation="${orientation}" data-view="${view}" data-home="${options.home ?? "right"}"${theme}${colours === "" ? "" : ` style="${colours}"`}>${inline}${root}</svg>`);
|
|
205
224
|
}
|
|
206
225
|
/** Half the strip above or below the points: where their numbers sit. */
|
package/dist/element.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type Position } from "./board.ts";
|
|
1
|
+
import { SugorokuFrame } from "./elementFrame.ts";
|
|
3
2
|
import type { GameState } from "./game.ts";
|
|
4
3
|
import type { Match } from "./match.ts";
|
|
5
4
|
import { type SugorokuMount, type SugorokuMountOptions } from "./mount.ts";
|
|
6
|
-
import type { Side } from "./side.ts";
|
|
7
|
-
import { type VariantKey } from "./variants.ts";
|
|
8
5
|
/**
|
|
9
6
|
* THE `<sugoroku-board>` ELEMENT: a playable backgammon board in a tag, with no
|
|
10
7
|
* framework. `@johnmorrisdotca/sugoroku/element/define` defines it; this entry
|
|
@@ -33,21 +30,6 @@ import { type VariantKey } from "./variants.ts";
|
|
|
33
30
|
* `nextGame`, `newMatch`, `record`) and the properties `game` and `match`. Nothing in it can be selected, and its box stays
|
|
34
31
|
* one steady shape whatever is on the board.
|
|
35
32
|
*/
|
|
36
|
-
declare const ElementBase: typeof HTMLElement;
|
|
37
|
-
declare class SugorokuFrame extends ElementBase {
|
|
38
|
-
#private;
|
|
39
|
-
protected frame(): void;
|
|
40
|
-
protected write(name: string, value: unknown): void;
|
|
41
|
-
/** Symbolic display size, reflected. */
|
|
42
|
-
get size(): string | null;
|
|
43
|
-
set size(value: string | null);
|
|
44
|
-
/** Pixel display width, reflected. */
|
|
45
|
-
get width(): string | null;
|
|
46
|
-
set width(value: string | number | null);
|
|
47
|
-
/** Spoken group label, reflected. */
|
|
48
|
-
get label(): string | null;
|
|
49
|
-
set label(value: string | null);
|
|
50
|
-
}
|
|
51
33
|
/** The real mounted options, checked alongside builder coverage.
|
|
52
34
|
* @example
|
|
53
35
|
* ```ts
|
|
@@ -181,106 +163,5 @@ export declare class SugorokuBoard extends SugorokuFrame {
|
|
|
181
163
|
* ```
|
|
182
164
|
*/
|
|
183
165
|
export declare function defineBoard(tagName?: string, registry?: CustomElementRegistry | undefined): void;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
* @param text - Position ID, JSON position, or null for the variant's start.
|
|
187
|
-
* @param variant - The native variant used for checker counts and layout.
|
|
188
|
-
* @param turn - The on-roll side encoded by a GNU ID.
|
|
189
|
-
* @returns A complete position, or null for malformed or inconsistent input.
|
|
190
|
-
* @example
|
|
191
|
-
* ```ts
|
|
192
|
-
* import { readEmbedPosition } from "@johnmorrisdotca/sugoroku/element";
|
|
193
|
-
* console.log(readEmbedPosition("4HPwATDgc/ABMA")?.points[0].length);
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
export declare function readEmbedPosition(text: string | null, variant?: VariantKey, turn?: Side): Position | null;
|
|
197
|
-
/** Host data and all native SVG drawing choices for a position.
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* import type { SugorokuPositionOptions } from "@johnmorrisdotca/sugoroku/element";
|
|
201
|
-
* const options: SugorokuPositionOptions = {};
|
|
202
|
-
* console.log(Object.keys(options).length); // 0
|
|
203
|
-
* ```
|
|
204
|
-
*/
|
|
205
|
-
export type SugorokuPositionOptions = SugorokuDrawOptions & {
|
|
206
|
-
position?: Position;
|
|
207
|
-
onChange?: (position: Position) => void;
|
|
208
|
-
};
|
|
209
|
-
/** Native draw keys, checked by the shared builder.
|
|
210
|
-
* @example
|
|
211
|
-
* ```ts
|
|
212
|
-
* import { SUGOROKU_DRAW_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
|
|
213
|
-
* console.log(typeof SUGOROKU_DRAW_OPTION_KEYS); // object
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
export declare const SUGOROKU_DRAW_OPTION_KEYS: string[];
|
|
217
|
-
/** All host position options, checked by the builder.
|
|
218
|
-
* @example
|
|
219
|
-
* ```ts
|
|
220
|
-
* import { SUGOROKU_POSITION_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
|
|
221
|
-
* console.log(typeof SUGOROKU_POSITION_OPTION_KEYS); // object
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
export declare const SUGOROKU_POSITION_OPTION_KEYS: string[];
|
|
225
|
-
/** A read-only backgammon position, drawn by the native SVG writer.
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* import { SugorokuPosition } from "@johnmorrisdotca/sugoroku/element";
|
|
229
|
-
* console.log(SugorokuPosition.observedAttributes.includes("lang")); // true
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
export declare class SugorokuPosition extends SugorokuFrame {
|
|
233
|
-
#private;
|
|
234
|
-
static observedAttributes: string[];
|
|
235
|
-
/** Structured current position, or null after an input error. */
|
|
236
|
-
get value(): Position | null;
|
|
237
|
-
/** Native drawing options and trusted host position data. */
|
|
238
|
-
get options(): SugorokuPositionOptions;
|
|
239
|
-
set options(value: SugorokuPositionOptions);
|
|
240
|
-
connectedCallback(): void;
|
|
241
|
-
disconnectedCallback(): void;
|
|
242
|
-
attributeChangedCallback(): void;
|
|
243
|
-
/** Position ID or JSON, reflected. Assign an object to serialize it. */
|
|
244
|
-
get position(): string | null;
|
|
245
|
-
set position(value: string | Position | null);
|
|
246
|
-
/** The `variant` attribute, reflected. */
|
|
247
|
-
get variant(): string | null;
|
|
248
|
-
set variant(value: string | number | boolean | null | undefined);
|
|
249
|
-
/** The `turn` attribute, reflected. */
|
|
250
|
-
get turn(): string | null;
|
|
251
|
-
set turn(value: string | number | boolean | null | undefined);
|
|
252
|
-
/** The `board` attribute, reflected. */
|
|
253
|
-
get board(): string | null;
|
|
254
|
-
set board(value: string | number | boolean | null | undefined);
|
|
255
|
-
/** The `checkers` attribute, reflected. */
|
|
256
|
-
get checkers(): string | null;
|
|
257
|
-
set checkers(value: string | number | boolean | null | undefined);
|
|
258
|
-
/** The `theme` attribute, reflected. */
|
|
259
|
-
get theme(): string | null;
|
|
260
|
-
set theme(value: string | number | boolean | null | undefined);
|
|
261
|
-
/** The `home` attribute, reflected. */
|
|
262
|
-
get home(): string | null;
|
|
263
|
-
set home(value: string | number | boolean | null | undefined);
|
|
264
|
-
/** The `view` attribute, reflected. */
|
|
265
|
-
get view(): string | null;
|
|
266
|
-
set view(value: string | number | boolean | null | undefined);
|
|
267
|
-
/** The `numbers` attribute, reflected. */
|
|
268
|
-
get numbers(): string | null;
|
|
269
|
-
set numbers(value: string | number | boolean | null | undefined);
|
|
270
|
-
/** The `orientation` attribute, reflected. */
|
|
271
|
-
get orientation(): string | null;
|
|
272
|
-
set orientation(value: string | number | boolean | null | undefined);
|
|
273
|
-
}
|
|
274
|
-
/** Defines a static position, or a subclass under a host's tag. Safe on a server.
|
|
275
|
-
* @param tagName - The custom tag name; omitted to use the package default.
|
|
276
|
-
* @param registry - The custom-element registry; omitted outside a browser.
|
|
277
|
-
* @returns Nothing; existing definitions and server imports remain safe.
|
|
278
|
-
* @example
|
|
279
|
-
* ```ts
|
|
280
|
-
* import { definePosition } from "@johnmorrisdotca/sugoroku/element";
|
|
281
|
-
* definePosition();
|
|
282
|
-
* console.log(typeof definePosition); // function
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
export declare function definePosition(tagName?: string, registry?: CustomElementRegistry | undefined): void;
|
|
286
|
-
export {};
|
|
166
|
+
export type { SugorokuPositionOptions } from "./positionElement.ts";
|
|
167
|
+
export { definePosition, readEmbedPosition, SUGOROKU_DRAW_OPTION_KEYS, SUGOROKU_POSITION_OPTION_KEYS, SugorokuPosition, } from "./positionElement.ts";
|