@dxos/plugin-chess 0.10.0 → 0.11.1
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,10 @@
|
|
|
1
|
+
import { Capability } from "@dxos/app-framework";
|
|
2
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { ChessSkill } from "#skills";
|
|
5
|
+
//#region src/capabilities/skill-definition.ts
|
|
6
|
+
var skillDefinition = () => Effect.succeed([Capability.contributes(AppCapabilities.SkillDefinition, ChessSkill)]);
|
|
7
|
+
//#endregion
|
|
8
|
+
export { skillDefinition as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=chunk-skill-definition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-skill-definition.mjs","names":[],"sources":["../../src/capabilities/skill-definition.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\n\nimport { ChessSkill } from '#skills';\n\nconst skillDefinition = () => Effect.succeed([Capability.contributes(AppCapabilities.SkillDefinition, ChessSkill)]);\n\nexport default skillDefinition;\n"],"mappings":";;;;;AAWA,IAAM,wBAAwB,OAAO,QAAQ,CAAC,WAAW,YAAY,gBAAgB,iBAAiB,UAAU,CAAC,CAAC"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
// src/skills/chess-skill.ts
|
|
2
1
|
import { Skill, Template } from "@dxos/compute";
|
|
3
2
|
import { trim } from "@dxos/util";
|
|
4
3
|
import { Chess, ChessOperation } from "#types";
|
|
4
|
+
//#region src/skills/chess-skill.ts
|
|
5
5
|
var operations = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
ChessOperation.Move,
|
|
7
|
+
ChessOperation.Play,
|
|
8
|
+
ChessOperation.Print
|
|
9
9
|
];
|
|
10
10
|
var make = () => Skill.make({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}),
|
|
16
|
-
instructions: Template.make({
|
|
17
|
-
source: trim`
|
|
11
|
+
key: Chess.SKILL_KEY,
|
|
12
|
+
name: "Chess",
|
|
13
|
+
tools: Skill.toolDefinitions({ operations }),
|
|
14
|
+
instructions: Template.make({ source: trim`
|
|
18
15
|
You are an expert chess player.
|
|
19
16
|
To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
|
|
20
17
|
You could suggest a good next move or offer to play a move.
|
|
@@ -23,16 +20,13 @@ var make = () => Skill.make({
|
|
|
23
20
|
When setting a chess position, always set the "pgn" field (move list in standard PGN notation) on the org.dxos.type.chess.state object.
|
|
24
21
|
The "fen" field is not used by the UI for display — the board is driven exclusively from "pgn".
|
|
25
22
|
Setting "fen" alone or leaving "pgn" empty will result in the initial position being shown.
|
|
26
|
-
`
|
|
27
|
-
})
|
|
23
|
+
` })
|
|
28
24
|
});
|
|
29
25
|
var skill = {
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
key: Chess.SKILL_KEY,
|
|
27
|
+
make
|
|
32
28
|
};
|
|
33
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
export { skill as t };
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
chess_skill_default
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=chunk-IKWULCKX.mjs.map
|
|
32
|
+
//# sourceMappingURL=chunk-skills.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-skills.mjs","names":[],"sources":["../../src/skills/chess-skill.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Skill, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { Chess, ChessOperation } from '#types';\n\nconst operations = [ChessOperation.Move, ChessOperation.Play, ChessOperation.Print];\n\nconst make = () =>\n Skill.make({\n key: Chess.SKILL_KEY,\n name: 'Chess',\n tools: Skill.toolDefinitions({ operations }),\n instructions: Template.make({\n source: trim`\n You are an expert chess player.\n To analyze a game you can access the \"pgn\" property by loading the context object that represents the current game.\n You could suggest a good next move or offer to play a move.\n Don't actually make a move unless you are asked to.\n\n When setting a chess position, always set the \"pgn\" field (move list in standard PGN notation) on the org.dxos.type.chess.state object.\n The \"fen\" field is not used by the UI for display — the board is driven exclusively from \"pgn\".\n Setting \"fen\" alone or leaving \"pgn\" empty will result in the initial position being shown.\n `,\n }),\n });\n\nconst skill: Skill.Definition = {\n key: Chess.SKILL_KEY,\n make,\n};\n\nexport default skill;\n"],"mappings":";;;;AASA,IAAM,aAAa;CAAC,eAAe;CAAM,eAAe;CAAM,eAAe;AAAK;AAElF,IAAM,aACJ,MAAM,KAAK;CACT,KAAK,MAAM;CACX,MAAM;CACN,OAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC;CAC3C,cAAc,SAAS,KAAK,EAC1B,QAAQ,IAAI;;;;;;;;;QAUd,CAAC;AACH,CAAC;AAEH,IAAM,QAA0B;CAC9B,KAAK,MAAM;CACX;AACF"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Operation } from "@dxos/compute";
|
|
2
|
+
import { Chess } from "chess.js";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { AppAnnotation } from "@dxos/app-toolkit";
|
|
5
|
+
import { Annotation, DXN, Database, Obj, Ref, Type } from "@dxos/echo";
|
|
6
|
+
import { FormInputAnnotation, HiddenAnnotation, LabelAnnotation } from "@dxos/echo/Annotation";
|
|
7
|
+
import { log } from "@dxos/log";
|
|
8
|
+
import { Game } from "@dxos/plugin-game/types";
|
|
9
|
+
//#region \0rolldown/runtime.js
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/types/Chess.ts
|
|
22
|
+
var Chess_exports = /* @__PURE__ */ __exportAll({
|
|
23
|
+
SKILL_KEY: () => SKILL_KEY,
|
|
24
|
+
State: () => State,
|
|
25
|
+
make: () => make$1
|
|
26
|
+
});
|
|
27
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
|
|
28
|
+
var SKILL_KEY = "org.dxos.skill.chess";
|
|
29
|
+
/**
|
|
30
|
+
* Chess variant state. Referenced by the base `Game` object via `Game.variant`.
|
|
31
|
+
* Players, name, and other game-shared fields live on the base `Game`.
|
|
32
|
+
*/
|
|
33
|
+
var State = class extends Type.makeObject(DXN.make("org.dxos.type.chess.state", "0.1.0"))(Schema.Struct({
|
|
34
|
+
pgn: Schema.String.annotations({ description: "Portable Game Notation." }).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
35
|
+
fen: Schema.String.annotations({ description: "Forsyth-Edwards Notation." }).pipe(FormInputAnnotation.set(false), Schema.optional)
|
|
36
|
+
}).pipe(Annotation.IconAnnotation.set({
|
|
37
|
+
icon: "ph--shield-chevron--regular",
|
|
38
|
+
hue: "amber"
|
|
39
|
+
}), AppAnnotation.SkillsAnnotation.set([SKILL_KEY]), HiddenAnnotation.set(true))) {};
|
|
40
|
+
var make$1 = ({ pgn, fen } = {}) => {
|
|
41
|
+
const chess = new Chess();
|
|
42
|
+
if (pgn) try {
|
|
43
|
+
chess.loadPgn(pgn);
|
|
44
|
+
} catch {
|
|
45
|
+
log.warn(pgn, void 0, {
|
|
46
|
+
"~LogMeta": "~LogMeta",
|
|
47
|
+
F: __dxlog_file,
|
|
48
|
+
L: 44,
|
|
49
|
+
S: void 0
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return Obj.make(State, {
|
|
53
|
+
pgn,
|
|
54
|
+
fen
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/types/ChessPositionIndex.ts
|
|
59
|
+
var ChessPositionIndex_exports = /* @__PURE__ */ __exportAll({
|
|
60
|
+
Index: () => Index,
|
|
61
|
+
PositionEntry: () => PositionEntry,
|
|
62
|
+
PositionIndex: () => PositionIndex,
|
|
63
|
+
Side: () => Side,
|
|
64
|
+
SideIndex: () => SideIndex,
|
|
65
|
+
make: () => make
|
|
66
|
+
});
|
|
67
|
+
/** Side the reviewed player may play in indexed games. */
|
|
68
|
+
var Side = Schema.Literal("white", "black");
|
|
69
|
+
/** Games that reached a normalized FEN while the reviewed player was on this side. */
|
|
70
|
+
var PositionEntry = Schema.Struct({ games: Schema.mutable(Schema.Array(Ref.Ref(Game.Game))).pipe(FormInputAnnotation.set(false)) });
|
|
71
|
+
/** FEN-keyed lookup of {@link PositionEntry} for one side. */
|
|
72
|
+
var SideIndex = Schema.Record({
|
|
73
|
+
key: Schema.String,
|
|
74
|
+
value: PositionEntry
|
|
75
|
+
});
|
|
76
|
+
/** Per-side position reach counts for a player review. */
|
|
77
|
+
var Index = Schema.Struct({
|
|
78
|
+
white: SideIndex,
|
|
79
|
+
black: SideIndex
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Aggregated chess positions reached by a player across indexed games.
|
|
83
|
+
* Stored as a child of {@link PlayerReview}.
|
|
84
|
+
*/
|
|
85
|
+
var PositionIndex = class extends Type.makeObject(DXN.make("org.dxos.type.chess.positionIndex", "0.1.0"))(Schema.Struct({ index: Index.pipe(FormInputAnnotation.set(false)) }).pipe(Annotation.IconAnnotation.set({
|
|
86
|
+
icon: "ph--map-trifold--regular",
|
|
87
|
+
hue: "amber"
|
|
88
|
+
}))) {};
|
|
89
|
+
/** Creates an empty position index. */
|
|
90
|
+
var make = () => Obj.make(PositionIndex, { index: {
|
|
91
|
+
white: {},
|
|
92
|
+
black: {}
|
|
93
|
+
} });
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/types/PlayerReview.ts
|
|
96
|
+
var PlayerReview_exports = /* @__PURE__ */ __exportAll({
|
|
97
|
+
Review: () => Review,
|
|
98
|
+
makeReview: () => makeReview
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Personal chess opening/position review for a single player.
|
|
102
|
+
* Indexes all reachable positions (by side) across games in the space.
|
|
103
|
+
*/
|
|
104
|
+
var Review = class extends Type.makeObject(DXN.make("org.dxos.type.chess.playerReview", "0.1.0"))(Schema.Struct({
|
|
105
|
+
name: Schema.optional(Schema.String),
|
|
106
|
+
/** DID of the reviewed player; matched against {@link org.dxos.type.game} players. */
|
|
107
|
+
playerIdentity: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
108
|
+
/** Display name fallback when identity is absent (e.g. Chess.com username). */
|
|
109
|
+
playerName: Schema.String.pipe(Schema.optional),
|
|
110
|
+
positionIndex: Ref.Ref(PositionIndex).pipe(FormInputAnnotation.set(false))
|
|
111
|
+
}).pipe(LabelAnnotation.set(["name"]), Annotation.IconAnnotation.set({
|
|
112
|
+
icon: "ph--chart-polar--regular",
|
|
113
|
+
hue: "amber"
|
|
114
|
+
}))) {};
|
|
115
|
+
/** Creates a player review with an empty child position index. */
|
|
116
|
+
var makeReview = (props = {}) => {
|
|
117
|
+
const positionIndex = make();
|
|
118
|
+
const review = Obj.make(Review, {
|
|
119
|
+
...props,
|
|
120
|
+
name: props.name ?? props.playerName ?? "Player review",
|
|
121
|
+
positionIndex: Ref.make(positionIndex)
|
|
122
|
+
});
|
|
123
|
+
Obj.setParent(positionIndex, review);
|
|
124
|
+
return review;
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/types/ChessOperation.ts
|
|
128
|
+
var ChessOperation_exports = /* @__PURE__ */ __exportAll({
|
|
129
|
+
Move: () => Move,
|
|
130
|
+
Play: () => Play,
|
|
131
|
+
Print: () => Print,
|
|
132
|
+
RebuildPositionIndex: () => RebuildPositionIndex
|
|
133
|
+
});
|
|
134
|
+
var Move = Operation.make({
|
|
135
|
+
meta: {
|
|
136
|
+
key: DXN.make("org.dxos.function.chess.move"),
|
|
137
|
+
name: "Move",
|
|
138
|
+
description: "Makes a move in the given chess game.",
|
|
139
|
+
icon: "ph--play--regular"
|
|
140
|
+
},
|
|
141
|
+
input: Schema.Struct({
|
|
142
|
+
game: Game.GameRef(State).annotations({ description: "The ID of the game object (variant must be Chess)." }),
|
|
143
|
+
move: Schema.String.annotations({
|
|
144
|
+
description: "The move to make in the chess game.",
|
|
145
|
+
examples: ["e4", "Bf3"]
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
output: Schema.Struct({ pgn: Schema.String.annotations({ description: "The PGN of the game after the move was played." }) }),
|
|
149
|
+
services: [Database.Service]
|
|
150
|
+
});
|
|
151
|
+
var Play = Operation.make({
|
|
152
|
+
meta: {
|
|
153
|
+
key: DXN.make("org.dxos.function.chess.play"),
|
|
154
|
+
name: "Play",
|
|
155
|
+
description: "Uses the chess engine to play the next move.",
|
|
156
|
+
icon: "ph--play--regular"
|
|
157
|
+
},
|
|
158
|
+
input: Schema.Struct({
|
|
159
|
+
game: Game.GameRef(State).annotations({ description: "The ID of the game object (variant must be Chess)." }),
|
|
160
|
+
side: Schema.optional(Schema.Literal("white", "black", "any")).annotations({
|
|
161
|
+
description: "The side to play.",
|
|
162
|
+
defaultValue: "any"
|
|
163
|
+
})
|
|
164
|
+
}),
|
|
165
|
+
output: Schema.Struct({
|
|
166
|
+
pgn: Schema.String.annotations({ description: "The PGN of the game after the move was played." }),
|
|
167
|
+
move: Schema.optional(Schema.String).annotations({ description: "The move that was played." })
|
|
168
|
+
}),
|
|
169
|
+
services: [Database.Service]
|
|
170
|
+
});
|
|
171
|
+
var Print = Operation.make({
|
|
172
|
+
meta: {
|
|
173
|
+
key: DXN.make("org.dxos.function.chess.print"),
|
|
174
|
+
name: "Print game",
|
|
175
|
+
description: "Prints the chess game to ASCII.",
|
|
176
|
+
icon: "ph--clipboard-text--regular"
|
|
177
|
+
},
|
|
178
|
+
input: Schema.Struct({
|
|
179
|
+
pgn: Schema.optional(Schema.String.annotations({ description: "Portable Game Notation." })),
|
|
180
|
+
fen: Schema.optional(Schema.String.annotations({ description: "Forsyth-Edwards Notation." }))
|
|
181
|
+
}),
|
|
182
|
+
output: Schema.Struct({ ascii: Schema.String })
|
|
183
|
+
});
|
|
184
|
+
/** Rebuilds a player review position index from all chess games in the space. */
|
|
185
|
+
var RebuildPositionIndex = Operation.make({
|
|
186
|
+
meta: {
|
|
187
|
+
key: DXN.make("org.dxos.plugin.chess.operation.rebuildPositionIndex"),
|
|
188
|
+
name: "Rebuild Position Index",
|
|
189
|
+
description: "Scans chess games and updates the player review position index.",
|
|
190
|
+
icon: "ph--arrows-clockwise--regular"
|
|
191
|
+
},
|
|
192
|
+
services: [Database.Service],
|
|
193
|
+
input: Schema.Struct({ review: Ref.Ref(Review).annotations({ description: "Player review whose position index should be rebuilt." }) }),
|
|
194
|
+
output: Schema.Struct({
|
|
195
|
+
gamesScanned: Schema.Number,
|
|
196
|
+
positionsUpdated: Schema.Number
|
|
197
|
+
})
|
|
198
|
+
}).pipe(Operation.visible);
|
|
199
|
+
//#endregion
|
|
200
|
+
export { RebuildPositionIndex as a, Chess_exports as c, Print as i, State as l, Move as n, PlayerReview_exports as o, Play as r, ChessPositionIndex_exports as s, ChessOperation_exports as t };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=chunk-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-types.mjs","names":[],"sources":["../../src/types/Chess.ts","../../src/types/ChessPositionIndex.ts","../../src/types/PlayerReview.ts","../../src/types/ChessOperation.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { AppAnnotation } from '@dxos/app-toolkit';\nimport { Annotation, DXN, Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, HiddenAnnotation } from '@dxos/echo/Annotation';\nimport { log } from '@dxos/log';\n\nexport const SKILL_KEY = 'org.dxos.skill.chess';\n\n/**\n * Chess variant state. Referenced by the base `Game` object via `Game.variant`.\n * Players, name, and other game-shared fields live on the base `Game`.\n */\nexport class State extends Type.makeObject<State>(DXN.make('org.dxos.type.chess.state', '0.1.0'))(\n Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'Portable Game Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n fen: Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n }).pipe(\n Annotation.IconAnnotation.set({ icon: 'ph--shield-chevron--regular', hue: 'amber' }),\n AppAnnotation.SkillsAnnotation.set([SKILL_KEY]),\n // Implementation detail of the unified `Game` schema. The user-facing object is `Game`;\n // this state is only ever referenced via `Game.variant`. HiddenAnnotation keeps it out of the\n // navtree's typed branches so an orphaned state object doesn't reappear after the\n // wrapping Game is deleted.\n HiddenAnnotation.set(true),\n ),\n) {}\n\nexport const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {\n const chess = new ChessJS();\n if (pgn) {\n try {\n chess.loadPgn(pgn);\n } catch {\n log.warn(pgn);\n }\n }\n\n return Obj.make(State, {\n pgn,\n fen,\n });\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation } from '@dxos/echo/Annotation';\nimport { Game } from '@dxos/plugin-game/types';\n\n/** Side the reviewed player may play in indexed games. */\nexport const Side = Schema.Literal('white', 'black');\nexport type Side = Schema.Schema.Type<typeof Side>;\n\n/** Games that reached a normalized FEN while the reviewed player was on this side. */\nexport const PositionEntry = Schema.Struct({\n games: Schema.mutable(Schema.Array(Ref.Ref(Game.Game))).pipe(FormInputAnnotation.set(false)),\n});\n\nexport type PositionEntry = Schema.Schema.Type<typeof PositionEntry>;\n\n/** FEN-keyed lookup of {@link PositionEntry} for one side. */\nexport const SideIndex = Schema.Record({ key: Schema.String, value: PositionEntry });\n\nexport type SideIndex = Schema.Schema.Type<typeof SideIndex>;\n\n/** Per-side position reach counts for a player review. */\nexport const Index = Schema.Struct({\n white: SideIndex,\n black: SideIndex,\n});\n\nexport type Index = Schema.Schema.Type<typeof Index>;\n\n/**\n * Aggregated chess positions reached by a player across indexed games.\n * Stored as a child of {@link PlayerReview}.\n */\nexport class PositionIndex extends Type.makeObject<PositionIndex>(\n DXN.make('org.dxos.type.chess.positionIndex', '0.1.0'),\n)(\n Schema.Struct({\n index: Index.pipe(FormInputAnnotation.set(false)),\n }).pipe(Annotation.IconAnnotation.set({ icon: 'ph--map-trifold--regular', hue: 'amber' })),\n) {}\n\n/** Creates an empty position index. */\nexport const make = (): PositionIndex =>\n Obj.make(PositionIndex, {\n index: { white: {}, black: {} },\n });\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/Annotation';\n\nimport * as ChessPositionIndex from './ChessPositionIndex';\n\n/**\n * Personal chess opening/position review for a single player.\n * Indexes all reachable positions (by side) across games in the space.\n */\nexport class Review extends Type.makeObject<Review>(DXN.make('org.dxos.type.chess.playerReview', '0.1.0'))(\n Schema.Struct({\n name: Schema.optional(Schema.String),\n /** DID of the reviewed player; matched against {@link org.dxos.type.game} players. */\n playerIdentity: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),\n /** Display name fallback when identity is absent (e.g. Chess.com username). */\n playerName: Schema.String.pipe(Schema.optional),\n positionIndex: Ref.Ref(ChessPositionIndex.PositionIndex).pipe(FormInputAnnotation.set(false)),\n }).pipe(\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--chart-polar--regular', hue: 'amber' }),\n ),\n) {}\n\nexport type MakeReviewProps = {\n name?: string;\n playerIdentity?: string;\n playerName?: string;\n};\n\n/** Creates a player review with an empty child position index. */\nexport const makeReview = (props: MakeReviewProps = {}): Review => {\n const positionIndex = ChessPositionIndex.make();\n const review = Obj.make(Review, {\n ...props,\n name: props.name ?? props.playerName ?? 'Player review',\n positionIndex: Ref.make(positionIndex),\n });\n Obj.setParent(positionIndex, review);\n return review;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, DXN, Ref } from '@dxos/echo';\nimport { Game } from '@dxos/plugin-game/types';\n\nimport * as Chess from './Chess';\nimport * as PlayerReview from './PlayerReview';\n\nexport const Move = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.move'),\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n icon: 'ph--play--regular',\n },\n input: Schema.Struct({\n game: Game.GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Play = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.play'),\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n icon: 'ph--play--regular',\n },\n input: Schema.Struct({\n game: Game.GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({\n description: 'The side to play.',\n defaultValue: 'any',\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n move: Schema.optional(Schema.String).annotations({\n description: 'The move that was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Print = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.print'),\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\n icon: 'ph--clipboard-text--regular',\n },\n input: Schema.Struct({\n pgn: Schema.optional(\n Schema.String.annotations({\n description: 'Portable Game Notation.',\n }),\n ),\n fen: Schema.optional(\n Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }),\n ),\n }),\n output: Schema.Struct({\n ascii: Schema.String,\n }),\n});\n\n/** Rebuilds a player review position index from all chess games in the space. */\nexport const RebuildPositionIndex = Operation.make({\n meta: {\n key: DXN.make('org.dxos.plugin.chess.operation.rebuildPositionIndex'),\n name: 'Rebuild Position Index',\n description: 'Scans chess games and updates the player review position index.',\n icon: 'ph--arrows-clockwise--regular',\n },\n services: [Database.Service],\n input: Schema.Struct({\n review: Ref.Ref(PlayerReview.Review).annotations({\n description: 'Player review whose position index should be rebuilt.',\n }),\n }),\n output: Schema.Struct({\n gamesScanned: Schema.Number,\n positionsUpdated: Schema.Number,\n }),\n}).pipe(Operation.visible);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAa,YAAY;;;;;AAMzB,IAAa,QAAb,cAA2B,KAAK,WAAkB,IAAI,KAAK,6BAA6B,OAAO,CAAC,CAAC,CAC/F,OAAO,OAAO;CACZ,KAAK,OAAO,OAAO,YAAY,EAC7B,aAAa,0BACf,CAAC,CAAC,CAAC,KAAK,oBAAoB,IAAI,KAAK,GAAG,OAAO,QAAQ;CACvD,KAAK,OAAO,OAAO,YAAY,EAC7B,aAAa,4BACf,CAAC,CAAC,CAAC,KAAK,oBAAoB,IAAI,KAAK,GAAG,OAAO,QAAQ;AACzD,CAAC,CAAC,CAAC,KACD,WAAW,eAAe,IAAI;CAAE,MAAM;CAA+B,KAAK;AAAQ,CAAC,GACnF,cAAc,iBAAiB,IAAI,CAAC,SAAS,CAAC,GAK9C,iBAAiB,IAAI,IAAI,CAC3B,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,UAAQ,EAAE,KAAK,QAAwC,CAAC,MAAa;CAChF,MAAM,QAAQ,IAAI,MAAQ;CAC1B,IAAI,KACF,IAAI;EACF,MAAM,QAAQ,GAAG;CACnB,QAAQ;EACN,IAAI,KAAK,KAAE,KAAA,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,KAAA;EAAA,CAAC;CACd;CAGF,OAAO,IAAI,KAAK,OAAO;EACrB;EACA;CACF,CAAC;AACH;;;;;;;;;;;;ACtCA,IAAa,OAAO,OAAO,QAAQ,SAAS,OAAO;;AAInD,IAAa,gBAAgB,OAAO,OAAO,EACzC,OAAO,OAAO,QAAQ,OAAO,MAAM,IAAI,IAAI,K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KAAK,OAAO,SACV,OAAO,OAAO,YAAY,EACxB,aAAa,0BACf,CAAC,CACH;EACA,KAAK,OAAO,SACV,OAAO,OAAO,YAAY,EACxB,aAAa,4BACf,CAAC,CACH;CACF,CAAC;CACD,QAAQ,OAAO,OAAO,EACpB,OAAO,OAAO,OAChB,CAAC;AACH,CAAC;;AAGD,IAAa,uBAAuB,UAAU,KAAK;CACjD,MAAM;EACJ,KAAK,IAAI,KAAK,sDAAsD;EACpE,MAAM;EACN,aAAa;EACb,MAAM;CACR;CACA,UAAU,CAAC,SAAS,OAAO;CAC3B,OAAO,OAAO,OAAO,EACnB,QAAQ,IAAI,IAAI,MAAmB,CAAC,CAAC,YAAY,EAC/C,aAAa,wDACf,CAAC,EACH,CAAC;CACD,QAAQ,OAAO,OAAO;EACpB,cAAc,OAAO;EACrB,kBAAkB,OAAO;CAC3B,CAAC;AACH,CAAC,CAAC,CAAC,KAAK,UAAU,OAAO"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { meta } from "#meta";
|
|
2
|
+
import { RegistryContext, useAtomValue } from "@effect-atom/atom-react";
|
|
3
|
+
import { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
|
4
|
+
import { useObject } from "@dxos/echo-react";
|
|
5
|
+
import { useSoundEffect } from "@dxos/react-ui-audio";
|
|
6
|
+
import { ChessModel, Chessboard as Chessboard$1, Gameboard, getRawPgn, useGameboardContext } from "@dxos/react-ui-gameboard";
|
|
7
|
+
import { Icon, IconButton, useTranslation } from "@dxos/react-ui";
|
|
8
|
+
import { mx } from "@dxos/ui-theme";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/Chessboard/Info.tsx
|
|
11
|
+
var INFO_NAME = "Chessboard.Info";
|
|
12
|
+
var Info = ({ classNames, orientation = "white", onOrientationChange, onClose, ...props }) => {
|
|
13
|
+
const { t } = useTranslation(meta.profile.key);
|
|
14
|
+
const { model } = useGameboardContext(INFO_NAME);
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: mx("grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden dx-group-surface rounded-xs", classNames),
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ jsx(PlayerIndicator, {
|
|
19
|
+
model,
|
|
20
|
+
player: orientation === "white" ? "black" : "white",
|
|
21
|
+
icon: onClose && /* @__PURE__ */ jsx(IconButton, {
|
|
22
|
+
variant: "ghost",
|
|
23
|
+
icon: "ph--x--regular",
|
|
24
|
+
iconOnly: true,
|
|
25
|
+
label: t("close-info.button"),
|
|
26
|
+
size: 4,
|
|
27
|
+
onClick: onClose
|
|
28
|
+
})
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ jsx(History, {
|
|
31
|
+
model,
|
|
32
|
+
...props
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx(PlayerIndicator, {
|
|
35
|
+
model,
|
|
36
|
+
player: orientation,
|
|
37
|
+
icon: onOrientationChange && /* @__PURE__ */ jsx(IconButton, {
|
|
38
|
+
classNames: mx("transition duration-200 ease-linear", orientation === "white" && "rotate-180"),
|
|
39
|
+
icon: "ph--arrows-clockwise--regular",
|
|
40
|
+
iconOnly: true,
|
|
41
|
+
label: t("flip-board.button"),
|
|
42
|
+
size: 4,
|
|
43
|
+
onClick: () => onOrientationChange(orientation === "white" ? "black" : "white")
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
Info.displayName = INFO_NAME;
|
|
50
|
+
var History = ({ classNames, model, min, max, onSelect }) => {
|
|
51
|
+
const { t } = useTranslation(meta.profile.key);
|
|
52
|
+
const moveIndex = useAtomValue(model.moveIndex);
|
|
53
|
+
const label = model.game.isGameOver() ? model.game.isCheckmate() ? t("game.checkmate.label") : model.game.isStalemate() ? t("game.stalemate.label") : t("game.draw.label") : model.game.isCheck() ? t("game.check.label") : void 0;
|
|
54
|
+
const history = model.game.history();
|
|
55
|
+
const moves = useMemo(() => history.reduce((acc, move, index) => {
|
|
56
|
+
if (index % 2 === 0) acc.push([{
|
|
57
|
+
index,
|
|
58
|
+
move
|
|
59
|
+
}]);
|
|
60
|
+
else acc[acc.length - 1].push({
|
|
61
|
+
index,
|
|
62
|
+
move
|
|
63
|
+
});
|
|
64
|
+
return acc;
|
|
65
|
+
}, []), [history.length]);
|
|
66
|
+
const scrollerRef = useRef(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });
|
|
69
|
+
}, [history.length]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const div = scrollerRef.current?.querySelector(`[data-index="${moveIndex - 1}"]`);
|
|
72
|
+
scrollerRef.current?.classList.add("scrollbar-none");
|
|
73
|
+
div?.scrollIntoView({ behavior: "smooth" });
|
|
74
|
+
scrollerRef.current?.classList.remove("scrollbar-none");
|
|
75
|
+
}, [moveIndex]);
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
77
|
+
ref: scrollerRef,
|
|
78
|
+
tabIndex: 0,
|
|
79
|
+
"data-chessboard-arrow-navigation": true,
|
|
80
|
+
className: mx("overflow-y-auto outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500", classNames),
|
|
81
|
+
style: {
|
|
82
|
+
minHeight: min === void 0 ? "auto" : `${min * 24}px`,
|
|
83
|
+
maxHeight: max === void 0 ? "auto" : `${max * 24}px`
|
|
84
|
+
},
|
|
85
|
+
children: [moves.map(([a, b], index) => /* @__PURE__ */ jsxs("div", {
|
|
86
|
+
className: "grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx("div", {
|
|
89
|
+
className: "content-center text-xs text-subdued",
|
|
90
|
+
children: index + 1
|
|
91
|
+
}),
|
|
92
|
+
a && /* @__PURE__ */ jsx("div", {
|
|
93
|
+
"data-index": a.index,
|
|
94
|
+
className: mx("ps-2 text-sm cursor-pointer", a.index === moveIndex - 1 && "bg-primary-500"),
|
|
95
|
+
onClick: () => onSelect?.(a.index + 1),
|
|
96
|
+
children: a.move
|
|
97
|
+
}),
|
|
98
|
+
b && /* @__PURE__ */ jsx("div", {
|
|
99
|
+
"data-index": b.index,
|
|
100
|
+
className: mx("ps-2 text-sm cursor-pointer", b.index === moveIndex - 1 && "bg-primary-500"),
|
|
101
|
+
onClick: () => onSelect?.(b.index + 1),
|
|
102
|
+
children: b.move
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}, index)), label && /* @__PURE__ */ jsx("div", {
|
|
106
|
+
className: "text-center",
|
|
107
|
+
children: label
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
var PlayerIndicator = ({ children, model, player, icon }) => {
|
|
112
|
+
const turn = player === (model.game.turn() === "w" ? "white" : "black");
|
|
113
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
114
|
+
className: "grid grid-cols-[var(--dx-rail-item)_1fr_var(--dx-rail-item)] gap-2 h-(--dx-rail-size) px-1 flex items-center overflow-hidden",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx("div", {
|
|
117
|
+
className: "place-items-center",
|
|
118
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
119
|
+
icon: turn ? "ph--circle--fill" : "ph--circle--thin",
|
|
120
|
+
size: 6,
|
|
121
|
+
classNames: mx(turn && (model.game.isCheckmate() ? "text-error-500" : "text-success-text"))
|
|
122
|
+
})
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ jsx("div", {
|
|
125
|
+
className: "truncate overflow-hidden items-center",
|
|
126
|
+
children
|
|
127
|
+
}),
|
|
128
|
+
icon
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/components/Chessboard/types.ts
|
|
134
|
+
var ExtendedChessModel = class extends ChessModel {
|
|
135
|
+
object;
|
|
136
|
+
constructor(registry, object) {
|
|
137
|
+
super(registry);
|
|
138
|
+
this.object = object;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/components/Chessboard/Chessboard.tsx
|
|
143
|
+
var Root = forwardRef(({ state, children }, forwardedRef) => {
|
|
144
|
+
const registry = useContext(RegistryContext);
|
|
145
|
+
const model = useMemo(() => new ExtendedChessModel(registry, state), [registry]);
|
|
146
|
+
const click = useSoundEffect("Click");
|
|
147
|
+
const [pgn, updatePgn] = useObject(state, "pgn");
|
|
148
|
+
useImperativeHandle(forwardedRef, () => {
|
|
149
|
+
return { setMoveNumber: (index) => model.setMoveIndex(index) };
|
|
150
|
+
}, [model]);
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (model.pgn !== getRawPgn(pgn ?? "")) {
|
|
153
|
+
const silent = model.pgn === "*";
|
|
154
|
+
model.update(pgn);
|
|
155
|
+
if (!silent) click.play();
|
|
156
|
+
}
|
|
157
|
+
}, [pgn]);
|
|
158
|
+
const handleDrop = useCallback((move) => {
|
|
159
|
+
if (!model.makeMove(move)) return false;
|
|
160
|
+
click.play();
|
|
161
|
+
updatePgn(() => model.pgn);
|
|
162
|
+
return true;
|
|
163
|
+
}, [model]);
|
|
164
|
+
const handleKeyDown = useCallback((ev) => {
|
|
165
|
+
if (!(ev.target instanceof HTMLElement ? ev.target : void 0)?.closest("[data-chessboard-arrow-navigation]")) return;
|
|
166
|
+
const moveIndex = registry.get(model.moveIndex);
|
|
167
|
+
switch (ev.key) {
|
|
168
|
+
case "ArrowUp":
|
|
169
|
+
ev.preventDefault();
|
|
170
|
+
model.setMoveIndex(0);
|
|
171
|
+
break;
|
|
172
|
+
case "ArrowDown":
|
|
173
|
+
ev.preventDefault();
|
|
174
|
+
model.setMoveIndex(model.game.history().length);
|
|
175
|
+
break;
|
|
176
|
+
case "ArrowLeft":
|
|
177
|
+
if (moveIndex > 0) {
|
|
178
|
+
ev.preventDefault();
|
|
179
|
+
model.setMoveIndex(moveIndex - 1);
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case "ArrowRight":
|
|
183
|
+
if (moveIndex < model.game.history().length) {
|
|
184
|
+
ev.preventDefault();
|
|
185
|
+
model.setMoveIndex(moveIndex + 1);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}, [registry, model]);
|
|
190
|
+
return /* @__PURE__ */ jsx(Gameboard.Root, {
|
|
191
|
+
model,
|
|
192
|
+
onDrop: handleDrop,
|
|
193
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
194
|
+
className: "contents",
|
|
195
|
+
onKeyDown: handleKeyDown,
|
|
196
|
+
children
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
var Content = ({ classNames, children }) => {
|
|
201
|
+
return /* @__PURE__ */ jsx(Gameboard.Content, {
|
|
202
|
+
grow: true,
|
|
203
|
+
contain: true,
|
|
204
|
+
classNames,
|
|
205
|
+
children
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
var BOARD_NAME = "Chessboard.Board";
|
|
209
|
+
var Board = (props) => /* @__PURE__ */ jsx("div", {
|
|
210
|
+
className: "contents",
|
|
211
|
+
"data-chessboard-arrow-navigation": true,
|
|
212
|
+
children: /* @__PURE__ */ jsx(Chessboard$1, { ...props })
|
|
213
|
+
});
|
|
214
|
+
Board.displayName = BOARD_NAME;
|
|
215
|
+
var Chessboard = {
|
|
216
|
+
Root,
|
|
217
|
+
Content,
|
|
218
|
+
Board,
|
|
219
|
+
Info
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
222
|
+
export { Chessboard };
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/components/Chessboard/Info.tsx","../../src/components/Chessboard/types.ts","../../src/components/Chessboard/Chessboard.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '#meta';\n\nimport { type ExtendedChessModel } from './types';\n\nconst INFO_NAME = 'Chessboard.Info';\n\nexport type InfoProps = ThemedClassName<\n {\n orientation?: Player;\n onOrientationChange?: (orientation: Player) => void;\n onClose?: () => void;\n } & Pick<HistoryProps, 'min' | 'max' | 'onSelect'>\n>;\n\nexport const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {\n const { t } = useTranslation(meta.profile.key);\n const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden dx-group-surface rounded-xs',\n classNames,\n )}\n >\n <PlayerIndicator\n model={model}\n player={orientation === 'white' ? 'black' : 'white'}\n icon={\n onClose && (\n <IconButton\n variant='ghost'\n icon='ph--x--regular'\n iconOnly\n label={t('close-info.button')}\n size={4}\n onClick={onClose}\n />\n )\n }\n />\n\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip-board.button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n />\n </div>\n );\n};\n\nInfo.displayName = INFO_NAME;\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.profile.key);\n const moveIndex = useAtomValue(model.moveIndex);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate.label')\n : model.game.isStalemate()\n ? t('game.stalemate.label')\n : t('game.draw.label')\n : model.game.isCheck()\n ? t('game.check.label')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${moveIndex - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [moveIndex]);\n\n return (\n <div\n ref={scrollerRef}\n tabIndex={0}\n data-chessboard-arrow-navigation\n className={mx('overflow-y-auto outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500', classNames)}\n style={{\n minHeight: min === undefined ? 'auto' : `${min * 24}px`,\n maxHeight: max === undefined ? 'auto' : `${max * 24}px`,\n }}\n >\n {moves.map(([a, b], index) => (\n <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4'>\n <div className='content-center text-xs text-subdued'>{index + 1}</div>\n {a && (\n <div\n data-index={a.index}\n className={mx('ps-2 text-sm cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(a.index + 1)}\n >\n {a.move}\n </div>\n )}\n {b && (\n <div\n data-index={b.index}\n className={mx('ps-2 text-sm cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(b.index + 1)}\n >\n {b.move}\n </div>\n )}\n </div>\n ))}\n {label && <div className='text-center'>{label}</div>}\n </div>\n );\n};\n\n//\n// PlayerIndicator\n//\n\ntype PlayerIndicatorProps = PropsWithChildren<{\n model: ExtendedChessModel;\n player: Player;\n icon?: JSX.Element;\n}>;\n\nconst PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {\n const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');\n return (\n <div className='grid grid-cols-[var(--dx-rail-item)_1fr_var(--dx-rail-item)] gap-2 h-(--dx-rail-size) px-1 flex items-center overflow-hidden'>\n <div className='place-items-center'>\n <Icon\n icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}\n size={6}\n classNames={mx(turn && (model.game.isCheckmate() ? 'text-error-500' : 'text-success-text'))}\n />\n </div>\n <div className='truncate overflow-hidden items-center'>{children}</div>\n {icon}\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Registry } from '@effect-atom/atom';\n\nimport { ChessModel } from '@dxos/react-ui-gameboard';\n\nimport { type Chess } from '#types';\n\nexport class ExtendedChessModel extends ChessModel {\n constructor(\n registry: Registry.Registry,\n readonly object: Chess.State,\n ) {\n super(registry);\n }\n}\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from 'react';\n\nimport { useObject } from '@dxos/echo-react';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { useSoundEffect } from '@dxos/react-ui-audio';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n} from '@dxos/react-ui-gameboard';\n\nimport { type Chess } from '#types';\n\nimport { Info, type InfoProps } from './Info';\nimport { ExtendedChessModel } from './types';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n state: Chess.State;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ state, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, state), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(state, 'pgn');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // TODO(wittjosiah): Rather than useEffect to sync ECHO object to model, create an alternative model implementation.\n // This model would take the ECHO object and derive game state directly from that.\n // Mutation methods would mutate the ECHO object and other state would be derived from that.\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [pgn]);\n\n // Move.\n const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(\n (move) => {\n if (!model.makeMove(move)) {\n return false;\n }\n\n void click.play();\n updatePgn(() => model.pgn);\n return true;\n },\n [model],\n );\n\n // Keyboard navigation — fires regardless of which descendant (Board or Info) has focus.\n // Gated to elements marked data-chessboard-arrow-navigation to avoid intercepting toolbar controls.\n const handleKeyDown = useCallback(\n (ev: React.KeyboardEvent) => {\n const target = ev.target instanceof HTMLElement ? ev.target : undefined;\n if (!target?.closest('[data-chessboard-arrow-navigation]')) {\n return;\n }\n\n const moveIndex = registry.get(model.moveIndex);\n switch (ev.key) {\n case 'ArrowUp':\n ev.preventDefault();\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n ev.preventDefault();\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (moveIndex > 0) {\n ev.preventDefault();\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n ev.preventDefault();\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n },\n [registry, model],\n );\n\n return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {/* display:contents is layout-transparent; catches keydown bubbled from any focused descendant. */}\n <div className='contents' onKeyDown={handleKeyDown}>\n {children}\n </div>\n </Gameboard.Root>\n );\n});\n\n//\n// Content\n//\n\ntype Role = 'card--content';\n\ntype ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;\n\nconst Content = ({ classNames, children }: ContentProps) => {\n return (\n <Gameboard.Content grow contain classNames={classNames}>\n {children}\n </Gameboard.Content>\n );\n};\n\n//\n// Board\n//\n\nconst BOARD_NAME = 'Chessboard.Board';\n\ntype BoardProps = NaturalChessboardProps;\n\nconst Board = (props: BoardProps) => (\n <div className='contents' data-chessboard-arrow-navigation>\n <NaturalChessboard {...props} />\n </div>\n);\n\nBoard.displayName = BOARD_NAME;\n\n//\n// Chessboard\n//\n\nexport const Chessboard = {\n Root: Root,\n Content: Content,\n Board: Board,\n Info: Info,\n};\n\nexport type {\n BoardProps as ChessboardBoardProps,\n ContentProps as ChessboardContentProps,\n InfoProps as ChessboardInfoProps,\n RootProps as ChessboardRootProps,\n};\n"],"mappings":";;;;;;;;;;AAeA,IAAM,YAAY;AAUlB,IAAa,QAAQ,EAAE,YAAY,cAAc,SAAS,qBAAqB,SAAS,GAAG,YAAuB;CAChH,MAAM,EAAE,MAAM,eAAe,KAAK,QAAQ,GAAG;CAC7C,MAAM,EAAE,UAAU,oBAAwC,SAAS;CAEnE,OACE,qBAAC,OAAD;EACE,WAAW,GACT,qHACA,UACF;YAJF;GAME,oBAAC,iBAAD;IACS;IACP,QAAQ,gBAAgB,UAAU,UAAU;IAC5C,MACE,WACE,oBAAC,YAAD;KACE,SAAQ;KACR,MAAK;KACL,UAAA;KACA,OAAO,EAAE,mBAAmB;KAC5B,MAAM;KACN,SAAS;IACV,CAAA;GAGN,CAAA;GAED,oBAAC,SAAD;IAAgB;IAAO,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MAAM,aAAa,YAAY,CAAC;IAClC;IACA;GACF,KAAK;IACH,IAAI,YAAY,MAAM,KAAK,QAAQ,CAAC,CAAC,QAAQ;KAC3C,GAAG,eAAe;KAClB,MAAM,aAAa,YAAY,CAAC;IAClC;IACA;EACJ;CACF,GACA,CAAC,UAAU,KAAK,CAClB;CAEA,OACE,oBAAC,UAAU,MAAX;EAAuB;EAAO,QAAQ;YAEpC,oBAAC,OAAD;GAAK,WAAU;GAAW,WAAW;GAClC;EACE,CAAA;CACS,CAAA;AAEpB,CAAC;AAUD,IAAM,WAAW,EAAE,YAAY,eAA6B;CAC1D,OACE,oBAAC,UAAU,SAAX;EAAmB,MAAA;EAAK,SAAA;EAAoB;EACzC;CACgB,CAAA;AAEvB;AAMA,IAAM,aAAa;AAInB,IAAM,SAAS,UACb,oBAAC,OAAD;CAAK,WAAU;CAAW,oCAAA;WACxB,oBAAC,cAAD,EAAmB,GAAI,MAAQ,CAAA;AAC5B,CAAA;AAGP,MAAM,cAAc;AAMpB,IAAa,aAAa;CAClB;CACG;CACF;CACD;AACR"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { lazy } from "react";
|
|
2
|
+
//#region src/containers/index.ts
|
|
3
|
+
var ChessArticle = lazy(() => import("./chunk-ChessArticle.mjs"));
|
|
4
|
+
var ChessCard = lazy(() => import("./chunk-ChessCard.mjs"));
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ChessArticle, ChessCard };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=containers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containers.mjs","names":[],"sources":["../../src/containers/index.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type ComponentType, lazy } from 'react';\n\nexport const ChessArticle: ComponentType<any> = lazy(() => import('./ChessArticle'));\nexport const ChessCard: ComponentType<any> = lazy(() => import('./ChessCard'));\n"],"mappings":";;AAMA,IAAa,eAAmC,WAAW,OAAO,2BAAiB;AACnF,IAAa,YAAgC,WAAW,OAAO,wBAAc"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as Chess_exports, o as PlayerReview_exports, s as ChessPositionIndex_exports, t as ChessOperation_exports } from "./chunk-types.mjs";
|
|
2
|
+
import { t as skill } from "./chunk-skills.mjs";
|
|
3
|
+
import { t as meta } from "./chunk-meta.mjs";
|
|
4
|
+
export { Chess_exports as Chess, ChessOperation_exports as ChessOperation, ChessPositionIndex_exports as ChessPositionIndex, skill as ChessSkill, PlayerReview_exports as PlayerReview, meta };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OperationHandlerSet } from "@dxos/compute";
|
|
2
|
+
//#region src/operations/index.ts
|
|
3
|
+
var ChessOperationHandlerSet = OperationHandlerSet.lazy(() => import("./chunk-move.mjs"), () => import("./chunk-play.mjs"), () => import("./chunk-print.mjs"), () => import("./chunk-rebuild-position-index.mjs"));
|
|
4
|
+
//#endregion
|
|
5
|
+
export { ChessOperationHandlerSet };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=operations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.mjs","names":[],"sources":["../../src/operations/index.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/compute';\n\nexport const ChessOperationHandlerSet = OperationHandlerSet.lazy(\n () => import('./move'),\n () => import('./play'),\n () => import('./print'),\n () => import('./rebuild-position-index'),\n);\n"],"mappings":";;AAMA,IAAa,2BAA2B,oBAAoB,WACpD,OAAO,2BACP,OAAO,2BACP,OAAO,4BACP,OAAO,qCACf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { t as meta } from "./chunk-meta.mjs";
|
|
2
|
+
import { ChessOperationHandlerSet } from "./operations.mjs";
|
|
3
|
+
import { Plugin } from "@dxos/app-framework";
|
|
4
|
+
//#region src/plugin.ts
|
|
5
|
+
var ChessPlugin = Plugin.lazy(meta, () => import("#plugin"));
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ChessOperationHandlerSet, ChessPlugin };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../src/plugin.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport const ChessPlugin = Plugin.lazy(meta, () => import('#plugin'));\n\nexport { ChessOperationHandlerSet } from './operations';\n"],"mappings":";;;;AAQA,IAAa,cAAc,OAAO,KAAK,YAAY,OAAO,UAAU"}
|