@dxos/plugin-chess 0.8.4-main.b97322e → 0.8.4-main.f5c0578

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 (152) hide show
  1. package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs +90 -0
  2. package/dist/lib/browser/ChessboardContainer-NNIOQIRP.mjs.map +7 -0
  3. package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs +38 -0
  4. package/dist/lib/browser/blueprint-definition-OJQYAZGZ.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-2W3S5N6C.mjs +257 -0
  6. package/dist/lib/browser/chunk-2W3S5N6C.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-EJMPHRSR.mjs +94 -0
  8. package/dist/lib/browser/chunk-EJMPHRSR.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-OBJAHY6H.mjs +79 -0
  10. package/dist/lib/browser/chunk-OBJAHY6H.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-PE3IWOFR.mjs +28 -0
  12. package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-PPBBLHAC.mjs +8 -0
  14. package/dist/lib/browser/chunk-PPBBLHAC.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +42 -24
  16. package/dist/lib/browser/index.mjs.map +3 -3
  17. package/dist/lib/browser/{intent-resolver-KQYYX44R.mjs → intent-resolver-JWKKRNGG.mjs} +8 -11
  18. package/dist/lib/browser/intent-resolver-JWKKRNGG.mjs.map +7 -0
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/{react-surface-PLUCWIYP.mjs → react-surface-RIXD6RTS.mjs} +11 -9
  21. package/dist/lib/browser/react-surface-RIXD6RTS.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +6 -7
  23. package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs +91 -0
  24. package/dist/lib/node-esm/ChessboardContainer-FCPUV2T2.mjs.map +7 -0
  25. package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs +39 -0
  26. package/dist/lib/node-esm/blueprint-definition-F5SGHCDA.mjs.map +7 -0
  27. package/dist/lib/node-esm/{chunk-QFINI7CC.mjs → chunk-42EKKMOO.mjs} +3 -3
  28. package/dist/lib/node-esm/chunk-42EKKMOO.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-5APYXPBX.mjs +95 -0
  30. package/dist/lib/node-esm/chunk-5APYXPBX.mjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-6OWCPDUA.mjs +29 -0
  32. package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-LCCUF5X5.mjs +80 -0
  34. package/dist/lib/node-esm/chunk-LCCUF5X5.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-QAGOXJGH.mjs +258 -0
  36. package/dist/lib/node-esm/chunk-QAGOXJGH.mjs.map +7 -0
  37. package/dist/lib/node-esm/index.mjs +42 -24
  38. package/dist/lib/node-esm/index.mjs.map +3 -3
  39. package/dist/lib/node-esm/{intent-resolver-GXK2JROQ.mjs → intent-resolver-G6XJAW6C.mjs} +8 -11
  40. package/dist/lib/node-esm/intent-resolver-G6XJAW6C.mjs.map +7 -0
  41. package/dist/lib/node-esm/meta.json +1 -1
  42. package/dist/lib/node-esm/{react-surface-NGLNIWN3.mjs → react-surface-GGRDWZJT.mjs} +11 -9
  43. package/dist/lib/node-esm/react-surface-GGRDWZJT.mjs.map +7 -0
  44. package/dist/lib/node-esm/types/index.mjs +6 -7
  45. package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
  46. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
  48. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/index.d.ts +1 -1
  50. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  51. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  52. package/dist/types/src/components/Card.stories.d.ts +49 -0
  53. package/dist/types/src/components/Card.stories.d.ts.map +1 -0
  54. package/dist/types/src/components/Chessboard.d.ts +32 -0
  55. package/dist/types/src/components/Chessboard.d.ts.map +1 -0
  56. package/dist/types/src/components/Chessboard.stories.d.ts +39 -5
  57. package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
  58. package/dist/types/src/components/ChessboardArticle.d.ts +6 -0
  59. package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -0
  60. package/dist/types/src/components/ChessboardContainer.d.ts +9 -0
  61. package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -0
  62. package/dist/types/src/components/ChessboardInfo.d.ts +20 -0
  63. package/dist/types/src/components/ChessboardInfo.d.ts.map +1 -0
  64. package/dist/types/src/components/ChessboardPlayers.d.ts +8 -0
  65. package/dist/types/src/components/ChessboardPlayers.d.ts.map +1 -0
  66. package/dist/types/src/components/index.d.ts +2 -5
  67. package/dist/types/src/components/index.d.ts.map +1 -1
  68. package/dist/types/src/functions/index.d.ts +3 -0
  69. package/dist/types/src/functions/index.d.ts.map +1 -0
  70. package/dist/types/src/functions/move.d.ts +6 -0
  71. package/dist/types/src/functions/move.d.ts.map +1 -0
  72. package/dist/types/src/functions/play.d.ts +8 -0
  73. package/dist/types/src/functions/play.d.ts.map +1 -0
  74. package/dist/types/src/index.d.ts +2 -0
  75. package/dist/types/src/index.d.ts.map +1 -1
  76. package/dist/types/src/meta.d.ts.map +1 -1
  77. package/dist/types/src/translations.d.ts +8 -2
  78. package/dist/types/src/translations.d.ts.map +1 -1
  79. package/dist/types/src/types/Chess.d.ts +24 -0
  80. package/dist/types/src/types/Chess.d.ts.map +1 -0
  81. package/dist/types/src/types/ChessAction.d.ts +23 -0
  82. package/dist/types/src/types/ChessAction.d.ts.map +1 -0
  83. package/dist/types/src/types/index.d.ts +2 -2
  84. package/dist/types/src/types/index.d.ts.map +1 -1
  85. package/dist/types/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +29 -25
  87. package/src/ChessPlugin.tsx +7 -7
  88. package/src/capabilities/artifact-definition.ts +24 -20
  89. package/src/capabilities/blueprint-definition.ts +34 -0
  90. package/src/capabilities/index.ts +1 -1
  91. package/src/capabilities/intent-resolver.ts +3 -7
  92. package/src/capabilities/react-surface.tsx +5 -5
  93. package/src/components/Card.stories.tsx +68 -0
  94. package/src/components/Chessboard.stories.tsx +33 -24
  95. package/src/components/Chessboard.tsx +101 -0
  96. package/src/components/ChessboardArticle.tsx +57 -0
  97. package/src/components/ChessboardContainer.tsx +44 -0
  98. package/src/components/ChessboardInfo.tsx +140 -0
  99. package/src/components/{PlayerSelector.tsx → ChessboardPlayers.tsx} +25 -10
  100. package/src/components/index.ts +2 -2
  101. package/src/functions/index.ts +6 -0
  102. package/src/functions/move.ts +43 -0
  103. package/src/functions/play.ts +45 -0
  104. package/src/index.ts +2 -0
  105. package/src/meta.ts +4 -2
  106. package/src/translations.ts +8 -2
  107. package/src/types/Chess.ts +56 -0
  108. package/src/types/ChessAction.ts +19 -0
  109. package/src/types/index.ts +2 -2
  110. package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs +0 -129
  111. package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs.map +0 -7
  112. package/dist/lib/browser/artifact-definition-A2FSM255.mjs +0 -182
  113. package/dist/lib/browser/artifact-definition-A2FSM255.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-A3WEUKPK.mjs +0 -61
  115. package/dist/lib/browser/chunk-A3WEUKPK.mjs.map +0 -7
  116. package/dist/lib/browser/chunk-KDADGLPC.mjs +0 -8
  117. package/dist/lib/browser/chunk-KDADGLPC.mjs.map +0 -7
  118. package/dist/lib/browser/chunk-ZXH3N4NA.mjs +0 -66
  119. package/dist/lib/browser/chunk-ZXH3N4NA.mjs.map +0 -7
  120. package/dist/lib/browser/intent-resolver-KQYYX44R.mjs.map +0 -7
  121. package/dist/lib/browser/react-surface-PLUCWIYP.mjs.map +0 -7
  122. package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs +0 -130
  123. package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map +0 -7
  124. package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs +0 -183
  125. package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map +0 -7
  126. package/dist/lib/node-esm/chunk-27D3JA3K.mjs +0 -68
  127. package/dist/lib/node-esm/chunk-27D3JA3K.mjs.map +0 -7
  128. package/dist/lib/node-esm/chunk-IS3Y25PL.mjs +0 -63
  129. package/dist/lib/node-esm/chunk-IS3Y25PL.mjs.map +0 -7
  130. package/dist/lib/node-esm/chunk-QFINI7CC.mjs.map +0 -7
  131. package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map +0 -7
  132. package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map +0 -7
  133. package/dist/types/src/components/Chess.d.ts +0 -14
  134. package/dist/types/src/components/Chess.d.ts.map +0 -1
  135. package/dist/types/src/components/ChessContainer.d.ts +0 -8
  136. package/dist/types/src/components/ChessContainer.d.ts.map +0 -1
  137. package/dist/types/src/components/ChessContainer.stories.d.ts +0 -23
  138. package/dist/types/src/components/ChessContainer.stories.d.ts.map +0 -1
  139. package/dist/types/src/components/ChessPanel.d.ts +0 -11
  140. package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
  141. package/dist/types/src/components/PlayerSelector.d.ts +0 -8
  142. package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
  143. package/dist/types/src/types/schema.d.ts +0 -29
  144. package/dist/types/src/types/schema.d.ts.map +0 -1
  145. package/dist/types/src/types/types.d.ts +0 -32
  146. package/dist/types/src/types/types.d.ts.map +0 -1
  147. package/src/components/Chess.tsx +0 -60
  148. package/src/components/ChessContainer.stories.tsx +0 -110
  149. package/src/components/ChessContainer.tsx +0 -71
  150. package/src/components/ChessPanel.tsx +0 -67
  151. package/src/types/schema.ts +0 -34
  152. package/src/types/types.ts +0 -20
@@ -1,110 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
8
- import React, { useEffect, useState } from 'react';
9
-
10
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
11
- import { withPluginManager } from '@dxos/app-framework/testing';
12
- import { Filter, Obj } from '@dxos/echo';
13
- import { ClientPlugin } from '@dxos/plugin-client';
14
- import { SpacePlugin } from '@dxos/plugin-space';
15
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
16
- import { ThemePlugin } from '@dxos/plugin-theme';
17
- import { useClient } from '@dxos/react-client';
18
- import { useQuery, useSpaces } from '@dxos/react-client/echo';
19
- import { CardContainer } from '@dxos/react-ui-stack/testing';
20
- import { defaultTx } from '@dxos/react-ui-theme';
21
- import { withLayout } from '@dxos/storybook-utils';
22
-
23
- import ChessContainer from './ChessContainer';
24
- import { ChessType } from '../types';
25
-
26
- type StoryProps = {
27
- role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
28
- };
29
-
30
- const render: Meta<StoryProps>['render'] = ({ role }) => {
31
- const _client = useClient();
32
- const spaces = useSpaces();
33
- const space = spaces[spaces.length - 1];
34
- const games = useQuery(space, Filter.type(ChessType));
35
- const [game, setGame] = useState<ChessType>();
36
-
37
- useEffect(() => {
38
- if (games.length && !game) {
39
- const board = games[0];
40
- setGame(board);
41
- }
42
- }, [games]);
43
-
44
- if (!game) {
45
- return <span>…</span>;
46
- }
47
-
48
- return (
49
- <CardContainer icon='ph--castle-turret--regular' role={role}>
50
- <ChessContainer game={game} role={role} />
51
- </CardContainer>
52
- );
53
- };
54
-
55
- const meta: Meta<StoryProps> = {
56
- title: 'Cards/plugin-chess',
57
- render,
58
- decorators: [
59
- withLayout(),
60
- withPluginManager({
61
- plugins: [
62
- ThemePlugin({ tx: defaultTx }),
63
- ClientPlugin({
64
- types: [ChessType],
65
- onClientInitialized: async (_, client) => {
66
- await client.halo.createIdentity();
67
- const space = await client.spaces.create();
68
- await space.waitUntilReady();
69
- const game = Obj.make(ChessType, {
70
- name: 'Example Chess Game',
71
- playerWhite: 'Player 1',
72
- playerBlack: 'Player 2',
73
- moves: [],
74
- pgn: '',
75
- fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', // Starting position
76
- });
77
- space.db.add(game);
78
- },
79
- }),
80
- StorybookLayoutPlugin(),
81
- SpacePlugin(),
82
- IntentPlugin(),
83
- SettingsPlugin(),
84
- ],
85
- }),
86
- ],
87
- parameters: {
88
- layout: 'centered',
89
- },
90
- };
91
-
92
- export default meta;
93
-
94
- export const Popover = {
95
- args: {
96
- role: 'card--popover',
97
- },
98
- };
99
-
100
- export const Intrinsic = {
101
- args: {
102
- role: 'card--intrinsic',
103
- },
104
- };
105
-
106
- export const Extrinsic = {
107
- args: {
108
- role: 'card--extrinsic',
109
- },
110
- };
@@ -1,71 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { getSpace } from '@dxos/react-client/echo';
8
- import { StackItem } from '@dxos/react-ui-stack';
9
-
10
- import { Chess } from './Chess';
11
- import { PlayerSelector } from './PlayerSelector';
12
- import { type ChessType } from '../types';
13
-
14
- const containFragment = 'is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]';
15
-
16
- const ChessContainer = ({ game, role }: { game: ChessType; role?: string }) => {
17
- const space = getSpace(game);
18
-
19
- if (!space) {
20
- return null;
21
- }
22
-
23
- switch (role) {
24
- case 'card--popover': {
25
- return (
26
- <Chess.Root game={game}>
27
- <div role='none' className='popover-square size-container'>
28
- <Chess.Board classNames={containFragment} />
29
- </div>
30
- </Chess.Root>
31
- );
32
- }
33
- case 'card--extrinsic': {
34
- return (
35
- <Chess.Root game={game}>
36
- <div role='none' className='grid is-full bs-full size-container place-content-center'>
37
- <Chess.Board classNames={containFragment} />
38
- </div>
39
- </Chess.Root>
40
- );
41
- }
42
- case 'card--intrinsic': {
43
- return (
44
- <Chess.Root game={game}>
45
- <Chess.Board />
46
- </Chess.Root>
47
- );
48
- }
49
- default: {
50
- return (
51
- <StackItem.Content>
52
- <div role='none' className='grid grid-rows-[60px_1fr_60px] grow overflow-hidden'>
53
- <div />
54
-
55
- <div className='flex m-4 overflow-hidden'>
56
- <Chess.Root game={game}>
57
- <Chess.Content>
58
- <Chess.Board />
59
- </Chess.Content>
60
- </Chess.Root>
61
- </div>
62
-
63
- <PlayerSelector space={space} game={game} />
64
- </div>
65
- </StackItem.Content>
66
- );
67
- }
68
- }
69
- };
70
-
71
- export default ChessContainer;
@@ -1,67 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Color } from 'chess.js';
6
- import React, { type FC } from 'react';
7
-
8
- import { type ThemedClassName, Icon } from '@dxos/react-ui';
9
- import { type ChessModel } from '@dxos/react-ui-gameboard';
10
- import { mx } from '@dxos/react-ui-theme';
11
-
12
- export type ChessPanelProps = ThemedClassName<{
13
- model: ChessModel;
14
- orientation?: Color;
15
- onFlip?: () => void;
16
- }>;
17
-
18
- export const ChessPanel: FC<ChessPanelProps> = ({ classNames, model, orientation = 'w', onFlip }) => {
19
- const game = model.game;
20
- const history = game.history();
21
- const label = game.isGameOver()
22
- ? game.isCheckmate()
23
- ? 'CHECKMATE'
24
- : game.isStalemate()
25
- ? 'STALEMATE'
26
- : 'DRAW'
27
- : game.isCheck()
28
- ? 'CHECK'
29
- : history.length
30
- ? `Move ${history.length}`
31
- : '';
32
-
33
- const Player = ({ color }: { color: Color }) => {
34
- const turn = color === game.turn();
35
-
36
- return (
37
- <div className='flex items-center'>
38
- <Icon
39
- icon={turn ? 'ph--circle--fill' : 'ph--circle--thin'}
40
- size={4}
41
- classNames={mx(turn && (game.isCheckmate() ? 'text-red-500' : 'text-green-500'))}
42
- />
43
- </div>
44
- );
45
- };
46
-
47
- return (
48
- <div className={mx('flex flex-col', classNames)}>
49
- <div className='flex items-center justify-between pl-2 pr-2 border-b' style={{ height: 32 }}>
50
- <Player color={orientation === 'w' ? 'b' : 'w'} />
51
- {onFlip && (
52
- <button onClick={onFlip}>
53
- <Icon icon='ph--arrow-u-right-down--thin' size={6} />
54
- </button>
55
- )}
56
- </div>
57
-
58
- <div className='flex flex-col justify-center pl-2 font-thin' style={{ height: 40 }}>
59
- {label}
60
- </div>
61
-
62
- <div className='flex items-center justify-between pl-2 pr-2 border-t' style={{ height: 32 }}>
63
- <Player color={orientation} />
64
- </div>
65
- </div>
66
- );
67
- };
@@ -1,34 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { Type } from '@dxos/echo';
8
-
9
- export const MoveSchema = Schema.mutable(
10
- Schema.partial(
11
- Schema.Struct({
12
- source: Schema.String,
13
- target: Schema.String,
14
- piece: Schema.String,
15
- }),
16
- ),
17
- );
18
-
19
- export const ChessType = Schema.Struct({
20
- name: Schema.optional(Schema.String),
21
- playerWhite: Schema.String,
22
- playerBlack: Schema.String,
23
- moves: Schema.mutable(Schema.Array(Schema.String)),
24
- // TODO(wittjosiah): Remove. Redundant with moves.
25
- pgn: Schema.String,
26
- fen: Schema.String,
27
- }).pipe(
28
- Schema.partial,
29
- Type.Obj({
30
- typename: 'dxos.org/type/Chess',
31
- version: '0.1.0',
32
- }),
33
- );
34
- export interface ChessType extends Schema.Schema.Type<typeof ChessType> {}
@@ -1,20 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { ChessType } from './schema';
8
- import { meta } from '../meta';
9
-
10
- export namespace ChessAction {
11
- export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
12
- input: Schema.Struct({
13
- name: Schema.optional(Schema.String),
14
- fen: Schema.optional(Schema.String),
15
- }),
16
- output: Schema.Struct({
17
- object: ChessType,
18
- }),
19
- }) {}
20
- }