@dxos/plugin-chess 0.8.4-main.b97322e → 0.8.4-main.bc2380dfbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/ChessArticle-QLLKZGPH.mjs +88 -0
- package/dist/lib/neutral/ChessArticle-QLLKZGPH.mjs.map +7 -0
- package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs +19 -0
- package/dist/lib/neutral/ChessCard-I5RSZZIP.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.mjs +10 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs +23 -0
- package/dist/lib/neutral/ChessPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ChessPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-PZXHAYLD.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-PZXHAYLD.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +13 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5UOTTW6U.mjs +8 -0
- package/dist/lib/neutral/chunk-5UOTTW6U.mjs.map +7 -0
- package/dist/lib/neutral/chunk-E4LZPHAQ.mjs +148 -0
- package/dist/lib/neutral/chunk-E4LZPHAQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HVIKFYAW.mjs +29 -0
- package/dist/lib/neutral/chunk-HVIKFYAW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NYIJLMS3.mjs +25 -0
- package/dist/lib/neutral/chunk-NYIJLMS3.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs +34 -0
- package/dist/lib/neutral/chunk-XWKNXG62.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +239 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/game-variant-24UKIBRM.mjs +40 -0
- package/dist/lib/neutral/game-variant-24UKIBRM.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +18 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/move-RQZ7BJY3.mjs +37 -0
- package/dist/lib/neutral/move-RQZ7BJY3.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs +13 -0
- package/dist/lib/neutral/operation-handler-EKZKFQUG.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/play-GDGCEPQL.mjs +46 -0
- package/dist/lib/neutral/play-GDGCEPQL.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/print-ZQA74KZI.mjs +29 -0
- package/dist/lib/neutral/print-ZQA74KZI.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +34 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/ChessPlugin.d.ts +3 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/ChessPlugin.node.d.ts +8 -0
- package/dist/types/src/ChessPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.test.d.ts +2 -0
- package/dist/types/src/ChessPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ChessPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/game-variant.d.ts +6 -0
- package/dist/types/src/capabilities/game-variant.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +38 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +57 -0
- package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Info.d.ts +20 -0
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +5 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +56 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +5 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts +15 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +2 -0
- package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/move.d.ts +5 -0
- package/dist/types/src/operations/move.d.ts.map +1 -0
- package/dist/types/src/operations/play.d.ts +5 -0
- package/dist/types/src/operations/play.d.ts.map +1 -0
- package/dist/types/src/operations/print.d.ts +5 -0
- package/dist/types/src/operations/print.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -14
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +18 -0
- package/dist/types/src/types/Chess.d.ts.map +1 -0
- package/dist/types/src/types/ChessOperation.d.ts +24 -0
- package/dist/types/src/types/ChessOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +117 -51
- package/src/ChessPlugin.node.ts +23 -0
- package/src/ChessPlugin.test.ts +50 -0
- package/src/ChessPlugin.tsx +20 -54
- package/src/ChessPlugin.workerd.ts +18 -0
- package/src/blueprints/chess-blueprint.ts +32 -0
- package/src/blueprints/index.ts +5 -0
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/game-variant.ts +42 -0
- package/src/capabilities/index.ts +9 -4
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/components/Chessboard/Chessboard.stories.tsx +94 -0
- package/src/components/Chessboard/Chessboard.tsx +180 -0
- package/src/components/Chessboard/Info.tsx +193 -0
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +2 -6
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +59 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +108 -0
- package/src/containers/ChessArticle/index.ts +5 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +47 -0
- package/src/containers/ChessCard/ChessCard.tsx +27 -0
- package/src/containers/ChessCard/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +2 -4
- package/src/meta.ts +11 -7
- package/src/operations/index.ts +11 -0
- package/src/operations/move.ts +36 -0
- package/src/operations/play.ts +45 -0
- package/src/operations/print.ts +28 -0
- package/src/plugin.ts +11 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +18 -12
- package/src/types/Chess.ts +59 -0
- package/src/types/ChessOperation.ts +85 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs +0 -129
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A2FSM255.mjs +0 -182
- package/dist/lib/browser/artifact-definition-A2FSM255.mjs.map +0 -7
- package/dist/lib/browser/chunk-A3WEUKPK.mjs +0 -61
- package/dist/lib/browser/chunk-A3WEUKPK.mjs.map +0 -7
- package/dist/lib/browser/chunk-KDADGLPC.mjs +0 -8
- package/dist/lib/browser/chunk-KDADGLPC.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZXH3N4NA.mjs +0 -66
- package/dist/lib/browser/chunk-ZXH3N4NA.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -98
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs +0 -28
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-PLUCWIYP.mjs +0 -36
- package/dist/lib/browser/react-surface-PLUCWIYP.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -11
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs +0 -130
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs +0 -183
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-27D3JA3K.mjs +0 -68
- package/dist/lib/node-esm/chunk-27D3JA3K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs +0 -63
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QFINI7CC.mjs +0 -10
- package/dist/lib/node-esm/chunk-QFINI7CC.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -99
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs +0 -29
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs +0 -37
- package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -12
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Chess.d.ts +0 -14
- package/dist/types/src/components/Chess.d.ts.map +0 -1
- package/dist/types/src/components/ChessContainer.d.ts +0 -8
- package/dist/types/src/components/ChessContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChessContainer.stories.d.ts +0 -23
- package/dist/types/src/components/ChessContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChessPanel.d.ts +0 -11
- package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
- package/dist/types/src/components/Chessboard.stories.d.ts +0 -8
- package/dist/types/src/components/Chessboard.stories.d.ts.map +0 -1
- package/dist/types/src/components/PlayerSelector.d.ts +0 -8
- package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -29
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -32
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -124
- package/src/capabilities/intent-resolver.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -23
- package/src/components/Chess.tsx +0 -60
- package/src/components/ChessContainer.stories.tsx +0 -110
- package/src/components/ChessContainer.tsx +0 -71
- package/src/components/ChessPanel.tsx +0 -67
- package/src/components/Chessboard.stories.tsx +0 -41
- package/src/components/PlayerSelector.tsx +0 -82
- package/src/types/schema.ts +0 -34
- package/src/types/types.ts +0 -20
- /package/dist/lib/{browser/types/index.mjs.map → neutral/ChessPlugin.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/blueprints}/index.mjs.map +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/index.ts", "../../../src/ChessPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const ArtifactDefinition = lazy(() => import('./artifact-definition'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\nimport { defineObjectForm } from '@dxos/plugin-space/types';\n\nimport { ArtifactDefinition, IntentResolver, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { ChessAction, ChessType } from './types';\n\nexport const ChessPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/metadata`,\n activatesOn: Events.SetupMetadata,\n activate: () =>\n contributes(Capabilities.Metadata, {\n id: ChessType.typename,\n metadata: {\n icon: 'ph--shield-chevron--regular',\n },\n }),\n }),\n defineModule({\n id: `${meta.id}/module/object-form`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () =>\n contributes(\n SpaceCapabilities.ObjectForm,\n defineObjectForm({\n objectSchema: ChessType,\n getIntent: () => createIntent(ChessAction.Create),\n }),\n ),\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/artifact-definition`,\n activatesOn: Events.SetupArtifactDefinition,\n activate: ArtifactDefinition,\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { ChessType } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [ChessType.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 'rename object label': 'Rename game',\n 'delete object label': 'Delete game',\n },\n [meta.id]: {\n 'plugin name': 'Chess',\n 'delete game label': 'Delete',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAIA,SAASA,YAAY;AAEd,IAAMC,qBAAqBC,KAAK,MAAM,OAAO,oCAAA,CAAA;AAC7C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,eAAeF,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ACJ9C,SAASG,cAAcC,aAAaC,cAAcC,cAAcC,cAAcC,cAAc;AAC5F,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;;;ACE1B,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,UAAUC,QAAQ,GAAG;QACpB,kBAAkB;QAClB,uBAAuB;QACvB,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,uBAAuB;QACvB,uBAAuB;MACzB;MACA,CAACC,KAAKC,EAAE,GAAG;QACT,eAAe;QACf,qBAAqB;MACvB;IACF;EACF;;;;ADZK,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,MAAMC,YAAYC,aAAaC,cAAcC,YAAAA;EACzD,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOO;IACpBL,UAAU,MACRC,YAAYC,aAAaI,UAAU;MACjCV,IAAIW,UAAUC;MACdC,UAAU;QACRC,MAAM;MACR;IACF,CAAA;EACJ,CAAA;EACAf,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAac,aAAaC;IAC1BZ,UAAU,MACRC,YACEY,kBAAkBC,YAClBC,iBAAiB;MACfC,cAAcT;MACdU,WAAW,MAAMC,aAAaC,YAAYC,MAAM;IAClD,CAAA,CAAA;EAEN,CAAA;EACAzB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOuB;IACpBrB,UAAUsB;EACZ,CAAA;EACA3B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOyB;IACpBvB,UAAUwB;EACZ,CAAA;EACA7B,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAO2B;IACpBzB,UAAU0B;EACZ,CAAA;CACD;",
|
|
6
|
-
"names": ["lazy", "ArtifactDefinition", "lazy", "IntentResolver", "ReactSurface", "Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "ClientEvents", "SpaceCapabilities", "defineObjectForm", "translations", "ChessType", "typename", "meta", "id", "ChessPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "SetupMetadata", "Metadata", "ChessType", "typename", "metadata", "icon", "ClientEvents", "SetupSchema", "SpaceCapabilities", "ObjectForm", "defineObjectForm", "objectSchema", "getIntent", "createIntent", "ChessAction", "Create", "SetupReactSurface", "ReactSurface", "SetupIntentResolver", "IntentResolver", "SetupArtifactDefinition", "ArtifactDefinition"]
|
|
7
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ChessAction,
|
|
4
|
-
ChessType
|
|
5
|
-
} from "./chunk-IS3Y25PL.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/intent-resolver.ts
|
|
8
|
-
import { Chess } from "chess.js";
|
|
9
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
10
|
-
import { Obj } from "@dxos/echo";
|
|
11
|
-
var intent_resolver_default = () => contributes(Capabilities.IntentResolver, createResolver({
|
|
12
|
-
intent: ChessAction.Create,
|
|
13
|
-
resolve: ({ name, fen }) => {
|
|
14
|
-
const pgn = fen ? new Chess(fen).pgn() : void 0;
|
|
15
|
-
return {
|
|
16
|
-
data: {
|
|
17
|
-
object: Obj.make(ChessType, {
|
|
18
|
-
name,
|
|
19
|
-
fen,
|
|
20
|
-
pgn
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
export {
|
|
27
|
-
intent_resolver_default as default
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=intent-resolver-GXK2JROQ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess } from 'chess.js';\n\nimport { Capabilities, contributes, createResolver } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { ChessAction, ChessType } from '../types';\n\nexport default () =>\n contributes(\n Capabilities.IntentResolver,\n createResolver({\n intent: ChessAction.Create,\n resolve: ({ name, fen }) => {\n const pgn = fen ? new Chess(fen).pgn() : undefined;\n return {\n data: {\n object: Obj.make(ChessType, { name, fen, pgn }),\n },\n };\n },\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAIA,SAASA,aAAa;AAEtB,SAASC,cAAcC,aAAaC,sBAAsB;AAC1D,SAASC,WAAW;AAIpB,IAAA,0BAAe,MACbC,YACEC,aAAaC,gBACbC,eAAe;EACbC,QAAQC,YAAYC;EACpBC,SAAS,CAAC,EAAEC,MAAMC,IAAG,MAAE;AACrB,UAAMC,MAAMD,MAAM,IAAIE,MAAMF,GAAAA,EAAKC,IAAG,IAAKE;AACzC,WAAO;MACLC,MAAM;QACJC,QAAQC,IAAIC,KAAKC,WAAW;UAAET;UAAMC;UAAKC;QAAI,CAAA;MAC/C;IACF;EACF;AACF,CAAA,CAAA;",
|
|
6
|
-
"names": ["Chess", "Capabilities", "contributes", "createResolver", "Obj", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "ChessAction", "Create", "resolve", "name", "fen", "pgn", "Chess", "undefined", "data", "object", "Obj", "make", "ChessType"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/meta.ts":{"bytes":2020,"imports":[],"format":"esm"},"src/types/schema.ts":{"bytes":3031,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/types/types.ts":{"bytes":2147,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"src/meta.ts","kind":"import-statement","original":"../meta"}],"format":"esm"},"src/types/index.ts":{"bytes":541,"imports":[{"path":"src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/capabilities/artifact-definition.ts":{"bytes":19075,"imports":[{"path":"chess.js","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"../meta"},{"path":"src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"src/capabilities/intent-resolver.ts":{"bytes":2679,"imports":[{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"src/components/Chess.tsx":{"bytes":5947,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-gameboard","kind":"import-statement","external":true}],"format":"esm"},"src/components/PlayerSelector.tsx":{"bytes":8842,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/display-name","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"format":"esm"},"src/components/ChessContainer.tsx":{"bytes":7151,"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"src/components/Chess.tsx","kind":"import-statement","original":"./Chess"},{"path":"src/components/PlayerSelector.tsx","kind":"import-statement","original":"./PlayerSelector"}],"format":"esm"},"src/components/index.ts":{"bytes":838,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/components/Chess.tsx","kind":"import-statement","original":"./Chess"},{"path":"src/components/ChessContainer.tsx","kind":"dynamic-import","original":"./ChessContainer"}],"format":"esm"},"src/capabilities/react-surface.tsx":{"bytes":3374,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"src/components/index.ts","kind":"import-statement","original":"../components"},{"path":"src/meta.ts","kind":"import-statement","original":"../meta"},{"path":"src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"src/capabilities/index.ts":{"bytes":1316,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/capabilities/artifact-definition.ts","kind":"dynamic-import","original":"./artifact-definition"},{"path":"src/capabilities/intent-resolver.ts","kind":"dynamic-import","original":"./intent-resolver"},{"path":"src/capabilities/react-surface.tsx","kind":"dynamic-import","original":"./react-surface"}],"format":"esm"},"src/translations.ts":{"bytes":2420,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/ChessPlugin.tsx":{"bytes":7255,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true},{"path":"src/capabilities/index.ts","kind":"import-statement","original":"./capabilities"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/translations.ts","kind":"import-statement","original":"./translations"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/index.ts":{"bytes":741,"imports":[{"path":"src/capabilities/index.ts","kind":"import-statement","original":"./capabilities"},{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/ChessPlugin.tsx","kind":"import-statement","original":"./ChessPlugin"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5223},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-QFINI7CC.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-IS3Y25PL.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-27D3JA3K.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs","kind":"dynamic-import"},{"path":"dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs","kind":"dynamic-import"},{"path":"dist/lib/node-esm/react-surface-NGLNIWN3.mjs","kind":"dynamic-import"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true}],"exports":["ArtifactDefinition","CHESS_PLUGIN","Chess","ChessContainer","ChessPlugin","IntentResolver","ReactSurface","meta"],"entryPoint":"src/index.ts","inputs":{"src/capabilities/index.ts":{"bytesInOutput":273},"src/index.ts":{"bytesInOutput":0},"src/ChessPlugin.tsx":{"bytesInOutput":1492},"src/translations.ts":{"bytesInOutput":480}},"bytes":2803},"dist/lib/node-esm/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/types/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-IS3Y25PL.mjs","kind":"import-statement"}],"exports":["ChessAction","ChessType","MoveSchema"],"entryPoint":"src/types/index.ts","inputs":{},"bytes":262},"dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":8481},"dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-IS3Y25PL.mjs","kind":"import-statement"},{"path":"chess.js","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/assistant","kind":"import-statement","external":true},{"path":"@dxos/blueprints","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/plugin-space/types","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/artifact-definition.ts","inputs":{"src/capabilities/artifact-definition.ts":{"bytesInOutput":5945}},"bytes":6267},"dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1375},"dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-IS3Y25PL.mjs","kind":"import-statement"},{"path":"chess.js","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/intent-resolver.ts","inputs":{"src/capabilities/intent-resolver.ts":{"bytesInOutput":503}},"bytes":805},"dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7675},"dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-27D3JA3K.mjs","kind":"import-statement"},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-stack","kind":"import-statement","external":true},{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/display-name","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/components/ChessContainer.tsx","inputs":{"src/components/ChessContainer.tsx":{"bytesInOutput":2219},"src/components/PlayerSelector.tsx":{"bytesInOutput":2519}},"bytes":5093},"dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1577},"dist/lib/node-esm/react-surface-NGLNIWN3.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-QFINI7CC.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-IS3Y25PL.mjs","kind":"import-statement"},{"path":"dist/lib/node-esm/chunk-27D3JA3K.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/react-surface.tsx","inputs":{"src/capabilities/react-surface.tsx":{"bytesInOutput":715}},"bytes":1093},"dist/lib/node-esm/chunk-QFINI7CC.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":395},"dist/lib/node-esm/chunk-QFINI7CC.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs","kind":"dynamic-import"}],"exports":["ChessContainer"],"inputs":{"src/components/index.ts":{"bytesInOutput":104}},"bytes":298},"dist/lib/node-esm/chunk-IS3Y25PL.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3484},"dist/lib/node-esm/chunk-IS3Y25PL.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["CHESS_PLUGIN","ChessAction","ChessType","MoveSchema","meta"],"inputs":{"src/types/schema.ts":{"bytesInOutput":586},"src/types/index.ts":{"bytesInOutput":0},"src/types/types.ts":{"bytesInOutput":430},"src/meta.ts":{"bytesInOutput":513}},"bytes":1829},"dist/lib/node-esm/chunk-27D3JA3K.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2854},"dist/lib/node-esm/chunk-27D3JA3K.mjs":{"imports":[{"path":"@preact-signals/safe-react/tracking","kind":"import-statement","external":true},{"path":"chess.js","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui-gameboard","kind":"import-statement","external":true}],"exports":["Chess"],"inputs":{"src/components/Chess.tsx":{"bytesInOutput":1646}},"bytes":1832}}}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ChessContainer
|
|
4
|
-
} from "./chunk-QFINI7CC.mjs";
|
|
5
|
-
import {
|
|
6
|
-
ChessType,
|
|
7
|
-
meta
|
|
8
|
-
} from "./chunk-IS3Y25PL.mjs";
|
|
9
|
-
import "./chunk-27D3JA3K.mjs";
|
|
10
|
-
|
|
11
|
-
// src/capabilities/react-surface.tsx
|
|
12
|
-
import React from "react";
|
|
13
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
14
|
-
import { Obj } from "@dxos/echo";
|
|
15
|
-
var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
16
|
-
createSurface({
|
|
17
|
-
id: meta.id,
|
|
18
|
-
role: [
|
|
19
|
-
"article",
|
|
20
|
-
"section",
|
|
21
|
-
"card--intrinsic",
|
|
22
|
-
"card--extrinsic",
|
|
23
|
-
"card--popover",
|
|
24
|
-
"card--transclusion"
|
|
25
|
-
],
|
|
26
|
-
// TODO(burdon): Could this be standardized so that we don't require a subject property (like below)?
|
|
27
|
-
filter: (data) => Obj.instanceOf(ChessType, data.subject),
|
|
28
|
-
component: ({ data, role }) => /* @__PURE__ */ React.createElement(ChessContainer, {
|
|
29
|
-
game: data.subject,
|
|
30
|
-
role
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
]);
|
|
34
|
-
export {
|
|
35
|
-
react_surface_default as default
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=react-surface-NGLNIWN3.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\n\nimport { ChessContainer } from '../components';\nimport { meta } from '../meta';\nimport { ChessType } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: meta.id,\n role: ['article', 'section', 'card--intrinsic', 'card--extrinsic', 'card--popover', 'card--transclusion'],\n // TODO(burdon): Could this be standardized so that we don't require a subject property (like below)?\n filter: (data): data is { subject: ChessType } => Obj.instanceOf(ChessType, data.subject),\n component: ({ data, role }) => <ChessContainer game={data.subject} role={role} />,\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAcC,aAAaC,qBAAqB;AACzD,SAASC,WAAW;AAMpB,IAAA,wBAAe,MACbC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;MAAW;MAAmB;MAAmB;MAAiB;;;IAEpFC,QAAQ,CAACC,SAAyCC,IAAIC,WAAWC,WAAWH,KAAKI,OAAO;IACxFC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAO,sBAAA,cAACQ,gBAAAA;MAAeC,MAAMP,KAAKI;MAASN;;EACrE,CAAA;CACD;",
|
|
6
|
-
"names": ["React", "Capabilities", "contributes", "createSurface", "Obj", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "ChessType", "subject", "component", "ChessContainer", "game"]
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ChessAction,
|
|
4
|
-
ChessType,
|
|
5
|
-
MoveSchema
|
|
6
|
-
} from "../chunk-IS3Y25PL.mjs";
|
|
7
|
-
export {
|
|
8
|
-
ChessAction,
|
|
9
|
-
ChessType,
|
|
10
|
-
MoveSchema
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
2
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
3
|
-
declare global {
|
|
4
|
-
interface ToolContextExtensions {
|
|
5
|
-
space?: Space;
|
|
6
|
-
dispatch?: PromiseIntentDispatcher;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
declare const _default: () => import("@dxos/app-framework").Capability<import("@dxos/blueprints").ArtifactDefinition>;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=artifact-definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-definition.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/artifact-definition.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkD,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAMnH,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAM7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,QAAQ,CAAC,EAAE,uBAAuB,CAAC;KACpC;CACF;;AAED,wBAgGE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAA+B,MAAM,qBAAqB,CAAC;;AAKhF,wBAcI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAA8B,MAAM,qBAAqB,CAAC;;AAO/E,wBASK"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { type PropsWithChildren } from 'react';
|
|
2
|
-
import { type ChessType } from '../types';
|
|
3
|
-
export declare const Chess: {
|
|
4
|
-
Root: ({ game, children }: PropsWithChildren<{
|
|
5
|
-
game: ChessType;
|
|
6
|
-
}>) => React.JSX.Element | null;
|
|
7
|
-
Content: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<{
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
}>, "className"> & {
|
|
10
|
-
classNames?: import("@dxos/react-ui-types").ClassNameValue;
|
|
11
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
-
Board: React.MemoExoticComponent<({ orientation, showLabels, debug, rows, cols, classNames }: import("@dxos/react-ui-gameboard").ChessboardProps) => React.JSX.Element>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=Chess.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chess.d.ts","sourceRoot":"","sources":["../../../../src/components/Chess.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAMvF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AA4C1C,eAAO,MAAM,KAAK;+BA1CqB,iBAAiB,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;;;;;;;CA8C5E,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ChessType } from '../types';
|
|
3
|
-
declare const ChessContainer: ({ game, role }: {
|
|
4
|
-
game: ChessType;
|
|
5
|
-
role?: string;
|
|
6
|
-
}) => React.JSX.Element | null;
|
|
7
|
-
export default ChessContainer;
|
|
8
|
-
//# sourceMappingURL=ChessContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,cAAc,GAAI,gBAAgB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,6BAqDzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type Meta } from '@storybook/react-vite';
|
|
3
|
-
type StoryProps = {
|
|
4
|
-
role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
|
|
5
|
-
};
|
|
6
|
-
declare const meta: Meta<StoryProps>;
|
|
7
|
-
export default meta;
|
|
8
|
-
export declare const Popover: {
|
|
9
|
-
args: {
|
|
10
|
-
role: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare const Intrinsic: {
|
|
14
|
-
args: {
|
|
15
|
-
role: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare const Extrinsic: {
|
|
19
|
-
args: {
|
|
20
|
-
role: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=ChessContainer.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessContainer.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessContainer.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAmBlD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;CAC/D,CAAC;AA2BF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAAU,CAmC1B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO;;;;CAInB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Color } from 'chess.js';
|
|
2
|
-
import { type FC } from 'react';
|
|
3
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
-
import { type ChessModel } from '@dxos/react-ui-gameboard';
|
|
5
|
-
export type ChessPanelProps = ThemedClassName<{
|
|
6
|
-
model: ChessModel;
|
|
7
|
-
orientation?: Color;
|
|
8
|
-
onFlip?: () => void;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const ChessPanel: FC<ChessPanelProps>;
|
|
11
|
-
//# sourceMappingURL=ChessPanel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChessPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChessPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,eAAe,EAAQ,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;IAC5C,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAiD1C,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { Chessboard } from '@dxos/react-ui-gameboard';
|
|
4
|
-
declare const meta: Meta<typeof Chessboard>;
|
|
5
|
-
type Story = StoryObj<typeof Chessboard>;
|
|
6
|
-
export default meta;
|
|
7
|
-
export declare const Default: Story;
|
|
8
|
-
//# sourceMappingURL=Chessboard.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chessboard.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Chessboard.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAa,UAAU,EAAc,MAAM,0BAA0B,CAAC;AAoB7E,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAKjC,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAC;AAEzC,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
3
|
-
import { type ChessType } from '../types';
|
|
4
|
-
export declare const PlayerSelector: ({ space, game }: {
|
|
5
|
-
space: Space;
|
|
6
|
-
game: ChessType;
|
|
7
|
-
}) => React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=PlayerSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlayerSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/PlayerSelector.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAc,KAAK,KAAK,EAAoB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,cAAc,GAAI,iBAAiB;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,sBAuBhF,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { Type } from '@dxos/echo';
|
|
3
|
-
export declare const MoveSchema: Schema.mutable<Schema.SchemaClass<{
|
|
4
|
-
readonly source?: string | undefined;
|
|
5
|
-
readonly target?: string | undefined;
|
|
6
|
-
readonly piece?: string | undefined;
|
|
7
|
-
}, {
|
|
8
|
-
readonly source?: string | undefined;
|
|
9
|
-
readonly target?: string | undefined;
|
|
10
|
-
readonly piece?: string | undefined;
|
|
11
|
-
}, never>>;
|
|
12
|
-
export declare const ChessType: Type.obj<Schema.SchemaClass<{
|
|
13
|
-
readonly name?: string | undefined;
|
|
14
|
-
readonly playerWhite?: string | undefined;
|
|
15
|
-
readonly playerBlack?: string | undefined;
|
|
16
|
-
readonly moves?: string[] | undefined;
|
|
17
|
-
readonly pgn?: string | undefined;
|
|
18
|
-
readonly fen?: string | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
readonly playerWhite?: string | undefined;
|
|
21
|
-
readonly playerBlack?: string | undefined;
|
|
22
|
-
readonly moves?: string[] | undefined;
|
|
23
|
-
readonly pgn?: string | undefined;
|
|
24
|
-
readonly fen?: string | undefined;
|
|
25
|
-
readonly name?: string | undefined;
|
|
26
|
-
}, never>>;
|
|
27
|
-
export interface ChessType extends Schema.Schema.Type<typeof ChessType> {
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/types/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,eAAO,MAAM,UAAU;;;;;;;;UAQtB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;UAcrB,CAAC;AACF,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC;CAAG"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
export declare namespace ChessAction {
|
|
3
|
-
const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
|
|
4
|
-
readonly _tag: Schema.tag<`${string}/action/create`>;
|
|
5
|
-
} & {
|
|
6
|
-
input: Schema.Struct<{
|
|
7
|
-
name: Schema.optional<typeof Schema.String>;
|
|
8
|
-
fen: Schema.optional<typeof Schema.String>;
|
|
9
|
-
}>;
|
|
10
|
-
output: Schema.Struct<{
|
|
11
|
-
object: import("@dxos/echo/Type").obj<Schema.SchemaClass<{
|
|
12
|
-
readonly name?: string | undefined;
|
|
13
|
-
readonly playerWhite?: string | undefined;
|
|
14
|
-
readonly playerBlack?: string | undefined;
|
|
15
|
-
readonly moves?: string[] | undefined;
|
|
16
|
-
readonly pgn?: string | undefined;
|
|
17
|
-
readonly fen?: string | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
readonly playerWhite?: string | undefined;
|
|
20
|
-
readonly playerBlack?: string | undefined;
|
|
21
|
-
readonly moves?: string[] | undefined;
|
|
22
|
-
readonly pgn?: string | undefined;
|
|
23
|
-
readonly fen?: string | undefined;
|
|
24
|
-
readonly name?: string | undefined;
|
|
25
|
-
}, never>>;
|
|
26
|
-
}>;
|
|
27
|
-
}>;
|
|
28
|
-
export class Create extends Create_base {
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,yBAAiB,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;IAC3B,MAAM,OAAO,MAAO,SAAQ,WAQ1B;KAAG;;CACN"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess } from 'chess.js';
|
|
6
|
-
import { pipe, Schema } from 'effect';
|
|
7
|
-
|
|
8
|
-
import { createTool, ToolResult } from '@dxos/ai';
|
|
9
|
-
import { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
-
import { createArtifactElement, VersionPin, ArtifactId } from '@dxos/assistant';
|
|
11
|
-
import { defineArtifact } from '@dxos/blueprints';
|
|
12
|
-
import { Obj } from '@dxos/echo';
|
|
13
|
-
import { invariant } from '@dxos/invariant';
|
|
14
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
15
|
-
import { Filter, type Space } from '@dxos/react-client/echo';
|
|
16
|
-
|
|
17
|
-
import { meta } from '../meta';
|
|
18
|
-
import { ChessAction, ChessType } from '../types';
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Factor out.
|
|
21
|
-
declare global {
|
|
22
|
-
interface ToolContextExtensions {
|
|
23
|
-
space?: Space;
|
|
24
|
-
dispatch?: PromiseIntentDispatcher;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default () => {
|
|
29
|
-
const definition = defineArtifact({
|
|
30
|
-
id: `artifact:${meta.id}`,
|
|
31
|
-
name: meta.name,
|
|
32
|
-
description: 'Provides a simple chess engine.',
|
|
33
|
-
instructions: `
|
|
34
|
-
- If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.
|
|
35
|
-
- Always inspect the chess game at the start of every prompt realting to a chess game, as it might have changed since the interaction.
|
|
36
|
-
`,
|
|
37
|
-
schema: ChessType,
|
|
38
|
-
tools: [
|
|
39
|
-
createTool(meta.id, {
|
|
40
|
-
name: 'create',
|
|
41
|
-
description: 'Create a new chess game. Returns the artifact definition for the game.',
|
|
42
|
-
caption: 'Creating chess game...',
|
|
43
|
-
schema: Schema.Struct({
|
|
44
|
-
fen: Schema.String.annotations({ description: 'The state of the chess game in the FEN format.' }),
|
|
45
|
-
}),
|
|
46
|
-
execute: async ({ fen }, { extensions }) => {
|
|
47
|
-
invariant(extensions?.space, 'No space');
|
|
48
|
-
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
49
|
-
const intent = pipe(
|
|
50
|
-
createIntent(ChessAction.Create, { fen }),
|
|
51
|
-
chain(SpaceAction.AddObject, { target: extensions.space }),
|
|
52
|
-
);
|
|
53
|
-
const { data, error } = await extensions.dispatch(intent);
|
|
54
|
-
if (!data || error) {
|
|
55
|
-
return ToolResult.Error(error?.message ?? 'Failed to create chess game');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return ToolResult.Success(createArtifactElement(data.id), [
|
|
59
|
-
VersionPin.createBlock(VersionPin.fromObject(data.object)),
|
|
60
|
-
]);
|
|
61
|
-
},
|
|
62
|
-
}),
|
|
63
|
-
createTool(meta.id, {
|
|
64
|
-
name: 'list',
|
|
65
|
-
description: 'Query all active chess games.',
|
|
66
|
-
caption: 'Getting games...',
|
|
67
|
-
schema: Schema.Struct({}),
|
|
68
|
-
execute: async (_, { extensions }) => {
|
|
69
|
-
invariant(extensions?.space, 'No space');
|
|
70
|
-
const { objects: games } = await extensions.space.db.query(Filter.type(ChessType)).run();
|
|
71
|
-
invariant(games.length > 0, 'No chess games found');
|
|
72
|
-
|
|
73
|
-
return ToolResult.Success(games);
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
createTool(meta.id, {
|
|
77
|
-
name: 'inspect',
|
|
78
|
-
description: 'Get the current state of the chess game.',
|
|
79
|
-
caption: 'Inspecting game...',
|
|
80
|
-
schema: Schema.Struct({ id: ArtifactId }),
|
|
81
|
-
execute: async ({ id }, { extensions }) => {
|
|
82
|
-
invariant(extensions?.space, 'No space');
|
|
83
|
-
const game = await extensions.space.db
|
|
84
|
-
.query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
|
|
85
|
-
.first();
|
|
86
|
-
invariant(Obj.instanceOf(ChessType, game));
|
|
87
|
-
|
|
88
|
-
return ToolResult.Success(game.fen);
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
createTool(meta.id, {
|
|
92
|
-
name: 'move',
|
|
93
|
-
description: 'Make a move in the chess game.',
|
|
94
|
-
caption: 'Making chess move...',
|
|
95
|
-
schema: Schema.Struct({
|
|
96
|
-
id: ArtifactId,
|
|
97
|
-
move: Schema.String.annotations({
|
|
98
|
-
description: 'The move to make in the chess game.',
|
|
99
|
-
examples: ['e4', 'Bf3'],
|
|
100
|
-
}),
|
|
101
|
-
}),
|
|
102
|
-
execute: async ({ id, move }, { extensions }) => {
|
|
103
|
-
invariant(extensions?.space, 'No space');
|
|
104
|
-
const game = await extensions.space.db
|
|
105
|
-
.query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
|
|
106
|
-
.first();
|
|
107
|
-
invariant(Obj.instanceOf(ChessType, game));
|
|
108
|
-
|
|
109
|
-
const board = new Chess(game.fen);
|
|
110
|
-
try {
|
|
111
|
-
board.move(move);
|
|
112
|
-
} catch (error: any) {
|
|
113
|
-
return ToolResult.Error(error.message);
|
|
114
|
-
}
|
|
115
|
-
game.pgn = board.pgn();
|
|
116
|
-
game.fen = board.fen();
|
|
117
|
-
return ToolResult.Success(game.fen);
|
|
118
|
-
},
|
|
119
|
-
}),
|
|
120
|
-
],
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return contributes(Capabilities.ArtifactDefinition, definition);
|
|
124
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess } from 'chess.js';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
|
|
10
|
-
import { ChessAction, ChessType } from '../types';
|
|
11
|
-
|
|
12
|
-
export default () =>
|
|
13
|
-
contributes(
|
|
14
|
-
Capabilities.IntentResolver,
|
|
15
|
-
createResolver({
|
|
16
|
-
intent: ChessAction.Create,
|
|
17
|
-
resolve: ({ name, fen }) => {
|
|
18
|
-
const pgn = fen ? new Chess(fen).pgn() : undefined;
|
|
19
|
-
return {
|
|
20
|
-
data: {
|
|
21
|
-
object: Obj.make(ChessType, { name, fen, pgn }),
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
|
|
10
|
-
import { ChessContainer } from '../components';
|
|
11
|
-
import { meta } from '../meta';
|
|
12
|
-
import { ChessType } from '../types';
|
|
13
|
-
|
|
14
|
-
export default () =>
|
|
15
|
-
contributes(Capabilities.ReactSurface, [
|
|
16
|
-
createSurface({
|
|
17
|
-
id: meta.id,
|
|
18
|
-
role: ['article', 'section', 'card--intrinsic', 'card--extrinsic', 'card--popover', 'card--transclusion'],
|
|
19
|
-
// TODO(burdon): Could this be standardized so that we don't require a subject property (like below)?
|
|
20
|
-
filter: (data): data is { subject: ChessType } => Obj.instanceOf(ChessType, data.subject),
|
|
21
|
-
component: ({ data, role }) => <ChessContainer game={data.subject} role={role} />,
|
|
22
|
-
}),
|
|
23
|
-
]);
|
package/src/components/Chess.tsx
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
-
import React, { type PropsWithChildren, useCallback, useEffect, useMemo } from 'react';
|
|
7
|
-
|
|
8
|
-
import { log } from '@dxos/log';
|
|
9
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
-
import { ChessModel, Gameboard, Chessboard, type GameboardRootProps } from '@dxos/react-ui-gameboard';
|
|
11
|
-
|
|
12
|
-
import { type ChessType } from '../types';
|
|
13
|
-
|
|
14
|
-
const ChessRoot = ({ game, children }: PropsWithChildren<{ game: ChessType }>) => {
|
|
15
|
-
const model = useMemo(() => new ChessModel(), []);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!model || game.pgn !== model?.game.pgn()) {
|
|
18
|
-
const chess = new ChessJS();
|
|
19
|
-
if (game.pgn) {
|
|
20
|
-
try {
|
|
21
|
-
chess.loadPgn(game.pgn);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
log.catch(err, { game });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
model.initialize(chess.fen());
|
|
28
|
-
}
|
|
29
|
-
}, [game.pgn]);
|
|
30
|
-
|
|
31
|
-
const space = getSpace(game);
|
|
32
|
-
if (!space) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const handleDrop = useCallback<NonNullable<GameboardRootProps['onDrop']>>(
|
|
37
|
-
(move) => {
|
|
38
|
-
if (model.makeMove(move)) {
|
|
39
|
-
game.pgn = model.game.pgn();
|
|
40
|
-
game.fen = model.game.fen();
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false;
|
|
45
|
-
},
|
|
46
|
-
[model],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Gameboard.Root model={model} onDrop={handleDrop}>
|
|
51
|
-
{children}
|
|
52
|
-
</Gameboard.Root>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Chess = {
|
|
57
|
-
Root: ChessRoot,
|
|
58
|
-
Content: Gameboard.Content,
|
|
59
|
-
Board: Chessboard,
|
|
60
|
-
};
|