@dxos/plugin-chess 0.7.5-labs.e27f9b9 → 0.7.5-main.2567c87
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/ChessContainer-JYXOZIDK.mjs +505 -0
- package/dist/lib/browser/ChessContainer-JYXOZIDK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VYBCAEUF.mjs → chunk-VHSLLEH3.mjs} +8 -11
- package/dist/lib/browser/chunk-VHSLLEH3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -32
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-FUAOSHHX.mjs +19 -0
- package/dist/lib/browser/intent-resolver-FUAOSHHX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-63EO2PZO.mjs +30 -0
- package/dist/lib/browser/react-surface-63EO2PZO.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node/ChessContainer-XRP7D63X.cjs +518 -0
- package/dist/lib/node/ChessContainer-XRP7D63X.cjs.map +7 -0
- package/dist/lib/node/{chunk-J5YKJRP3.cjs → chunk-3BLH7NRV.cjs} +11 -14
- package/dist/lib/node/chunk-3BLH7NRV.cjs.map +7 -0
- package/dist/lib/node/index.cjs +31 -49
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{intent-resolver-OIFDW46S.cjs → intent-resolver-VTB6P3IL.cjs} +11 -20
- package/dist/lib/node/intent-resolver-VTB6P3IL.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{chunk-TEZPML34.cjs → react-surface-PO42G64E.cjs} +22 -11
- package/dist/lib/node/react-surface-PO42G64E.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +6 -6
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/ChessContainer-37QUCUTD.mjs +507 -0
- package/dist/lib/node-esm/ChessContainer-37QUCUTD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TXUWVQWY.mjs → chunk-M2CRYWX5.mjs} +8 -11
- package/dist/lib/node-esm/chunk-M2CRYWX5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +15 -32
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-35HIBBYC.mjs → intent-resolver-MKEQFVZO.mjs} +9 -18
- package/dist/lib/node-esm/intent-resolver-MKEQFVZO.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-CXEBEDLT.mjs +31 -0
- package/dist/lib/node-esm/react-surface-CXEBEDLT.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -3
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chess.d.ts +9 -0
- package/dist/types/src/components/Chess.d.ts.map +1 -0
- package/dist/types/src/components/ChessContainer.d.ts +3 -4
- package/dist/types/src/components/ChessContainer.d.ts.map +1 -1
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +37 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +13 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/pieces/custom.d.ts +3 -0
- package/dist/types/src/components/Chessboard/pieces/custom.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/pieces/index.d.ts +4 -0
- package/dist/types/src/components/Chessboard/pieces/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/pieces/phosphor.d.ts +3 -0
- package/dist/types/src/components/Chessboard/pieces/phosphor.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/pieces/riohacha.d.ts +3 -0
- package/dist/types/src/components/Chessboard/pieces/riohacha.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +2 -4
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -4
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +20 -22
- package/src/ChessPlugin.tsx +17 -14
- package/src/capabilities/index.ts +0 -1
- package/src/capabilities/intent-resolver.ts +5 -13
- package/src/capabilities/react-surface.tsx +5 -12
- package/src/components/{PlayerSelector.tsx → Chess.tsx} +50 -3
- package/src/components/ChessContainer.tsx +4 -14
- package/src/components/Chessboard/Chessboard.stories.tsx +43 -0
- package/src/components/Chessboard/Chessboard.tsx +170 -0
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/pieces/custom.tsx +82 -0
- package/src/components/Chessboard/pieces/index.ts +7 -0
- package/src/components/Chessboard/pieces/phosphor.tsx +71 -0
- package/src/components/Chessboard/pieces/riohacha.tsx +166 -0
- package/src/components/index.ts +0 -2
- package/src/index.ts +1 -4
- package/src/translations.ts +2 -2
- package/src/types/schema.ts +1 -3
- package/src/types/types.ts +5 -6
- package/dist/lib/browser/ChessContainer-2MMUB5S7.mjs +0 -86
- package/dist/lib/browser/ChessContainer-2MMUB5S7.mjs.map +0 -7
- package/dist/lib/browser/artifact-YWAB5JJL.mjs +0 -174
- package/dist/lib/browser/artifact-YWAB5JJL.mjs.map +0 -7
- package/dist/lib/browser/chunk-672NU6IC.mjs +0 -8
- package/dist/lib/browser/chunk-672NU6IC.mjs.map +0 -7
- package/dist/lib/browser/chunk-RGPTBDH7.mjs +0 -41
- package/dist/lib/browser/chunk-RGPTBDH7.mjs.map +0 -7
- package/dist/lib/browser/chunk-VYBCAEUF.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BKKGQ5TJ.mjs +0 -28
- package/dist/lib/browser/intent-resolver-BKKGQ5TJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-Y7XMQYOV.mjs +0 -42
- package/dist/lib/browser/react-surface-Y7XMQYOV.mjs.map +0 -7
- package/dist/lib/node/ChessContainer-CMYJDMSG.cjs +0 -108
- package/dist/lib/node/ChessContainer-CMYJDMSG.cjs.map +0 -7
- package/dist/lib/node/artifact-YWL3LBIO.cjs +0 -189
- package/dist/lib/node/artifact-YWL3LBIO.cjs.map +0 -7
- package/dist/lib/node/chunk-J5YKJRP3.cjs.map +0 -7
- package/dist/lib/node/chunk-TEZPML34.cjs.map +0 -7
- package/dist/lib/node/chunk-YTD6SK5V.cjs +0 -73
- package/dist/lib/node/chunk-YTD6SK5V.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-OIFDW46S.cjs.map +0 -7
- package/dist/lib/node/react-surface-35CG6JQF.cjs +0 -62
- package/dist/lib/node/react-surface-35CG6JQF.cjs.map +0 -7
- package/dist/lib/node-esm/ChessContainer-WV2CO5WO.mjs +0 -87
- package/dist/lib/node-esm/ChessContainer-WV2CO5WO.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-B6IEF7U5.mjs +0 -175
- package/dist/lib/node-esm/artifact-B6IEF7U5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GJW6TXCL.mjs +0 -43
- package/dist/lib/node-esm/chunk-GJW6TXCL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TXUWVQWY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YXXJHXSV.mjs +0 -10
- package/dist/lib/node-esm/chunk-YXXJHXSV.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-35HIBBYC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4FNRAFRL.mjs +0 -43
- package/dist/lib/node-esm/react-surface-4FNRAFRL.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact.d.ts +0 -11
- package/dist/types/src/capabilities/artifact.d.ts.map +0 -1
- package/dist/types/src/components/ChessComponent.d.ts +0 -6
- package/dist/types/src/components/ChessComponent.d.ts.map +0 -1
- package/dist/types/src/components/ChessPanel.d.ts +0 -11
- package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -8
- package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/PlayerSelector.d.ts +0 -8
- package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
- package/src/capabilities/artifact.ts +0 -109
- package/src/components/ChessComponent.tsx +0 -48
- package/src/components/ChessPanel.tsx +0 -67
- package/src/components/Chessboard.stories.tsx +0 -39
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var artifact_YWL3LBIO_exports = {};
|
|
20
|
-
__export(artifact_YWL3LBIO_exports, {
|
|
21
|
-
default: () => artifact_default
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(artifact_YWL3LBIO_exports);
|
|
24
|
-
var import_chunk_J5YKJRP3 = require("./chunk-J5YKJRP3.cjs");
|
|
25
|
-
var import_chess = require("chess.js");
|
|
26
|
-
var import_effect = require("effect");
|
|
27
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
28
|
-
var import_artifact = require("@dxos/artifact");
|
|
29
|
-
var import_assistant = require("@dxos/assistant");
|
|
30
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
31
|
-
var import_invariant = require("@dxos/invariant");
|
|
32
|
-
var import_types = require("@dxos/plugin-space/types");
|
|
33
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
34
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-chess/src/capabilities/artifact.ts";
|
|
35
|
-
var artifact_default = () => {
|
|
36
|
-
const definition = (0, import_artifact.defineArtifact)({
|
|
37
|
-
id: "plugin-chess",
|
|
38
|
-
instructions: `
|
|
39
|
-
Chess:
|
|
40
|
-
- If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.
|
|
41
|
-
`,
|
|
42
|
-
schema: import_chunk_J5YKJRP3.ChessType,
|
|
43
|
-
tools: [
|
|
44
|
-
(0, import_artifact.defineTool)({
|
|
45
|
-
name: "chess_new",
|
|
46
|
-
description: "Create a new chess game. Returns the artifact definition for the game",
|
|
47
|
-
schema: import_echo_schema.S.Struct({
|
|
48
|
-
fen: import_echo_schema.S.String.annotations({
|
|
49
|
-
description: "The state of the chess game in the FEN format."
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
execute: async ({ fen }, { extensions }) => {
|
|
53
|
-
(0, import_invariant.invariant)(extensions?.space, "No space", {
|
|
54
|
-
F: __dxlog_file,
|
|
55
|
-
L: 42,
|
|
56
|
-
S: void 0,
|
|
57
|
-
A: [
|
|
58
|
-
"extensions?.space",
|
|
59
|
-
"'No space'"
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
(0, import_invariant.invariant)(extensions?.dispatch, "No intent dispatcher", {
|
|
63
|
-
F: __dxlog_file,
|
|
64
|
-
L: 43,
|
|
65
|
-
S: void 0,
|
|
66
|
-
A: [
|
|
67
|
-
"extensions?.dispatch",
|
|
68
|
-
"'No intent dispatcher'"
|
|
69
|
-
]
|
|
70
|
-
});
|
|
71
|
-
const intent = (0, import_effect.pipe)((0, import_app_framework.createIntent)(import_chunk_J5YKJRP3.ChessAction.Create, {
|
|
72
|
-
fen
|
|
73
|
-
}), (0, import_app_framework.chain)(import_types.SpaceAction.AddObject, {
|
|
74
|
-
target: extensions.space
|
|
75
|
-
}));
|
|
76
|
-
const { data, error } = await extensions.dispatch(intent);
|
|
77
|
-
if (!data || error) {
|
|
78
|
-
return import_artifact.ToolResult.Error(error?.message ?? "Failed to create chess game");
|
|
79
|
-
}
|
|
80
|
-
return import_artifact.ToolResult.Success((0, import_assistant.createArtifactElement)(data.id));
|
|
81
|
-
}
|
|
82
|
-
}),
|
|
83
|
-
(0, import_artifact.defineTool)({
|
|
84
|
-
name: "chess_query",
|
|
85
|
-
description: "Query all active chess games.",
|
|
86
|
-
schema: import_echo_schema.S.Struct({}),
|
|
87
|
-
execute: async (_, { extensions }) => {
|
|
88
|
-
(0, import_invariant.invariant)(extensions?.space, "No space", {
|
|
89
|
-
F: __dxlog_file,
|
|
90
|
-
L: 61,
|
|
91
|
-
S: void 0,
|
|
92
|
-
A: [
|
|
93
|
-
"extensions?.space",
|
|
94
|
-
"'No space'"
|
|
95
|
-
]
|
|
96
|
-
});
|
|
97
|
-
const { objects: games } = await extensions.space.db.query(import_echo.Filter.schema(import_chunk_J5YKJRP3.ChessType)).run();
|
|
98
|
-
(0, import_invariant.invariant)(games.length > 0, "No chess games found", {
|
|
99
|
-
F: __dxlog_file,
|
|
100
|
-
L: 63,
|
|
101
|
-
S: void 0,
|
|
102
|
-
A: [
|
|
103
|
-
"games.length > 0",
|
|
104
|
-
"'No chess games found'"
|
|
105
|
-
]
|
|
106
|
-
});
|
|
107
|
-
return import_artifact.ToolResult.Success(games);
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
(0, import_artifact.defineTool)({
|
|
111
|
-
name: "chess_inspect",
|
|
112
|
-
description: "Get the current state of the chess game.",
|
|
113
|
-
schema: import_echo_schema.S.Struct({
|
|
114
|
-
id: import_echo_schema.ObjectId
|
|
115
|
-
}),
|
|
116
|
-
execute: async ({ id }, { extensions }) => {
|
|
117
|
-
(0, import_invariant.invariant)(extensions?.space, "No space", {
|
|
118
|
-
F: __dxlog_file,
|
|
119
|
-
L: 72,
|
|
120
|
-
S: void 0,
|
|
121
|
-
A: [
|
|
122
|
-
"extensions?.space",
|
|
123
|
-
"'No space'"
|
|
124
|
-
]
|
|
125
|
-
});
|
|
126
|
-
const { objects: games } = await extensions.space.db.query(import_echo.Filter.schema(import_chunk_J5YKJRP3.ChessType)).run();
|
|
127
|
-
const game = games.find((game2) => game2.id === id);
|
|
128
|
-
(0, import_invariant.invariant)((0, import_echo_schema.isInstanceOf)(import_chunk_J5YKJRP3.ChessType, game), void 0, {
|
|
129
|
-
F: __dxlog_file,
|
|
130
|
-
L: 75,
|
|
131
|
-
S: void 0,
|
|
132
|
-
A: [
|
|
133
|
-
"isInstanceOf(ChessType, game)",
|
|
134
|
-
""
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
return import_artifact.ToolResult.Success(game.fen);
|
|
138
|
-
}
|
|
139
|
-
}),
|
|
140
|
-
(0, import_artifact.defineTool)({
|
|
141
|
-
name: "chess_move",
|
|
142
|
-
description: "Make a move in the chess game.",
|
|
143
|
-
schema: import_echo_schema.S.Struct({
|
|
144
|
-
id: import_echo_schema.ObjectId,
|
|
145
|
-
move: import_echo_schema.S.String.annotations({
|
|
146
|
-
description: "The move to make in the chess game.",
|
|
147
|
-
examples: [
|
|
148
|
-
"e4",
|
|
149
|
-
"Bf3"
|
|
150
|
-
]
|
|
151
|
-
})
|
|
152
|
-
}),
|
|
153
|
-
execute: async ({ id, move }, { extensions }) => {
|
|
154
|
-
(0, import_invariant.invariant)(extensions?.space, "No space", {
|
|
155
|
-
F: __dxlog_file,
|
|
156
|
-
L: 90,
|
|
157
|
-
S: void 0,
|
|
158
|
-
A: [
|
|
159
|
-
"extensions?.space",
|
|
160
|
-
"'No space'"
|
|
161
|
-
]
|
|
162
|
-
});
|
|
163
|
-
const { objects: games } = await extensions.space.db.query(import_echo.Filter.schema(import_chunk_J5YKJRP3.ChessType)).run();
|
|
164
|
-
const game = games.find((game2) => game2.id === id);
|
|
165
|
-
(0, import_invariant.invariant)((0, import_echo_schema.isInstanceOf)(import_chunk_J5YKJRP3.ChessType, game), void 0, {
|
|
166
|
-
F: __dxlog_file,
|
|
167
|
-
L: 93,
|
|
168
|
-
S: void 0,
|
|
169
|
-
A: [
|
|
170
|
-
"isInstanceOf(ChessType, game)",
|
|
171
|
-
""
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
const board = new import_chess.Chess(game.fen);
|
|
175
|
-
try {
|
|
176
|
-
board.move(move);
|
|
177
|
-
} catch (error) {
|
|
178
|
-
return import_artifact.ToolResult.Error(error.message);
|
|
179
|
-
}
|
|
180
|
-
game.pgn = board.pgn();
|
|
181
|
-
game.fen = board.fen();
|
|
182
|
-
return import_artifact.ToolResult.Success(game.fen);
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
]
|
|
186
|
-
});
|
|
187
|
-
return (0, import_app_framework.contributes)(import_app_framework.Capabilities.ArtifactDefinition, definition);
|
|
188
|
-
};
|
|
189
|
-
//# sourceMappingURL=artifact-YWL3LBIO.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/artifact.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess } from 'chess.js';\nimport { pipe } from 'effect';\n\nimport { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';\nimport { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';\nimport { createArtifactElement } from '@dxos/assistant';\nimport { isInstanceOf, ObjectId, S } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Filter, type Space } from '@dxos/react-client/echo';\n\nimport { ChessAction, ChessType } from '../types';\n\n// TODO(burdon): Factor out.\ndeclare global {\n interface ToolContextExtensions {\n space?: Space;\n dispatch?: PromiseIntentDispatcher;\n }\n}\n\nexport default () => {\n const definition = defineArtifact({\n id: 'plugin-chess',\n instructions: `\n Chess:\n - If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.\n `,\n schema: ChessType,\n tools: [\n defineTool({\n name: 'chess_new',\n description: 'Create a new chess game. Returns the artifact definition for the game',\n schema: S.Struct({\n fen: S.String.annotations({ description: 'The state of the chess game in the FEN format.' }),\n }),\n execute: async ({ fen }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n invariant(extensions?.dispatch, 'No intent dispatcher');\n const intent = pipe(\n createIntent(ChessAction.Create, { fen }),\n chain(SpaceAction.AddObject, { target: extensions.space }),\n );\n const { data, error } = await extensions.dispatch(intent);\n if (!data || error) {\n return ToolResult.Error(error?.message ?? 'Failed to create chess game');\n }\n\n return ToolResult.Success(createArtifactElement(data.id));\n },\n }),\n defineTool({\n name: 'chess_query',\n description: 'Query all active chess games.',\n schema: S.Struct({}),\n execute: async (_, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();\n invariant(games.length > 0, 'No chess games found');\n return ToolResult.Success(games);\n },\n }),\n defineTool({\n name: 'chess_inspect',\n description: 'Get the current state of the chess game.',\n schema: S.Struct({ id: ObjectId }),\n execute: async ({ id }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();\n const game = games.find((game) => game.id === id);\n invariant(isInstanceOf(ChessType, game));\n return ToolResult.Success(game.fen);\n },\n }),\n defineTool({\n name: 'chess_move',\n description: 'Make a move in the chess game.',\n schema: S.Struct({\n id: ObjectId,\n move: S.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n execute: async ({ id, move }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const { objects: games } = await extensions.space.db.query(Filter.schema(ChessType)).run();\n const game = games.find((game) => game.id === id);\n invariant(isInstanceOf(ChessType, game));\n const board = new Chess(game.fen);\n try {\n board.move(move);\n } catch (error: any) {\n return ToolResult.Error(error.message);\n }\n game.pgn = board.pgn();\n game.fen = board.fen();\n return ToolResult.Success(game.fen);\n },\n }),\n ],\n });\n\n return contributes(Capabilities.ArtifactDefinition, definition);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AACtB,oBAAqB;AAErB,2BAA6F;AAC7F,sBAAuD;AACvD,uBAAsC;AACtC,yBAA0C;AAC1C,uBAA0B;AAC1B,mBAA4B;AAC5B,kBAAmC;;AAYnC,IAAA,mBAAe,MAAA;AACb,QAAMA,iBAAaC,gCAAe;IAChCC,IAAI;IACJC,cAAc;;;;IAIdC,QAAQC;IACRC,OAAO;UACLC,4BAAW;QACTC,MAAM;QACNC,aAAa;QACbL,QAAQM,qBAAEC,OAAO;UACfC,KAAKF,qBAAEG,OAAOC,YAAY;YAAEL,aAAa;UAAiD,CAAA;QAC5F,CAAA;QACAM,SAAS,OAAO,EAAEH,IAAG,GAAI,EAAEI,WAAU,MAAE;AACrCC,0CAAUD,YAAYE,OAAO,YAAA;;;;;;;;;AAC7BD,0CAAUD,YAAYG,UAAU,wBAAA;;;;;;;;;AAChC,gBAAMC,aAASC,wBACbC,mCAAaC,kCAAYC,QAAQ;YAAEZ;UAAI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pC;MACF,CAAA;UACAL,4BAAW;QACTC,MAAM;QACNC,aAAa;QACbL,QAAQM,qBAAEC,OAAO;UACfT,IAAI0C;UACJI,MAAMtC,qBAAEG,OAAOC,YAAY;YACzBL,aAAa;YACbwC,UAAU;cAAC;cAAM;;UACnB,CAAA;QACF,CAAA;QACAlC,SAAS,OAAO,EAAEb,IAAI8C,KAAI,GAAI,EAAEhC,WAAU,MAAE;AAC1CC,0CAAUD,YAAYE,OAAO,YAAA;;;;;;;;;AAC7B,gBAAM,EAAEmB,SAASC,MAAK,IAAK,MAAMtB,WAAWE,MAAMqB,GAAGC,MAAMC,mBAAOrC,OAAOC,+BAAAA,CAAAA,EAAYqC,IAAG;AACxF,gBAAMG,OAAOP,MAAMQ,KAAK,CAACD,UAASA,MAAK3C,OAAOA,EAAAA;AAC9Ce,8CAAU8B,iCAAa1C,iCAAWwC,IAAAA,GAAAA,QAAAA;;;;;;;;;AAClC,gBAAMK,QAAQ,IAAIC,mBAAMN,KAAKjC,GAAG;AAChC,cAAI;AACFsC,kBAAMF,KAAKA,IAAAA;UACb,SAASlB,OAAY;AACnB,mBAAOC,2BAAWC,MAAMF,MAAMG,OAAO;UACvC;AACAY,eAAKO,MAAMF,MAAME,IAAG;AACpBP,eAAKjC,MAAMsC,MAAMtC,IAAG;AACpB,iBAAOmB,2BAAWG,QAAQW,KAAKjC,GAAG;QACpC;MACF,CAAA;;EAEJ,CAAA;AAEA,aAAOyC,kCAAYC,kCAAaC,oBAAoBvD,UAAAA;AACtD;",
|
|
6
|
-
"names": ["definition", "defineArtifact", "id", "instructions", "schema", "ChessType", "tools", "defineTool", "name", "description", "S", "Struct", "fen", "String", "annotations", "execute", "extensions", "invariant", "space", "dispatch", "intent", "pipe", "createIntent", "ChessAction", "Create", "chain", "SpaceAction", "AddObject", "target", "data", "error", "ToolResult", "Error", "message", "Success", "createArtifactElement", "_", "objects", "games", "db", "query", "Filter", "run", "length", "ObjectId", "game", "find", "isInstanceOf", "move", "examples", "board", "Chess", "pgn", "contributes", "Capabilities", "ArtifactDefinition"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\nexport const MoveSchema = S.mutable(\n S.partial(\n S.Struct({\n source: S.String,\n target: S.String,\n piece: S.String,\n }),\n ),\n);\n\nexport class ChessType extends TypedObject({ typename: 'dxos.org/type/Chess', version: '0.1.0' })(\n {\n name: S.optional(S.String),\n playerWhite: S.String,\n playerBlack: S.String,\n moves: S.mutable(S.Array(S.String)),\n // TODO(wittjosiah): Remove. Redundant with moves.\n pgn: S.String,\n fen: S.String,\n },\n { partial: true },\n) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { isInstanceOf, S } from '@dxos/echo-schema';\nimport { isReactiveObject } from '@dxos/live-object';\n\nimport { ChessType } from './schema';\nimport { CHESS_PLUGIN } from '../meta';\n\nexport namespace ChessAction {\n const CHESS_ACTION = `${CHESS_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${CHESS_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n fen: S.optional(S.String),\n }),\n output: S.Struct({\n object: ChessType,\n }),\n }) {}\n}\n\nexport const isObject = (object: unknown): object is typeof ChessType => {\n return isReactiveObject(object) && isInstanceOf(ChessType, object);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const CHESS_PLUGIN = 'dxos.org/plugin/chess';\n\nexport const meta = {\n id: CHESS_PLUGIN,\n name: 'Chess',\n description: 'Play chess.',\n icon: 'ph--shield-chevron--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',\n} satisfies PluginMeta;\n"],
|
|
5
|
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7D;",
|
|
6
|
-
"names": ["import_echo_schema", "MoveSchema", "S", "mutable", "partial", "Struct", "source", "String", "target", "piece", "ChessType", "TypedObject", "typename", "version", "name", "optional", "playerWhite", "playerBlack", "moves", "Array", "pgn", "fen", "CHESS_PLUGIN", "meta", "id", "description", "icon", "ChessAction", "CHESS_ACTION", "Create", "TaggedClass", "input", "output", "object", "isObject", "isReactiveObject", "isInstanceOf"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './ChessComponent';\n\nexport const ChessContainer = lazy(() => import('./ChessContainer'));\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAqB;AAId,IAAMA,qBAAiBC,mBAAK,MAAM,OAAO,+BAAA,CAAA;",
|
|
6
|
-
"names": ["ChessContainer", "lazy"]
|
|
7
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var chunk_YTD6SK5V_exports = {};
|
|
30
|
-
__export(chunk_YTD6SK5V_exports, {
|
|
31
|
-
ChessComponent: () => ChessComponent
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(chunk_YTD6SK5V_exports);
|
|
34
|
-
var import_chess = require("chess.js");
|
|
35
|
-
var import_react = __toESM(require("react"));
|
|
36
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
37
|
-
var import_react_ui_gameboard = require("@dxos/react-ui-gameboard");
|
|
38
|
-
var ChessComponent = ({ game }) => {
|
|
39
|
-
const model = (0, import_react.useMemo)(() => new import_react_ui_gameboard.ChessModel(), []);
|
|
40
|
-
(0, import_react.useEffect)(() => {
|
|
41
|
-
if (!model || game.pgn !== model?.game.pgn()) {
|
|
42
|
-
const chess = new import_chess.Chess();
|
|
43
|
-
if (game.pgn) {
|
|
44
|
-
chess.loadPgn(game.pgn);
|
|
45
|
-
}
|
|
46
|
-
model.initialize(chess.fen());
|
|
47
|
-
}
|
|
48
|
-
}, [
|
|
49
|
-
game.pgn
|
|
50
|
-
]);
|
|
51
|
-
const space = (0, import_echo.getSpace)(game);
|
|
52
|
-
if (!space) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
const handleDrop = (0, import_react.useCallback)((move) => {
|
|
56
|
-
if (model.makeMove(move)) {
|
|
57
|
-
game.pgn = model.game.pgn();
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}, [
|
|
62
|
-
model
|
|
63
|
-
]);
|
|
64
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_gameboard.Board.Root, {
|
|
65
|
-
model,
|
|
66
|
-
onDrop: handleDrop
|
|
67
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui_gameboard.Chessboard, null));
|
|
68
|
-
};
|
|
69
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
-
0 && (module.exports = {
|
|
71
|
-
ChessComponent
|
|
72
|
-
});
|
|
73
|
-
//# sourceMappingURL=chunk-YTD6SK5V.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ChessComponent.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess } from 'chess.js';\nimport React, { useCallback, useEffect, useMemo } from 'react';\n\nimport { getSpace } from '@dxos/react-client/echo';\nimport { ChessModel, Board, Chessboard, type BoardRootProps } from '@dxos/react-ui-gameboard';\n\nimport { type ChessType } from '../types';\n\nexport const ChessComponent = ({ game }: { game: ChessType }) => {\n const model = useMemo(() => new ChessModel(), []);\n useEffect(() => {\n if (!model || game.pgn !== model?.game.pgn()) {\n const chess = new Chess();\n if (game.pgn) {\n chess.loadPgn(game.pgn);\n }\n\n model.initialize(chess.fen());\n }\n }, [game.pgn]);\n\n const space = getSpace(game);\n if (!space) {\n return null;\n }\n\n const handleDrop = useCallback<NonNullable<BoardRootProps['onDrop']>>(\n (move) => {\n if (model.makeMove(move)) {\n game.pgn = model.game.pgn();\n return true;\n }\n\n return false;\n },\n [model],\n );\n\n return (\n <Board.Root model={model} onDrop={handleDrop}>\n <Chessboard />\n </Board.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AACtB,mBAAuD;AAEvD,kBAAyB;AACzB,gCAAmE;AAI5D,IAAMA,iBAAiB,CAAC,EAAEC,KAAI,MAAuB;AAC1D,QAAMC,YAAQC,sBAAQ,MAAM,IAAIC,qCAAAA,GAAc,CAAA,CAAE;AAChDC,8BAAU,MAAA;AACR,QAAI,CAACH,SAASD,KAAKK,QAAQJ,OAAOD,KAAKK,IAAAA,GAAO;AAC5C,YAAMC,QAAQ,IAAIC,mBAAAA;AAClB,UAAIP,KAAKK,KAAK;AACZC,cAAME,QAAQR,KAAKK,GAAG;MACxB;AAEAJ,YAAMQ,WAAWH,MAAMI,IAAG,CAAA;IAC5B;EACF,GAAG;IAACV,KAAKK;GAAI;AAEb,QAAMM,YAAQC,sBAASZ,IAAAA;AACvB,MAAI,CAACW,OAAO;AACV,WAAO;EACT;AAEA,QAAME,iBAAaC,0BACjB,CAACC,SAAAA;AACC,QAAId,MAAMe,SAASD,IAAAA,GAAO;AACxBf,WAAKK,MAAMJ,MAAMD,KAAKK,IAAG;AACzB,aAAO;IACT;AAEA,WAAO;EACT,GACA;IAACJ;GAAM;AAGT,SACE,6BAAAgB,QAAA,cAACC,gCAAMC,MAAI;IAAClB;IAAcmB,QAAQP;KAChC,6BAAAI,QAAA,cAACI,sCAAAA,IAAAA,CAAAA;AAGP;",
|
|
6
|
-
"names": ["ChessComponent", "game", "model", "useMemo", "ChessModel", "useEffect", "pgn", "chess", "Chess", "loadPgn", "initialize", "fen", "space", "getSpace", "handleDrop", "useCallback", "move", "makeMove", "React", "Board", "Root", "onDrop", "Chessboard"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess } from 'chess.js';\n\nimport { Capabilities, contributes, createResolver } from '@dxos/app-framework';\nimport { create } from '@dxos/live-object';\n\nimport { ChessAction, ChessType } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: ChessAction.Create,\n resolve: ({ name, fen }) => {\n const pgn = fen ? new Chess(fen).pgn() : undefined;\n return {\n data: {\n object: create(ChessType, { name, fen, pgn }),\n },\n };\n },\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AAEtB,2BAA0D;AAC1D,yBAAuB;AAIvB,IAAA,0BAAe,UACbA,kCACEC,kCAAaC,oBACbC,qCAAe;EACbC,QAAQC,kCAAYC;EACpBC,SAAS,CAAC,EAAEC,MAAMC,IAAG,MAAE;AACrB,UAAMC,MAAMD,MAAM,IAAIE,mBAAMF,GAAAA,EAAKC,IAAG,IAAKE;AACzC,WAAO;MACLC,MAAM;QACJC,YAAQC,2BAAOC,iCAAW;UAAER;UAAMC;UAAKC;QAAI,CAAA;MAC7C;IACF;EACF;AACF,CAAA,CAAA;",
|
|
6
|
-
"names": ["contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ChessAction", "Create", "resolve", "name", "fen", "pgn", "Chess", "undefined", "data", "object", "create", "ChessType"]
|
|
7
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var react_surface_35CG6JQF_exports = {};
|
|
30
|
-
__export(react_surface_35CG6JQF_exports, {
|
|
31
|
-
default: () => react_surface_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(react_surface_35CG6JQF_exports);
|
|
34
|
-
var import_chunk_TEZPML34 = require("./chunk-TEZPML34.cjs");
|
|
35
|
-
var import_chunk_J5YKJRP3 = require("./chunk-J5YKJRP3.cjs");
|
|
36
|
-
var import_chunk_YTD6SK5V = require("./chunk-YTD6SK5V.cjs");
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
39
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
40
|
-
var react_surface_default = () => (0, import_app_framework.contributes)(import_app_framework.Capabilities.ReactSurface, [
|
|
41
|
-
(0, import_app_framework.createSurface)({
|
|
42
|
-
id: import_chunk_J5YKJRP3.CHESS_PLUGIN,
|
|
43
|
-
role: [
|
|
44
|
-
"article",
|
|
45
|
-
"section"
|
|
46
|
-
],
|
|
47
|
-
filter: (data) => (0, import_chunk_J5YKJRP3.isObject)(data.subject),
|
|
48
|
-
component: ({ data, role }) => /* @__PURE__ */ import_react.default.createElement(import_chunk_TEZPML34.ChessContainer, {
|
|
49
|
-
game: data.subject,
|
|
50
|
-
role
|
|
51
|
-
})
|
|
52
|
-
}),
|
|
53
|
-
(0, import_app_framework.createSurface)({
|
|
54
|
-
id: "plugin-chess",
|
|
55
|
-
role: "canvas-node",
|
|
56
|
-
filter: (data) => (0, import_echo_schema.isInstanceOf)(import_chunk_J5YKJRP3.ChessType, data),
|
|
57
|
-
component: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_chunk_YTD6SK5V.ChessComponent, {
|
|
58
|
-
game: data
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
]);
|
|
62
|
-
//# sourceMappingURL=react-surface-35CG6JQF.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { isInstanceOf } from '@dxos/echo-schema';\n\nimport { ChessContainer } from '../components';\nimport { ChessComponent } from '../components/ChessComponent';\nimport { CHESS_PLUGIN } from '../meta';\nimport { ChessType, isObject } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: CHESS_PLUGIN,\n role: ['article', 'section'],\n filter: (data): data is { subject: ChessType } => isObject(data.subject),\n component: ({ data, role }) => <ChessContainer game={data.subject} role={role} />,\n }),\n createSurface({\n id: 'plugin-chess',\n role: 'canvas-node',\n filter: (data): data is any => isInstanceOf(ChessType, data),\n component: ({ data }) => <ChessComponent game={data} />,\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,2BAAyD;AACzD,yBAA6B;AAO7B,IAAA,wBAAe,UACbA,kCAAYC,kCAAaC,cAAc;MACrCC,oCAAc;IACZC,IAAIC;IACJC,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,aAAyCC,gCAASD,KAAKE,OAAO;IACvEC,WAAW,CAAC,EAAEH,MAAMF,KAAI,MAAO,6BAAAM,QAAA,cAACC,sCAAAA;MAAeC,MAAMN,KAAKE;MAASJ;;EACrE,CAAA;MACAH,oCAAc;IACZC,IAAI;IACJE,MAAM;IACNC,QAAQ,CAACC,aAAsBO,iCAAaC,iCAAWR,IAAAA;IACvDG,WAAW,CAAC,EAAEH,KAAI,MAAO,6BAAAI,QAAA,cAACK,sCAAAA;MAAeH,MAAMN;;EACjD,CAAA;CACD;",
|
|
6
|
-
"names": ["contributes", "Capabilities", "ReactSurface", "createSurface", "id", "CHESS_PLUGIN", "role", "filter", "data", "isObject", "subject", "component", "React", "ChessContainer", "game", "isInstanceOf", "ChessType", "ChessComponent"]
|
|
7
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ChessComponent
|
|
4
|
-
} from "./chunk-GJW6TXCL.mjs";
|
|
5
|
-
|
|
6
|
-
// packages/plugins/plugin-chess/src/components/ChessContainer.tsx
|
|
7
|
-
import React2 from "react";
|
|
8
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
9
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
10
|
-
|
|
11
|
-
// packages/plugins/plugin-chess/src/components/PlayerSelector.tsx
|
|
12
|
-
import { CrownCross } from "@phosphor-icons/react";
|
|
13
|
-
import React from "react";
|
|
14
|
-
import { generateName } from "@dxos/display-name";
|
|
15
|
-
import { useMembers } from "@dxos/react-client/echo";
|
|
16
|
-
import { Input, Select, useThemeContext } from "@dxos/react-ui";
|
|
17
|
-
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
18
|
-
var PlayerSelector = ({ space, game }) => {
|
|
19
|
-
const members = useMembers(space.key);
|
|
20
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
21
|
-
role: "none",
|
|
22
|
-
className: "grid grid-cols-2 gap-8"
|
|
23
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
24
|
-
role: "none",
|
|
25
|
-
className: "flex flex-row-reverse items-center gap-2"
|
|
26
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelect, {
|
|
27
|
-
side: "white",
|
|
28
|
-
value: game.playerWhite,
|
|
29
|
-
onValueChange: (player) => game.playerWhite = player,
|
|
30
|
-
members
|
|
31
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
32
|
-
role: "none",
|
|
33
|
-
className: "flex flex-row items-center gap-2"
|
|
34
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelect, {
|
|
35
|
-
side: "black",
|
|
36
|
-
value: game.playerBlack,
|
|
37
|
-
onValueChange: (player) => game.playerBlack = player,
|
|
38
|
-
members
|
|
39
|
-
})));
|
|
40
|
-
};
|
|
41
|
-
var PlayerSelect = ({ side, value, onValueChange, members }) => {
|
|
42
|
-
const { themeMode } = useThemeContext();
|
|
43
|
-
const iconFillMode = side === "black" && themeMode === "light" || side === "white" && themeMode === "dark" ? "fill" : void 0;
|
|
44
|
-
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, null, /* @__PURE__ */ React.createElement(CrownCross, {
|
|
45
|
-
className: mx(getSize(6)),
|
|
46
|
-
weight: iconFillMode,
|
|
47
|
-
"aria-label": `Chess icon for side ${side}`
|
|
48
|
-
})), /* @__PURE__ */ React.createElement(Select.Root, {
|
|
49
|
-
value,
|
|
50
|
-
onValueChange
|
|
51
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
52
|
-
placeholder: "Select player"
|
|
53
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, members.map((member) => {
|
|
54
|
-
const memberKey = member.identity.identityKey.toHex();
|
|
55
|
-
const displayName = member.identity?.profile?.displayName || generateName(memberKey);
|
|
56
|
-
return /* @__PURE__ */ React.createElement(Select.Option, {
|
|
57
|
-
key: memberKey,
|
|
58
|
-
value: memberKey
|
|
59
|
-
}, displayName);
|
|
60
|
-
}))))));
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// packages/plugins/plugin-chess/src/components/ChessContainer.tsx
|
|
64
|
-
var ChessContainer = ({ game }) => {
|
|
65
|
-
const space = getSpace(game);
|
|
66
|
-
if (!space) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return /* @__PURE__ */ React2.createElement(StackItem.Content, {
|
|
70
|
-
toolbar: false
|
|
71
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
72
|
-
role: "none",
|
|
73
|
-
className: "grid grid-rows-[60px_1fr_60px] grow overflow-hidden"
|
|
74
|
-
}, /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("div", {
|
|
75
|
-
className: "flex m-4 overflow-hidden"
|
|
76
|
-
}, /* @__PURE__ */ React2.createElement(ChessComponent, {
|
|
77
|
-
game
|
|
78
|
-
})), /* @__PURE__ */ React2.createElement(PlayerSelector, {
|
|
79
|
-
space,
|
|
80
|
-
game
|
|
81
|
-
})));
|
|
82
|
-
};
|
|
83
|
-
var ChessContainer_default = ChessContainer;
|
|
84
|
-
export {
|
|
85
|
-
ChessContainer_default as default
|
|
86
|
-
};
|
|
87
|
-
//# sourceMappingURL=ChessContainer-WV2CO5WO.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ChessContainer.tsx", "../../../src/components/PlayerSelector.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { ChessComponent } from './ChessComponent';\nimport { PlayerSelector } from './PlayerSelector';\nimport { type ChessType } from '../types';\n\nconst ChessContainer = ({ game }: { game: ChessType; role?: string }) => {\n const space = getSpace(game);\n if (!space) {\n return null;\n }\n\n return (\n <StackItem.Content toolbar={false}>\n <div role='none' className='grid grid-rows-[60px_1fr_60px] grow overflow-hidden'>\n <div />\n\n <div className='flex m-4 overflow-hidden'>\n <ChessComponent game={game} />\n </div>\n\n <PlayerSelector space={space} game={game} />\n </div>\n </StackItem.Content>\n );\n};\n\nexport default ChessContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { CrownCross } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { useMembers, type Space, type SpaceMember } from '@dxos/react-client/echo';\nimport { Input, Select, useThemeContext } from '@dxos/react-ui';\nimport { getSize, mx } from '@dxos/react-ui-theme';\n\nimport { type ChessType } from '../types';\n\nexport const PlayerSelector = ({ space, game }: { space: Space; game: ChessType }) => {\n const members = useMembers(space.key);\n\n return (\n <div role='none' className='grid grid-cols-2 gap-8'>\n <div role='none' className='flex flex-row-reverse items-center gap-2'>\n <PlayerSelect\n side='white'\n value={game.playerWhite}\n onValueChange={(player) => (game.playerWhite = player)}\n members={members}\n />\n </div>\n <div role='none' className='flex flex-row items-center gap-2'>\n <PlayerSelect\n side='black'\n value={game.playerBlack}\n onValueChange={(player) => (game.playerBlack = player)}\n members={members}\n />\n </div>\n </div>\n );\n};\n\nconst PlayerSelect = ({\n side,\n value,\n onValueChange,\n members,\n}: {\n side: 'white' | 'black';\n value: string | undefined;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n}) => {\n const { themeMode } = useThemeContext();\n const iconFillMode =\n (side === 'black' && themeMode === 'light') || (side === 'white' && themeMode === 'dark') ? 'fill' : undefined;\n\n return (\n <Input.Root>\n <Input.Label>\n <CrownCross className={mx(getSize(6))} weight={iconFillMode} aria-label={`Chess icon for side ${side}`} />\n </Input.Label>\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={'Select player'} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {members.map((member) => {\n const memberKey = member.identity.identityKey.toHex();\n const displayName = member.identity?.profile?.displayName || generateName(memberKey);\n return (\n <Select.Option key={memberKey} value={memberKey}>\n {displayName}\n </Select.Option>\n );\n })}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </Input.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;;;ACH1B,SAASC,kBAAkB;AAC3B,OAAOC,WAAW;AAElB,SAASC,oBAAoB;AAC7B,SAASC,kBAAgD;AACzD,SAASC,OAAOC,QAAQC,uBAAuB;AAC/C,SAASC,SAASC,UAAU;AAIrB,IAAMC,iBAAiB,CAAC,EAAEC,OAAOC,KAAI,MAAqC;AAC/E,QAAMC,UAAUC,WAAWH,MAAMI,GAAG;AAEpC,SACE,sBAAA,cAACC,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,sBAAA,cAACF,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,sBAAA,cAACC,cAAAA;IACCC,MAAK;IACLC,OAAOT,KAAKU;IACZC,eAAe,CAACC,WAAYZ,KAAKU,cAAcE;IAC/CX;OAGJ,sBAAA,cAACG,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,sBAAA,cAACC,cAAAA;IACCC,MAAK;IACLC,OAAOT,KAAKa;IACZF,eAAe,CAACC,WAAYZ,KAAKa,cAAcD;IAC/CX;;AAKV;AAEA,IAAM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eV;IAAcD;;AAItC;AAEA,IAAA,yBAAeD;",
|
|
6
|
-
"names": ["React", "getSpace", "StackItem", "CrownCross", "React", "generateName", "useMembers", "Input", "Select", "useThemeContext", "getSize", "mx", "PlayerSelector", "space", "game", "members", "useMembers", "key", "div", "role", "className", "PlayerSelect", "side", "value", "playerWhite", "onValueChange", "player", "playerBlack", "themeMode", "useThemeContext", "iconFillMode", "undefined", "Input", "Root", "Label", "CrownCross", "mx", "getSize", "weight", "aria-label", "Select", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "map", "member", "memberKey", "identity", "identityKey", "toHex", "displayName", "profile", "generateName", "Option", "ChessContainer", "game", "space", "getSpace", "React", "StackItem", "Content", "toolbar", "div", "role", "className", "ChessComponent", "PlayerSelector"]
|
|
7
|
-
}
|