@dxos/plugin-chess 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a

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 (90) hide show
  1. package/dist/lib/neutral/{ChessCard-4TUTIFB6.mjs → ChessCard-VJ3I6MIB.mjs} +8 -3
  2. package/dist/lib/neutral/ChessCard-VJ3I6MIB.mjs.map +7 -0
  3. package/dist/lib/neutral/ChessPlugin.mjs +1 -1
  4. package/dist/lib/neutral/ChessPlugin.node.mjs +3 -3
  5. package/dist/lib/neutral/ChessPlugin.node.mjs.map +3 -3
  6. package/dist/lib/neutral/capabilities/index.mjs +3 -3
  7. package/dist/lib/neutral/capabilities/index.mjs.map +3 -3
  8. package/dist/lib/neutral/{chunk-ZSC5H6M4.mjs → chunk-AMXVX7V2.mjs} +2 -2
  9. package/dist/lib/neutral/{chunk-S66CCWNQ.mjs → chunk-DXIET5G2.mjs} +11 -11
  10. package/dist/lib/neutral/chunk-DXIET5G2.mjs.map +7 -0
  11. package/dist/lib/neutral/{chunk-IQCSIZXM.mjs → chunk-EXZ3XFEG.mjs} +5 -5
  12. package/dist/lib/neutral/chunk-EXZ3XFEG.mjs.map +7 -0
  13. package/dist/lib/neutral/{chunk-3WMTSPOZ.mjs → chunk-IKWULCKX.mjs} +10 -10
  14. package/dist/lib/neutral/chunk-IKWULCKX.mjs.map +7 -0
  15. package/dist/lib/neutral/components/index.mjs +45 -44
  16. package/dist/lib/neutral/components/index.mjs.map +3 -3
  17. package/dist/lib/neutral/containers/index.mjs +1 -1
  18. package/dist/lib/neutral/index.mjs +4 -4
  19. package/dist/lib/neutral/meta.json +1 -1
  20. package/dist/lib/neutral/{move-6W6APHVW.mjs → move-UMDTQST4.mjs} +2 -2
  21. package/dist/lib/neutral/operations/index.mjs +1 -1
  22. package/dist/lib/neutral/{play-T5TY3ZWY.mjs → play-7XTJZ4N6.mjs} +2 -2
  23. package/dist/lib/neutral/plugin.mjs +1 -1
  24. package/dist/lib/neutral/{print-5KYMJ2SU.mjs → print-JR4VB3UX.mjs} +2 -2
  25. package/dist/lib/neutral/skill-definition-ZGQBUE4R.mjs +15 -0
  26. package/dist/lib/neutral/skill-definition-ZGQBUE4R.mjs.map +7 -0
  27. package/dist/lib/neutral/skills/index.mjs +8 -0
  28. package/dist/lib/neutral/testing.mjs +1 -1
  29. package/dist/lib/neutral/types/index.mjs +1 -1
  30. package/dist/types/src/capabilities/game-variant.d.ts +1 -2
  31. package/dist/types/src/capabilities/game-variant.d.ts.map +1 -1
  32. package/dist/types/src/capabilities/index.d.ts +1 -1
  33. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  34. package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
  35. package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
  36. package/dist/types/src/components/Chessboard/Chessboard.d.ts +1 -1
  37. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  38. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +2 -2
  39. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  40. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +2 -2
  41. package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -1
  42. package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -1
  43. package/dist/types/src/index.d.ts +1 -1
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/meta.d.ts +4 -0
  46. package/dist/types/src/meta.d.ts.map +1 -1
  47. package/dist/types/src/skills/chess-skill.d.ts +4 -0
  48. package/dist/types/src/skills/chess-skill.d.ts.map +1 -0
  49. package/dist/types/src/skills/index.d.ts +2 -0
  50. package/dist/types/src/skills/index.d.ts.map +1 -0
  51. package/dist/types/src/types/Chess.d.ts +8 -7
  52. package/dist/types/src/types/Chess.d.ts.map +1 -1
  53. package/dist/types/src/types/ChessOperation.d.ts +2 -8
  54. package/dist/types/src/types/ChessOperation.d.ts.map +1 -1
  55. package/dist/types/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +38 -38
  57. package/src/ChessPlugin.node.ts +2 -2
  58. package/src/ChessPlugin.test.ts +1 -1
  59. package/src/ChessPlugin.tsx +3 -3
  60. package/src/capabilities/index.ts +1 -1
  61. package/src/capabilities/skill-definition.ts +14 -0
  62. package/src/components/Chessboard/Chessboard.stories.tsx +2 -2
  63. package/src/components/Chessboard/Chessboard.tsx +47 -45
  64. package/src/components/Chessboard/Info.tsx +3 -1
  65. package/src/containers/ChessArticle/ChessArticle.stories.tsx +2 -2
  66. package/src/containers/ChessCard/ChessCard.tsx +12 -5
  67. package/src/index.ts +1 -1
  68. package/src/{blueprints/chess-blueprint.ts → skills/chess-skill.ts} +7 -7
  69. package/src/skills/index.ts +5 -0
  70. package/src/types/Chess.ts +20 -21
  71. package/dist/lib/neutral/ChessCard-4TUTIFB6.mjs.map +0 -7
  72. package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs +0 -15
  73. package/dist/lib/neutral/blueprint-definition-4MOWVVWD.mjs.map +0 -7
  74. package/dist/lib/neutral/blueprints/index.mjs +0 -8
  75. package/dist/lib/neutral/chunk-3WMTSPOZ.mjs.map +0 -7
  76. package/dist/lib/neutral/chunk-IQCSIZXM.mjs.map +0 -7
  77. package/dist/lib/neutral/chunk-S66CCWNQ.mjs.map +0 -7
  78. package/dist/types/src/blueprints/chess-blueprint.d.ts +0 -4
  79. package/dist/types/src/blueprints/chess-blueprint.d.ts.map +0 -1
  80. package/dist/types/src/blueprints/index.d.ts +0 -2
  81. package/dist/types/src/blueprints/index.d.ts.map +0 -1
  82. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -6
  83. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  84. package/src/blueprints/index.ts +0 -5
  85. package/src/capabilities/blueprint-definition.ts +0 -19
  86. /package/dist/lib/neutral/{chunk-ZSC5H6M4.mjs.map → chunk-AMXVX7V2.mjs.map} +0 -0
  87. /package/dist/lib/neutral/{move-6W6APHVW.mjs.map → move-UMDTQST4.mjs.map} +0 -0
  88. /package/dist/lib/neutral/{play-T5TY3ZWY.mjs.map → play-7XTJZ4N6.mjs.map} +0 -0
  89. /package/dist/lib/neutral/{print-5KYMJ2SU.mjs.map → print-JR4VB3UX.mjs.map} +0 -0
  90. /package/dist/lib/neutral/{blueprints → skills}/index.mjs.map +0 -0
@@ -3,17 +3,22 @@ import "./chunk-J5LGTIGS.mjs";
3
3
  // src/containers/ChessCard/ChessCard.tsx
4
4
  import React from "react";
5
5
  import { Obj } from "@dxos/echo";
6
+ import { Card } from "@dxos/react-ui";
6
7
  import { Chessboard } from "#components";
7
8
  import { Chess } from "#types";
8
9
  var ChessCard = ({ variant }) => {
9
10
  if (!Obj.instanceOf(Chess.State, variant)) {
10
11
  return null;
11
12
  }
12
- return /* @__PURE__ */ React.createElement(Chessboard.Root, {
13
+ return /* @__PURE__ */ React.createElement(Card.Body, null, /* @__PURE__ */ React.createElement(Card.Section, {
14
+ classNames: "aspect-square"
15
+ }, /* @__PURE__ */ React.createElement(Card.Row, {
16
+ fullWidth: true
17
+ }, /* @__PURE__ */ React.createElement(Chessboard.Root, {
13
18
  state: variant
14
- }, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, null)));
19
+ }, /* @__PURE__ */ React.createElement(Chessboard.Content, null, /* @__PURE__ */ React.createElement(Chessboard.Board, null))))));
15
20
  };
16
21
  export {
17
22
  ChessCard as default
18
23
  };
19
- //# sourceMappingURL=ChessCard-4TUTIFB6.mjs.map
24
+ //# sourceMappingURL=ChessCard-VJ3I6MIB.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/containers/ChessCard/ChessCard.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { type GameVariantSurfaceProps } from '@dxos/plugin-game/types';\nimport { Card } from '@dxos/react-ui';\n\nimport { Chessboard } from '#components';\nimport { Chess } from '#types';\n\nexport type ChessCardProps = GameVariantSurfaceProps;\n\nexport const ChessCard = ({ variant }: ChessCardProps) => {\n if (!Obj.instanceOf(Chess.State, variant)) {\n return null;\n }\n\n return (\n <Card.Body>\n <Card.Section classNames='aspect-square'>\n <Card.Row fullWidth>\n <Chessboard.Root state={variant}>\n <Chessboard.Content>\n <Chessboard.Board />\n </Chessboard.Content>\n </Chessboard.Root>\n </Card.Row>\n </Card.Section>\n </Card.Body>\n );\n};\n"],
5
+ "mappings": ";;;AAIA,OAAOA,WAAW;AAElB,SAASC,WAAW;AAEpB,SAASC,YAAY;AAErB,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AAIf,IAAMC,YAAY,CAAC,EAAEC,QAAO,MAAkB;AACnD,MAAI,CAACL,IAAIM,WAAWH,MAAMI,OAAOF,OAAAA,GAAU;AACzC,WAAO;EACT;AAEA,SACE,sBAAA,cAACJ,KAAKO,MAAI,MACR,sBAAA,cAACP,KAAKQ,SAAO;IAACC,YAAW;KACvB,sBAAA,cAACT,KAAKU,KAAG;IAACC,WAAAA;KACR,sBAAA,cAACV,WAAWW,MAAI;IAACC,OAAOT;KACtB,sBAAA,cAACH,WAAWa,SAAO,MACjB,sBAAA,cAACb,WAAWc,OAAK,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAO/B;",
6
+ "names": ["React", "Obj", "Card", "Chessboard", "Chess", "ChessCard", "variant", "instanceOf", "State", "Body", "Section", "classNames", "Row", "fullWidth", "Root", "state", "Content", "Board"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ChessPlugin,
3
3
  ChessPlugin_default
4
- } from "./chunk-IQCSIZXM.mjs";
4
+ } from "./chunk-EXZ3XFEG.mjs";
5
5
  import "./chunk-J5LGTIGS.mjs";
6
6
  export {
7
7
  ChessPlugin,
@@ -3,15 +3,15 @@ import "./chunk-J5LGTIGS.mjs";
3
3
  // src/ChessPlugin.node.ts
4
4
  import { Plugin } from "@dxos/app-framework";
5
5
  import { AppPlugin } from "@dxos/app-toolkit";
6
- import { BlueprintDefinition, OperationHandler } from "#capabilities";
6
+ import { OperationHandler, SkillDefinition } from "#capabilities";
7
7
  import { meta } from "#meta";
8
8
  import { Chess } from "#types";
9
9
  var ChessPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
10
10
  schema: [
11
11
  Chess.State
12
12
  ]
13
- }), AppPlugin.addBlueprintDefinitionModule({
14
- activate: BlueprintDefinition
13
+ }), AppPlugin.addSkillDefinitionModule({
14
+ activate: SkillDefinition
15
15
  }), AppPlugin.addOperationHandlerModule({
16
16
  activate: OperationHandler
17
17
  }), Plugin.make);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/ChessPlugin.node.ts"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { BlueprintDefinition, OperationHandler } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n/**\n * Headless variant of ChessPlugin (no React surfaces / GameVariant).\n * Used in node contexts (CLI, agents) where rendering is unavailable.\n */\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addBlueprintDefinitionModule({ activate: BlueprintDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
5
- "mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,qBAAqBC,wBAAwB;AACtD,SAASC,YAAY;AACrB,SAASC,aAAa;AAMf,IAAMC,cAAcN,OAAOO,OAAOH,IAAAA,EAAMI,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL,MAAMM;;AAAO,CAAA,GAClDV,UAAUW,6BAA6B;EAAEC,UAAUX;AAAoB,CAAA,GACvED,UAAUa,0BAA0B;EAAED,UAAUV;AAAiB,CAAA,GACjEH,OAAOe,IAAI;AAGb,IAAA,2BAAeT;",
6
- "names": ["Plugin", "AppPlugin", "BlueprintDefinition", "OperationHandler", "meta", "Chess", "ChessPlugin", "define", "pipe", "addSchemaModule", "schema", "State", "addBlueprintDefinitionModule", "activate", "addOperationHandlerModule", "make"]
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { OperationHandler, SkillDefinition } from '#capabilities';\nimport { meta } from '#meta';\nimport { Chess } from '#types';\n\n/**\n * Headless variant of ChessPlugin (no React surfaces / GameVariant).\n * Used in node contexts (CLI, agents) where rendering is unavailable.\n */\nexport const ChessPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addSkillDefinitionModule({ activate: SkillDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n"],
5
+ "mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,kBAAkBC,uBAAuB;AAClD,SAASC,YAAY;AACrB,SAASC,aAAa;AAMf,IAAMC,cAAcN,OAAOO,OAAOH,IAAAA,EAAMI,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL,MAAMM;;AAAO,CAAA,GAClDV,UAAUW,yBAAyB;EAAEC,UAAUV;AAAgB,CAAA,GAC/DF,UAAUa,0BAA0B;EAAED,UAAUX;AAAiB,CAAA,GACjEF,OAAOe,IAAI;AAGb,IAAA,2BAAeT;",
6
+ "names": ["Plugin", "AppPlugin", "OperationHandler", "SkillDefinition", "meta", "Chess", "ChessPlugin", "define", "pipe", "addSchemaModule", "schema", "State", "addSkillDefinitionModule", "activate", "addOperationHandlerModule", "make"]
7
7
  }
@@ -2,12 +2,12 @@ import "../chunk-J5LGTIGS.mjs";
2
2
 
3
3
  // src/capabilities/index.ts
4
4
  import { Capability } from "@dxos/app-framework";
5
- var BlueprintDefinition = Capability.lazy("BlueprintDefinition", () => import("../blueprint-definition-4MOWVVWD.mjs"));
5
+ var SkillDefinition = Capability.lazy("SkillDefinition", () => import("../skill-definition-ZGQBUE4R.mjs"));
6
6
  var GameVariant = Capability.lazy("GameVariant", () => import("../game-variant-ZLPEN2QK.mjs"));
7
7
  var OperationHandler = Capability.lazy("OperationHandler", () => import("../operation-handler-EKZKFQUG.mjs"));
8
8
  export {
9
- BlueprintDefinition,
10
9
  GameVariant,
11
- OperationHandler
10
+ OperationHandler,
11
+ SkillDefinition
12
12
  };
13
13
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/capabilities/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\nimport type { OperationHandlerSet } from '@dxos/compute';\n\nexport const BlueprintDefinition = Capability.lazy('BlueprintDefinition', () => import('./blueprint-definition'));\nexport const GameVariant = Capability.lazy('GameVariant', () => import('./game-variant'));\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\n"],
5
- "mappings": ";;;AAIA,SAASA,kBAAkB;AAGpB,IAAMC,sBAAsBD,WAAWE,KAAK,uBAAuB,MAAM,OAAO,sCAAA,CAAA;AAChF,IAAMC,cAAcH,WAAWE,KAAK,eAAe,MAAM,OAAO,8BAAA,CAAA;AAChE,IAAME,mBAAmBJ,WAAWE,KACzC,oBACA,MAAM,OAAO,mCAAA,CAAA;",
6
- "names": ["Capability", "BlueprintDefinition", "lazy", "GameVariant", "OperationHandler"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\nimport type { OperationHandlerSet } from '@dxos/compute';\n\nexport const SkillDefinition = Capability.lazy('SkillDefinition', () => import('./skill-definition'));\nexport const GameVariant = Capability.lazy('GameVariant', () => import('./game-variant'));\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\n"],
5
+ "mappings": ";;;AAIA,SAASA,kBAAkB;AAGpB,IAAMC,kBAAkBD,WAAWE,KAAK,mBAAmB,MAAM,OAAO,kCAAA,CAAA;AACxE,IAAMC,cAAcH,WAAWE,KAAK,eAAe,MAAM,OAAO,8BAAA,CAAA;AAChE,IAAME,mBAAmBJ,WAAWE,KACzC,oBACA,MAAM,OAAO,mCAAA,CAAA;",
6
+ "names": ["Capability", "SkillDefinition", "lazy", "GameVariant", "OperationHandler"]
7
7
  }
@@ -1,8 +1,8 @@
1
1
  // src/operations/index.ts
2
2
  import { OperationHandlerSet } from "@dxos/compute";
3
- var ChessOperationHandlerSet = OperationHandlerSet.lazy(() => import("./move-6W6APHVW.mjs"), () => import("./play-T5TY3ZWY.mjs"), () => import("./print-5KYMJ2SU.mjs"));
3
+ var ChessOperationHandlerSet = OperationHandlerSet.lazy(() => import("./move-UMDTQST4.mjs"), () => import("./play-7XTJZ4N6.mjs"), () => import("./print-JR4VB3UX.mjs"));
4
4
 
5
5
  export {
6
6
  ChessOperationHandlerSet
7
7
  };
8
- //# sourceMappingURL=chunk-ZSC5H6M4.mjs.map
8
+ //# sourceMappingURL=chunk-AMXVX7V2.mjs.map
@@ -5,19 +5,19 @@ import {
5
5
  // src/types/Chess.ts
6
6
  var Chess_exports = {};
7
7
  __export(Chess_exports, {
8
- BLUEPRINT_KEY: () => BLUEPRINT_KEY,
8
+ SKILL_KEY: () => SKILL_KEY,
9
9
  State: () => State,
10
10
  make: () => make
11
11
  });
12
12
  import { Chess as ChessJS } from "chess.js";
13
13
  import * as Schema from "effect/Schema";
14
14
  import { AppAnnotation } from "@dxos/app-toolkit";
15
- import { DXN, Annotation, Obj, Type } from "@dxos/echo";
15
+ import { Annotation, DXN, Obj, Type } from "@dxos/echo";
16
16
  import { FormInputAnnotation, HiddenAnnotation } from "@dxos/echo/Annotation";
17
17
  import { log } from "@dxos/log";
18
18
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/types/Chess.ts";
19
- var BLUEPRINT_KEY = "org.dxos.blueprint.chess";
20
- var State = Schema.Struct({
19
+ var SKILL_KEY = "org.dxos.skill.chess";
20
+ var State = class extends Type.makeObject(DXN.make("org.dxos.type.chess.state", "0.1.0"))(Schema.Struct({
21
21
  pgn: Schema.String.annotations({
22
22
  description: "Portable Game Notation."
23
23
  }).pipe(FormInputAnnotation.set(false), Schema.optional),
@@ -29,23 +29,23 @@ var State = Schema.Struct({
29
29
  icon: "ph--shield-chevron--regular",
30
30
  hue: "amber"
31
31
  }),
32
- AppAnnotation.BlueprintsAnnotation.set([
33
- BLUEPRINT_KEY
32
+ AppAnnotation.SkillsAnnotation.set([
33
+ SKILL_KEY
34
34
  ]),
35
35
  // Implementation detail of the unified `Game` schema. The user-facing object is `Game`;
36
36
  // this state is only ever referenced via `Game.variant`. HiddenAnnotation keeps it out of the
37
37
  // navtree's typed branches so an orphaned state object doesn't reappear after the
38
38
  // wrapping Game is deleted.
39
- HiddenAnnotation.set(true),
40
- Type.makeObject(DXN.make("org.dxos.type.chess.state", "0.1.0"))
41
- );
39
+ HiddenAnnotation.set(true)
40
+ )) {
41
+ };
42
42
  var make = ({ pgn, fen } = {}) => {
43
43
  const chess = new ChessJS();
44
44
  if (pgn) {
45
45
  try {
46
46
  chess.loadPgn(pgn);
47
47
  } catch {
48
- log.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 37, S: void 0 });
48
+ log.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 38, S: void 0 });
49
49
  }
50
50
  }
51
51
  return Obj.make(State, {
@@ -145,4 +145,4 @@ export {
145
145
  Chess_exports,
146
146
  ChessOperation_exports
147
147
  };
148
- //# sourceMappingURL=chunk-S66CCWNQ.mjs.map
148
+ //# sourceMappingURL=chunk-DXIET5G2.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types/Chess.ts", "../../../src/types/ChessOperation.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Chess as ChessJS } from 'chess.js';\nimport * as Schema from 'effect/Schema';\n\nimport { AppAnnotation } from '@dxos/app-toolkit';\nimport { Annotation, DXN, Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation, HiddenAnnotation } from '@dxos/echo/Annotation';\nimport { log } from '@dxos/log';\n\nexport const SKILL_KEY = 'org.dxos.skill.chess';\n\n/**\n * Chess variant state. Referenced by the base `Game` object via `Game.variant`.\n * Players, name, and other game-shared fields live on the base `Game`.\n */\nexport class State extends Type.makeObject<State>(DXN.make('org.dxos.type.chess.state', '0.1.0'))(\n Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'Portable Game Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n fen: Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }).pipe(FormInputAnnotation.set(false), Schema.optional),\n }).pipe(\n Annotation.IconAnnotation.set({ icon: 'ph--shield-chevron--regular', hue: 'amber' }),\n AppAnnotation.SkillsAnnotation.set([SKILL_KEY]),\n // Implementation detail of the unified `Game` schema. The user-facing object is `Game`;\n // this state is only ever referenced via `Game.variant`. HiddenAnnotation keeps it out of the\n // navtree's typed branches so an orphaned state object doesn't reappear after the\n // wrapping Game is deleted.\n HiddenAnnotation.set(true),\n ),\n) {}\n\nexport const make = ({ pgn, fen }: { pgn?: string; fen?: string } = {}): State => {\n const chess = new ChessJS();\n if (pgn) {\n try {\n chess.loadPgn(pgn);\n } catch {\n log.warn(pgn);\n }\n }\n\n return Obj.make(State, {\n pgn,\n fen,\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/compute';\nimport { Database, DXN } from '@dxos/echo';\nimport { GameRef } from '@dxos/plugin-game/types';\n\nimport * as Chess from './Chess';\n\nexport const Move = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.move'),\n name: 'Move',\n description: 'Makes a move in the given chess game.',\n icon: 'ph--play--regular',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Play = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.play'),\n name: 'Play',\n description: 'Uses the chess engine to play the next move.',\n icon: 'ph--play--regular',\n },\n input: Schema.Struct({\n game: GameRef(Chess.State).annotations({\n description: 'The ID of the game object (variant must be Chess).',\n }),\n side: Schema.optional(Schema.Literal('white', 'black', 'any')).annotations({\n description: 'The side to play.',\n defaultValue: 'any',\n }),\n }),\n output: Schema.Struct({\n pgn: Schema.String.annotations({\n description: 'The PGN of the game after the move was played.',\n }),\n move: Schema.optional(Schema.String).annotations({\n description: 'The move that was played.',\n }),\n }),\n services: [Database.Service],\n});\n\nexport const Print = Operation.make({\n meta: {\n key: DXN.make('org.dxos.function.chess.print'),\n name: 'Print game',\n description: 'Prints the chess game to ASCII.',\n icon: 'ph--clipboard-text--regular',\n },\n input: Schema.Struct({\n pgn: Schema.optional(\n Schema.String.annotations({\n description: 'Portable Game Notation.',\n }),\n ),\n fen: Schema.optional(\n Schema.String.annotations({\n description: 'Forsyth-Edwards Notation.',\n }),\n ),\n }),\n output: Schema.Struct({\n ascii: Schema.String,\n }),\n});\n"],
5
+ "mappings": ";;;;;AAAA;;;;;;AAIA,SAASA,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bU,UAAU;QAAC;QAAM;;IACnB,CAAA;EACF,CAAA;EACAC,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BP,aAAa;IACf,CAAA;EACF,CAAA;EACAa,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMC,OAAOtB,UAAUC,KAAK;EACjCC,MAAM;IACJC,KAAKC,KAAIH,KAAK,8BAAA;IACdI,MAAM;IACNC,aAAa;IACbC,MAAM;EACR;EACAC,OAAcC,eAAO;IACnBC,MAAMC,QAAcC,KAAK,EAAEC,YAAY;MACrCP,aAAa;IACf,CAAA;IACAiB,MAAaC,iBAAgBC,gBAAQ,SAAS,SAAS,KAAA,CAAA,EAAQZ,YAAY;MACzEP,aAAa;MACboB,cAAc;IAChB,CAAA;EACF,CAAA;EACAT,QAAeR,eAAO;IACpBS,KAAYH,eAAOF,YAAY;MAC7BP,aAAa;IACf,CAAA;IACAQ,MAAaU,iBAAgBT,cAAM,EAAEF,YAAY;MAC/CP,aAAa;IACf,CAAA;EACF,CAAA;EACAa,UAAU;IAACC,SAASC;;AACtB,CAAA;AAEO,IAAMM,QAAQ3B,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAKC,KAAIH,KAAK,+BAAA;IACdI,MAAM;IACNC,aAAa;IACbC,MAAM;EACR;EACAC,OAAcC,eAAO;IACnBS,KAAYM,iBACHT,eAAOF,YAAY;MACxBP,aAAa;IACf,CAAA,CAAA;IAEFsB,KAAYJ,iBACHT,eAAOF,YAAY;MACxBP,aAAa;IACf,CAAA,CAAA;EAEJ,CAAA;EACAW,QAAeR,eAAO;IACpBoB,OAAcd;EAChB,CAAA;AACF,CAAA;",
6
+ "names": ["Chess", "ChessJS", "Schema", "AppAnnotation", "Annotation", "DXN", "Obj", "Type", "FormInputAnnotation", "HiddenAnnotation", "log", "SKILL_KEY", "description", "fen", "String", "IconAnnotation", "icon", "hue", "make", "pgn", "chess", "warn", "Schema", "Operation", "Database", "DXN", "GameRef", "Move", "Operation", "make", "meta", "key", "DXN", "name", "description", "icon", "input", "Struct", "game", "GameRef", "State", "annotations", "move", "String", "examples", "output", "pgn", "services", "Database", "Service", "Play", "side", "optional", "Literal", "defaultValue", "Print", "fen", "ascii"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  // src/ChessPlugin.tsx
2
2
  import { Plugin } from "@dxos/app-framework";
3
- import { AppPlugin, AppActivationEvents } from "@dxos/app-toolkit";
4
- import { BlueprintDefinition, GameVariant, OperationHandler } from "#capabilities";
3
+ import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
4
+ import { GameVariant, OperationHandler, SkillDefinition } from "#capabilities";
5
5
  import { meta } from "#meta";
6
6
  import { translations } from "#translations";
7
7
  import { Chess } from "#types";
@@ -14,8 +14,8 @@ var ChessPlugin = Plugin.define(meta).pipe(Plugin.addModule({
14
14
  id: "game-variant",
15
15
  activatesOn: AppActivationEvents.SetupSchema,
16
16
  activate: GameVariant
17
- }), AppPlugin.addBlueprintDefinitionModule({
18
- activate: BlueprintDefinition
17
+ }), AppPlugin.addSkillDefinitionModule({
18
+ activate: SkillDefinition
19
19
  }), AppPlugin.addOperationHandlerModule({
20
20
  activate: OperationHandler
21
21
  }), AppPlugin.addPluginAssetModule({
@@ -38,4 +38,4 @@ export {
38
38
  ChessPlugin,
39
39
  ChessPlugin_default
40
40
  };
41
- //# sourceMappingURL=chunk-IQCSIZXM.mjs.map
41
+ //# sourceMappingURL=chunk-EXZ3XFEG.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/ChessPlugin.tsx", "raw-loader:/__w/dxos/dxos/packages/plugins/plugin-chess/PLUGIN.mdl"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppActivationEvents, AppPlugin } from '@dxos/app-toolkit';\n\nimport { GameVariant, OperationHandler, SkillDefinition } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Chess } from '#types';\n\n// eslint-disable-next-line import/no-relative-packages\nimport pluginSpec from '../PLUGIN.mdl?raw';\n\nexport const ChessPlugin = Plugin.define(meta).pipe(\n Plugin.addModule({\n id: 'game-variant',\n activatesOn: AppActivationEvents.SetupSchema,\n activate: GameVariant,\n }),\n AppPlugin.addSkillDefinitionModule({ activate: SkillDefinition }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addPluginAssetModule({\n asset: { pluginId: meta.profile.key, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },\n }),\n AppPlugin.addSchemaModule({ schema: [Chess.State] }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default ChessPlugin;\n", "---\nid: org.dxos.plugin.chess\nname: ChessPlugin\nversion: 0.1.0\n---\n\nA two-player chess game plugin for `DXOS` Composer.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n| `service` | `org.dxos.mdl.service@1.0` |\n\n## Types\n\n```mdl\ntype Color\n literals: white | black\n```\n\n```mdl\ntype PieceKind\n literals: pawn | rook | knight | bishop | queen | king\n```\n\n```mdl\ntype Piece\n fields:\n kind: PieceKind\n color: Color\n```\n\n```mdl\ntype Square\n fields:\n file: a | b | c | d | e | f | g | h\n rank: 1..8\n piece?: Piece\n```\n\n```mdl\ntype Move\n fields:\n from: Square\n to: Square\n promotion?: PieceKind # only valid for pawn reaching back rank\n```\n\n```mdl\ntype Board\n fields:\n squares: Square[8][8]\n turn: Color\n status: playing | check | checkmate | stalemate\n moves: Move[] # full move history\n```\n\n```mdl\ntype Player\n fields:\n id: string\n name: string\n color: Color\n```\n\n```mdl\ntype GameStatus\n literals: waiting | active | finished\n```\n\n```mdl\ntype Game\n fields:\n id: string\n players: Player[2]\n board: Board\n status: GameStatus\n winner?: Player\n```\n\n## Components\n\n```mdl\ncomponent Lobby\n desc: Entry point where players create or join a game.\n props:\n playerId: string\n state:\n games: Game[] # list of open/active games\n selected?: Game\n slots:\n header?: ReactNode\n empty?: ReactNode # shown when games list is empty\n actions:\n createGame() \u2192 Game\n joinGame(game: Game) \u2192 Game\n spectate(game: Game)\n emits:\n onJoin(game: Game)\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 [header slot] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 Game list \u2502\n \u2502 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502\n \u2502 \u2502 game row \u2502 \u2502\n \u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\n \u2502 [empty slot] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 [Create Game] \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent Gameboard\n desc: Interactive chess board for an active game.\n props:\n game: Game\n playerId: string # identifies which side the viewer plays\n state:\n selected?: Square # currently selected square\n highlights: Square[] # legal move targets for selected piece\n perspective: Color # which side is at the bottom (default: player's color)\n slots:\n toolbar?: ReactNode\n sidebar?: ReactNode\n overlay?: ReactNode # e.g. checkmate / promotion dialogs\n actions:\n selectSquare(square: Square)\n submitMove(move: Move)\n flipBoard()\n emits:\n onMove(move: Move)\n onResign()\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 [toolbar slot] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 \u2502 [sidebar] \u2502\n \u2502 8\u00D78 \u2502 \u2502\n \u2502 board \u2502 move history \u2502\n \u2502 \u2502 \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 [overlay slot] \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n## Services\n\n```mdl\nservice ChessEngine\n desc: Validates moves and computes game state. May be local (WASM) or remote.\n loading: lazy\n ops:\n validate(board: Board, move: Move) \u2192 Move\n legalMoves(board: Board, square: Square) \u2192 Square[]\n applyMove(board: Board, move: Move) \u2192 Board\n errors:\n EngineNotReady: engine has not finished loading\n```\n\n```mdl\nservice GameStore\n desc: Persists and replicates Game state via ECHO.\n ops:\n create(white: Player, black: Player) \u2192 Game\n load(id: string) \u2192 Game\n save(game: Game) \u2192 Game\n list() \u2192 Game[]\n effects: [echo:write, echo:read]\n```\n\n## Operations\n\nPure operations (no effects, no service dependencies) \u2014 safe to call anywhere.\n\n```mdl\nop getLegalMoves\n desc: Returns legal target squares for the piece on the given square.\n input:\n board: Board\n square: Square\n output: Square[]\n errors:\n EmptySquare: no piece on square\n WrongSide: piece does not belong to the active side\n requires: [ChessEngine]\n```\n\n```mdl\nop validateMove\n desc: Checks a move against chess rules without mutating state.\n input:\n board: Board\n move: Move\n output: Move\n errors:\n IllegalMove: move violates chess rules\n WrongTurn: piece does not belong to the active side\n GameOver: game has already ended\n requires: [ChessEngine]\n```\n\n```mdl\nop applyMove\n desc: Applies a validated move and returns the next board state.\n input:\n board: Board\n move: Move # must be pre-validated\n output: Board\n requires: [ChessEngine]\n note: does not persist; use submitMove for the full transactional flow\n```\n\nEffectful operations \u2014 mutate persistent state.\n\n```mdl\nop startGame\n desc: Creates a new Game with two players and an initial Board.\n input:\n white: Player\n black: Player\n output: Game\n effects: [echo:write]\n requires: [GameStore]\n```\n\n```mdl\nop submitMove\n desc: Validates and applies a move, then persists the updated Game.\n input:\n game: Game\n player: Player\n move: Move\n output: Game\n errors:\n WrongTurn: player is not the active side\n IllegalMove: move violates chess rules\n GameOver: game has already ended\n effects: [echo:write]\n requires: [ChessEngine, GameStore]\n note: |\n Composes validateMove \u2192 applyMove \u2192 GameStore.save.\n Atomic: Game is not persisted if validation fails.\n```\n\n```mdl\nop resignGame\n desc: Player forfeits; opponent wins.\n input:\n game: Game\n player: Player\n output: Game # Game.status === finished, Game.winner set\n errors:\n GameOver: game has already ended\n effects: [echo:write]\n requires: [GameStore]\n```\n\n## Features\n\n```mdl\nfeat F-1: Start Game\n\n req F-1.1: New Board created with pieces in standard starting positions.\n req F-1.2: White moves first.\n```\n\n```mdl\nfeat F-2: Make Move\n\n req F-2.1:\n when: player submits a Move on their turn\n then: Move validated against chess rules\n errors: [InvalidMove, WrongTurn, GameOver]\n\n req F-2.2:\n when: Move is valid\n then: Board updated; turn advances to opponent\n\n req F-2.3:\n when: resulting position leaves opponent's king in check\n then: Board.status set to check\n\n req F-2.4:\n when: no legal moves remain for the side to move\n then: Board.status set to checkmate (if in check) or stalemate\n```\n\n```mdl\nfeat F-3: Lobby\n\n req F-3.1: Player sees list of open games on entering the Lobby.\n req F-3.2:\n when: player creates a game\n then: new Game created with status waiting; player assigned white\n\n req F-3.3:\n when: second player joins an open game\n then: Game.status transitions to active; joining player assigned black\n\n req F-3.4:\n when: Game.status becomes active\n then: both players navigated to Gameboard\n```\n\n```mdl\nfeat F-4: Gameboard\n\n req F-4.1:\n when: player selects a square containing their piece\n then: legal move targets highlighted on board\n\n req F-4.2:\n when: player selects a highlighted target square\n then: Move submitted via submitMove(); board updated on success\n\n req F-4.3:\n when: pawn reaches the back rank\n then: promotion dialog shown via overlay slot; player selects piece kind\n\n req F-4.4:\n when: Game.status is finished\n then: result overlay shown (winner or draw); further moves disabled\n```\n\n```mdl\nfeat F-5: Move Validation\n\n req F-5.1:\n when: Gameboard calls submitMove\n then: op:validateMove runs before any state change\n\n req F-5.2:\n when: validation fails\n then: error returned to caller; Game state unchanged\n\n req F-5.3:\n when: square is selected on Gameboard\n then: op:getLegalMoves called; results drive component:Gameboard.highlights\n```\n\n```mdl\nfeat F-6: Game Persistence\n\n req F-6.1:\n when: op:startGame completes\n then: Game written to ECHO and visible in component:Lobby game list\n\n req F-6.2:\n when: op:submitMove completes\n then: updated Game replicated to all peers via ECHO\n\n req F-6.3:\n when: peer receives a Game update\n then: component:Gameboard re-renders with new Board state\n tags: [collaborative]\n```\n\n## Acceptance\n\n```mdl\ntest T-1: New game starting position\n given: a new game is started\n then:\n - Board.turn === white\n - Board.status === playing\n - each player has 16 pieces in standard positions\n```\n\n```mdl\ntest T-2: Illegal move rejected\n given: it is white's turn\n when: white attempts to move a black piece\n then: WrongTurn error; Board unchanged\n```\n\n```mdl\ntest T-3: Create and join game\n given: two players are in the Lobby\n when: player A creates a game, player B joins it\n then:\n - Game.status === active\n - Game.players[0].color === white # creator\n - Game.players[1].color === black # joiner\n - both players see the Gameboard\n```\n\n```mdl\ntest T-4: Legal move highlight\n given: Gameboard is shown, it is white's turn\n when: white selects the e2 pawn\n then:\n - squares e3 and e4 are highlighted\n - no other squares are highlighted\n```\n\n```mdl\ntest T-5: Pawn promotion\n given: white pawn is on e7, it is white's turn\n when: white moves pawn to e8\n then:\n - promotion overlay appears\n - after player selects queen, Move recorded with promotion: queen\n - board shows white queen on e8\n```\n\n```mdl\ntest T-6: Submit valid move\n given: active game, white's turn, white player logged in\n when: white submits pawn e2\u2192e4\n then:\n - op:validateMove returns move without error\n - Board updated: e4 occupied by white pawn, e2 empty\n - Game.board.turn === black\n - Game persisted to ECHO\n```\n\n```mdl\ntest T-7: Submit invalid move rejected atomically\n given: active game, white's turn\n when: white submits an illegal move (e2\u2192e5)\n then:\n - IllegalMove error returned\n - Game.board unchanged\n - no ECHO write occurs\n```\n\n```mdl\ntest T-8: Legal moves highlighted\n given: new game, white's turn, Gameboard shown\n when: player selects e2\n then:\n - op:getLegalMoves returns [e3, e4]\n - Gameboard.highlights === [e3, e4]\n```\n\n---\n\n## Appendix: Extension Definitions\n\nExtension block types used in this document are defined below using\nthe core `ext` primitive \u2014 the only construct the base language provides.\n\n```mdl\next type\n uri: dxos.spec/ext/type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap # name[?]: TypeExpr (# inline comment)\n literals?: UnionList # a | b | c\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: dxos.spec/ext/feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self # feat blocks may contain feat blocks\n```\n\n```mdl\next test\n uri: dxos.spec/ext/test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap # external inputs (immutable inside component)\n state?: FieldMap # internal reactive state\n slots?: FieldMap # named ReactNode injection points\n actions?: ActionMap # methods the component exposes or handles\n emits?: EventMap # events the component raises to its parent\n layout?: CodeBlock # ASCII sketch of visual structure (non-normative)\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap # named input parameters\n output?: TypeExpr # return type\n errors?: ErrorMap # name: Prose (when this error occurs)\n effects?: EffectList # echo:read | echo:write | http | fs | ...\n requires?: ServiceList # injected service dependencies\n note?: Prose # implementation guidance (non-normative)\n```\n\n```mdl\next service\n uri: org.dxos.mdl.service@1.0\n desc: An external or system-level dependency providing named operations.\n fields:\n desc?: Prose\n loading?: eager | lazy\n ops?: OpMap # name(params) \u2192 ReturnType\n errors?: ErrorMap\n note?: Prose\n```\n"],
5
+ "mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,qBAAqBC,iBAAiB;AAE/C,SAASC,aAAaC,kBAAkBC,uBAAuB;AAC/D,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,aAAa;;;ACVtB;;;ADeO,IAAMC,cAAcC,OAAOC,OAAOC,IAAAA,EAAMC,KAC7CH,OAAOI,UAAU;EACfC,IAAI;EACJC,aAAaC,oBAAoBC;EACjCC,UAAUC;AACZ,CAAA,GACAC,UAAUC,yBAAyB;EAAEH,UAAUI;AAAgB,CAAA,GAC/DF,UAAUG,0BAA0B;EAAEL,UAAUM;AAAiB,CAAA,GACjEJ,UAAUK,qBAAqB;EAC7BC,OAAO;IAAEC,UAAUhB,KAAKiB,QAAQC;IAAKC,MAAM;IAAcC,SAASC;IAAYC,UAAU;EAAoB;AAC9G,CAAA,GACAb,UAAUc,gBAAgB;EAAEC,QAAQ;IAACC,MAAMC;;AAAO,CAAA,GAClDjB,UAAUkB,sBAAsB;EAAEC;AAAa,CAAA,GAC/C9B,OAAO+B,IAAI;AAGb,IAAA,sBAAehC;",
6
+ "names": ["Plugin", "AppActivationEvents", "AppPlugin", "GameVariant", "OperationHandler", "SkillDefinition", "meta", "translations", "Chess", "ChessPlugin", "Plugin", "define", "meta", "pipe", "addModule", "id", "activatesOn", "AppActivationEvents", "SetupSchema", "activate", "GameVariant", "AppPlugin", "addSkillDefinitionModule", "SkillDefinition", "addOperationHandlerModule", "OperationHandler", "addPluginAssetModule", "asset", "pluginId", "profile", "key", "path", "content", "pluginSpec", "mimeType", "addSchemaModule", "schema", "Chess", "State", "addTranslationsModule", "translations", "make"]
7
+ }
@@ -1,5 +1,5 @@
1
- // src/blueprints/chess-blueprint.ts
2
- import { Blueprint, Template } from "@dxos/compute";
1
+ // src/skills/chess-skill.ts
2
+ import { Skill, Template } from "@dxos/compute";
3
3
  import { trim } from "@dxos/util";
4
4
  import { Chess, ChessOperation } from "#types";
5
5
  var operations = [
@@ -7,10 +7,10 @@ var operations = [
7
7
  ChessOperation.Play,
8
8
  ChessOperation.Print
9
9
  ];
10
- var make = () => Blueprint.make({
11
- key: Chess.BLUEPRINT_KEY,
10
+ var make = () => Skill.make({
11
+ key: Chess.SKILL_KEY,
12
12
  name: "Chess",
13
- tools: Blueprint.toolDefinitions({
13
+ tools: Skill.toolDefinitions({
14
14
  operations
15
15
  }),
16
16
  instructions: Template.make({
@@ -26,13 +26,13 @@ var make = () => Blueprint.make({
26
26
  `
27
27
  })
28
28
  });
29
- var blueprint = {
30
- key: Chess.BLUEPRINT_KEY,
29
+ var skill = {
30
+ key: Chess.SKILL_KEY,
31
31
  make
32
32
  };
33
- var chess_blueprint_default = blueprint;
33
+ var chess_skill_default = skill;
34
34
 
35
35
  export {
36
- chess_blueprint_default
36
+ chess_skill_default
37
37
  };
38
- //# sourceMappingURL=chunk-3WMTSPOZ.mjs.map
38
+ //# sourceMappingURL=chunk-IKWULCKX.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/skills/chess-skill.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Skill, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { Chess, ChessOperation } from '#types';\n\nconst operations = [ChessOperation.Move, ChessOperation.Play, ChessOperation.Print];\n\nconst make = () =>\n Skill.make({\n key: Chess.SKILL_KEY,\n name: 'Chess',\n tools: Skill.toolDefinitions({ operations }),\n instructions: Template.make({\n source: trim`\n You are an expert chess player.\n To analyze a game you can access the \"pgn\" property by loading the context object that represents the current game.\n You could suggest a good next move or offer to play a move.\n Don't actually make a move unless you are asked to.\n\n When setting a chess position, always set the \"pgn\" field (move list in standard PGN notation) on the org.dxos.type.chess.state object.\n The \"fen\" field is not used by the UI for display — the board is driven exclusively from \"pgn\".\n Setting \"fen\" alone or leaving \"pgn\" empty will result in the initial position being shown.\n `,\n }),\n });\n\nconst skill: Skill.Definition = {\n key: Chess.SKILL_KEY,\n make,\n};\n\nexport default skill;\n"],
5
+ "mappings": ";AAIA,SAASA,OAAOC,gBAAgB;AAChC,SAASC,YAAY;AAErB,SAASC,OAAOC,sBAAsB;AAEtC,IAAMC,aAAa;EAACD,eAAeE;EAAMF,eAAeG;EAAMH,eAAeI;;AAE7E,IAAMC,OAAO,MACXT,MAAMS,KAAK;EACTC,KAAKP,MAAMQ;EACXC,MAAM;EACNC,OAAOb,MAAMc,gBAAgB;IAAET;EAAW,CAAA;EAC1CU,cAAcd,SAASQ,KAAK;IAC1BO,QAAQd;;;;;;;;;;EAUV,CAAA;AACF,CAAA;AAEF,IAAMe,QAA0B;EAC9BP,KAAKP,MAAMQ;EACXF;AACF;AAEA,IAAA,sBAAeQ;",
6
+ "names": ["Skill", "Template", "trim", "Chess", "ChessOperation", "operations", "Move", "Play", "Print", "make", "key", "SKILL_KEY", "name", "tools", "toolDefinitions", "instructions", "source", "skill"]
7
+ }
@@ -2,11 +2,10 @@ import "../chunk-J5LGTIGS.mjs";
2
2
 
3
3
  // src/components/Chessboard/Chessboard.tsx
4
4
  import { RegistryContext } from "@effect-atom/atom-react";
5
- import React2, { forwardRef, useCallback, useContext, useEffect as useEffect2, useImperativeHandle, useMemo as useMemo2, useRef as useRef2 } from "react";
6
- import { addEventListener } from "@dxos/async";
5
+ import React2, { forwardRef, useCallback, useContext, useEffect as useEffect2, useImperativeHandle, useMemo as useMemo2 } from "react";
7
6
  import { useObject } from "@dxos/echo-react";
8
7
  import { useSoundEffect } from "@dxos/react-ui-audio";
9
- import { Gameboard, Chessboard as NaturalChessboard, getRawPgn, useGameboardContext as useGameboardContext2 } from "@dxos/react-ui-gameboard";
8
+ import { Gameboard, Chessboard as NaturalChessboard, getRawPgn } from "@dxos/react-ui-gameboard";
10
9
 
11
10
  // src/components/Chessboard/Info.tsx
12
11
  import { useAtomValue } from "@effect-atom/atom-react";
@@ -92,7 +91,9 @@ var History = ({ classNames, model, min, max, onSelect }) => {
92
91
  ]);
93
92
  return /* @__PURE__ */ React.createElement("div", {
94
93
  ref: scrollerRef,
95
- className: mx("overflow-y-auto", classNames),
94
+ tabIndex: 0,
95
+ "data-chessboard-arrow-navigation": true,
96
+ className: mx("overflow-y-auto outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500", classNames),
96
97
  style: {
97
98
  minHeight: min === void 0 ? "auto" : `${min * 24}px`,
98
99
  maxHeight: max === void 0 ? "auto" : `${max * 24}px`
@@ -174,10 +175,45 @@ var Root = /* @__PURE__ */ forwardRef(({ state, children }, forwardedRef) => {
174
175
  }, [
175
176
  model
176
177
  ]);
178
+ const handleKeyDown = useCallback((ev) => {
179
+ const target = ev.target instanceof HTMLElement ? ev.target : void 0;
180
+ if (!target?.closest("[data-chessboard-arrow-navigation]")) {
181
+ return;
182
+ }
183
+ const moveIndex = registry.get(model.moveIndex);
184
+ switch (ev.key) {
185
+ case "ArrowUp":
186
+ ev.preventDefault();
187
+ model.setMoveIndex(0);
188
+ break;
189
+ case "ArrowDown":
190
+ ev.preventDefault();
191
+ model.setMoveIndex(model.game.history().length);
192
+ break;
193
+ case "ArrowLeft":
194
+ if (moveIndex > 0) {
195
+ ev.preventDefault();
196
+ model.setMoveIndex(moveIndex - 1);
197
+ }
198
+ break;
199
+ case "ArrowRight":
200
+ if (moveIndex < model.game.history().length) {
201
+ ev.preventDefault();
202
+ model.setMoveIndex(moveIndex + 1);
203
+ }
204
+ break;
205
+ }
206
+ }, [
207
+ registry,
208
+ model
209
+ ]);
177
210
  return /* @__PURE__ */ React2.createElement(Gameboard.Root, {
178
211
  model,
179
212
  onDrop: handleDrop
180
- }, children);
213
+ }, /* @__PURE__ */ React2.createElement("div", {
214
+ className: "contents",
215
+ onKeyDown: handleKeyDown
216
+ }, children));
181
217
  });
182
218
  var Content = ({ classNames, children }) => {
183
219
  return /* @__PURE__ */ React2.createElement(Gameboard.Content, {
@@ -187,45 +223,10 @@ var Content = ({ classNames, children }) => {
187
223
  }, children);
188
224
  };
189
225
  var BOARD_NAME = "Chessboard.Board";
190
- var Board = (props) => {
191
- const registry = useContext(RegistryContext);
192
- const { model } = useGameboardContext2(BOARD_NAME);
193
- const ref = useRef2(null);
194
- useEffect2(() => {
195
- if (!ref.current) {
196
- return;
197
- }
198
- ref.current.setAttribute("data-arrow-keys", "all");
199
- return addEventListener(ref.current, "keydown", (ev) => {
200
- const moveIndex = registry.get(model.moveIndex);
201
- switch (ev.key) {
202
- case "ArrowUp":
203
- model.setMoveIndex(0);
204
- break;
205
- case "ArrowDown":
206
- model.setMoveIndex(model.game.history().length);
207
- break;
208
- case "ArrowLeft":
209
- if (moveIndex > 0) {
210
- model.setMoveIndex(moveIndex - 1);
211
- }
212
- break;
213
- case "ArrowRight":
214
- if (moveIndex < model.game.history().length) {
215
- model.setMoveIndex(moveIndex + 1);
216
- }
217
- break;
218
- }
219
- });
220
- }, [
221
- registry,
222
- model
223
- ]);
224
- return /* @__PURE__ */ React2.createElement(NaturalChessboard, {
225
- ...props,
226
- ref
227
- });
228
- };
226
+ var Board = (props) => /* @__PURE__ */ React2.createElement("div", {
227
+ className: "contents",
228
+ "data-chessboard-arrow-navigation": true
229
+ }, /* @__PURE__ */ React2.createElement(NaturalChessboard, props));
229
230
  Board.displayName = BOARD_NAME;
230
231
  var Chessboard = {
231
232
  Root,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/Chessboard/Chessboard.tsx", "../../../../src/components/Chessboard/Info.tsx", "../../../../src/components/Chessboard/types.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 { useSoundEffect } from '@dxos/react-ui-audio';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n useGameboardContext,\n} from '@dxos/react-ui-gameboard';\n\nimport { type Chess } from '#types';\n\nimport { Info, type InfoProps } from './Info';\nimport { ExtendedChessModel } from './types';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n state: Chess.State;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ state, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, state), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(state, 'pgn');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // TODO(wittjosiah): Rather than useEffect to sync ECHO object to model, create an alternative model implementation.\n // This model would take the ECHO object and derive game state directly from that.\n // Mutation methods would mutate the ECHO object and other state would be derived from that.\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [pgn]);\n\n // Move.\n const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(\n (move) => {\n if (!model.makeMove(move)) {\n return false;\n }\n\n void click.play();\n updatePgn(() => model.pgn);\n return true;\n },\n [model],\n );\n\n 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 { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '#meta';\n\nimport { type ExtendedChessModel } from './types';\n\nconst INFO_NAME = 'Chessboard.Info';\n\nexport type InfoProps = ThemedClassName<\n {\n orientation?: Player;\n onOrientationChange?: (orientation: Player) => void;\n onClose?: () => void;\n } & Pick<HistoryProps, 'min' | 'max' | 'onSelect'>\n>;\n\nexport const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {\n const { t } = useTranslation(meta.profile.key);\n const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden 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\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip-board.button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n />\n </div>\n );\n};\n\nInfo.displayName = INFO_NAME;\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.profile.key);\n const moveIndex = useAtomValue(model.moveIndex);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate.label')\n : model.game.isStalemate()\n ? t('game.stalemate.label')\n : t('game.draw.label')\n : model.game.isCheck()\n ? t('game.check.label')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${moveIndex - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [moveIndex]);\n\n return (\n <div\n ref={scrollerRef}\n 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// 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.State,\n ) {\n super(registry);\n }\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,SAASC,sBAAsB;AAC/B,SAEEC,WAEAC,cAAcC,mBAEdC,WACAC,uBAAAA,4BACK;;;ACxBP,SAASC,oBAAoB;AAC7B,OAAOC,SAA2CC,WAAWC,SAASC,cAAc;AAEpF,SAASC,MAAMC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AAE5C,WAAOC,iBAAiBJ,IAAIE,SAAS,WAAW,CAACG,OAAAA;AAC/C,YAAMC,YAAYzC,SAAS0C,IAAIvC,MAAMsC,SAAS;AAC9C,cAAQD,GAAGG,KAAG;QACZ,KAAK;AACHxC,gBAAMW,aAAa,CAAA;AACnB;QACF,KAAK;AACHX,gBAAMW,aAAaX,MAAMyC,KAAKC,QAAO,EAAGC,MAAM;AAC9C;QACF,KAAK;AACH,cAAIL,YAAY,GAAG;AACjBtC,kBAAMW,aAAa2B,YAAY,CAAA;UACjC;AACA;QACF,KAAK;AACH,cAAIA,YAAYtC,MAAMyC,KAAKC,QAAO,EAAGC,QAAQ;AAC3C3C,kBAAMW,aAAa2B,YAAY,CAAA;UACjC;AACA;MACJ;IACF,CAAA;EACF,GAAG;IAACzC;IAAUG;GAAM;AAEpB,SAAO,gBAAAqB,OAAA,cAACuB,mBAAAA;IAAmB,GAAGd;IAAOE;;AACvC;AAEAH,MAAMgB,cAAcjB;AAMb,IAAMkB,aAAa;EACxBtD;EACAgC;EACAK;EACAkB;AACF;",
6
- "names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useRef", "addEventListener", "useObject", "useSoundEffect", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useGameboardContext", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "Icon", "IconButton", "useTranslation", "useGameboardContext", "mx", "meta", "INFO_NAME", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "profile", "key", "model", "div", "className", "PlayerIndicator", "player", "icon", "variant", "iconOnly", "label", "size", "onClick", "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", "data-index", "children", "turn", "ChessModel", "ExtendedChessModel", "registry", "object", "Root", "forwardRef", "state", "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", "game", "history", "length", "NaturalChessboard", "displayName", "Chessboard", "Info"]
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} from 'react';\n\nimport { useObject } from '@dxos/echo-react';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { useSoundEffect } from '@dxos/react-ui-audio';\nimport {\n type ChessModel,\n Gameboard,\n type GameboardRootProps,\n Chessboard as NaturalChessboard,\n type ChessboardProps as NaturalChessboardProps,\n getRawPgn,\n} from '@dxos/react-ui-gameboard';\n\nimport { type Chess } from '#types';\n\nimport { Info, type InfoProps } from './Info';\nimport { ExtendedChessModel } from './types';\n\nexport interface ChessboardController {\n setMoveNumber(index: number): void;\n}\n\n//\n// Root\n//\n\ntype RootProps = PropsWithChildren<{\n state: Chess.State;\n}>;\n\nconst Root = forwardRef<ChessboardController, RootProps>(({ state, children }, forwardedRef) => {\n const registry = useContext(RegistryContext);\n const model = useMemo(() => new ExtendedChessModel(registry, state), [registry]);\n const click = useSoundEffect('Click');\n const [pgn, updatePgn] = useObject(state, 'pgn');\n\n // Controller.\n useImperativeHandle(forwardedRef, () => {\n return {\n setMoveNumber: (index) => model.setMoveIndex(index),\n };\n }, [model]);\n\n // TODO(wittjosiah): Rather than useEffect to sync ECHO object to model, create an alternative model implementation.\n // This model would take the ECHO object and derive game state directly from that.\n // Mutation methods would mutate the ECHO object and other state would be derived from that.\n\n // External change.\n // NOTE: Warning if user has not interacted with the board.\n useEffect(() => {\n if (model.pgn !== getRawPgn(pgn ?? '')) {\n const silent = model.pgn === '*';\n model.update(pgn);\n if (!silent) {\n void click.play();\n }\n }\n }, [pgn]);\n\n // Move.\n const handleDrop = useCallback<NonNullable<GameboardRootProps<ChessModel>['onDrop']>>(\n (move) => {\n if (!model.makeMove(move)) {\n return false;\n }\n\n void click.play();\n updatePgn(() => model.pgn);\n return true;\n },\n [model],\n );\n\n // Keyboard navigation — fires regardless of which descendant (Board or Info) has focus.\n // Gated to elements marked data-chessboard-arrow-navigation to avoid intercepting toolbar controls.\n const handleKeyDown = useCallback(\n (ev: React.KeyboardEvent) => {\n const target = ev.target instanceof HTMLElement ? ev.target : undefined;\n if (!target?.closest('[data-chessboard-arrow-navigation]')) {\n return;\n }\n\n const moveIndex = registry.get(model.moveIndex);\n switch (ev.key) {\n case 'ArrowUp':\n ev.preventDefault();\n model.setMoveIndex(0);\n break;\n case 'ArrowDown':\n ev.preventDefault();\n model.setMoveIndex(model.game.history().length);\n break;\n case 'ArrowLeft':\n if (moveIndex > 0) {\n ev.preventDefault();\n model.setMoveIndex(moveIndex - 1);\n }\n break;\n case 'ArrowRight':\n if (moveIndex < model.game.history().length) {\n ev.preventDefault();\n model.setMoveIndex(moveIndex + 1);\n }\n break;\n }\n },\n [registry, model],\n );\n\n return (\n <Gameboard.Root model={model} onDrop={handleDrop}>\n {/* display:contents is layout-transparent; catches keydown bubbled from any focused descendant. */}\n <div className='contents' onKeyDown={handleKeyDown}>\n {children}\n </div>\n </Gameboard.Root>\n );\n});\n\n//\n// Content\n//\n\ntype Role = 'card--content';\n\ntype ContentProps = ThemedClassName<PropsWithChildren<{ role?: Role }>>;\n\nconst Content = ({ classNames, children }: ContentProps) => {\n return (\n <Gameboard.Content grow contain classNames={classNames}>\n {children}\n </Gameboard.Content>\n );\n};\n\n//\n// Board\n//\n\nconst BOARD_NAME = 'Chessboard.Board';\n\ntype BoardProps = NaturalChessboardProps;\n\nconst Board = (props: BoardProps) => (\n <div className='contents' data-chessboard-arrow-navigation>\n <NaturalChessboard {...props} />\n </div>\n);\n\nBoard.displayName = BOARD_NAME;\n\n//\n// Chessboard\n//\n\nexport const Chessboard = {\n Root: Root,\n Content: Content,\n Board: Board,\n Info: Info,\n};\n\nexport type {\n BoardProps as ChessboardBoardProps,\n ContentProps as ChessboardContentProps,\n InfoProps as ChessboardInfoProps,\n RootProps as ChessboardRootProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { type JSX, type PropsWithChildren, useEffect, useMemo, useRef } from 'react';\n\nimport { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { type Player, useGameboardContext } from '@dxos/react-ui-gameboard';\nimport { mx } from '@dxos/ui-theme';\n\nimport { meta } from '#meta';\n\nimport { type ExtendedChessModel } from './types';\n\nconst INFO_NAME = 'Chessboard.Info';\n\nexport type InfoProps = ThemedClassName<\n {\n orientation?: Player;\n onOrientationChange?: (orientation: Player) => void;\n onClose?: () => void;\n } & Pick<HistoryProps, 'min' | 'max' | 'onSelect'>\n>;\n\nexport const Info = ({ classNames, orientation = 'white', onOrientationChange, onClose, ...props }: InfoProps) => {\n const { t } = useTranslation(meta.profile.key);\n const { model } = useGameboardContext<ExtendedChessModel>(INFO_NAME);\n\n return (\n <div\n className={mx(\n 'grid grid-rows-[min-content_1fr_min-content] w-full min-w-[18rem] p-2 overflow-hidden 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\n <History model={model} {...props} />\n\n <PlayerIndicator\n model={model}\n player={orientation}\n icon={\n onOrientationChange && (\n <IconButton\n classNames={mx('transition duration-200 ease-linear', orientation === 'white' && 'rotate-180')}\n icon='ph--arrows-clockwise--regular'\n iconOnly\n label={t('flip-board.button')}\n size={4}\n onClick={() => onOrientationChange(orientation === 'white' ? 'black' : 'white')}\n />\n )\n }\n />\n </div>\n );\n};\n\nInfo.displayName = INFO_NAME;\n\n//\n// History\n//\n\ntype HistoryProps = ThemedClassName<{\n model: ExtendedChessModel;\n min?: number;\n max?: number;\n onSelect?: (index: number) => void;\n}>;\n\nconst History = ({ classNames, model, min, max, onSelect }: HistoryProps) => {\n const { t } = useTranslation(meta.profile.key);\n const moveIndex = useAtomValue(model.moveIndex);\n const label = model.game.isGameOver()\n ? model.game.isCheckmate()\n ? t('game.checkmate.label')\n : model.game.isStalemate()\n ? t('game.stalemate.label')\n : t('game.draw.label')\n : model.game.isCheck()\n ? t('game.check.label')\n : undefined;\n\n const history = model.game.history();\n const moves = useMemo(\n () =>\n history.reduce(\n (acc, move, index) => {\n if (index % 2 === 0) {\n acc.push([{ index, move }]);\n } else {\n acc[acc.length - 1].push({ index, move });\n }\n return acc;\n },\n [] as { index: number; move: string }[][],\n ),\n [history.length],\n );\n\n const scrollerRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n scrollerRef.current?.scrollTo({ top: scrollerRef.current.scrollHeight });\n }, [history.length]);\n\n useEffect(() => {\n const div = scrollerRef.current?.querySelector(`[data-index=\"${moveIndex - 1}\"]`);\n scrollerRef.current?.classList.add('scrollbar-none');\n div?.scrollIntoView({ behavior: 'smooth' });\n scrollerRef.current?.classList.remove('scrollbar-none');\n }, [moveIndex]);\n\n return (\n <div\n ref={scrollerRef}\n tabIndex={0}\n data-chessboard-arrow-navigation\n className={mx('overflow-y-auto outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500', classNames)}\n style={{\n minHeight: min === undefined ? 'auto' : `${min * 24}px`,\n maxHeight: max === undefined ? 'auto' : `${max * 24}px`,\n }}\n >\n {moves.map(([a, b], index) => (\n <div key={index} className='grid grid-cols-[3rem_1fr_1fr_1rem] gap-2 ps-4'>\n <div className='content-center text-xs text-subdued'>{index + 1}</div>\n {a && (\n <div\n data-index={a.index}\n className={mx('ps-2 text-sm cursor-pointer', a.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(a.index + 1)}\n >\n {a.move}\n </div>\n )}\n {b && (\n <div\n data-index={b.index}\n className={mx('ps-2 text-sm cursor-pointer', b.index === moveIndex - 1 && 'bg-primary-500')}\n onClick={() => onSelect?.(b.index + 1)}\n >\n {b.move}\n </div>\n )}\n </div>\n ))}\n {label && <div className='text-center'>{label}</div>}\n </div>\n );\n};\n\n//\n// PlayerIndicator\n//\n\ntype PlayerIndicatorProps = PropsWithChildren<{\n model: ExtendedChessModel;\n player: Player;\n icon?: JSX.Element;\n}>;\n\nconst PlayerIndicator = ({ children, model, player, icon }: PlayerIndicatorProps) => {\n const turn = player === (model.game.turn() === 'w' ? 'white' : 'black');\n return (\n <div className='grid grid-cols-[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// 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.State,\n ) {\n super(registry);\n }\n}\n"],
5
+ "mappings": ";;;AAIA,SAASA,uBAAuB;AAChC,OAAOC,UAELC,YACAC,aACAC,YACAC,aAAAA,YACAC,qBACAC,WAAAA,gBACK;AAEP,SA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M+B,KAAKC,QAAO,EAAGC,MAAM;AAC9C;MACF,KAAK;AACH,YAAIN,YAAY,GAAG;AACjBL,aAAGQ,eAAc;AACjB9B,gBAAMW,aAAagB,YAAY,CAAA;QACjC;AACA;MACF,KAAK;AACH,YAAIA,YAAY3B,MAAM+B,KAAKC,QAAO,EAAGC,QAAQ;AAC3CX,aAAGQ,eAAc;AACjB9B,gBAAMW,aAAagB,YAAY,CAAA;QACjC;AACA;IACJ;EACF,GACA;IAAC9B;IAAUG;GAAM;AAGnB,SACE,gBAAAkC,OAAA,cAACC,UAAU3C,MAAI;IAACQ;IAAcoC,QAAQnB;KAEpC,gBAAAiB,OAAA,cAACG,OAAAA;IAAIC,WAAU;IAAWC,WAAWlB;KAClC1B,QAAAA,CAAAA;AAIT,CAAA;AAUA,IAAM6C,UAAU,CAAC,EAAEC,YAAY9C,SAAQ,MAAgB;AACrD,SACE,gBAAAuC,OAAA,cAACC,UAAUK,SAAO;IAACE,MAAAA;IAAKC,SAAAA;IAAQF;KAC7B9C,QAAAA;AAGP;AAMA,IAAMiD,aAAa;AAInB,IAAMC,QAAQ,CAACC,UACb,gBAAAZ,OAAA,cAACG,OAAAA;EAAIC,WAAU;EAAWS,oCAAAA;GACxB,gBAAAb,OAAA,cAACc,mBAAsBF,KAAAA,CAAAA;AAI3BD,MAAMI,cAAcL;AAMb,IAAMM,aAAa;EACxB1D;EACAgD;EACAK;EACAM;AACF;",
6
+ "names": ["RegistryContext", "React", "forwardRef", "useCallback", "useContext", "useEffect", "useImperativeHandle", "useMemo", "useObject", "useSoundEffect", "Gameboard", "Chessboard", "NaturalChessboard", "getRawPgn", "useAtomValue", "React", "useEffect", "useMemo", "useRef", "Icon", "IconButton", "useTranslation", "useGameboardContext", "mx", "meta", "INFO_NAME", "Info", "classNames", "orientation", "onOrientationChange", "onClose", "props", "t", "profile", "key", "model", "div", "className", "PlayerIndicator", "player", "icon", "variant", "iconOnly", "label", "size", "onClick", "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", "tabIndex", "data-chessboard-arrow-navigation", "style", "minHeight", "maxHeight", "map", "a", "b", "data-index", "children", "turn", "ChessModel", "ExtendedChessModel", "registry", "object", "Root", "forwardRef", "state", "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", "handleKeyDown", "ev", "target", "HTMLElement", "undefined", "closest", "moveIndex", "get", "key", "preventDefault", "game", "history", "length", "React", "Gameboard", "onDrop", "div", "className", "onKeyDown", "Content", "classNames", "grow", "contain", "BOARD_NAME", "Board", "props", "data-chessboard-arrow-navigation", "NaturalChessboard", "displayName", "Chessboard", "Info"]
7
7
  }
@@ -3,7 +3,7 @@ import "../chunk-J5LGTIGS.mjs";
3
3
  // src/containers/index.ts
4
4
  import { lazy } from "react";
5
5
  var ChessArticle = lazy(() => import("../ChessArticle-MPRT54KQ.mjs"));
6
- var ChessCard = lazy(() => import("../ChessCard-4TUTIFB6.mjs"));
6
+ var ChessCard = lazy(() => import("../ChessCard-VJ3I6MIB.mjs"));
7
7
  export {
8
8
  ChessArticle,
9
9
  ChessCard
@@ -4,15 +4,15 @@ import {
4
4
  import {
5
5
  ChessOperation_exports,
6
6
  Chess_exports
7
- } from "./chunk-S66CCWNQ.mjs";
7
+ } from "./chunk-DXIET5G2.mjs";
8
8
  import {
9
- chess_blueprint_default
10
- } from "./chunk-3WMTSPOZ.mjs";
9
+ chess_skill_default
10
+ } from "./chunk-IKWULCKX.mjs";
11
11
  import "./chunk-J5LGTIGS.mjs";
12
12
  export {
13
13
  Chess_exports as Chess,
14
- chess_blueprint_default as ChessBlueprint,
15
14
  ChessOperation_exports as ChessOperation,
15
+ chess_skill_default as ChessSkill,
16
16
  meta
17
17
  };
18
18
  //# sourceMappingURL=index.mjs.map