@dxos/plugin-chess 0.8.4-main.422d1c7879 → 0.8.4-main.51f1e5ca51

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.
Files changed (122) hide show
  1. package/dist/lib/browser/blueprints/index.mjs +35 -6
  2. package/dist/lib/browser/blueprints/index.mjs.map +4 -4
  3. package/dist/lib/browser/{chunk-JZMN24DY.mjs → chunk-2DFOUJBD.mjs} +4 -4
  4. package/dist/lib/browser/chunk-2DFOUJBD.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-2TJN26DN.mjs → chunk-IN3LZ2OO.mjs} +2 -7
  6. package/dist/lib/browser/{chunk-2TJN26DN.mjs.map → chunk-IN3LZ2OO.mjs.map} +2 -2
  7. package/dist/lib/browser/{chunk-XAJZK6Z2.mjs → chunk-OBKYFOJA.mjs} +3 -3
  8. package/dist/lib/browser/chunk-OBKYFOJA.mjs.map +7 -0
  9. package/dist/lib/browser/cli/index.mjs +1 -1
  10. package/dist/lib/browser/cli/index.mjs.map +3 -3
  11. package/dist/lib/browser/{create-AJHN4QT4.mjs → create-2ME3FNBX.mjs} +4 -4
  12. package/dist/lib/browser/create-2ME3FNBX.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +10 -57
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/{move-T2NLRBR4.mjs → move-TTMIPD5J.mjs} +5 -5
  17. package/dist/lib/browser/move-TTMIPD5J.mjs.map +7 -0
  18. package/dist/lib/browser/operations/index.mjs +3 -3
  19. package/dist/lib/browser/{play-7VTMD3SJ.mjs → play-GHXPV2T2.mjs} +5 -5
  20. package/dist/lib/browser/play-GHXPV2T2.mjs.map +7 -0
  21. package/dist/lib/browser/{print-EW7LPW4D.mjs → print-RNAGAOM7.mjs} +4 -4
  22. package/dist/lib/browser/{print-EW7LPW4D.mjs.map → print-RNAGAOM7.mjs.map} +1 -1
  23. package/dist/lib/browser/translations.mjs +38 -0
  24. package/dist/lib/browser/translations.mjs.map +7 -0
  25. package/dist/lib/browser/types/index.mjs +1 -1
  26. package/dist/lib/node-esm/blueprints/index.mjs +35 -6
  27. package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
  28. package/dist/lib/node-esm/{chunk-NYU5JVXP.mjs → chunk-G2EHRXHX.mjs} +3 -3
  29. package/dist/lib/node-esm/chunk-G2EHRXHX.mjs.map +7 -0
  30. package/dist/lib/node-esm/{chunk-OIRJVY2R.mjs → chunk-OHBKSL2Q.mjs} +2 -7
  31. package/dist/lib/node-esm/{chunk-OIRJVY2R.mjs.map → chunk-OHBKSL2Q.mjs.map} +2 -2
  32. package/dist/lib/node-esm/{chunk-LQEDIKCV.mjs → chunk-V4FN2DZR.mjs} +4 -4
  33. package/dist/lib/node-esm/chunk-V4FN2DZR.mjs.map +7 -0
  34. package/dist/lib/node-esm/cli/index.mjs +1 -1
  35. package/dist/lib/node-esm/cli/index.mjs.map +3 -3
  36. package/dist/lib/node-esm/{create-QSETDT4N.mjs → create-CC2P7GPT.mjs} +4 -4
  37. package/dist/lib/node-esm/create-CC2P7GPT.mjs.map +7 -0
  38. package/dist/lib/node-esm/index.mjs +10 -57
  39. package/dist/lib/node-esm/index.mjs.map +4 -4
  40. package/dist/lib/node-esm/meta.json +1 -1
  41. package/dist/lib/node-esm/{move-5F2ANDTE.mjs → move-CYHXWHHM.mjs} +5 -5
  42. package/dist/lib/node-esm/move-CYHXWHHM.mjs.map +7 -0
  43. package/dist/lib/node-esm/operations/index.mjs +3 -3
  44. package/dist/lib/node-esm/{play-W4DQCQRX.mjs → play-KTNK2PBL.mjs} +5 -5
  45. package/dist/lib/node-esm/play-KTNK2PBL.mjs.map +7 -0
  46. package/dist/lib/node-esm/{print-UJHXAXMS.mjs → print-P23VKVNU.mjs} +4 -4
  47. package/dist/lib/node-esm/{print-UJHXAXMS.mjs.map → print-P23VKVNU.mjs.map} +1 -1
  48. package/dist/lib/node-esm/translations.mjs +39 -0
  49. package/dist/lib/node-esm/translations.mjs.map +7 -0
  50. package/dist/lib/node-esm/types/index.mjs +1 -1
  51. package/dist/types/src/ChessPlugin.d.ts.map +1 -1
  52. package/dist/types/src/blueprints/chess-blueprint.d.ts +2 -2
  53. package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -1
  54. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  55. package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -2
  56. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/index.d.ts +2 -2
  58. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  59. package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
  60. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
  61. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  62. package/dist/types/src/components/Chessboard/Chessboard.d.ts +4 -0
  63. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  64. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +40 -23
  65. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  66. package/dist/types/src/components/Chessboard/Info.d.ts +4 -5
  67. package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -1
  68. package/dist/types/src/components/Chessboard/types.d.ts.map +1 -1
  69. package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -1
  70. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +40 -23
  71. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
  72. package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
  73. package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -1
  74. package/dist/types/src/index.d.ts +0 -2
  75. package/dist/types/src/index.d.ts.map +1 -1
  76. package/dist/types/src/operations/create.d.ts +1 -1
  77. package/dist/types/src/operations/create.d.ts.map +1 -1
  78. package/dist/types/src/operations/definitions.d.ts +2 -2
  79. package/dist/types/src/operations/definitions.d.ts.map +1 -1
  80. package/dist/types/src/operations/index.d.ts +1 -1
  81. package/dist/types/src/operations/index.d.ts.map +1 -1
  82. package/dist/types/src/operations/move.d.ts +1 -1
  83. package/dist/types/src/operations/move.d.ts.map +1 -1
  84. package/dist/types/src/operations/play.d.ts +1 -1
  85. package/dist/types/src/operations/play.d.ts.map +1 -1
  86. package/dist/types/src/operations/print.d.ts +1 -1
  87. package/dist/types/src/operations/print.d.ts.map +1 -1
  88. package/dist/types/src/translations.d.ts +40 -24
  89. package/dist/types/src/translations.d.ts.map +1 -1
  90. package/dist/types/src/types/Chess.d.ts.map +1 -1
  91. package/dist/types/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +40 -35
  93. package/src/ChessPlugin.tsx +2 -3
  94. package/src/blueprints/chess-blueprint.ts +2 -3
  95. package/src/capabilities/artifact-definition.ts +2 -2
  96. package/src/capabilities/index.ts +1 -1
  97. package/src/capabilities/operation-handler.ts +1 -1
  98. package/src/cli/plugin.ts +1 -1
  99. package/src/components/Chessboard/Chessboard.stories.tsx +1 -1
  100. package/src/components/Chessboard/Info.tsx +2 -2
  101. package/src/containers/ChessArticle/ChessArticle.stories.tsx +1 -1
  102. package/src/index.ts +0 -2
  103. package/src/operations/create.ts +1 -1
  104. package/src/operations/definitions.ts +1 -1
  105. package/src/operations/index.ts +1 -1
  106. package/src/operations/move.ts +2 -2
  107. package/src/operations/play.ts +2 -2
  108. package/src/operations/print.ts +1 -1
  109. package/dist/lib/browser/chunk-JZMN24DY.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-MC7L6JNC.mjs +0 -36
  111. package/dist/lib/browser/chunk-MC7L6JNC.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-XAJZK6Z2.mjs.map +0 -7
  113. package/dist/lib/browser/create-AJHN4QT4.mjs.map +0 -7
  114. package/dist/lib/browser/move-T2NLRBR4.mjs.map +0 -7
  115. package/dist/lib/browser/play-7VTMD3SJ.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-4HZWCKMR.mjs +0 -38
  117. package/dist/lib/node-esm/chunk-4HZWCKMR.mjs.map +0 -7
  118. package/dist/lib/node-esm/chunk-LQEDIKCV.mjs.map +0 -7
  119. package/dist/lib/node-esm/chunk-NYU5JVXP.mjs.map +0 -7
  120. package/dist/lib/node-esm/create-QSETDT4N.mjs.map +0 -7
  121. package/dist/lib/node-esm/move-5F2ANDTE.mjs.map +0 -7
  122. package/dist/lib/node-esm/play-W4DQCQRX.mjs.map +0 -7
@@ -1,12 +1,41 @@
1
- import {
2
- chess_blueprint_default
3
- } from "../chunk-MC7L6JNC.mjs";
4
1
  import {
5
2
  operations_exports
6
- } from "../chunk-JZMN24DY.mjs";
7
- import "../chunk-XAJZK6Z2.mjs";
8
- import "../chunk-2TJN26DN.mjs";
3
+ } from "../chunk-2DFOUJBD.mjs";
4
+ import "../chunk-OBKYFOJA.mjs";
5
+ import "../chunk-IN3LZ2OO.mjs";
9
6
  import "../chunk-J5LGTIGS.mjs";
7
+
8
+ // src/blueprints/chess-blueprint.ts
9
+ import { Blueprint, Template } from "@dxos/compute";
10
+ import { trim } from "@dxos/util";
11
+ import { Create, Move, Play, Print } from "#operations";
12
+ var BLUEPRINT_KEY = "org.dxos.blueprint.chess";
13
+ var operations = [
14
+ Create,
15
+ Move,
16
+ Play,
17
+ Print
18
+ ];
19
+ var make = () => Blueprint.make({
20
+ key: BLUEPRINT_KEY,
21
+ name: "Chess",
22
+ tools: Blueprint.toolDefinitions({
23
+ operations
24
+ }),
25
+ instructions: Template.make({
26
+ source: trim`
27
+ You are an expert chess player.
28
+ To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
29
+ You could suggest a good next move or offer to play a move.
30
+ Don't actually make a move unless you are asked to.
31
+ `
32
+ })
33
+ });
34
+ var blueprint = {
35
+ key: BLUEPRINT_KEY,
36
+ make
37
+ };
38
+ var chess_blueprint_default = blueprint;
10
39
  export {
11
40
  chess_blueprint_default as ChessBlueprint,
12
41
  operations_exports as ChessFunctions
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
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
7
  }
@@ -3,7 +3,7 @@ import {
3
3
  Move,
4
4
  Play,
5
5
  Print
6
- } from "./chunk-XAJZK6Z2.mjs";
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/operation";
21
- var Handlers = OperationHandlerSet.lazy(() => import("./create-AJHN4QT4.mjs"), () => import("./move-T2NLRBR4.mjs"), () => import("./play-7VTMD3SJ.mjs"), () => import("./print-EW7LPW4D.mjs"));
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-JZMN24DY.mjs.map
28
+ //# sourceMappingURL=chunk-2DFOUJBD.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-2TJN26DN.mjs.map
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;;AAEb,IAAMC,OAAcC,cAAO;EAChCC,MAAaC,gBAAgBC,aAAM;EACnCC,SAAgBJ,cAAO;IACrBK,OAAcH,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;IAEFC,OAAcN,gBACLC,cAAOG,YAAY;MACxBC,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDS,KAAYR,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;EACvDU,KAAYT,cAAOG,YAAY;IAC7BC,aAAa;EACf,CAAA,EAAGE,KAAKb,oBAAoBc,IAAI,KAAA,GAAeR,eAAQ;AACzD,CAAA,EAAGO,KACDd,KAAKkB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAlB,gBAAgBa,IAAI;EAAC;CAAO,GAC5BjB,WAAWuB,eAAeN,IAAI;EAC5BO,MAAM;EACNC,KAAK;AACP,CAAA,CAAA;AAKK,IAAMC,OAAO,CAAC,EAAElB,MAAMU,KAAKC,IAAG,IAAoD,CAAC,MAAC;AACzF,QAAMQ,QAAQ,IAAI7B,QAAAA;AAClB,MAAIoB,KAAK;AACP,QAAI;AACFS,YAAMC,QAAQV,GAAAA;IAChB,QAAQ;AACNb,UAAIwB,KAAKX,KAAAA,QAAAA;;;;;;IACX;EACF;AAEA,SAAOjB,IAAIyB,KAAKpB,MAAM;IACpBE;IACAU;IACAC;IACAR,SAAS,CAAC;EACZ,CAAA;AACF;",
6
- "names": ["Chess", "ChessJS", "Schema", "Annotation", "Obj", "Type", "FormInputAnnotation", "LabelAnnotation", "log", "Game", "Struct", "name", "optional", "String", "players", "white", "annotations", "description", "black", "pipe", "set", "pgn", "fen", "object", "typename", "version", "IconAnnotation", "icon", "hue", "make", "chess", "loadPgn", "warn"]
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,11 +1,11 @@
1
1
  import {
2
2
  Chess_exports
3
- } from "./chunk-2TJN26DN.mjs";
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-XAJZK6Z2.mjs.map
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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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
+ }
@@ -4,7 +4,7 @@ import "../chunk-J5LGTIGS.mjs";
4
4
  import * as Effect from "effect/Effect";
5
5
  import { Plugin } from "@dxos/app-framework";
6
6
  import { AppPlugin } from "@dxos/app-toolkit";
7
- import { Operation } from "@dxos/operation";
7
+ import { Operation } from "@dxos/compute";
8
8
  import { SpaceOperation } from "@dxos/plugin-space/operations";
9
9
  import { meta } from "#meta";
10
10
  import { Chess } from "#types";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/plugin.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/operation';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n// TODO(wittjosiah): Factor out shared modules.\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n createObject: ((props, options) =>\n Effect.gen(function* () {\n const object = Chess.make(props);\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: options.target,\n hidden: true,\n targetNodeId: options.targetNodeId,\n });\n })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n Plugin.make,\n);\n"],
5
- "mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;AAG/B,SAASC,YAAY;AACrB,SAASC,aAAa;AAGf,IAAMC,cAAcC,OAAOC,OAAOC,IAAAA,EAAMC,KAC7CC,UAAUC,kBAAkB;EAC1BC,UAAU;IACRC,IAAIC,MAAMC,KAAKC;IACfJ,UAAU;MACRK,cAAe,CAACC,OAAOC,YACdC,WAAI,aAAA;AACT,cAAMC,SAASP,MAAMQ,KAAKJ,KAAAA;AAC1B,eAAO,OAAOK,UAAUC,OAAOC,eAAeC,WAAW;UACvDL;UACAM,QAAQR,QAAQQ;UAChBC,QAAQ;UACRC,cAAcV,QAAQU;QACxB,CAAA;MACF,CAAA;IACJ;EACF;AACF,CAAA,GACAnB,UAAUoB,gBAAgB;EAAEC,QAAQ;IAACjB,MAAMC;;AAAM,CAAA,GACjDT,OAAOgB,IAAI;",
6
- "names": ["Effect", "Plugin", "AppPlugin", "Operation", "SpaceOperation", "meta", "Chess", "ChessPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addMetadataModule", "metadata", "id", "Chess", "Game", "typename", "createObject", "props", "options", "gen", "object", "make", "Operation", "invoke", "SpaceOperation", "AddObject", "target", "hidden", "targetNodeId", "addSchemaModule", "schema"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/compute';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n// TODO(wittjosiah): Factor out shared modules.\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n createObject: ((props, options) =>\n Effect.gen(function* () {\n const object = Chess.make(props);\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: options.target,\n hidden: true,\n targetNodeId: options.targetNodeId,\n });\n })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n Plugin.make,\n);\n"],
5
+ "mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;AAG/B,SAASC,YAAY;AACrB,SAASC,aAAa;AAGf,IAAMC,cAAcN,OAAOO,OAAOH,IAAAA,EAAMI,KAC7CP,UAAUQ,kBAAkB;EAC1BC,UAAU;IACRC,IAAIN,MAAMO,KAAKC;IACfH,UAAU;MACRI,cAAe,CAACC,OAAOC,YACdC,WAAI,aAAA;AACT,cAAMC,SAASb,MAAMc,KAAKJ,KAAAA;AAC1B,eAAO,OAAOb,UAAUkB,OAAOjB,eAAekB,WAAW;UACvDH;UACAI,QAAQN,QAAQM;UAChBC,QAAQ;UACRC,cAAcR,QAAQQ;QACxB,CAAA;MACF,CAAA;IACJ;EACF;AACF,CAAA,GACAvB,UAAUwB,gBAAgB;EAAEC,QAAQ;IAACrB,MAAMO;;AAAM,CAAA,GACjDZ,OAAOmB,IAAI;",
6
+ "names": ["Effect", "Plugin", "AppPlugin", "Operation", "SpaceOperation", "meta", "Chess", "ChessPlugin", "define", "pipe", "addMetadataModule", "metadata", "id", "Game", "typename", "createObject", "props", "options", "gen", "object", "make", "invoke", "AddObject", "target", "hidden", "targetNodeId", "addSchemaModule", "schema"]
7
7
  }
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  Create
3
- } from "./chunk-XAJZK6Z2.mjs";
3
+ } from "./chunk-OBKYFOJA.mjs";
4
4
  import {
5
5
  Chess_exports
6
- } from "./chunk-2TJN26DN.mjs";
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-AJHN4QT4.mjs.map
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,13 +1,3 @@
1
- import {
2
- chess_blueprint_default
3
- } from "./chunk-MC7L6JNC.mjs";
4
- import {
5
- operations_exports
6
- } from "./chunk-JZMN24DY.mjs";
7
- import "./chunk-XAJZK6Z2.mjs";
8
- import {
9
- Chess_exports
10
- } from "./chunk-2TJN26DN.mjs";
11
1
  import "./chunk-J5LGTIGS.mjs";
12
2
 
13
3
  // src/components/Chessboard/Chessboard.tsx
@@ -50,7 +40,7 @@ var Info = ({ classNames, orientation = "white", onOrientationChange, onClose, .
50
40
  }, /* @__PURE__ */ React.createElement(PlayerSelector, {
51
41
  value: model.object.players?.[orientation === "white" ? "black" : "white"],
52
42
  onValueChange: (value) => {
53
- Obj.change(model.object, (obj) => {
43
+ Obj.update(model.object, (obj) => {
54
44
  obj.players[orientation === "white" ? "black" : "white"] = value;
55
45
  });
56
46
  },
@@ -72,7 +62,7 @@ var Info = ({ classNames, orientation = "white", onOrientationChange, onClose, .
72
62
  }, /* @__PURE__ */ React.createElement(PlayerSelector, {
73
63
  value: model.object.players?.[orientation],
74
64
  onValueChange: (value) => {
75
- Obj.change(model.object, (obj) => {
65
+ Obj.update(model.object, (obj) => {
76
66
  obj.players[orientation] = value;
77
67
  });
78
68
  },
@@ -303,63 +293,29 @@ import * as Effect from "effect/Effect";
303
293
  import * as Option from "effect/Option";
304
294
  import { Plugin } from "@dxos/app-framework";
305
295
  import { AppPlugin } from "@dxos/app-toolkit";
296
+ import { Operation } from "@dxos/compute";
306
297
  import { Annotation } from "@dxos/echo";
307
- import { Operation } from "@dxos/operation";
308
298
  import { SpaceOperation } from "@dxos/plugin-space/operations";
309
299
  import { ChessBlueprint } from "#blueprints";
310
300
  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
301
  import { meta as meta3 } from "#meta";
302
+ import { translations } from "#translations";
316
303
  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({
304
+ var ChessPlugin = Plugin.define(meta3).pipe(AppPlugin.addBlueprintDefinitionModule({
349
305
  activate: BlueprintDefinition
350
306
  }), AppPlugin.addOperationHandlerModule({
351
307
  activate: OperationHandler
352
308
  }), AppPlugin.addMetadataModule({
353
309
  metadata: {
354
- id: Chess2.Game.typename,
310
+ id: Chess.Game.typename,
355
311
  metadata: {
356
- icon: Annotation.IconAnnotation.get(Chess2.Game).pipe(Option.getOrThrow).icon,
357
- iconHue: Annotation.IconAnnotation.get(Chess2.Game).pipe(Option.getOrThrow).hue ?? "white",
312
+ icon: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).icon,
313
+ iconHue: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).hue ?? "white",
358
314
  blueprints: [
359
315
  ChessBlueprint.key
360
316
  ],
361
317
  createObject: (props, options) => Effect.gen(function* () {
362
- const object = Chess2.make(props);
318
+ const object = Chess.make(props);
363
319
  return yield* Operation.invoke(SpaceOperation.AddObject, {
364
320
  object,
365
321
  target: options.target,
@@ -371,7 +327,7 @@ var ChessPlugin = Plugin.define(meta4).pipe(AppPlugin.addBlueprintDefinitionModu
371
327
  }
372
328
  }), AppPlugin.addSchemaModule({
373
329
  schema: [
374
- Chess2.Game
330
+ Chess.Game
375
331
  ]
376
332
  }), AppPlugin.addSurfaceModule({
377
333
  activate: ReactSurface
@@ -379,9 +335,6 @@ var ChessPlugin = Plugin.define(meta4).pipe(AppPlugin.addBlueprintDefinitionModu
379
335
  translations
380
336
  }), Plugin.make);
381
337
  export {
382
- Chess_exports as Chess,
383
- chess_blueprint_default as ChessBlueprint,
384
- operations_exports as ChessFunctions,
385
338
  ChessPlugin,
386
339
  Chessboard,
387
340
  meta2 as meta
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/Chessboard/Chessboard.tsx", "../../../src/components/Chessboard/Info.tsx", "../../../src/components/Chessboard/types.ts", "../../../src/meta.ts", "../../../src/ChessPlugin.tsx", "../../../src/translations.ts"],
4
- "sourcesContent": ["//\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 useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { useObject } from '@dxos/echo-react';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\nimport { useSoundEffect } from '@dxos/react-ui-sfx';\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 game: Chess.Game;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(game, '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 return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {children}\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 const registry = useContext(RegistryContext);\n const { model } = useGameboardContext<ChessModel>(BOARD_NAME);\n\n // Keyboard navigation.\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n // Participate in keyboard navigation (set tabIndex={0})\n ref.current.setAttribute('data-arrow-keys', 'all');\n\n return addEventListener(ref.current, 'keydown', (ev) => {\n const moveIndex = registry.get(model.moveIndex);\n switch (ev.key) {\n case 'ArrowUp':\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (moveIndex > 0) {\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n });\n }, [registry, model]);\n\n return <NaturalChessboard {...props} ref={ref} />;\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 RootProps as ChessboardRootProps,\n ContentProps as ChessboardContentProps,\n BoardProps as ChessboardBoardProps,\n InfoProps as ChessboardInfoProps,\n};\n", "//\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 { generateName } from '@dxos/display-name';\nimport { Obj } from '@dxos/echo';\nimport { type SpaceMember, useMembers } from '@dxos/react-client/echo';\nimport { Icon, IconButton, Select, 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.id);\n const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);\n const db = Obj.getDatabase(model.object);\n const members = useMembers(db?.spaceId);\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 bg-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 <PlayerSelector\n value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}\n onValueChange={(value) => {\n Obj.change(model.object, (obj) => {\n obj.players![orientation === 'white' ? 'black' : 'white'] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\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 <PlayerSelector\n value={model.object.players?.[orientation]}\n onValueChange={(value) => {\n Obj.change(model.object, (obj) => {\n obj.players![orientation] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\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.id);\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 className={mx('overflow-y-auto', 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-[2rem_1fr_2rem] 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//\n// PlayerSelector\n//\n\ntype PlayerSelectorProps = {\n value?: string;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n};\n\nconst PlayerSelector = ({ value, onValueChange, members }: PlayerSelectorProps) => {\n const { t } = useTranslation(meta.id);\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={t('select-player.button')} />\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.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Registry } from '@effect-atom/atom-react';\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.Game,\n ) {\n super(registry);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.chess',\n name: 'Chess',\n description: trim`\n Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.\n Track game history and analyze moves in real-time.\n `,\n icon: 'ph--shield-chevron--regular',\n iconHue: 'amber',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',\n screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Annotation } from '@dxos/echo';\nimport { Operation } from '@dxos/operation';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { ChessBlueprint } from '#blueprints';\nimport { BlueprintDefinition, OperationHandler, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nimport { translations } from './translations';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n icon: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).icon,\n iconHue: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).hue ?? 'white',\n blueprints: [ChessBlueprint.key],\n createObject: ((props, options) =>\n Effect.gen(function* () {\n const object = Chess.make(props);\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: options.target,\n hidden: true,\n targetNodeId: options.targetNodeId,\n });\n })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\nexport const translations = [\n {\n 'en-US': {\n [Chess.Game.typename]: {\n 'typename.label': 'Game',\n 'typename.label_zero': 'Games',\n 'typename.label_one': 'Game',\n 'typename.label_other': 'Games',\n 'object-name.placeholder': 'New game',\n 'add-object.label': 'Add game',\n 'rename-object.label': 'Rename game',\n 'delete-object.label': 'Delete game',\n 'object-deleted.label': 'Game deleted',\n },\n [meta.id]: {\n 'plugin.name': 'Chess',\n 'delete-game.label': 'Delete',\n 'game.checkmate.label': 'Checkmate',\n 'game.stalemate.label': 'Stalemate',\n 'game.draw.label': 'Draw',\n 'game.check.label': 'Check',\n 'select-player.button': 'Select player',\n 'toggle-info.button': 'Toggle info',\n 'close-info.button': 'Close info',\n 'flip-board.button': 'Flip board',\n },\n },\n },\n] as const satisfies Resource[];\n"],
5
- "mappings": ";;;;;;;;;;;;;AAIA,SAASA,uBAAuB;AAChC,OAAOC,UAELC,YACAC,aACAC,YACAC,aAAAA,YACAC,qBACAC,WAAAA,UACAC,UAAAA,eACK;AAEP,SAASC,wBAAwB;AACjC,SAASC,iBAAiB;AAE1B,SAEEC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;AACP,SAASC,sBAAsB;;;ACxB/B,SAASC,oBAAoB;AAC7B,OAAOC,SAA2CC,WAAWC,SAASC,cAAc;AAEpF,SAASC,oBAAoB;AAC7B,SAASC,WAAW;AACpB,SAA2BC,kBAAkB;AAC7C,SAASC,MAAMC,YAAYC,QAA8BC,sBAAsB;AAC/E,SAAsBC,2BAA2B;AACjD,SAASC,UAAU;AAEnB,SAASC,YAAY;AAIrB,IAAMC,YAAY;AAUX,IAAMC,OAAO,CAAC,EAAEC,YAAYC,cAAc,SAASC,qBAAqBC,SAAS,GAAGC,MAAAA,MAAkB;AAC3G,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAM,EAAEC,MAAK,IAAKC,oBAAwCZ,SAAAA;AAC1D,QAAMa,KAAKC,IAAIC,YAAYJ,MAAMK,MAAM;AACvC,QAAMC,UAAUC,WAAWL,IAAIM,OAAAA;AAE/B,SACE,sBAAA,cAACC,OAAAA;IACCC,WAAWC,GACT,qHACApB,UAAAA;KAGF,sBAAA,cAACqB,iBAAAA;IACCZ;IACAa,QAAQrB,gBAAgB,UAAU,UAAU;IAC5CsB,MACEpB,WACE,sBAAA,cAACqB,YAAAA;MACCC,SAAQ;MACRF,MAAK;MACLG,UAAAA;MACAC,OAAOtB,EAAE,mBAAA;MACTuB,MAAM;MACNC,SAAS1B;;KAKf,sBAAA,cAAC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O;MAClFC,YAAY;QAACC,eAAeC;;MAC5BC,cAAe,CAACC,OAAOC,YACdC,WAAI,aAAA;AACT,cAAMC,SAASjB,OAAMkB,KAAKJ,KAAAA;AAC1B,eAAO,OAAOK,UAAUC,OAAOC,eAAeC,WAAW;UACvDL;UACAM,QAAQR,QAAQQ;UAChBC,QAAQ;UACRC,cAAcV,QAAQU;QACxB,CAAA;MACF,CAAA;IACJ;EACF;AACF,CAAA,GACAlC,UAAUmC,gBAAgB;EAAEC,QAAQ;IAAC3B,OAAMC;;AAAM,CAAA,GACjDV,UAAUqC,iBAAiB;EAAEnC,UAAUoC;AAAa,CAAA,GACpDtC,UAAUuC,sBAAsB;EAAEC;AAAa,CAAA,GAC/C5C,OAAO+B,IAAI;",
6
- "names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "useObject", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useSoundEffect", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "generateName", "Obj", "useMembers", "Icon", "IconButton", "Select", "useTranslation", "useGameboardContext", "mx", "meta", "INFO_NAME", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "useTranslation", "meta", "id", "model", "useGameboardContext", "db", "Obj", "getDatabase", "object", "members", "useMembers", "spaceId", "div", "className", "mx", "PlayerIndicator", "player", "icon", "IconButton", "variant", "iconOnly", "label", "size", "onClick", "PlayerSelector", "value", "players", "onValueChange", "change", "obj", "History", "displayName", "min", "max", "onSelect", "moveIndex", "useAtomValue", "game", "isGameOver", "isCheckmate", "isStalemate", "isCheck", "undefined", "history", "moves", "useMemo", "reduce", "acc", "move", "index", "push", "length", "scrollerRef", "useRef", "useEffect", "current", "scrollTo", "top", "scrollHeight", "querySelector", "classList", "add", "scrollIntoView", "behavior", "remove", "ref", "style", "minHeight", "maxHeight", "map", "a", "b", "key", "data-index", "children", "turn", "Icon", "Select", "Root", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "member", "memberKey", "identity", "identityKey", "toHex", "profile", "generateName", "Option", "Arrow", "ChessModel", "ExtendedChessModel", "ChessModel", "registry", "object", "Root", "forwardRef", "game", "children", "forwardedRef", "registry", "useContext", "RegistryContext", "model", "useMemo", "ExtendedChessModel", "click", "useSoundEffect", "pgn", "updatePgn", "useObject", "useImperativeHandle", "setMoveNumber", "index", "setMoveIndex", "useEffect", "getRawPgn", "silent", "update", "play", "handleDrop", "useCallback", "move", "makeMove", "React", "Gameboard", "onDrop", "Content", "classNames", "grow", "contain", "BOARD_NAME", "Board", "props", "useGameboardContext", "ref", "useRef", "current", "setAttribute", "addEventListener", "ev", "moveIndex", "get", "key", "history", "length", "NaturalChessboard", "displayName", "Chessboard", "Info", "trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "screenshots", "Effect", "Option", "Plugin", "AppPlugin", "Annotation", "Operation", "SpaceOperation", "ChessBlueprint", "BlueprintDefinition", "OperationHandler", "ReactSurface", "meta", "Chess", "meta", "Chess", "translations", "Chess", "Game", "typename", "meta", "id", "ChessPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addBlueprintDefinitionModule", "activate", "BlueprintDefinition", "addOperationHandlerModule", "OperationHandler", "addMetadataModule", "metadata", "id", "Chess", "Game", "typename", "icon", "Annotation", "IconAnnotation", "get", "getOrThrow", "iconHue", "hue", "blueprints", "ChessBlueprint", "key", "createObject", "props", "options", "gen", "object", "make", "Operation", "invoke", "SpaceOperation", "AddObject", "target", "hidden", "targetNodeId", "addSchemaModule", "schema", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations"]
3
+ "sources": ["../../../src/components/Chessboard/Chessboard.tsx", "../../../src/components/Chessboard/Info.tsx", "../../../src/components/Chessboard/types.ts", "../../../src/meta.ts", "../../../src/ChessPlugin.tsx"],
4
+ "sourcesContent": ["//\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 useRef,\n} from 'react';\n\nimport { addEventListener } from '@dxos/async';\nimport { useObject } from '@dxos/echo-react';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\nimport { useSoundEffect } from '@dxos/react-ui-sfx';\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 game: Chess.Game;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ game, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, game), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(game, '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 return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {children}\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 const registry = useContext(RegistryContext);\n const { model } = useGameboardContext<ChessModel>(BOARD_NAME);\n\n // Keyboard navigation.\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n // Participate in keyboard navigation (set tabIndex={0})\n ref.current.setAttribute('data-arrow-keys', 'all');\n\n return addEventListener(ref.current, 'keydown', (ev) => {\n const moveIndex = registry.get(model.moveIndex);\n switch (ev.key) {\n case 'ArrowUp':\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (moveIndex > 0) {\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n });\n }, [registry, model]);\n\n return <NaturalChessboard {...props} ref={ref} />;\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 RootProps as ChessboardRootProps,\n ContentProps as ChessboardContentProps,\n BoardProps as ChessboardBoardProps,\n InfoProps as ChessboardInfoProps,\n};\n", "//\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 { generateName } from '@dxos/display-name';\nimport { Obj } from '@dxos/echo';\nimport { type SpaceMember, useMembers } from '@dxos/react-client/echo';\nimport { Icon, IconButton, Select, 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.id);\n const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);\n const db = Obj.getDatabase(model.object);\n const members = useMembers(db?.spaceId);\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 bg-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 <PlayerSelector\n value={model.object.players?.[orientation === 'white' ? 'black' : 'white']}\n onValueChange={(value) => {\n Obj.update(model.object, (obj) => {\n obj.players![orientation === 'white' ? 'black' : 'white'] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\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 <PlayerSelector\n value={model.object.players?.[orientation]}\n onValueChange={(value) => {\n Obj.update(model.object, (obj) => {\n obj.players![orientation] = value;\n });\n }}\n members={members}\n />\n </PlayerIndicator>\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.id);\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 className={mx('overflow-y-auto', 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-[2rem_1fr_2rem] 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//\n// PlayerSelector\n//\n\ntype PlayerSelectorProps = {\n value?: string;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n};\n\nconst PlayerSelector = ({ value, onValueChange, members }: PlayerSelectorProps) => {\n const { t } = useTranslation(meta.id);\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={t('select-player.button')} />\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.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Registry } from '@effect-atom/atom-react';\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.Game,\n ) {\n super(registry);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.chess',\n name: 'Chess',\n description: trim`\n Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.\n Track game history and analyze moves in real-time.\n `,\n icon: 'ph--shield-chevron--regular',\n iconHue: 'amber',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',\n screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/compute';\nimport { Annotation } from '@dxos/echo';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\nimport { type CreateObject } from '@dxos/plugin-space/types';\n\nimport { ChessBlueprint } from '#blueprints';\nimport { BlueprintDefinition, OperationHandler, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Chess } from '#types';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addMetadataModule({\n metadata: {\n id: Chess.Game.typename,\n metadata: {\n icon: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).icon,\n iconHue: Annotation.IconAnnotation.get(Chess.Game).pipe(Option.getOrThrow).hue ?? 'white',\n blueprints: [ChessBlueprint.key],\n createObject: ((props, options) =>\n Effect.gen(function* () {\n const object = Chess.make(props);\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: options.target,\n hidden: true,\n targetNodeId: options.targetNodeId,\n });\n })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.Game] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n"],
5
+ "mappings": ";;;AAIA,SAASA,uBAAuB;AAChC,OAAOC,UAELC,YACAC,aACAC,YACAC,aAAAA,YACAC,qBACAC,WAAAA,UACAC,UAAAA,eACK;AAEP,SAASC,wBAAwB;AACjC,SAASC,iBAAiB;AAE1B,SAEEC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;AACP,SAASC,sBAAsB;;;ACxB/B,SAASC,oBAAoB;AAC7B,OAAOC,SAA2CC,WAAWC,SAASC,cAAc;AAEpF,SAASC,oBAAoB;AAC7B,SAASC,WAAW;AACpB,SAA2BC,kBAAkB;AAC7C,SAASC,MAAMC,YAAYC,QAA8BC,sBAAsB;AAC/E,SAAsBC,2BAA2B;AACjD,SAASC,UAAU;AAEnB,SAASC,YAAY;AAIrB,IAAMC,YAAY;AAUX,IAAMC,OAAO,CAAC,EAAEC,YAAYC,cAAc,SAASC,qBAAqBC,SAAS,GAAGC,MAAAA,MAAkB;AAC3G,QAAM,EAAEC,EAAC,IAAKX,eAAeG,KAAKS,EAAE;AACpC,QAAM,EAAEC,MAAK,IAAKZ,oBAAwCG,SAAAA;AAC1D,QAAMU,KAAKnB,IAAIoB,YAAYF,MAAMG,MAAM;AACvC,QAAMC,UAAUrB,WAAWkB,IAAII,OAAAA;AAE/B,SACE,sBAAA,cAACC,OAAAA;IACCC,WAAWlB,GACT,qHACAI,UAAAA;KAGF,sBAAA,cAACe,iBAAAA;IACCR;IACAS,QAAQf,gBAAgB,UAAU,UAAU;IAC5CgB,MACEd,WACE,sBAAA,cAACX,YAAAA;MACC0B,SAAQ;MACRD,MAAK;MACLE,UAAAA;MACAC,OAAOf,EAAE,mBAAA;MACTgB,MAAM;MACNC,SAASnB;;KAKf,sB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Aa,CAAA,GAC/CV,OAAOoC,IAAI;",
6
+ "names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "useObject", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useSoundEffect", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "generateName", "Obj", "useMembers", "Icon", "IconButton", "Select", "useTranslation", "useGameboardContext", "mx", "meta", "INFO_NAME", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "id", "model", "db", "getDatabase", "object", "members", "spaceId", "div", "className", "PlayerIndicator", "player", "icon", "variant", "iconOnly", "label", "size", "onClick", "PlayerSelector", "value", "players", "onValueChange", "update", "obj", "History", "displayName", "min", "max", "onSelect", "moveIndex", "game", "isGameOver", "isCheckmate", "isStalemate", "isCheck", "undefined", "history", "moves", "reduce", "acc", "move", "index", "push", "length", "scrollerRef", "current", "scrollTo", "top", "scrollHeight", "querySelector", "classList", "add", "scrollIntoView", "behavior", "remove", "ref", "style", "minHeight", "maxHeight", "map", "a", "b", "key", "data-index", "children", "turn", "Root", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "member", "memberKey", "identity", "identityKey", "toHex", "profile", "Option", "Arrow", "ChessModel", "ExtendedChessModel", "registry", "object", "Root", "forwardRef", "game", "children", "forwardedRef", "registry", "useContext", "RegistryContext", "model", "useMemo", "ExtendedChessModel", "click", "useSoundEffect", "pgn", "updatePgn", "useObject", "useImperativeHandle", "setMoveNumber", "index", "setMoveIndex", "useEffect", "getRawPgn", "silent", "update", "play", "handleDrop", "useCallback", "move", "makeMove", "React", "Gameboard", "onDrop", "Content", "classNames", "grow", "contain", "BOARD_NAME", "Board", "props", "useGameboardContext", "ref", "useRef", "current", "setAttribute", "addEventListener", "ev", "moveIndex", "get", "key", "history", "length", "NaturalChessboard", "displayName", "Chessboard", "Info", "trim", "meta", "id", "name", "description", "icon", "iconHue", "source", "screenshots", "Effect", "Option", "Plugin", "AppPlugin", "Operation", "Annotation", "SpaceOperation", "ChessBlueprint", "BlueprintDefinition", "OperationHandler", "ReactSurface", "meta", "translations", "Chess", "ChessPlugin", "define", "pipe", "addBlueprintDefinitionModule", "activate", "addOperationHandlerModule", "addMetadataModule", "metadata", "id", "Game", "typename", "icon", "IconAnnotation", "get", "getOrThrow", "iconHue", "hue", "blueprints", "key", "createObject", "props", "options", "gen", "object", "make", "invoke", "AddObject", "target", "hidden", "targetNodeId", "addSchemaModule", "schema", "addSurfaceModule", "addTranslationsModule"]
7
7
  }