react-chess-explorer 0.0.3 → 0.0.4

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Robert Blackwell
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Robert Blackwell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,63 +1,65 @@
1
- # react-chess-explorer
2
-
3
- ```bash
4
- npm install
5
- npm run build
6
- ```
7
-
8
- React components for **browsing and replaying chess games**. This package depends on **`react-chess-core` only** (board + engine primitives), not `react-chess-puzzle-kit`.
9
-
10
- **Status:** Phase 5 scaffold — paste requirements into `docs/REQUIREMENTS.md` (or issue) before implementing replay UI.
11
-
12
- ---
13
-
14
- ## Local setup
15
-
16
- ```bash
17
- # Build core first
18
- cd ../react-chess-core && npm run build
19
-
20
- cd ../react-chess-explorer
21
- npm install
22
- npm run build
23
- ```
24
-
25
- **Peer dependencies:** `react`, `react-chessboard`, `chess.js`, **`react-chess-core`**
26
-
27
- ```bash
28
- npm install react-chess-explorer react-chess-core
29
- ```
30
-
31
- ---
32
-
33
- ## Exports (scaffold)
34
-
35
- | Export | Role |
36
- |--------|------|
37
- | **`ExplorerPlaceholder`** | Themed board at start position + scaffold label |
38
- | **`EXPLORER_START_FEN`** | Default FEN constant |
39
-
40
- ---
41
-
42
- ## Requirements
43
-
44
- Add product/API requirements here when ready:
45
-
46
- - `docs/REQUIREMENTS.md` (create when you paste the doc)
47
-
48
- Planned scope (from migration plan): move list, ply navigation, optional engine — wired to EndChess `/games` routes.
49
-
50
- ---
51
-
52
- ## Related packages
53
-
54
- | Package | Role |
55
- |---------|------|
56
- | [react-chess-core](https://github.com/reblackwell3/react-chess-core) | Board theme, highlights, Stockfish |
57
- | [react-chess-puzzle-kit](https://github.com/reblackwell3/react-chess-puzzle-kit) | Puzzles (separate; not a dependency) |
58
-
59
- ---
60
-
61
- ## License
62
-
63
- MIT © Robert Blackwell
1
+ # react-chess-explorer
2
+
3
+ ```bash
4
+ npm install
5
+ npm run build
6
+ ```
7
+
8
+ React components for **browsing and replaying chess games**. This package depends on **`react-chess-core` only** (board + engine primitives), not `react-chess-puzzle-kit`.
9
+
10
+ Used in production at [endchess.com](https://endchess.com).
11
+
12
+ **Status:** Phase 5 scaffold — paste requirements into `docs/REQUIREMENTS.md` (or issue) before implementing replay UI.
13
+
14
+ ---
15
+
16
+ ## Local setup
17
+
18
+ ```bash
19
+ # Build core first
20
+ cd ../react-chess-core && npm run build
21
+
22
+ cd ../react-chess-explorer
23
+ npm install
24
+ npm run build
25
+ ```
26
+
27
+ **Peer dependencies:** `react`, `react-chessboard`, `chess.js`, **`react-chess-core`**
28
+
29
+ ```bash
30
+ npm install react-chess-explorer react-chess-core
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Exports (scaffold)
36
+
37
+ | Export | Role |
38
+ |--------|------|
39
+ | **`ExplorerPlaceholder`** | Themed board at start position + scaffold label |
40
+ | **`EXPLORER_START_FEN`** | Default FEN constant |
41
+
42
+ ---
43
+
44
+ ## Requirements
45
+
46
+ Add product/API requirements here when ready:
47
+
48
+ - `docs/REQUIREMENTS.md` (create when you paste the doc)
49
+
50
+ Planned scope (from migration plan): move list, ply navigation, optional engine — wired to EndChess `/games` routes.
51
+
52
+ ---
53
+
54
+ ## Related packages
55
+
56
+ | Package | Role |
57
+ |---------|------|
58
+ | [react-chess-core](https://github.com/reblackwell3/react-chess-core) | Board theme, highlights, Stockfish |
59
+ | [react-chess-puzzle-kit](https://github.com/reblackwell3/react-chess-puzzle-kit) | Puzzles (separate; not a dependency) |
60
+
61
+ ---
62
+
63
+ ## License
64
+
65
+ MIT © Robert Blackwell
package/dist/index.esm.js CHANGED
@@ -432,30 +432,31 @@ function useExplorerPrefetch({ fen, moves, positionReady, sources, fetchPosition
432
432
  return;
433
433
  }
434
434
  const sourcesParam = sources.length < ALL_GAME_SOURCES.length ? sources : undefined;
435
- for (const move of moves.slice(0, childCount)) {
435
+ const prefetchMove = (move) => {
436
436
  const childFen = fenAfterUci(fen, move.uci);
437
437
  if (!childFen) {
438
- continue;
438
+ return Promise.resolve();
439
439
  }
440
440
  const gamesKey = gamesSessionKey({
441
441
  fen: childFen,
442
442
  sources: sourcesParam,
443
443
  });
444
- if (!peekSessionGames(gamesKey)) {
445
- void fetchPositionGames({ fen: childFen, sources: sourcesParam })
444
+ const gamesPromise = peekSessionGames(gamesKey)
445
+ ? Promise.resolve()
446
+ : fetchPositionGames({ fen: childFen, sources: sourcesParam })
446
447
  .then((games) => {
447
448
  if (!cancelled) {
448
449
  setSessionGames(gamesKey, games);
449
450
  }
450
451
  })
451
452
  .catch(() => undefined);
452
- }
453
453
  if (!fetchPositionVariations) {
454
- continue;
454
+ return gamesPromise;
455
455
  }
456
456
  const variationsKey = variationsSessionKey(childFen);
457
- if (!peekSessionVariations(variationsKey)) {
458
- void fetchPositionVariations({
457
+ const variationsPromise = peekSessionVariations(variationsKey)
458
+ ? Promise.resolve()
459
+ : fetchPositionVariations({
459
460
  fen: childFen,
460
461
  mode: "variations",
461
462
  lineCount: EXPLORER_DEFAULT_VARIATION_LINE_COUNT,
@@ -468,8 +469,17 @@ function useExplorerPrefetch({ fen, moves, positionReady, sources, fetchPosition
468
469
  }
469
470
  })
470
471
  .catch(() => undefined);
472
+ return Promise.all([gamesPromise, variationsPromise]).then(() => undefined);
473
+ };
474
+ void (() => __awaiter(this, void 0, void 0, function* () {
475
+ const movesToPrefetch = moves.slice(0, childCount);
476
+ for (let index = 0; index < movesToPrefetch.length; index += 2) {
477
+ if (cancelled) {
478
+ return;
479
+ }
480
+ yield Promise.all(movesToPrefetch.slice(index, index + 2).map(prefetchMove));
471
481
  }
472
- }
482
+ }))();
473
483
  };
474
484
  if (typeof window.requestIdleCallback === "function") {
475
485
  idleHandle = window.requestIdleCallback(prefetchChildren, {
package/dist/index.js CHANGED
@@ -434,30 +434,31 @@ function useExplorerPrefetch({ fen, moves, positionReady, sources, fetchPosition
434
434
  return;
435
435
  }
436
436
  const sourcesParam = sources.length < ALL_GAME_SOURCES.length ? sources : undefined;
437
- for (const move of moves.slice(0, childCount)) {
437
+ const prefetchMove = (move) => {
438
438
  const childFen = fenAfterUci(fen, move.uci);
439
439
  if (!childFen) {
440
- continue;
440
+ return Promise.resolve();
441
441
  }
442
442
  const gamesKey = gamesSessionKey({
443
443
  fen: childFen,
444
444
  sources: sourcesParam,
445
445
  });
446
- if (!peekSessionGames(gamesKey)) {
447
- void fetchPositionGames({ fen: childFen, sources: sourcesParam })
446
+ const gamesPromise = peekSessionGames(gamesKey)
447
+ ? Promise.resolve()
448
+ : fetchPositionGames({ fen: childFen, sources: sourcesParam })
448
449
  .then((games) => {
449
450
  if (!cancelled) {
450
451
  setSessionGames(gamesKey, games);
451
452
  }
452
453
  })
453
454
  .catch(() => undefined);
454
- }
455
455
  if (!fetchPositionVariations) {
456
- continue;
456
+ return gamesPromise;
457
457
  }
458
458
  const variationsKey = variationsSessionKey(childFen);
459
- if (!peekSessionVariations(variationsKey)) {
460
- void fetchPositionVariations({
459
+ const variationsPromise = peekSessionVariations(variationsKey)
460
+ ? Promise.resolve()
461
+ : fetchPositionVariations({
461
462
  fen: childFen,
462
463
  mode: "variations",
463
464
  lineCount: EXPLORER_DEFAULT_VARIATION_LINE_COUNT,
@@ -470,8 +471,17 @@ function useExplorerPrefetch({ fen, moves, positionReady, sources, fetchPosition
470
471
  }
471
472
  })
472
473
  .catch(() => undefined);
474
+ return Promise.all([gamesPromise, variationsPromise]).then(() => undefined);
475
+ };
476
+ void (() => __awaiter(this, void 0, void 0, function* () {
477
+ const movesToPrefetch = moves.slice(0, childCount);
478
+ for (let index = 0; index < movesToPrefetch.length; index += 2) {
479
+ if (cancelled) {
480
+ return;
481
+ }
482
+ yield Promise.all(movesToPrefetch.slice(index, index + 2).map(prefetchMove));
473
483
  }
474
- }
484
+ }))();
475
485
  };
476
486
  if (typeof window.requestIdleCallback === "function") {
477
487
  idleHandle = window.requestIdleCallback(prefetchChildren, {
package/package.json CHANGED
@@ -1,59 +1,59 @@
1
- {
2
- "name": "react-chess-explorer",
3
- "version": "0.0.3",
4
- "description": "React components for browsing and replaying chess games (depends on react-chess-core only)",
5
- "license": "MIT",
6
- "author": "Robert Blackwell",
7
- "main": "dist/index.js",
8
- "module": "dist/index.esm.js",
9
- "types": "dist/index.d.ts",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/reblackwell3/react-chess-explorer.git"
13
- },
14
- "files": [
15
- "dist"
16
- ],
17
- "scripts": {
18
- "build": "rollup -c",
19
- "prepublishOnly": "npm run build",
20
- "storybook": "storybook dev -p 6008",
21
- "build-storybook": "storybook build"
22
- },
23
- "dependencies": {
24
- "rollup": "^4.22.2",
25
- "rollup-plugin-peer-deps-external": "^2.2.4",
26
- "typescript": "^5.6.2"
27
- },
28
- "peerDependencies": {
29
- "chess.js": "^1.0.0-beta.8",
30
- "react": "^18.3.1",
31
- "react-chess-core": "^0.1.1",
32
- "react-chessboard": "^4.7.1"
33
- },
34
- "devDependencies": {
35
- "@chromatic-com/storybook": "^1.9.0",
36
- "@rollup/plugin-commonjs": "^26.0.1",
37
- "@rollup/plugin-node-resolve": "^15.2.3",
38
- "@rollup/plugin-typescript": "^12.3.0",
39
- "@storybook/addon-essentials": "^8.2.9",
40
- "@storybook/addon-interactions": "^8.2.9",
41
- "@storybook/addon-links": "^8.2.9",
42
- "@storybook/addon-onboarding": "^8.2.9",
43
- "@storybook/blocks": "^8.2.9",
44
- "@storybook/preset-typescript": "^3.0.0",
45
- "@storybook/react": "^8.2.9",
46
- "@storybook/react-vite": "^8.2.9",
47
- "@storybook/test": "^8.2.9",
48
- "@types/react": "^18.3.12",
49
- "@types/react-dom": "^18.3.1",
50
- "@vitejs/plugin-react": "^4.3.1",
51
- "chess.js": "^1.0.0-beta.8",
52
- "react": "^18.3.1",
53
- "react-chess-core": "^0.1.1",
54
- "react-chessboard": "^4.7.1",
55
- "react-dom": "^18.3.1",
56
- "storybook": "^8.2.9",
57
- "tslib": "^2.8.1"
58
- }
59
- }
1
+ {
2
+ "name": "react-chess-explorer",
3
+ "version": "0.0.4",
4
+ "description": "React components for browsing and replaying chess games (depends on react-chess-core only)",
5
+ "license": "MIT",
6
+ "author": "Robert Blackwell",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "dist/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/reblackwell3/react-chess-explorer.git"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "rollup -c",
19
+ "prepublishOnly": "npm run build",
20
+ "storybook": "storybook dev -p 6008",
21
+ "build-storybook": "storybook build"
22
+ },
23
+ "dependencies": {
24
+ "rollup": "^4.22.2",
25
+ "rollup-plugin-peer-deps-external": "^2.2.4",
26
+ "typescript": "^5.6.2"
27
+ },
28
+ "peerDependencies": {
29
+ "chess.js": "^1.0.0-beta.8",
30
+ "react": "^18.3.1",
31
+ "react-chess-core": "^0.1.1",
32
+ "react-chessboard": "^4.7.1"
33
+ },
34
+ "devDependencies": {
35
+ "@chromatic-com/storybook": "^1.9.0",
36
+ "@rollup/plugin-commonjs": "^26.0.1",
37
+ "@rollup/plugin-node-resolve": "^15.2.3",
38
+ "@rollup/plugin-typescript": "^12.3.0",
39
+ "@storybook/addon-essentials": "^8.2.9",
40
+ "@storybook/addon-interactions": "^8.2.9",
41
+ "@storybook/addon-links": "^8.2.9",
42
+ "@storybook/addon-onboarding": "^8.2.9",
43
+ "@storybook/blocks": "^8.2.9",
44
+ "@storybook/preset-typescript": "^3.0.0",
45
+ "@storybook/react": "^8.2.9",
46
+ "@storybook/react-vite": "^8.2.9",
47
+ "@storybook/test": "^8.2.9",
48
+ "@types/react": "^18.3.12",
49
+ "@types/react-dom": "^18.3.1",
50
+ "@vitejs/plugin-react": "^4.3.1",
51
+ "chess.js": "^1.0.0-beta.8",
52
+ "react": "^18.3.1",
53
+ "react-chess-core": "^0.1.1",
54
+ "react-chessboard": "^4.7.1",
55
+ "react-dom": "^18.3.1",
56
+ "storybook": "^8.2.9",
57
+ "tslib": "^2.8.1"
58
+ }
59
+ }