@dxos/plugin-chess 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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/browser/blueprints/index.mjs +4 -4
- package/dist/lib/browser/{chunk-JZMN24DY.mjs → chunk-H6SON7WG.mjs} +4 -4
- package/dist/lib/browser/chunk-H6SON7WG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2TJN26DN.mjs → chunk-IN3LZ2OO.mjs} +2 -7
- package/dist/lib/browser/{chunk-2TJN26DN.mjs.map → chunk-IN3LZ2OO.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-MC7L6JNC.mjs → chunk-JYP24G6K.mjs} +2 -2
- package/dist/lib/browser/chunk-JYP24G6K.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XAJZK6Z2.mjs → chunk-OBKYFOJA.mjs} +3 -3
- package/dist/lib/browser/chunk-OBKYFOJA.mjs.map +7 -0
- package/dist/lib/browser/{create-AJHN4QT4.mjs → create-2ME3FNBX.mjs} +4 -4
- package/dist/lib/browser/create-2ME3FNBX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +10 -357
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{move-T2NLRBR4.mjs → move-TTMIPD5J.mjs} +5 -5
- package/dist/lib/browser/move-TTMIPD5J.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +3 -3
- package/dist/lib/browser/{play-7VTMD3SJ.mjs → play-GHXPV2T2.mjs} +5 -5
- package/dist/lib/browser/play-GHXPV2T2.mjs.map +7 -0
- package/dist/lib/browser/{print-EW7LPW4D.mjs → print-RNAGAOM7.mjs} +4 -4
- package/dist/lib/browser/{print-EW7LPW4D.mjs.map → print-RNAGAOM7.mjs.map} +1 -1
- package/dist/lib/browser/translations.mjs +38 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/blueprints/index.mjs +4 -4
- package/dist/lib/node-esm/{chunk-LQEDIKCV.mjs → chunk-4C4GPZTA.mjs} +4 -4
- package/dist/lib/node-esm/chunk-4C4GPZTA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NYU5JVXP.mjs → chunk-G2EHRXHX.mjs} +3 -3
- package/dist/lib/node-esm/chunk-G2EHRXHX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4HZWCKMR.mjs → chunk-NSFPC4IO.mjs} +2 -2
- package/dist/lib/node-esm/chunk-NSFPC4IO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OIRJVY2R.mjs → chunk-OHBKSL2Q.mjs} +2 -7
- package/dist/lib/node-esm/{chunk-OIRJVY2R.mjs.map → chunk-OHBKSL2Q.mjs.map} +2 -2
- package/dist/lib/node-esm/{create-QSETDT4N.mjs → create-CC2P7GPT.mjs} +4 -4
- package/dist/lib/node-esm/create-CC2P7GPT.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +10 -357
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{move-5F2ANDTE.mjs → move-CYHXWHHM.mjs} +5 -5
- package/dist/lib/node-esm/move-CYHXWHHM.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +3 -3
- package/dist/lib/node-esm/{play-W4DQCQRX.mjs → play-KTNK2PBL.mjs} +5 -5
- package/dist/lib/node-esm/play-KTNK2PBL.mjs.map +7 -0
- package/dist/lib/node-esm/{print-UJHXAXMS.mjs → print-P23VKVNU.mjs} +4 -4
- package/dist/lib/node-esm/{print-UJHXAXMS.mjs.map → print-P23VKVNU.mjs.map} +1 -1
- package/dist/lib/node-esm/translations.mjs +39 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/ChessPlugin.d.ts +1 -0
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/{cli/plugin.d.ts → ChessPlugin.node.d.ts} +2 -1
- package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.test.d.ts +2 -0
- package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +2 -2
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +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/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +4 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +40 -23
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Info.d.ts +4 -5
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +40 -23
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +1 -1
- package/dist/types/src/operations/create.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +2 -2
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/move.d.ts +1 -1
- package/dist/types/src/operations/move.d.ts.map +1 -1
- package/dist/types/src/operations/play.d.ts +1 -1
- package/dist/types/src/operations/play.d.ts.map +1 -1
- package/dist/types/src/operations/print.d.ts +1 -1
- package/dist/types/src/operations/print.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +40 -24
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +50 -48
- package/src/{cli/plugin.ts → ChessPlugin.node.ts} +11 -3
- package/src/ChessPlugin.test.ts +49 -0
- package/src/ChessPlugin.tsx +4 -3
- package/src/blueprints/chess-blueprint.ts +2 -3
- package/src/capabilities/artifact-definition.ts +2 -2
- package/src/capabilities/blueprint-definition.ts +2 -0
- package/src/capabilities/index.ts +2 -1
- package/src/capabilities/node.ts +16 -0
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/components/Chessboard/Chessboard.stories.tsx +1 -1
- package/src/components/Chessboard/Info.tsx +2 -2
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +1 -1
- package/src/index.ts +5 -2
- package/src/operations/create.ts +1 -1
- package/src/operations/definitions.ts +1 -1
- package/src/operations/index.ts +1 -1
- package/src/operations/move.ts +2 -2
- package/src/operations/play.ts +2 -2
- package/src/operations/print.ts +1 -1
- package/dist/lib/browser/chunk-JZMN24DY.mjs.map +0 -7
- package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +0 -7
- package/dist/lib/browser/chunk-XAJZK6Z2.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -34
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-AJHN4QT4.mjs.map +0 -7
- package/dist/lib/browser/move-T2NLRBR4.mjs.map +0 -7
- package/dist/lib/browser/play-7VTMD3SJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LQEDIKCV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYU5JVXP.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -35
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/create-QSETDT4N.mjs.map +0 -7
- package/dist/lib/node-esm/move-5F2ANDTE.mjs.map +0 -7
- package/dist/lib/node-esm/play-W4DQCQRX.mjs.map +0 -7
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/src/cli/index.ts +0 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chess_blueprint_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-JYP24G6K.mjs";
|
|
4
4
|
import {
|
|
5
5
|
operations_exports
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-H6SON7WG.mjs";
|
|
7
|
+
import "../chunk-OBKYFOJA.mjs";
|
|
8
|
+
import "../chunk-IN3LZ2OO.mjs";
|
|
9
9
|
import "../chunk-J5LGTIGS.mjs";
|
|
10
10
|
export {
|
|
11
11
|
chess_blueprint_default as ChessBlueprint,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Move,
|
|
4
4
|
Play,
|
|
5
5
|
Print
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OBKYFOJA.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -17,12 +17,12 @@ __export(operations_exports, {
|
|
|
17
17
|
Play: () => Play,
|
|
18
18
|
Print: () => Print
|
|
19
19
|
});
|
|
20
|
-
import { OperationHandlerSet } from "@dxos/
|
|
21
|
-
var Handlers = OperationHandlerSet.lazy(() => import("./create-
|
|
20
|
+
import { OperationHandlerSet } from "@dxos/compute";
|
|
21
|
+
var Handlers = OperationHandlerSet.lazy(() => import("./create-2ME3FNBX.mjs"), () => import("./move-TTMIPD5J.mjs"), () => import("./play-GHXPV2T2.mjs"), () => import("./print-RNAGAOM7.mjs"));
|
|
22
22
|
var ChessHandlers = Handlers;
|
|
23
23
|
|
|
24
24
|
export {
|
|
25
25
|
ChessHandlers,
|
|
26
26
|
operations_exports
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-H6SON7WG.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { OperationHandlerSet } from '@dxos/compute';\n\nconst Handlers = OperationHandlerSet.lazy(\n () => import('./create'),\n () => import('./move'),\n () => import('./play'),\n () => import('./print'),\n);\n\nexport { Create, Move, Play, Print } from './definitions';\n\nexport const ChessHandlers = Handlers;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA;;;;;;;;AAIA,SAASA,2BAA2B;AAEpC,IAAMC,WAAWD,oBAAoBE,KACnC,MAAM,OAAO,uBAAA,GACb,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,qBAAA,GACb,MAAM,OAAO,sBAAA,CAAA;AAKR,IAAMC,gBAAgBF;",
|
|
6
|
+
"names": ["OperationHandlerSet", "Handlers", "lazy", "ChessHandlers"]
|
|
7
|
+
}
|
|
@@ -45,12 +45,7 @@ var make = ({ name, pgn, fen } = {}) => {
|
|
|
45
45
|
try {
|
|
46
46
|
chess.loadPgn(pgn);
|
|
47
47
|
} catch {
|
|
48
|
-
log.warn(pgn, void 0, {
|
|
49
|
-
F: __dxlog_file,
|
|
50
|
-
L: 52,
|
|
51
|
-
S: void 0,
|
|
52
|
-
C: (f, a) => f(...a)
|
|
53
|
-
});
|
|
48
|
+
log.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 40, S: void 0 });
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
return Obj.make(Game, {
|
|
@@ -64,4 +59,4 @@ var make = ({ name, pgn, fen } = {}) => {
|
|
|
64
59
|
export {
|
|
65
60
|
Chess_exports
|
|
66
61
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-IN3LZ2OO.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types/Chess.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { log } from '@dxos/log';\n\nexport const Game = Schema.Struct({\n name: Schema.optional(Schema.String),\n players: Schema.Struct({\n white: Schema.optional(\n Schema.String.annotations({\n description: 'DID of white player',\n }),\n ),\n black: Schema.optional(\n Schema.String.annotations({\n description: 'DID of black player',\n }),\n ),\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\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 Type.object({\n typename: 'org.dxos.type.chess',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({\n icon: 'ph--shield-chevron--regular',\n hue: 'amber',\n }),\n);\n\nexport interface Game extends Schema.Schema.Type<typeof Game> {}\n\nexport const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: string } = {}) => {\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(Game, {\n name,\n pgn,\n fen,\n players: {},\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,YAAYC,KAAKC,YAAY;AACtC,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,WAAW
|
|
6
|
-
"names": ["Chess", "ChessJS", "Schema", "Annotation", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;AAIA,SAASA,SAASC,eAAe;AACjC,YAAYC,YAAY;AAExB,SAASC,YAAYC,KAAKC,YAAY;AACtC,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,WAAW;AAEpB,IAAA,eAAaC;AAEXC,IAASR,OAAc,cAAA;QACdA,gBACLA,aAAOS;WACLC,cAAa;IACf,OAAA,gBAAA,cAAA,YAAA;MAEFC,aAAcC;;IAGZ,OAAA,gBAAA,cAAA,YAAA;MAEIR,aAAAA;IACRS,CAAKb,CAAAA;UACHU,oBAAa,IAAA,KAAA,GAAA,eAAA;EACf,KAAQN,cAAAA,YAAuB;IAC/BU,aAAYL;UACVC,oBAAa,IAAA,KAAA,GAAA,eAAA;EACf,KAAQN,cAAAA,YAAuB;IAE/BD,aAAY;EACVY,CAAAA,EAAAA,KAAAA,oBAAU,IAAA,KAAA,GAAA,eAAA;QACVC,KAAS,OAAA;EAEXX,UAAAA;EAAqB,SAAA;CAAO,GAC5BJ,gBAAWgB,IAAAA;EACTC;IACAC,WAAK,eAAA,IAAA;EAEP,MAAA;EAIF,KAAO;;AAEL,IAAS,OAAA,CAAA,EAAA,MAAA,KAAA,IAAA,IAAA,CAAA,MAAA;QACP,QAAI,IAAA,QAAA;WACFC;AACF,QAAE;AACAd,YAAIe,QAAKR,GAAAA;IACX,QAAA;AACF,UAAA,KAAA,KAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;IAEA;;SAEEA,IAAAA,KAAAA,MAAAA;IACAC;IACAN;IACF;IACA,SAAA,CAAA;;;",
|
|
6
|
+
"names": ["Chess", "ChessJS", "Schema", "Annotation", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "players", "String", "description", "black", "optional", "pgn", "fen", "typename", "version", "IconAnnotation", "icon", "hue", "chess", "warn"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/blueprints/chess-blueprint.ts
|
|
2
|
-
import { Blueprint, Template } from "@dxos/
|
|
2
|
+
import { Blueprint, Template } from "@dxos/compute";
|
|
3
3
|
import { trim } from "@dxos/util";
|
|
4
4
|
import { Create, Move, Play, Print } from "#operations";
|
|
5
5
|
var BLUEPRINT_KEY = "org.dxos.blueprint.chess";
|
|
@@ -33,4 +33,4 @@ var chess_blueprint_default = blueprint;
|
|
|
33
33
|
export {
|
|
34
34
|
chess_blueprint_default
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
//# sourceMappingURL=chunk-JYP24G6K.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/blueprints/chess-blueprint.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { Create, Move, Play, Print } from '#operations';\n\nconst BLUEPRINT_KEY = 'org.dxos.blueprint.chess';\n\nconst operations = [Create, Move, Play, Print];\n\nconst make = () =>\n Blueprint.make({\n key: BLUEPRINT_KEY,\n name: 'Chess',\n tools: Blueprint.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 }),\n });\n\nconst blueprint: Blueprint.Definition = {\n key: BLUEPRINT_KEY,\n make,\n};\n\nexport default blueprint;\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAErB,SAASC,QAAQC,MAAMC,MAAMC,aAAa;AAE1C,IAAMC,gBAAgB;AAEtB,IAAMC,aAAa;EAACL;EAAQC;EAAMC;EAAMC;;AAExC,IAAMG,OAAO,MACXT,UAAUS,KAAK;EACbC,KAAKH;EACLI,MAAM;EACNC,OAAOZ,UAAUa,gBAAgB;IAAEL;EAAW,CAAA;EAC9CM,cAAcb,SAASQ,KAAK;IAC1BM,QAAQb;;;;;;EAMV,CAAA;AACF,CAAA;AAEF,IAAMc,YAAkC;EACtCN,KAAKH;EACLE;AACF;AAEA,IAAA,0BAAeO;",
|
|
6
|
+
"names": ["Blueprint", "Template", "trim", "Create", "Move", "Play", "Print", "BLUEPRINT_KEY", "operations", "make", "key", "name", "tools", "toolDefinitions", "instructions", "source", "blueprint"]
|
|
7
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Chess_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IN3LZ2OO.mjs";
|
|
4
4
|
|
|
5
5
|
// src/operations/definitions.ts
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
|
+
import { Operation } from "@dxos/compute";
|
|
7
8
|
import { Database, Ref } from "@dxos/echo";
|
|
8
|
-
import { Operation } from "@dxos/operation";
|
|
9
9
|
var Create = Operation.make({
|
|
10
10
|
meta: {
|
|
11
11
|
key: "org.dxos.function.chess.create",
|
|
@@ -107,4 +107,4 @@ export {
|
|
|
107
107
|
Play,
|
|
108
108
|
Print
|
|
109
109
|
};
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-OBKYFOJA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, Ref } from '@dxos/echo';\n\nimport { Chess } from '../types';\n\nexport const Create = Operation.make({\n meta: {\n key: 'org.dxos.function.chess.create',\n name: 'Create Chess',\n description: 'Creates a new chess game.',\n },\n input: Schema.Struct({\n name: Schema.optional(\n Schema.String.annotations({\n description: 'Name of the game.',\n }),\n ),\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: Chess.Game,\n services: [Database.Service],\n});\n\nexport const Move = Operation.make({\n meta: {\n key: 'org.dxos.function.chess.move',\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n },\n input: Schema.Struct({\n game: Ref.Ref(Chess.Game).annotations({\n description: 'The ID of the chess object.',\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: 'org.dxos.function.chess.play',\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n },\n input: Schema.Struct({\n game: Ref.Ref(Chess.Game).annotations({\n description: 'The ID of the chess object.',\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: 'org.dxos.function.chess.print',\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\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"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,UAAUC,WAAW;AAIvB,IAAMC,SAASC,UAAUC,KAAK;EACnCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBH,MAAaI,gBACJC,cAAOC,YAAY;MACxBL,aAAa;IACf,CAAA,CAAA;IAEFM,KAAYH,gBACHC,cAAOC,YAAY;MACxBL,aAAa;IACf,CAAA,CAAA;IAEFO,KAAYJ,gBACHC,cAAOC,YAAY;MACxBL,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA;EACAQ,QAAQC,cAAMC;EACdC,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMC,OAAOnB,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBa,MAAMC,IAAIA,IAAIP,cAAMC,IAAI,EAAEL,YAAY;MACpCL,aAAa;IACf,CAAA;IACAiB,MAAab,cAAOC,YAAY;MAC9BL,aAAa;MACbkB,UAAU;QAAC;QAAM;;IACnB,CAAA;EACF,CAAA;EACAV,QAAeN,cAAO;IACpBI,KAAYF,cAAOC,YAAY;MAC7BL,aAAa;IACf,CAAA;EACF,CAAA;EACAW,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMM,OAAOxB,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBa,MAAMC,IAAIA,IAAIP,cAAMC,IAAI,EAAEL,YAAY;MACpCL,aAAa;IACf,CAAA;IACAoB,MAAajB,gBAAgBkB,eAAQ,SAAS,SAAS,KAAA,CAAA,EAAQhB,YAAY;MACzEL,aAAa;MACbsB,cAAc;IAChB,CAAA;EACF,CAAA;EACAd,QAAeN,cAAO;IACpBI,KAAYF,cAAOC,YAAY;MAC7BL,aAAa;IACf,CAAA;IACAiB,MAAad,gBAAgBC,aAAM,EAAEC,YAAY;MAC/CL,aAAa;IACf,CAAA;EACF,CAAA;EACAW,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMU,QAAQ5B,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBI,KAAYH,gBACHC,cAAOC,YAAY;MACxBL,aAAa;IACf,CAAA,CAAA;IAEFO,KAAYJ,gBACHC,cAAOC,YAAY;MACxBL,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA;EACAQ,QAAeN,cAAO;IACpBsB,OAAcpB;EAChB,CAAA;AACF,CAAA;",
|
|
6
|
+
"names": ["Schema", "Operation", "Database", "Ref", "Create", "Operation", "make", "meta", "key", "name", "description", "input", "Struct", "optional", "String", "annotations", "pgn", "fen", "output", "Chess", "Game", "services", "Database", "Service", "Move", "game", "Ref", "move", "examples", "Play", "side", "Literal", "defaultValue", "Print", "ascii"]
|
|
7
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Create
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OBKYFOJA.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Chess_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IN3LZ2OO.mjs";
|
|
7
7
|
import "./chunk-J5LGTIGS.mjs";
|
|
8
8
|
|
|
9
9
|
// src/operations/create.ts
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
|
+
import { Operation } from "@dxos/compute";
|
|
11
12
|
import { Database } from "@dxos/echo";
|
|
12
|
-
import { Operation } from "@dxos/operation";
|
|
13
13
|
var handler = Create.pipe(Operation.withHandler(Effect.fn(function* ({ name, pgn, fen }) {
|
|
14
14
|
return yield* Database.add(Chess_exports.make({
|
|
15
15
|
name,
|
|
@@ -21,4 +21,4 @@ var create_default = handler;
|
|
|
21
21
|
export {
|
|
22
22
|
create_default as default
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=create-
|
|
24
|
+
//# sourceMappingURL=create-2ME3FNBX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/create.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Operation } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\n\nimport { Chess } from '../types';\nimport { Create } from './definitions';\n\nconst handler: Operation.WithHandler<typeof Create> = Create.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ name, pgn, fen }) {\n return yield* Database.add(Chess.make({ name, pgn, fen }));\n }),\n ),\n);\n\nexport default handler;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AAKzB,IAAMC,UAAgDC,OAAOC,KAC3DC,UAAUC,YACDC,UAAG,WAAW,EAAEC,MAAMC,KAAKC,IAAG,GAAE;AACrC,SAAO,OAAOC,SAASC,IAAIC,cAAMC,KAAK;IAAEN;IAAMC;IAAKC;EAAI,CAAA,CAAA;AACzD,CAAA,CAAA,CAAA;AAIJ,IAAA,iBAAeR;",
|
|
6
|
+
"names": ["Effect", "Operation", "Database", "handler", "Create", "pipe", "Operation", "withHandler", "fn", "name", "pgn", "fen", "Database", "add", "Chess", "make"]
|
|
7
|
+
}
|
|
@@ -1,289 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chess_blueprint_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JYP24G6K.mjs";
|
|
4
4
|
import {
|
|
5
5
|
operations_exports
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-H6SON7WG.mjs";
|
|
7
|
+
import "./chunk-OBKYFOJA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Chess_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IN3LZ2OO.mjs";
|
|
11
11
|
import "./chunk-J5LGTIGS.mjs";
|
|
12
12
|
|
|
13
|
-
// src/
|
|
14
|
-
import {
|
|
15
|
-
import React2, { forwardRef, useCallback, useContext, useEffect as useEffect2, useImperativeHandle, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
16
|
-
import { addEventListener } from "@dxos/async";
|
|
17
|
-
import { useObject } from "@dxos/echo-react";
|
|
18
|
-
import { Gameboard, Chessboard as NaturalChessboard, getRawPgn, useGameboardContext as useGameboardContext2 } from "@dxos/react-ui-gameboard";
|
|
19
|
-
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
20
|
-
|
|
21
|
-
// src/components/Chessboard/Info.tsx
|
|
22
|
-
import { useAtomValue } from "@effect-atom/atom-react";
|
|
23
|
-
import React, { useEffect, useMemo, useRef } from "react";
|
|
24
|
-
import { generateName } from "@dxos/display-name";
|
|
25
|
-
import { Obj } from "@dxos/echo";
|
|
26
|
-
import { useMembers } from "@dxos/react-client/echo";
|
|
27
|
-
import { Icon, IconButton, Select, useTranslation } from "@dxos/react-ui";
|
|
28
|
-
import { useGameboardContext } from "@dxos/react-ui-gameboard";
|
|
29
|
-
import { mx } from "@dxos/ui-theme";
|
|
30
|
-
import { meta } from "#meta";
|
|
31
|
-
var INFO_NAME = "Chessboard.Info";
|
|
32
|
-
var Info = ({ classNames, orientation = "white", onOrientationChange, onClose, ...props }) => {
|
|
33
|
-
const { t } = useTranslation(meta.id);
|
|
34
|
-
const { model } = useGameboardContext(INFO_NAME);
|
|
35
|
-
const db = Obj.getDatabase(model.object);
|
|
36
|
-
const members = useMembers(db?.spaceId);
|
|
37
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
38
|
-
className: mx("grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden bg-group-surface rounded-xs", classNames)
|
|
39
|
-
}, /* @__PURE__ */ React.createElement(PlayerIndicator, {
|
|
40
|
-
model,
|
|
41
|
-
player: orientation === "white" ? "black" : "white",
|
|
42
|
-
icon: onClose && /* @__PURE__ */ React.createElement(IconButton, {
|
|
43
|
-
variant: "ghost",
|
|
44
|
-
icon: "ph--x--regular",
|
|
45
|
-
iconOnly: true,
|
|
46
|
-
label: t("close-info.button"),
|
|
47
|
-
size: 4,
|
|
48
|
-
onClick: onClose
|
|
49
|
-
})
|
|
50
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelector, {
|
|
51
|
-
value: model.object.players?.[orientation === "white" ? "black" : "white"],
|
|
52
|
-
onValueChange: (value) => {
|
|
53
|
-
Obj.change(model.object, (obj) => {
|
|
54
|
-
obj.players[orientation === "white" ? "black" : "white"] = value;
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
members
|
|
58
|
-
})), /* @__PURE__ */ React.createElement(History, {
|
|
59
|
-
model,
|
|
60
|
-
...props
|
|
61
|
-
}), /* @__PURE__ */ React.createElement(PlayerIndicator, {
|
|
62
|
-
model,
|
|
63
|
-
player: orientation,
|
|
64
|
-
icon: onOrientationChange && /* @__PURE__ */ React.createElement(IconButton, {
|
|
65
|
-
classNames: mx("transition duration-200 ease-linear", orientation === "white" && "rotate-180"),
|
|
66
|
-
icon: "ph--arrows-clockwise--regular",
|
|
67
|
-
iconOnly: true,
|
|
68
|
-
label: t("flip-board.button"),
|
|
69
|
-
size: 4,
|
|
70
|
-
onClick: () => onOrientationChange(orientation === "white" ? "black" : "white")
|
|
71
|
-
})
|
|
72
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelector, {
|
|
73
|
-
value: model.object.players?.[orientation],
|
|
74
|
-
onValueChange: (value) => {
|
|
75
|
-
Obj.change(model.object, (obj) => {
|
|
76
|
-
obj.players[orientation] = value;
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
members
|
|
80
|
-
})));
|
|
81
|
-
};
|
|
82
|
-
Info.displayName = INFO_NAME;
|
|
83
|
-
var History = ({ classNames, model, min, max, onSelect }) => {
|
|
84
|
-
const { t } = useTranslation(meta.id);
|
|
85
|
-
const moveIndex = useAtomValue(model.moveIndex);
|
|
86
|
-
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;
|
|
87
|
-
const history = model.game.history();
|
|
88
|
-
const moves = useMemo(() => history.reduce((acc, move, index) => {
|
|
89
|
-
if (index % 2 === 0) {
|
|
90
|
-
acc.push([
|
|
91
|
-
{
|
|
92
|
-
index,
|
|
93
|
-
move
|
|
94
|
-
}
|
|
95
|
-
]);
|
|
96
|
-
} else {
|
|
97
|
-
acc[acc.length - 1].push({
|
|
98
|
-
index,
|
|
99
|
-
move
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return acc;
|
|
103
|
-
}, []), [
|
|
104
|
-
history.length
|
|
105
|
-
]);
|
|
106
|
-
const scrollerRef = useRef(null);
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
scrollerRef.current?.scrollTo({
|
|
109
|
-
top: scrollerRef.current.scrollHeight
|
|
110
|
-
});
|
|
111
|
-
}, [
|
|
112
|
-
history.length
|
|
113
|
-
]);
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
const div = scrollerRef.current?.querySelector(`[data-index="${moveIndex - 1}"]`);
|
|
116
|
-
scrollerRef.current?.classList.add("scrollbar-none");
|
|
117
|
-
div?.scrollIntoView({
|
|
118
|
-
behavior: "smooth"
|
|
119
|
-
});
|
|
120
|
-
scrollerRef.current?.classList.remove("scrollbar-none");
|
|
121
|
-
}, [
|
|
122
|
-
moveIndex
|
|
123
|
-
]);
|
|
124
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
125
|
-
ref: scrollerRef,
|
|
126
|
-
className: mx("overflow-y-auto", classNames),
|
|
127
|
-
style: {
|
|
128
|
-
minHeight: min === void 0 ? "auto" : `${min * 24}px`,
|
|
129
|
-
maxHeight: max === void 0 ? "auto" : `${max * 24}px`
|
|
130
|
-
}
|
|
131
|
-
}, moves.map(([a, b], index) => /* @__PURE__ */ React.createElement("div", {
|
|
132
|
-
key: index,
|
|
133
|
-
className: "grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4"
|
|
134
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
135
|
-
className: "content-center text-xs text-subdued"
|
|
136
|
-
}, index + 1), a && /* @__PURE__ */ React.createElement("div", {
|
|
137
|
-
"data-index": a.index,
|
|
138
|
-
className: mx("ps-2 text-sm cursor-pointer", a.index === moveIndex - 1 && "bg-primary-500"),
|
|
139
|
-
onClick: () => onSelect?.(a.index + 1)
|
|
140
|
-
}, a.move), b && /* @__PURE__ */ React.createElement("div", {
|
|
141
|
-
"data-index": b.index,
|
|
142
|
-
className: mx("ps-2 text-sm cursor-pointer", b.index === moveIndex - 1 && "bg-primary-500"),
|
|
143
|
-
onClick: () => onSelect?.(b.index + 1)
|
|
144
|
-
}, b.move))), label && /* @__PURE__ */ React.createElement("div", {
|
|
145
|
-
className: "text-center"
|
|
146
|
-
}, label));
|
|
147
|
-
};
|
|
148
|
-
var PlayerIndicator = ({ children, model, player, icon }) => {
|
|
149
|
-
const turn = player === (model.game.turn() === "w" ? "white" : "black");
|
|
150
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
151
|
-
className: "grid grid-cols-[2rem_1fr_2rem] gap-2 h-(--dx-rail-size) px-1 flex items-center overflow-hidden"
|
|
152
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
153
|
-
className: "place-items-center"
|
|
154
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
155
|
-
icon: turn ? "ph--circle--fill" : "ph--circle--thin",
|
|
156
|
-
size: 6,
|
|
157
|
-
classNames: mx(turn && (model.game.isCheckmate() ? "text-error-500" : "text-success-text"))
|
|
158
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
159
|
-
className: "truncate overflow-hidden items-center"
|
|
160
|
-
}, children), icon);
|
|
161
|
-
};
|
|
162
|
-
var PlayerSelector = ({ value, onValueChange, members }) => {
|
|
163
|
-
const { t } = useTranslation(meta.id);
|
|
164
|
-
return /* @__PURE__ */ React.createElement(Select.Root, {
|
|
165
|
-
value,
|
|
166
|
-
onValueChange
|
|
167
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
168
|
-
placeholder: t("select-player.button")
|
|
169
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, members.map((member) => {
|
|
170
|
-
const memberKey = member.identity.identityKey.toHex();
|
|
171
|
-
const displayName = member.identity?.profile?.displayName || generateName(memberKey);
|
|
172
|
-
return /* @__PURE__ */ React.createElement(Select.Option, {
|
|
173
|
-
key: memberKey,
|
|
174
|
-
value: memberKey
|
|
175
|
-
}, displayName);
|
|
176
|
-
})), /* @__PURE__ */ React.createElement(Select.Arrow, null))));
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// src/components/Chessboard/types.ts
|
|
180
|
-
import { ChessModel } from "@dxos/react-ui-gameboard";
|
|
181
|
-
var ExtendedChessModel = class extends ChessModel {
|
|
182
|
-
object;
|
|
183
|
-
constructor(registry, object) {
|
|
184
|
-
super(registry), this.object = object;
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/components/Chessboard/Chessboard.tsx
|
|
189
|
-
var Root = /* @__PURE__ */ forwardRef(({ game, children }, forwardedRef) => {
|
|
190
|
-
const registry = useContext(RegistryContext);
|
|
191
|
-
const model = useMemo2(() => new ExtendedChessModel(registry, game), [
|
|
192
|
-
registry
|
|
193
|
-
]);
|
|
194
|
-
const click = useSoundEffect("Click");
|
|
195
|
-
const [pgn, updatePgn] = useObject(game, "pgn");
|
|
196
|
-
useImperativeHandle(forwardedRef, () => {
|
|
197
|
-
return {
|
|
198
|
-
setMoveNumber: (index) => model.setMoveIndex(index)
|
|
199
|
-
};
|
|
200
|
-
}, [
|
|
201
|
-
model
|
|
202
|
-
]);
|
|
203
|
-
useEffect2(() => {
|
|
204
|
-
if (model.pgn !== getRawPgn(pgn ?? "")) {
|
|
205
|
-
const silent = model.pgn === "*";
|
|
206
|
-
model.update(pgn);
|
|
207
|
-
if (!silent) {
|
|
208
|
-
void click.play();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}, [
|
|
212
|
-
pgn
|
|
213
|
-
]);
|
|
214
|
-
const handleDrop = useCallback((move) => {
|
|
215
|
-
if (!model.makeMove(move)) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
void click.play();
|
|
219
|
-
updatePgn(() => model.pgn);
|
|
220
|
-
return true;
|
|
221
|
-
}, [
|
|
222
|
-
model
|
|
223
|
-
]);
|
|
224
|
-
return /* @__PURE__ */ React2.createElement(Gameboard.Root, {
|
|
225
|
-
model,
|
|
226
|
-
onDrop: handleDrop
|
|
227
|
-
}, children);
|
|
228
|
-
});
|
|
229
|
-
var Content = ({ classNames, children }) => {
|
|
230
|
-
return /* @__PURE__ */ React2.createElement(Gameboard.Content, {
|
|
231
|
-
grow: true,
|
|
232
|
-
contain: true,
|
|
233
|
-
classNames
|
|
234
|
-
}, children);
|
|
235
|
-
};
|
|
236
|
-
var BOARD_NAME = "Chessboard.Board";
|
|
237
|
-
var Board = (props) => {
|
|
238
|
-
const registry = useContext(RegistryContext);
|
|
239
|
-
const { model } = useGameboardContext2(BOARD_NAME);
|
|
240
|
-
const ref = useRef2(null);
|
|
241
|
-
useEffect2(() => {
|
|
242
|
-
if (!ref.current) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
ref.current.setAttribute("data-arrow-keys", "all");
|
|
246
|
-
return addEventListener(ref.current, "keydown", (ev) => {
|
|
247
|
-
const moveIndex = registry.get(model.moveIndex);
|
|
248
|
-
switch (ev.key) {
|
|
249
|
-
case "ArrowUp":
|
|
250
|
-
model.setMoveIndex(0);
|
|
251
|
-
break;
|
|
252
|
-
case "ArrowDown":
|
|
253
|
-
model.setMoveIndex(model.game.history().length);
|
|
254
|
-
break;
|
|
255
|
-
case "ArrowLeft":
|
|
256
|
-
if (moveIndex > 0) {
|
|
257
|
-
model.setMoveIndex(moveIndex - 1);
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
case "ArrowRight":
|
|
261
|
-
if (moveIndex < model.game.history().length) {
|
|
262
|
-
model.setMoveIndex(moveIndex + 1);
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}, [
|
|
268
|
-
registry,
|
|
269
|
-
model
|
|
270
|
-
]);
|
|
271
|
-
return /* @__PURE__ */ React2.createElement(NaturalChessboard, {
|
|
272
|
-
...props,
|
|
273
|
-
ref
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
Board.displayName = BOARD_NAME;
|
|
277
|
-
var Chessboard = {
|
|
278
|
-
Root,
|
|
279
|
-
Content,
|
|
280
|
-
Board,
|
|
281
|
-
Info
|
|
282
|
-
};
|
|
13
|
+
// src/index.ts
|
|
14
|
+
import { Plugin } from "@dxos/app-framework";
|
|
283
15
|
|
|
284
16
|
// src/meta.ts
|
|
285
17
|
import { trim } from "@dxos/util";
|
|
286
|
-
var
|
|
18
|
+
var meta = {
|
|
287
19
|
id: "org.dxos.plugin.chess",
|
|
288
20
|
name: "Chess",
|
|
289
21
|
description: trim`
|
|
@@ -298,92 +30,13 @@ var meta2 = {
|
|
|
298
30
|
]
|
|
299
31
|
};
|
|
300
32
|
|
|
301
|
-
// src/
|
|
302
|
-
|
|
303
|
-
import * as Option from "effect/Option";
|
|
304
|
-
import { Plugin } from "@dxos/app-framework";
|
|
305
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
306
|
-
import { Annotation } from "@dxos/echo";
|
|
307
|
-
import { Operation } from "@dxos/operation";
|
|
308
|
-
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
309
|
-
import { ChessBlueprint } from "#blueprints";
|
|
310
|
-
import { BlueprintDefinition, OperationHandler, ReactSurface } from "#capabilities";
|
|
311
|
-
import { meta as meta4 } from "#meta";
|
|
312
|
-
import { Chess as Chess2 } from "#types";
|
|
313
|
-
|
|
314
|
-
// src/translations.ts
|
|
315
|
-
import { meta as meta3 } from "#meta";
|
|
316
|
-
import { Chess } from "#types";
|
|
317
|
-
var translations = [
|
|
318
|
-
{
|
|
319
|
-
"en-US": {
|
|
320
|
-
[Chess.Game.typename]: {
|
|
321
|
-
"typename.label": "Game",
|
|
322
|
-
"typename.label_zero": "Games",
|
|
323
|
-
"typename.label_one": "Game",
|
|
324
|
-
"typename.label_other": "Games",
|
|
325
|
-
"object-name.placeholder": "New game",
|
|
326
|
-
"add-object.label": "Add game",
|
|
327
|
-
"rename-object.label": "Rename game",
|
|
328
|
-
"delete-object.label": "Delete game",
|
|
329
|
-
"object-deleted.label": "Game deleted"
|
|
330
|
-
},
|
|
331
|
-
[meta3.id]: {
|
|
332
|
-
"plugin.name": "Chess",
|
|
333
|
-
"delete-game.label": "Delete",
|
|
334
|
-
"game.checkmate.label": "Checkmate",
|
|
335
|
-
"game.stalemate.label": "Stalemate",
|
|
336
|
-
"game.draw.label": "Draw",
|
|
337
|
-
"game.check.label": "Check",
|
|
338
|
-
"select-player.button": "Select player",
|
|
339
|
-
"toggle-info.button": "Toggle info",
|
|
340
|
-
"close-info.button": "Close info",
|
|
341
|
-
"flip-board.button": "Flip board"
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
];
|
|
346
|
-
|
|
347
|
-
// src/ChessPlugin.tsx
|
|
348
|
-
var ChessPlugin = Plugin.define(meta4).pipe(AppPlugin.addBlueprintDefinitionModule({
|
|
349
|
-
activate: BlueprintDefinition
|
|
350
|
-
}), AppPlugin.addOperationHandlerModule({
|
|
351
|
-
activate: OperationHandler
|
|
352
|
-
}), AppPlugin.addMetadataModule({
|
|
353
|
-
metadata: {
|
|
354
|
-
id: Chess2.Game.typename,
|
|
355
|
-
metadata: {
|
|
356
|
-
icon: Annotation.IconAnnotation.get(Chess2.Game).pipe(Option.getOrThrow).icon,
|
|
357
|
-
iconHue: Annotation.IconAnnotation.get(Chess2.Game).pipe(Option.getOrThrow).hue ?? "white",
|
|
358
|
-
blueprints: [
|
|
359
|
-
ChessBlueprint.key
|
|
360
|
-
],
|
|
361
|
-
createObject: (props, options) => Effect.gen(function* () {
|
|
362
|
-
const object = Chess2.make(props);
|
|
363
|
-
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
364
|
-
object,
|
|
365
|
-
target: options.target,
|
|
366
|
-
hidden: true,
|
|
367
|
-
targetNodeId: options.targetNodeId
|
|
368
|
-
});
|
|
369
|
-
})
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}), AppPlugin.addSchemaModule({
|
|
373
|
-
schema: [
|
|
374
|
-
Chess2.Game
|
|
375
|
-
]
|
|
376
|
-
}), AppPlugin.addSurfaceModule({
|
|
377
|
-
activate: ReactSurface
|
|
378
|
-
}), AppPlugin.addTranslationsModule({
|
|
379
|
-
translations
|
|
380
|
-
}), Plugin.make);
|
|
33
|
+
// src/index.ts
|
|
34
|
+
var ChessPlugin = Plugin.lazy(meta, () => import("#plugin"));
|
|
381
35
|
export {
|
|
382
36
|
Chess_exports as Chess,
|
|
383
37
|
chess_blueprint_default as ChessBlueprint,
|
|
384
38
|
operations_exports as ChessFunctions,
|
|
385
39
|
ChessPlugin,
|
|
386
|
-
|
|
387
|
-
meta2 as meta
|
|
40
|
+
meta
|
|
388
41
|
};
|
|
389
42
|
//# sourceMappingURL=index.mjs.map
|