@dxos/plugin-chess 0.9.1-staging.ee54ba693a → 0.11.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/lib/ChessPlugin.mjs +2 -0
- package/dist/lib/ChessPlugin.node.mjs +19 -0
- package/dist/lib/ChessPlugin.node.mjs.map +1 -0
- package/dist/lib/ChessPlugin.workerd.mjs +15 -0
- package/dist/lib/ChessPlugin.workerd.mjs.map +1 -0
- package/dist/lib/capabilities/node.mjs +8 -0
- package/dist/lib/capabilities/node.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +9 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-ChessArticle.mjs +89 -0
- package/dist/lib/chunk-ChessArticle.mjs.map +1 -0
- package/dist/lib/chunk-ChessCard.mjs +25 -0
- package/dist/lib/chunk-ChessCard.mjs.map +1 -0
- package/dist/lib/chunk-ChessPlugin.mjs +26 -0
- package/dist/lib/chunk-ChessPlugin.mjs.map +1 -0
- package/dist/lib/chunk-game-variant.mjs +34 -0
- package/dist/lib/chunk-game-variant.mjs.map +1 -0
- package/dist/lib/chunk-meta.mjs +29 -0
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-move.mjs +23 -0
- package/dist/lib/chunk-move.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +11 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-play.mjs +32 -0
- package/dist/lib/chunk-play.mjs.map +1 -0
- package/dist/lib/chunk-print.mjs +18 -0
- package/dist/lib/chunk-print.mjs.map +1 -0
- package/dist/lib/chunk-rebuild-position-index.mjs +126 -0
- package/dist/lib/chunk-rebuild-position-index.mjs.map +1 -0
- package/dist/lib/chunk-skill-definition.mjs +10 -0
- package/dist/lib/chunk-skill-definition.mjs.map +1 -0
- package/dist/lib/{neutral/chunk-IKWULCKX.mjs → chunk-skills.mjs} +14 -20
- package/dist/lib/chunk-skills.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +202 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/components.mjs +224 -0
- package/dist/lib/components.mjs.map +1 -0
- package/dist/lib/containers.mjs +8 -0
- package/dist/lib/containers.mjs.map +1 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/operations.mjs +7 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/skills.mjs +2 -0
- package/dist/lib/testing.mjs +2 -0
- package/dist/lib/translations.mjs +51 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/capabilities/game-variant.d.ts +1 -1
- package/dist/types/src/capabilities/node.d.ts +5 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +52 -4
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/types.d.ts +1 -1
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +4 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +52 -4
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +4 -1
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
- package/dist/types/src/internal/position-index.d.ts +34 -0
- package/dist/types/src/internal/position-index.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/move.d.ts.map +1 -1
- package/dist/types/src/operations/play.d.ts.map +1 -1
- package/dist/types/src/operations/rebuild-position-index.d.ts +4 -0
- package/dist/types/src/operations/rebuild-position-index.d.ts.map +1 -0
- package/dist/types/src/operations/rebuild-position-index.test.d.ts +2 -0
- package/dist/types/src/operations/rebuild-position-index.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +52 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ChessOperation.d.ts +11 -3
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -1
- package/dist/types/src/types/ChessPositionIndex.d.ts +50 -0
- package/dist/types/src/types/ChessPositionIndex.d.ts.map +1 -0
- package/dist/types/src/types/PlayerReview.d.ts +23 -0
- package/dist/types/src/types/PlayerReview.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +1 -1
- package/package.json +50 -43
- package/src/ChessPlugin.node.ts +2 -2
- package/src/ChessPlugin.tsx +2 -2
- package/src/ChessPlugin.workerd.ts +2 -2
- package/src/capabilities/node.ts +16 -0
- package/src/components/Chessboard/Info.tsx +2 -2
- package/src/components/Chessboard/types.ts +1 -1
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +2 -2
- package/src/containers/ChessArticle/ChessArticle.tsx +19 -13
- package/src/containers/ChessCard/ChessCard.stories.tsx +2 -2
- package/src/containers/ChessCard/ChessCard.tsx +2 -0
- package/src/internal/position-index.ts +148 -0
- package/src/operations/index.ts +1 -0
- package/src/operations/move.ts +1 -2
- package/src/operations/play.ts +1 -2
- package/src/operations/rebuild-position-index.test.ts +118 -0
- package/src/operations/rebuild-position-index.ts +73 -0
- package/src/translations.ts +19 -1
- package/src/types/ChessOperation.ts +25 -4
- package/src/types/ChessPositionIndex.ts +53 -0
- package/src/types/PlayerReview.ts +48 -0
- package/src/types/index.ts +2 -0
- package/dist/lib/neutral/ChessArticle-MPRT54KQ.mjs +0 -89
- package/dist/lib/neutral/ChessArticle-MPRT54KQ.mjs.map +0 -7
- package/dist/lib/neutral/ChessCard-VJ3I6MIB.mjs +0 -24
- package/dist/lib/neutral/ChessCard-VJ3I6MIB.mjs.map +0 -7
- package/dist/lib/neutral/ChessPlugin.mjs +0 -10
- package/dist/lib/neutral/ChessPlugin.mjs.map +0 -7
- package/dist/lib/neutral/ChessPlugin.node.mjs +0 -23
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +0 -7
- package/dist/lib/neutral/ChessPlugin.workerd.mjs +0 -21
- package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/index.mjs +0 -13
- package/dist/lib/neutral/capabilities/index.mjs.map +0 -7
- package/dist/lib/neutral/chunk-AMXVX7V2.mjs +0 -8
- package/dist/lib/neutral/chunk-AMXVX7V2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DXIET5G2.mjs +0 -148
- package/dist/lib/neutral/chunk-DXIET5G2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EXZ3XFEG.mjs +0 -41
- package/dist/lib/neutral/chunk-EXZ3XFEG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IKWULCKX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YZTKZ5F7.mjs +0 -42
- package/dist/lib/neutral/chunk-YZTKZ5F7.mjs.map +0 -7
- package/dist/lib/neutral/components/index.mjs +0 -240
- package/dist/lib/neutral/components/index.mjs.map +0 -7
- package/dist/lib/neutral/containers/index.mjs +0 -11
- package/dist/lib/neutral/containers/index.mjs.map +0 -7
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs +0 -41
- package/dist/lib/neutral/game-variant-ZLPEN2QK.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -18
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -8
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/move-UMDTQST4.mjs +0 -37
- package/dist/lib/neutral/move-UMDTQST4.mjs.map +0 -7
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +0 -13
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +0 -7
- package/dist/lib/neutral/operations/index.mjs +0 -8
- package/dist/lib/neutral/operations/index.mjs.map +0 -7
- package/dist/lib/neutral/play-7XTJZ4N6.mjs +0 -46
- package/dist/lib/neutral/play-7XTJZ4N6.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -16
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/print-JR4VB3UX.mjs +0 -29
- package/dist/lib/neutral/print-JR4VB3UX.mjs.map +0 -7
- package/dist/lib/neutral/skill-definition-ZGQBUE4R.mjs +0 -15
- package/dist/lib/neutral/skill-definition-ZGQBUE4R.mjs.map +0 -7
- package/dist/lib/neutral/skills/index.mjs +0 -8
- package/dist/lib/neutral/skills/index.mjs.map +0 -7
- package/dist/lib/neutral/testing.mjs +0 -8
- package/dist/lib/neutral/testing.mjs.map +0 -7
- package/dist/lib/neutral/translations.mjs +0 -39
- package/dist/lib/neutral/translations.mjs.map +0 -7
- package/dist/lib/neutral/types/index.mjs +0 -10
- package/dist/lib/neutral/types/index.mjs.map +0 -7
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { it } from '@effect/vitest';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import { describe, expect, test } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { AssistantTestLayer } from '@dxos/agent-runtime/testing';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Database, Ref } from '@dxos/echo';
|
|
12
|
+
import { TestHelpers } from '@dxos/effect/testing';
|
|
13
|
+
import { EntityId } from '@dxos/keys';
|
|
14
|
+
import { Game } from '@dxos/plugin-game/types';
|
|
15
|
+
|
|
16
|
+
import * as positionIndexInternal from '../internal/position-index';
|
|
17
|
+
import { Chess, ChessOperation, ChessPositionIndex, PlayerReview } from '../types';
|
|
18
|
+
import { ChessOperationHandlerSet } from './index';
|
|
19
|
+
|
|
20
|
+
EntityId.dangerouslyDisableRandomness();
|
|
21
|
+
|
|
22
|
+
const TestLayer = AssistantTestLayer({
|
|
23
|
+
operationHandlers: ChessOperationHandlerSet,
|
|
24
|
+
types: [Chess.State, Game.Game, PlayerReview.Review, ChessPositionIndex.PositionIndex],
|
|
25
|
+
disableLlmMemoization: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('position-index', () => {
|
|
29
|
+
test('normalizes FEN to the first four fields', () => {
|
|
30
|
+
expect(positionIndexInternal.normalizeFen('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1')).toBe(
|
|
31
|
+
'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('collects white-to-move positions from PGN', () => {
|
|
36
|
+
const fens = positionIndexInternal.positionsForSide({
|
|
37
|
+
pgn: '1. e4 e5 2. Nf3',
|
|
38
|
+
side: 'white',
|
|
39
|
+
});
|
|
40
|
+
expect(fens.length).toBeGreaterThan(1);
|
|
41
|
+
expect(fens[0]).toBe(
|
|
42
|
+
positionIndexInternal.normalizeFen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'),
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('indexes only the first 10 full moves', () => {
|
|
47
|
+
const tenMoves =
|
|
48
|
+
'1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Na5 10. Bc2 c5 *';
|
|
49
|
+
const longer = `${tenMoves.slice(0, -2)} 11. d4 cxd4 12. cxd4 *`;
|
|
50
|
+
|
|
51
|
+
const limited = positionIndexInternal.positionsForSide({ pgn: longer, side: 'white' });
|
|
52
|
+
const baseline = positionIndexInternal.positionsForSide({ pgn: tenMoves, side: 'white' });
|
|
53
|
+
|
|
54
|
+
expect(limited).toEqual(baseline);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('RebuildPositionIndex', () => {
|
|
59
|
+
it.effect(
|
|
60
|
+
'indexes games for the reviewed player',
|
|
61
|
+
Effect.fnUntraced(
|
|
62
|
+
function* ({ expect }) {
|
|
63
|
+
const review = yield* Database.add(PlayerReview.makeReview({ playerName: 'alice' }));
|
|
64
|
+
const variant = Chess.make({ pgn: '1. e4 e5 2. Nf3 Nc6 *' });
|
|
65
|
+
const game = Game.make({
|
|
66
|
+
name: 'alice vs bob',
|
|
67
|
+
players: [
|
|
68
|
+
{ role: 'white', name: 'alice' },
|
|
69
|
+
{ role: 'black', name: 'bob' },
|
|
70
|
+
],
|
|
71
|
+
variant,
|
|
72
|
+
});
|
|
73
|
+
yield* Database.add(variant);
|
|
74
|
+
yield* Database.add(game);
|
|
75
|
+
yield* Database.flush();
|
|
76
|
+
|
|
77
|
+
const result = yield* Operation.invoke(ChessOperation.RebuildPositionIndex, { review: Ref.make(review) });
|
|
78
|
+
expect(result.gamesScanned).toBe(1);
|
|
79
|
+
expect(result.positionsUpdated).toBeGreaterThan(0);
|
|
80
|
+
|
|
81
|
+
const index = yield* Database.load(review.positionIndex);
|
|
82
|
+
const whiteKeys = Object.keys(index.index.white);
|
|
83
|
+
expect(whiteKeys.length).toBeGreaterThan(0);
|
|
84
|
+
const startKey = positionIndexInternal.normalizeFen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
|
|
85
|
+
expect(index.index.white[startKey]?.games).toHaveLength(1);
|
|
86
|
+
},
|
|
87
|
+
Effect.provide(TestLayer),
|
|
88
|
+
TestHelpers.provideTestContext,
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
it.effect(
|
|
93
|
+
'updates only changed FEN leaves on rebuild',
|
|
94
|
+
Effect.fnUntraced(
|
|
95
|
+
function* ({ expect }) {
|
|
96
|
+
const review = yield* Database.add(PlayerReview.makeReview({ playerName: 'alice' }));
|
|
97
|
+
const variant = Chess.make({ pgn: '1. e4 e5 *' });
|
|
98
|
+
const game = Game.make({
|
|
99
|
+
players: [
|
|
100
|
+
{ role: 'white', name: 'alice' },
|
|
101
|
+
{ role: 'black', name: 'bob' },
|
|
102
|
+
],
|
|
103
|
+
variant,
|
|
104
|
+
});
|
|
105
|
+
yield* Database.add(variant);
|
|
106
|
+
yield* Database.add(game);
|
|
107
|
+
yield* Database.flush();
|
|
108
|
+
|
|
109
|
+
const first = yield* Operation.invoke(ChessOperation.RebuildPositionIndex, { review: Ref.make(review) });
|
|
110
|
+
const second = yield* Operation.invoke(ChessOperation.RebuildPositionIndex, { review: Ref.make(review) });
|
|
111
|
+
expect(first.positionsUpdated).toBeGreaterThan(0);
|
|
112
|
+
expect(second.positionsUpdated).toBe(0);
|
|
113
|
+
},
|
|
114
|
+
Effect.provide(TestLayer),
|
|
115
|
+
TestHelpers.provideTestContext,
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Database, Filter, Ref } from '@dxos/echo';
|
|
10
|
+
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { Game, GameVariantMismatchError, loadGame } from '@dxos/plugin-game/types';
|
|
12
|
+
|
|
13
|
+
import * as positionIndexInternal from '../internal/position-index';
|
|
14
|
+
import { Chess, ChessOperation, ChessPositionIndex } from '../types';
|
|
15
|
+
|
|
16
|
+
export default ChessOperation.RebuildPositionIndex.pipe(
|
|
17
|
+
Operation.withHandler(
|
|
18
|
+
Effect.fn(function* ({ review: reviewRef }) {
|
|
19
|
+
const review = yield* Database.load(reviewRef);
|
|
20
|
+
invariant(
|
|
21
|
+
review.playerIdentity || review.playerName,
|
|
22
|
+
'Player review requires playerIdentity or playerName to match games.',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const positionIndex = yield* Database.load(review.positionIndex);
|
|
26
|
+
const games = yield* Database.query(Filter.type(Game.Game)).run;
|
|
27
|
+
|
|
28
|
+
const processed: Array<{
|
|
29
|
+
game: Game.Game;
|
|
30
|
+
side: ChessPositionIndex.Side;
|
|
31
|
+
fens: readonly string[];
|
|
32
|
+
}> = [];
|
|
33
|
+
|
|
34
|
+
for (const game of games) {
|
|
35
|
+
const side = positionIndexInternal.playerSideInGame(review, game);
|
|
36
|
+
if (!side) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Skip games whose variant is not chess, but let database/ref failures abort the rebuild
|
|
41
|
+
// rather than silently producing a partial index.
|
|
42
|
+
const loaded = yield* loadGame(Ref.make(game), Chess.State).pipe(
|
|
43
|
+
Effect.asSome,
|
|
44
|
+
Effect.catchIf(
|
|
45
|
+
(error) => error instanceof GameVariantMismatchError,
|
|
46
|
+
() => Effect.succeedNone,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
if (Option.isNone(loaded)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { variant } = loaded.value;
|
|
54
|
+
processed.push({
|
|
55
|
+
game,
|
|
56
|
+
side,
|
|
57
|
+
fens: positionIndexInternal.positionsForSide({
|
|
58
|
+
pgn: variant.pgn,
|
|
59
|
+
fen: variant.fen,
|
|
60
|
+
side,
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const nextIndex = positionIndexInternal.buildIndex(processed);
|
|
66
|
+
const positionsUpdated = positionIndexInternal.applyIndexDiff(positionIndex, nextIndex);
|
|
67
|
+
yield* Database.flush();
|
|
68
|
+
|
|
69
|
+
return { gamesScanned: processed.length, positionsUpdated };
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
Operation.opaqueHandler,
|
|
73
|
+
);
|
package/src/translations.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Type } from '@dxos/echo';
|
|
|
6
6
|
import { type Resource } from '@dxos/react-ui';
|
|
7
7
|
|
|
8
8
|
import { meta } from '#meta';
|
|
9
|
-
import { Chess } from '#types';
|
|
9
|
+
import { Chess, ChessPositionIndex, PlayerReview } from '#types';
|
|
10
10
|
|
|
11
11
|
export const translations = [
|
|
12
12
|
{
|
|
@@ -21,10 +21,28 @@ export const translations = [
|
|
|
21
21
|
'rename-object.label': 'Rename chess game',
|
|
22
22
|
'delete-object.label': 'Delete chess game',
|
|
23
23
|
},
|
|
24
|
+
[Type.getTypename(PlayerReview.Review)]: {
|
|
25
|
+
'typename.label': 'Player review',
|
|
26
|
+
'typename.label_zero': 'Player reviews',
|
|
27
|
+
'typename.label_one': 'Player review',
|
|
28
|
+
'typename.label_other': 'Player reviews',
|
|
29
|
+
'object-name.placeholder': 'Player review',
|
|
30
|
+
'add-object.label': 'Add player review',
|
|
31
|
+
'rename-object.label': 'Rename player review',
|
|
32
|
+
'delete-object.label': 'Delete player review',
|
|
33
|
+
},
|
|
34
|
+
[Type.getTypename(ChessPositionIndex.PositionIndex)]: {
|
|
35
|
+
'typename.label': 'Position index',
|
|
36
|
+
'typename.label_zero': 'Position indexes',
|
|
37
|
+
'typename.label_one': 'Position index',
|
|
38
|
+
'typename.label_other': 'Position indexes',
|
|
39
|
+
},
|
|
24
40
|
[meta.profile.key]: {
|
|
25
41
|
'plugin.name': 'Chess',
|
|
26
42
|
'new-game.button': 'New game',
|
|
27
43
|
'delete-game.label': 'Delete',
|
|
44
|
+
'rebuild-position-index.button': 'Rebuild index',
|
|
45
|
+
'rebuild-position-index-error.title': 'Failed to rebuild position index',
|
|
28
46
|
'game.checkmate.label': 'Checkmate',
|
|
29
47
|
'game.stalemate.label': 'Stalemate',
|
|
30
48
|
'game.draw.label': 'Draw',
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
9
|
import { Operation } from '@dxos/compute';
|
|
10
|
-
import { Database, DXN } from '@dxos/echo';
|
|
11
|
-
import {
|
|
10
|
+
import { Database, DXN, Ref } from '@dxos/echo';
|
|
11
|
+
import { Game } from '@dxos/plugin-game/types';
|
|
12
12
|
|
|
13
13
|
import * as Chess from './Chess';
|
|
14
|
+
import * as PlayerReview from './PlayerReview';
|
|
14
15
|
|
|
15
16
|
export const Move = Operation.make({
|
|
16
17
|
meta: {
|
|
@@ -20,7 +21,7 @@ export const Move = Operation.make({
|
|
|
20
21
|
icon: 'ph--play--regular',
|
|
21
22
|
},
|
|
22
23
|
input: Schema.Struct({
|
|
23
|
-
game: GameRef(Chess.State).annotations({
|
|
24
|
+
game: Game.GameRef(Chess.State).annotations({
|
|
24
25
|
description: 'The ID of the game object (variant must be Chess).',
|
|
25
26
|
}),
|
|
26
27
|
move: Schema.String.annotations({
|
|
@@ -44,7 +45,7 @@ export const Play = Operation.make({
|
|
|
44
45
|
icon: 'ph--play--regular',
|
|
45
46
|
},
|
|
46
47
|
input: Schema.Struct({
|
|
47
|
-
game: GameRef(Chess.State).annotations({
|
|
48
|
+
game: Game.GameRef(Chess.State).annotations({
|
|
48
49
|
description: 'The ID of the game object (variant must be Chess).',
|
|
49
50
|
}),
|
|
50
51
|
side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({
|
|
@@ -86,3 +87,23 @@ export const Print = Operation.make({
|
|
|
86
87
|
ascii: Schema.String,
|
|
87
88
|
}),
|
|
88
89
|
});
|
|
90
|
+
|
|
91
|
+
/** Rebuilds a player review position index from all chess games in the space. */
|
|
92
|
+
export const RebuildPositionIndex = Operation.make({
|
|
93
|
+
meta: {
|
|
94
|
+
key: DXN.make('org.dxos.plugin.chess.operation.rebuildPositionIndex'),
|
|
95
|
+
name: 'Rebuild Position Index',
|
|
96
|
+
description: 'Scans chess games and updates the player review position index.',
|
|
97
|
+
icon: 'ph--arrows-clockwise--regular',
|
|
98
|
+
},
|
|
99
|
+
services: [Database.Service],
|
|
100
|
+
input: Schema.Struct({
|
|
101
|
+
review: Ref.Ref(PlayerReview.Review).annotations({
|
|
102
|
+
description: 'Player review whose position index should be rebuilt.',
|
|
103
|
+
}),
|
|
104
|
+
}),
|
|
105
|
+
output: Schema.Struct({
|
|
106
|
+
gamesScanned: Schema.Number,
|
|
107
|
+
positionsUpdated: Schema.Number,
|
|
108
|
+
}),
|
|
109
|
+
}).pipe(Operation.visible);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { FormInputAnnotation } from '@dxos/echo/Annotation';
|
|
11
|
+
import { Game } from '@dxos/plugin-game/types';
|
|
12
|
+
|
|
13
|
+
/** Side the reviewed player may play in indexed games. */
|
|
14
|
+
export const Side = Schema.Literal('white', 'black');
|
|
15
|
+
export type Side = Schema.Schema.Type<typeof Side>;
|
|
16
|
+
|
|
17
|
+
/** Games that reached a normalized FEN while the reviewed player was on this side. */
|
|
18
|
+
export const PositionEntry = Schema.Struct({
|
|
19
|
+
games: Schema.mutable(Schema.Array(Ref.Ref(Game.Game))).pipe(FormInputAnnotation.set(false)),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type PositionEntry = Schema.Schema.Type<typeof PositionEntry>;
|
|
23
|
+
|
|
24
|
+
/** FEN-keyed lookup of {@link PositionEntry} for one side. */
|
|
25
|
+
export const SideIndex = Schema.Record({ key: Schema.String, value: PositionEntry });
|
|
26
|
+
|
|
27
|
+
export type SideIndex = Schema.Schema.Type<typeof SideIndex>;
|
|
28
|
+
|
|
29
|
+
/** Per-side position reach counts for a player review. */
|
|
30
|
+
export const Index = Schema.Struct({
|
|
31
|
+
white: SideIndex,
|
|
32
|
+
black: SideIndex,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type Index = Schema.Schema.Type<typeof Index>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Aggregated chess positions reached by a player across indexed games.
|
|
39
|
+
* Stored as a child of {@link PlayerReview}.
|
|
40
|
+
*/
|
|
41
|
+
export class PositionIndex extends Type.makeObject<PositionIndex>(
|
|
42
|
+
DXN.make('org.dxos.type.chess.positionIndex', '0.1.0'),
|
|
43
|
+
)(
|
|
44
|
+
Schema.Struct({
|
|
45
|
+
index: Index.pipe(FormInputAnnotation.set(false)),
|
|
46
|
+
}).pipe(Annotation.IconAnnotation.set({ icon: 'ph--map-trifold--regular', hue: 'amber' })),
|
|
47
|
+
) {}
|
|
48
|
+
|
|
49
|
+
/** Creates an empty position index. */
|
|
50
|
+
export const make = (): PositionIndex =>
|
|
51
|
+
Obj.make(PositionIndex, {
|
|
52
|
+
index: { white: {}, black: {} },
|
|
53
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
9
|
+
import { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/Annotation';
|
|
11
|
+
|
|
12
|
+
import * as ChessPositionIndex from './ChessPositionIndex';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Personal chess opening/position review for a single player.
|
|
16
|
+
* Indexes all reachable positions (by side) across games in the space.
|
|
17
|
+
*/
|
|
18
|
+
export class Review extends Type.makeObject<Review>(DXN.make('org.dxos.type.chess.playerReview', '0.1.0'))(
|
|
19
|
+
Schema.Struct({
|
|
20
|
+
name: Schema.optional(Schema.String),
|
|
21
|
+
/** DID of the reviewed player; matched against {@link org.dxos.type.game} players. */
|
|
22
|
+
playerIdentity: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
23
|
+
/** Display name fallback when identity is absent (e.g. Chess.com username). */
|
|
24
|
+
playerName: Schema.String.pipe(Schema.optional),
|
|
25
|
+
positionIndex: Ref.Ref(ChessPositionIndex.PositionIndex).pipe(FormInputAnnotation.set(false)),
|
|
26
|
+
}).pipe(
|
|
27
|
+
LabelAnnotation.set(['name']),
|
|
28
|
+
Annotation.IconAnnotation.set({ icon: 'ph--chart-polar--regular', hue: 'amber' }),
|
|
29
|
+
),
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
export type MakeReviewProps = {
|
|
33
|
+
name?: string;
|
|
34
|
+
playerIdentity?: string;
|
|
35
|
+
playerName?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Creates a player review with an empty child position index. */
|
|
39
|
+
export const makeReview = (props: MakeReviewProps = {}): Review => {
|
|
40
|
+
const positionIndex = ChessPositionIndex.make();
|
|
41
|
+
const review = Obj.make(Review, {
|
|
42
|
+
...props,
|
|
43
|
+
name: props.name ?? props.playerName ?? 'Player review',
|
|
44
|
+
positionIndex: Ref.make(positionIndex),
|
|
45
|
+
});
|
|
46
|
+
Obj.setParent(positionIndex, review);
|
|
47
|
+
return review;
|
|
48
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/containers/ChessArticle/ChessArticle.tsx
|
|
4
|
-
import { Chess as ChessJS } from "chess.js";
|
|
5
|
-
import React, { useCallback, useRef, useState } from "react";
|
|
6
|
-
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
7
|
-
import { Obj } from "@dxos/echo";
|
|
8
|
-
import { Panel, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
9
|
-
import { mx } from "@dxos/ui-theme";
|
|
10
|
-
import { Chessboard } from "#components";
|
|
11
|
-
import { meta } from "#meta";
|
|
12
|
-
import { Chess } from "#types";
|
|
13
|
-
var ChessArticle = ({ role, variant }) => {
|
|
14
|
-
const { t } = useTranslation(meta.profile.key);
|
|
15
|
-
const [orientation, setOrientation] = useState("white");
|
|
16
|
-
const [showInfo, setShowInfo] = useState(true);
|
|
17
|
-
const controller = useRef(null);
|
|
18
|
-
const handleSelect = useCallback((index) => {
|
|
19
|
-
controller.current?.setMoveNumber(index);
|
|
20
|
-
}, []);
|
|
21
|
-
const isGameOver = (() => {
|
|
22
|
-
if (!Obj.instanceOf(Chess.State, variant) || !variant.pgn && !variant.fen) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const chess = new ChessJS();
|
|
27
|
-
if (variant.pgn) {
|
|
28
|
-
chess.loadPgn(variant.pgn);
|
|
29
|
-
} else if (variant.fen) {
|
|
30
|
-
chess.load(variant.fen);
|
|
31
|
-
}
|
|
32
|
-
return chess.isGameOver();
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
})();
|
|
37
|
-
const handleNewGame = useCallback(() => {
|
|
38
|
-
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
Obj.update(variant, (variant2) => {
|
|
42
|
-
const mutable = variant2;
|
|
43
|
-
mutable.pgn = void 0;
|
|
44
|
-
mutable.fen = void 0;
|
|
45
|
-
});
|
|
46
|
-
}, [
|
|
47
|
-
variant
|
|
48
|
-
]);
|
|
49
|
-
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
53
|
-
state: variant,
|
|
54
|
-
ref: controller
|
|
55
|
-
}, /* @__PURE__ */ React.createElement(Panel.Root, {
|
|
56
|
-
role,
|
|
57
|
-
classNames: "@container"
|
|
58
|
-
}, /* @__PURE__ */ React.createElement(Panel.Toolbar, {
|
|
59
|
-
asChild: true
|
|
60
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, isGameOver && /* @__PURE__ */ React.createElement(Toolbar.Button, {
|
|
61
|
-
onClick: handleNewGame
|
|
62
|
-
}, t("new-game.button")), /* @__PURE__ */ React.createElement("div", {
|
|
63
|
-
className: "grow"
|
|
64
|
-
}), /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
65
|
-
icon: "ph--info--regular",
|
|
66
|
-
iconOnly: true,
|
|
67
|
-
label: t("toggle-info.button"),
|
|
68
|
-
classNames: mx("invisible @4xl:visible"),
|
|
69
|
-
onClick: () => setShowInfo((open) => !open)
|
|
70
|
-
}))), /* @__PURE__ */ React.createElement(Panel.Content, null, /* @__PURE__ */ React.createElement("div", {
|
|
71
|
-
className: mx("grid h-full w-full", showInfo && "@4xl:grid-cols-[1fr_320px] gap-8", role === AppSurface.Article.role && "p-4", role === AppSurface.Section.role && "aspect-square", role === AppSurface.Section.role && showInfo && "@4xl:aspect-auto")
|
|
72
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, {
|
|
73
|
-
classNames: "border rounded-xs",
|
|
74
|
-
orientation
|
|
75
|
-
})), showInfo && /* @__PURE__ */ React.createElement("div", {
|
|
76
|
-
className: "hidden @4xl:flex flex-col justify-center items-center overflow-hidden"
|
|
77
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Info, {
|
|
78
|
-
orientation,
|
|
79
|
-
min: 8,
|
|
80
|
-
max: 8,
|
|
81
|
-
onOrientationChange: setOrientation,
|
|
82
|
-
onClose: () => setShowInfo(false),
|
|
83
|
-
onSelect: handleSelect
|
|
84
|
-
}))))));
|
|
85
|
-
};
|
|
86
|
-
export {
|
|
87
|
-
ChessArticle as default
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=ChessArticle-MPRT54KQ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/ChessArticle/ChessArticle.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { AppSurface } from '@dxos/app-toolkit/ui';\nimport { Obj } from '@dxos/echo';\nimport { type GameVariantSurfaceProps } from '@dxos/plugin-game/types';\nimport { Panel, Toolbar, useTranslation } from '@dxos/react-ui';\nimport { type Player } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Chessboard, type ChessboardController, type ChessboardInfoProps } from '#components';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nexport type ChessArticleProps = GameVariantSurfaceProps;\n\nexport const ChessArticle = ({ role, variant }: ChessArticleProps) => {\n const { t } = useTranslation(meta.profile.key);\n const [orientation, setOrientation] = useState<Player>('white');\n const [showInfo, setShowInfo] = useState(true);\n const controller = useRef<ChessboardController>(null);\n\n const handleSelect = useCallback<NonNullable<ChessboardInfoProps['onSelect']>>((index) => {\n controller.current?.setMoveNumber(index);\n }, []);\n\n const isGameOver = (() => {\n if (!Obj.instanceOf(Chess.State, variant) || (!variant.pgn && !variant.fen)) {\n return false;\n }\n try {\n const chess = new ChessJS();\n if (variant.pgn) {\n chess.loadPgn(variant.pgn);\n } else if (variant.fen) {\n chess.load(variant.fen);\n }\n return chess.isGameOver();\n } catch {\n return false;\n }\n })();\n\n const handleNewGame = useCallback(() => {\n if (!Obj.instanceOf(Chess.State, variant)) {\n return;\n }\n Obj.update(variant, (variant) => {\n const mutable = variant as Obj.Mutable<typeof variant>;\n mutable.pgn = undefined;\n mutable.fen = undefined;\n });\n }, [variant]);\n\n if (!Obj.instanceOf(Chess.State, variant)) {\n return null;\n }\n\n return (\n <Chessboard.Root state={variant} ref={controller}>\n <Panel.Root role={role} classNames='@container'>\n <Panel.Toolbar asChild>\n <Toolbar.Root>\n {isGameOver && <Toolbar.Button onClick={handleNewGame}>{t('new-game.button')}</Toolbar.Button>}\n <div className='grow' />\n <Toolbar.IconButton\n icon='ph--info--regular'\n iconOnly\n label={t('toggle-info.button')}\n classNames={mx('invisible @4xl:visible')}\n onClick={() => setShowInfo((open) => !open)}\n />\n </Toolbar.Root>\n </Panel.Toolbar>\n <Panel.Content>\n <div\n className={mx(\n 'grid h-full w-full',\n showInfo && '@4xl:grid-cols-[1fr_320px] gap-8',\n role === AppSurface.Article.role && 'p-4',\n role === AppSurface.Section.role && 'aspect-square',\n role === AppSurface.Section.role && showInfo && '@4xl:aspect-auto',\n )}\n >\n <Chessboard.Content>\n <Chessboard.Board classNames='border rounded-xs' orientation={orientation} />\n </Chessboard.Content>\n {showInfo && (\n <div className='hidden @4xl:flex flex-col justify-center items-center overflow-hidden'>\n <Chessboard.Info\n orientation={orientation}\n min={8}\n max={8}\n onOrientationChange={setOrientation}\n onClose={() => setShowInfo(false)}\n onSelect={handleSelect}\n />\n </div>\n )}\n </div>\n </Panel.Content>\n </Panel.Root>\n </Chessboard.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["Chess", "ChessJS", "React", "useCallback", "useRef", "useState", "AppSurface", "Obj", "Panel", "Toolbar", "useTranslation", "mx", "Chessboard", "meta", "ChessArticle", "role", "variant", "t", "profile", "key", "orientation", "setOrientation", "showInfo", "setShowInfo", "controller", "handleSelect", "index", "current", "setMoveNumber", "isGameOver", "instanceOf", "State", "pgn", "fen", "chess", "loadPgn", "load", "handleNewGame", "update", "mutable", "undefined", "Root", "state", "ref", "classNames", "asChild", "Button", "onClick", "div", "className", "IconButton", "icon", "iconOnly", "label", "open", "Content", "Article", "Section", "Board", "Info", "min", "max", "onOrientationChange", "onClose", "onSelect"]
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/containers/ChessCard/ChessCard.tsx
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { Obj } from "@dxos/echo";
|
|
6
|
-
import { Card } from "@dxos/react-ui";
|
|
7
|
-
import { Chessboard } from "#components";
|
|
8
|
-
import { Chess } from "#types";
|
|
9
|
-
var ChessCard = ({ variant }) => {
|
|
10
|
-
if (!Obj.instanceOf(Chess.State, variant)) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
return /* @__PURE__ */ React.createElement(Card.Body, null, /* @__PURE__ */ React.createElement(Card.Section, {
|
|
14
|
-
classNames: "aspect-square"
|
|
15
|
-
}, /* @__PURE__ */ React.createElement(Card.Row, {
|
|
16
|
-
fullWidth: true
|
|
17
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Root, {
|
|
18
|
-
state: variant
|
|
19
|
-
}, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, null))))));
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
ChessCard as default
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=ChessCard-VJ3I6MIB.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/containers/ChessCard/ChessCard.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { type GameVariantSurfaceProps } from '@dxos/plugin-game/types';\nimport { Card } from '@dxos/react-ui';\n\nimport { Chessboard } from '#components';\nimport { Chess } from '#types';\n\nexport type ChessCardProps = GameVariantSurfaceProps;\n\nexport const ChessCard = ({ variant }: ChessCardProps) => {\n if (!Obj.instanceOf(Chess.State, variant)) {\n return null;\n }\n\n return (\n <Card.Body>\n <Card.Section classNames='aspect-square'>\n <Card.Row fullWidth>\n <Chessboard.Root state={variant}>\n <Chessboard.Content>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n </Card.Row>\n </Card.Section>\n </Card.Body>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,OAAOA,WAAW;AAElB,SAASC,WAAW;AAEpB,SAASC,YAAY;AAErB,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AAIf,IAAMC,YAAY,CAAC,EAAEC,QAAO,MAAkB;AACnD,MAAI,CAACL,IAAIM,WAAWH,MAAMI,OAAOF,OAAAA,GAAU;AACzC,WAAO;EACT;AAEA,SACE,sBAAA,cAACJ,KAAKO,MAAI,MACR,sBAAA,cAACP,KAAKQ,SAAO;IAACC,YAAW;KACvB,sBAAA,cAACT,KAAKU,KAAG;IAACC,WAAAA;KACR,sBAAA,cAACV,WAAWW,MAAI;IAACC,OAAOT;KACtB,sBAAA,cAACH,WAAWa,SAAO,MACjB,sBAAA,cAACb,WAAWc,OAAK,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAO/B;",
|
|
6
|
-
"names": ["React", "Obj", "Card", "Chessboard", "Chess", "ChessCard", "variant", "instanceOf", "State", "Body", "Section", "classNames", "Row", "fullWidth", "Root", "state", "Content", "Board"]
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/ChessPlugin.node.ts
|
|
4
|
-
import { Plugin } from "@dxos/app-framework";
|
|
5
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
-
import { OperationHandler, SkillDefinition } from "#capabilities";
|
|
7
|
-
import { meta } from "#meta";
|
|
8
|
-
import { Chess } from "#types";
|
|
9
|
-
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
|
|
10
|
-
schema: [
|
|
11
|
-
Chess.State
|
|
12
|
-
]
|
|
13
|
-
}), AppPlugin.addSkillDefinitionModule({
|
|
14
|
-
activate: SkillDefinition
|
|
15
|
-
}), AppPlugin.addOperationHandlerModule({
|
|
16
|
-
activate: OperationHandler
|
|
17
|
-
}), Plugin.make);
|
|
18
|
-
var ChessPlugin_node_default = ChessPlugin;
|
|
19
|
-
export {
|
|
20
|
-
ChessPlugin,
|
|
21
|
-
ChessPlugin_node_default as default
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=ChessPlugin.node.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/ChessPlugin.node.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { OperationHandler, SkillDefinition } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n/**\n * Headless variant of ChessPlugin (no React surfaces / GameVariant).\n * Used in node contexts (CLI, agents) where rendering is unavailable.\n */\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addSkillDefinitionModule({ activate: SkillDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,kBAAkBC,uBAAuB;AAClD,SAASC,YAAY;AACrB,SAASC,aAAa;AAMf,IAAMC,cAAcN,OAAOO,OAAOH,IAAAA,EAAMI,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL,MAAMM;;AAAO,CAAA,GAClDV,UAAUW,yBAAyB;EAAEC,UAAUV;AAAgB,CAAA,GAC/DF,UAAUa,0BAA0B;EAAED,UAAUX;AAAiB,CAAA,GACjEF,OAAOe,IAAI;AAGb,IAAA,2BAAeT;",
|
|
6
|
-
"names": ["Plugin", "AppPlugin", "OperationHandler", "SkillDefinition", "meta", "Chess", "ChessPlugin", "define", "pipe", "addSchemaModule", "schema", "State", "addSkillDefinitionModule", "activate", "addOperationHandlerModule", "make"]
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/ChessPlugin.workerd.ts
|
|
4
|
-
import { Plugin } from "@dxos/app-framework";
|
|
5
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
-
import { OperationHandler } from "#capabilities";
|
|
7
|
-
import { meta } from "#meta";
|
|
8
|
-
import { Chess } from "#types";
|
|
9
|
-
var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addOperationHandlerModule({
|
|
10
|
-
activate: OperationHandler
|
|
11
|
-
}), AppPlugin.addSchemaModule({
|
|
12
|
-
schema: [
|
|
13
|
-
Chess.State
|
|
14
|
-
]
|
|
15
|
-
}), Plugin.make);
|
|
16
|
-
var ChessPlugin_workerd_default = ChessPlugin;
|
|
17
|
-
export {
|
|
18
|
-
ChessPlugin,
|
|
19
|
-
ChessPlugin_workerd_default as default
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=ChessPlugin.workerd.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/ChessPlugin.workerd.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { OperationHandler } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,wBAAwB;AACjC,SAASC,YAAY;AACrB,SAASC,aAAa;AAEf,IAAMC,cAAcL,OAAOM,OAAOH,IAAAA,EAAMI,KAC7CN,UAAUO,0BAA0B;EAAEC,UAAUP;AAAiB,CAAA,GACjED,UAAUS,gBAAgB;EAAEC,QAAQ;IAACP,MAAMQ;;AAAO,CAAA,GAClDZ,OAAOa,IAAI;AAGb,IAAA,8BAAeR;",
|
|
6
|
-
"names": ["Plugin", "AppPlugin", "OperationHandler", "meta", "Chess", "ChessPlugin", "define", "pipe", "addOperationHandlerModule", "activate", "addSchemaModule", "schema", "State", "make"]
|
|
7
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/capabilities/index.ts
|
|
4
|
-
import { Capability } from "@dxos/app-framework";
|
|
5
|
-
var SkillDefinition = Capability.lazy("SkillDefinition", () => import("../skill-definition-ZGQBUE4R.mjs"));
|
|
6
|
-
var GameVariant = Capability.lazy("GameVariant", () => import("../game-variant-ZLPEN2QK.mjs"));
|
|
7
|
-
var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-EKZKFQUG.mjs"));
|
|
8
|
-
export {
|
|
9
|
-
GameVariant,
|
|
10
|
-
OperationHandler,
|
|
11
|
-
SkillDefinition
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/capabilities/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\nimport type { OperationHandlerSet } from '@dxos/compute';\n\nexport const SkillDefinition = Capability.lazy('SkillDefinition', () => import('./skill-definition'));\nexport const GameVariant = Capability.lazy('GameVariant', () => import('./game-variant'));\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,kBAAkB;AAGpB,IAAMC,kBAAkBD,WAAWE,KAAK,mBAAmB,MAAM,OAAO,kCAAA,CAAA;AACxE,IAAMC,cAAcH,WAAWE,KAAK,eAAe,MAAM,OAAO,8BAAA,CAAA;AAChE,IAAME,mBAAmBJ,WAAWE,KACzC,oBACA,MAAM,OAAO,mCAAA,CAAA;",
|
|
6
|
-
"names": ["Capability", "SkillDefinition", "lazy", "GameVariant", "OperationHandler"]
|
|
7
|
-
}
|