@ankhorage/zora 21.1.4 → 22.0.0

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 (109) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -1
  3. package/dist/features/authoring/index.d.ts +0 -4
  4. package/dist/features/authoring/index.d.ts.map +1 -1
  5. package/dist/features/authoring/index.js +0 -3
  6. package/dist/features/authoring/index.js.map +1 -1
  7. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts +1 -1
  8. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts.map +1 -1
  9. package/dist/features/chess/adapters/inbound/ChessBoard.js +23 -7
  10. package/dist/features/chess/adapters/inbound/ChessBoard.js.map +1 -1
  11. package/dist/features/chess/meta.d.ts +68 -0
  12. package/dist/features/chess/meta.d.ts.map +1 -1
  13. package/dist/features/chess/meta.js +36 -1
  14. package/dist/features/chess/meta.js.map +1 -1
  15. package/dist/features/chess/public.d.ts +3 -1
  16. package/dist/features/chess/public.d.ts.map +1 -1
  17. package/dist/features/chess/public.js +2 -0
  18. package/dist/features/chess/public.js.map +1 -1
  19. package/dist/features/chess/utils/chessEngine.d.ts +8 -0
  20. package/dist/features/chess/utils/chessEngine.d.ts.map +1 -0
  21. package/dist/features/chess/utils/chessEngine.js +71 -0
  22. package/dist/features/chess/utils/chessEngine.js.map +1 -0
  23. package/dist/features/tabletop/meta.d.ts +32 -0
  24. package/dist/features/tabletop/meta.d.ts.map +1 -1
  25. package/dist/features/tabletop/meta.js +24 -0
  26. package/dist/features/tabletop/meta.js.map +1 -1
  27. package/dist/features/tabletop/public.d.ts +1 -0
  28. package/dist/features/tabletop/public.d.ts.map +1 -1
  29. package/dist/features/tabletop/public.js +1 -0
  30. package/dist/features/tabletop/public.js.map +1 -1
  31. package/dist/index.d.ts +4 -7
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +3 -5
  34. package/dist/index.js.map +1 -1
  35. package/dist/types/chess.d.ts +10 -0
  36. package/dist/types/chess.d.ts.map +1 -1
  37. package/dist/types/chess.js.map +1 -1
  38. package/package.json +4 -3
  39. package/src/features/authoring/featureManifest.test.ts +46 -10
  40. package/src/features/authoring/index.ts +0 -8
  41. package/src/features/chess/adapters/inbound/ChessBoard.tsx +34 -11
  42. package/src/features/chess/meta.ts +36 -1
  43. package/src/features/chess/public.test.tsx +83 -0
  44. package/src/features/chess/public.ts +3 -0
  45. package/src/features/chess/utils/chessEngine.test.ts +35 -0
  46. package/src/features/chess/utils/chessEngine.ts +83 -0
  47. package/src/features/chessTabletopOwnership.test.ts +8 -4
  48. package/src/features/tabletop/meta.ts +24 -0
  49. package/src/features/tabletop/public.test.tsx +12 -0
  50. package/src/features/tabletop/public.ts +1 -0
  51. package/src/index.ts +7 -15
  52. package/src/structureOwnership.test.ts +2 -7
  53. package/src/types/chess.ts +11 -0
  54. package/web-dist/chunks/Accordion-784f23tq.js +3813 -0
  55. package/web-dist/components/card-back/CardBack.js +1 -1
  56. package/web-dist/components/card-hand/CardHand.js +1 -1
  57. package/web-dist/components/chess-board/ChessBoard.js +1 -1
  58. package/web-dist/components/opening-book/OpeningBook.js +1 -1
  59. package/web-dist/components/playing-card/PlayingCard.js +1 -1
  60. package/web-dist/components/poker-training-table/PokerTrainingTable.js +1 -1
  61. package/web-dist/components/tabletop-table/TabletopTable.js +1 -1
  62. package/web-dist/manifest.json +12 -24
  63. package/dist/features/plugin/ZORA_CORE_PLUGIN.d.ts +0 -4
  64. package/dist/features/plugin/ZORA_CORE_PLUGIN.d.ts.map +0 -1
  65. package/dist/features/plugin/ZORA_CORE_PLUGIN.js +0 -8
  66. package/dist/features/plugin/ZORA_CORE_PLUGIN.js.map +0 -1
  67. package/dist/features/plugin/ZORA_CORE_PLUGIN_METADATA.d.ts +0 -3
  68. package/dist/features/plugin/ZORA_CORE_PLUGIN_METADATA.d.ts.map +0 -1
  69. package/dist/features/plugin/ZORA_CORE_PLUGIN_METADATA.js +0 -36
  70. package/dist/features/plugin/ZORA_CORE_PLUGIN_METADATA.js.map +0 -1
  71. package/dist/features/plugin/application/use-cases/composeZoraPluginMetadata.d.ts +0 -4
  72. package/dist/features/plugin/application/use-cases/composeZoraPluginMetadata.d.ts.map +0 -1
  73. package/dist/features/plugin/application/use-cases/composeZoraPluginMetadata.js +0 -106
  74. package/dist/features/plugin/application/use-cases/composeZoraPluginMetadata.js.map +0 -1
  75. package/dist/features/plugin/application/use-cases/composeZoraPlugins.d.ts +0 -4
  76. package/dist/features/plugin/application/use-cases/composeZoraPlugins.d.ts.map +0 -1
  77. package/dist/features/plugin/application/use-cases/composeZoraPlugins.js +0 -41
  78. package/dist/features/plugin/application/use-cases/composeZoraPlugins.js.map +0 -1
  79. package/dist/features/plugin/domain/ZoraPluginCompositionError.d.ts +0 -14
  80. package/dist/features/plugin/domain/ZoraPluginCompositionError.d.ts.map +0 -1
  81. package/dist/features/plugin/domain/ZoraPluginCompositionError.js +0 -14
  82. package/dist/features/plugin/domain/ZoraPluginCompositionError.js.map +0 -1
  83. package/dist/features/plugin/public.d.ts +0 -4
  84. package/dist/features/plugin/public.d.ts.map +0 -1
  85. package/dist/features/plugin/public.js +0 -4
  86. package/dist/features/plugin/public.js.map +0 -1
  87. package/dist/features/plugin/runtime.d.ts +0 -3
  88. package/dist/features/plugin/runtime.d.ts.map +0 -1
  89. package/dist/features/plugin/runtime.js +0 -3
  90. package/dist/features/plugin/runtime.js.map +0 -1
  91. package/dist/types/plugin.d.ts +0 -29
  92. package/dist/types/plugin.d.ts.map +0 -1
  93. package/dist/types/plugin.js +0 -2
  94. package/dist/types/plugin.js.map +0 -1
  95. package/src/features/plugin/ZORA_CORE_PLUGIN.ts +0 -9
  96. package/src/features/plugin/ZORA_CORE_PLUGIN_METADATA.ts +0 -49
  97. package/src/features/plugin/application/use-cases/composeZoraPluginMetadata.ts +0 -166
  98. package/src/features/plugin/application/use-cases/composeZoraPlugins.ts +0 -76
  99. package/src/features/plugin/domain/ZoraPluginCompositionError.ts +0 -21
  100. package/src/features/plugin/pluginComposition.test.ts +0 -139
  101. package/src/features/plugin/public.ts +0 -3
  102. package/src/features/plugin/runtime.ts +0 -2
  103. package/src/types/plugin.ts +0 -43
  104. package/web-dist/chunks/Accordion-86z2tvvz.js +0 -321
  105. package/web-dist/components/zora-plugin-composition-error/ZoraPluginCompositionError.d.ts +0 -3
  106. package/web-dist/components/zora-plugin-composition-error/ZoraPluginCompositionError.js +0 -17
  107. package/web-dist/components/zora-plugin-composition-error/index.d.ts +0 -1
  108. package/web-dist/components/zora-plugin-composition-error/index.js +0 -2
  109. /package/web-dist/chunks/{Accordion-57mn1j9e.js → Accordion-z585n0mr.js} +0 -0
@@ -1,321 +0,0 @@
1
- 'use client';
2
- import {
3
- require_cjs
4
- } from "./Accordion-7hn324r1.js";
5
- import {
6
- withZoraThemeScope
7
- } from "./Accordion-k3bc4kad.js";
8
- import {
9
- useZoraTheme2
10
- } from "./Accordion-7zfskq1s.js";
11
- import {
12
- __toESM
13
- } from "./Accordion-9qvmwkxe.js";
14
-
15
- // src/features/chess/adapters/inbound/ChessBoard.tsx
16
- var import_react_native = __toESM(require_cjs(), 1);
17
-
18
- // src/features/chess/utils/createBoardSquares.ts
19
- var files = ["a", "b", "c", "d", "e", "f", "g", "h"];
20
- var ranks = ["1", "2", "3", "4", "5", "6", "7", "8"];
21
- function createBoardSquares(orientation) {
22
- const displayedRanks = orientation === "white" ? [...ranks].reverse() : [...ranks];
23
- const displayedFiles = orientation === "white" ? [...files] : [...files].reverse();
24
- return displayedRanks.flatMap((rank) => displayedFiles.map((file) => `${file}${rank}`));
25
- }
26
-
27
- // src/features/chess/utils/createChessBoardColorScheme.ts
28
- function createChessBoardColorScheme(theme, overrides) {
29
- return {
30
- border: theme.semantics.neutral.divider,
31
- coordinateText: theme.semantics.content.muted,
32
- darkPiece: theme.semantics.content.default,
33
- darkSquare: theme.semantics.neutral.surfaceHover,
34
- darkSquareText: theme.semantics.content.muted,
35
- lastMoveFrom: theme.semantics.warning.softBg,
36
- lastMoveTo: theme.semantics.warning.softBg,
37
- legalTarget: theme.semantics.success.softBg,
38
- lightPiece: theme.semantics.content.default,
39
- lightSquare: theme.semantics.neutral.surface,
40
- lightSquareText: theme.semantics.content.muted,
41
- selectedSquare: theme.semantics.action.primary.softBg,
42
- ...overrides
43
- };
44
- }
45
-
46
- // src/features/chess/utils/isLightSquare.ts
47
- var files2 = "abcdefgh";
48
- function isLightSquare(square) {
49
- return (files2.indexOf(square[0] ?? "") + Number(square[1]) - 1) % 2 === 1;
50
- }
51
-
52
- // src/features/chess/adapters/inbound/ChessBoard.tsx
53
- import { jsx, jsxs } from "react/jsx-runtime";
54
- var symbols = new Map([
55
- ["white:p", "♙"],
56
- ["white:n", "♘"],
57
- ["white:b", "♗"],
58
- ["white:r", "♖"],
59
- ["white:q", "♕"],
60
- ["white:k", "♔"],
61
- ["black:p", "♟"],
62
- ["black:n", "♞"],
63
- ["black:b", "♝"],
64
- ["black:r", "♜"],
65
- ["black:q", "♛"],
66
- ["black:k", "♚"]
67
- ]);
68
- var ChessBoard2 = withZoraThemeScope(ChessBoardInner);
69
- function ChessBoardInner({
70
- pieces = [],
71
- orientation = "white",
72
- selectedSquare = null,
73
- legalTargets = [],
74
- lastMove = null,
75
- disabled = false,
76
- showCoordinates = false,
77
- colorScheme,
78
- onSquarePress,
79
- onMoveAttempt,
80
- renderPiece,
81
- interactionPolicy,
82
- testID
83
- }) {
84
- const { theme } = useZoraTheme2();
85
- const colors = createChessBoardColorScheme(theme, colorScheme);
86
- const squares = createBoardSquares(orientation);
87
- const piecesBySquare = new Map(pieces.map((piece) => [piece.square, piece]));
88
- const legalTargetSet = new Set(legalTargets);
89
- const pressSquare = (square) => {
90
- if (disabled || interactionPolicy === "passive")
91
- return;
92
- onSquarePress?.(square);
93
- if (selectedSquare !== null && selectedSquare !== square)
94
- onMoveAttempt?.({ from: selectedSquare, to: square });
95
- };
96
- return /* @__PURE__ */ jsx(import_react_native.View, {
97
- accessibilityLabel: "Chess board",
98
- style: [styles.board, { borderColor: colors.border, opacity: disabled ? 0.56 : 1 }],
99
- testID,
100
- children: squares.map((square) => {
101
- const piece = piecesBySquare.get(square);
102
- const light = isLightSquare(square);
103
- const isTarget = legalTargetSet.has(square);
104
- const backgroundColor = selectedSquare === square ? colors.selectedSquare : isTarget ? colors.legalTarget : lastMove?.from === square ? colors.lastMoveFrom : lastMove?.to === square ? colors.lastMoveTo : light ? colors.lightSquare : colors.darkSquare;
105
- const pieceContent = piece === undefined ? null : renderPiece ? renderPiece({
106
- color: piece.color === "white" ? colors.lightPiece : colors.darkPiece,
107
- piece: piece.piece,
108
- square
109
- }) : symbols.get(`${piece.color}:${piece.piece.toLowerCase()}`) ?? piece.piece;
110
- return /* @__PURE__ */ jsxs(import_react_native.Pressable, {
111
- accessibilityLabel: square,
112
- accessibilityRole: "button",
113
- disabled: disabled || interactionPolicy === "passive",
114
- onPress: () => pressSquare(square),
115
- style: [styles.square, { backgroundColor }],
116
- testID: testID ? `${testID}-square-${square}` : undefined,
117
- children: [
118
- showCoordinates ? /* @__PURE__ */ jsx(import_react_native.Text, {
119
- style: [
120
- styles.coordinate,
121
- { color: light ? colors.lightSquareText : colors.darkSquareText }
122
- ],
123
- children: square
124
- }) : null,
125
- piece === undefined ? null : /* @__PURE__ */ jsx(import_react_native.View, {
126
- pointerEvents: "none",
127
- style: styles.pieceContainer,
128
- children: renderPiece ? pieceContent : /* @__PURE__ */ jsx(import_react_native.Text, {
129
- style: [
130
- styles.piece,
131
- { color: piece.color === "white" ? colors.lightPiece : colors.darkPiece }
132
- ],
133
- children: pieceContent
134
- })
135
- })
136
- ]
137
- }, square);
138
- })
139
- });
140
- }
141
- var styles = import_react_native.StyleSheet.create({
142
- board: {
143
- aspectRatio: 1,
144
- borderRadius: 12,
145
- borderWidth: import_react_native.StyleSheet.hairlineWidth,
146
- flexDirection: "row",
147
- flexWrap: "wrap",
148
- overflow: "hidden",
149
- width: "100%"
150
- },
151
- coordinate: {
152
- fontSize: 9,
153
- fontWeight: "600",
154
- left: 3,
155
- opacity: 0.72,
156
- position: "absolute",
157
- top: 2,
158
- zIndex: 2
159
- },
160
- piece: { fontSize: 32, fontWeight: "600", lineHeight: 38 },
161
- pieceContainer: {
162
- alignItems: "center",
163
- bottom: 0,
164
- justifyContent: "center",
165
- left: 0,
166
- position: "absolute",
167
- right: 0,
168
- top: 0
169
- },
170
- square: {
171
- alignItems: "center",
172
- aspectRatio: 1,
173
- width: "12.5%",
174
- justifyContent: "center",
175
- position: "relative"
176
- }
177
- });
178
-
179
- // src/features/chess/adapters/inbound/OpeningBook.tsx
180
- var import_react_native2 = __toESM(require_cjs(), 1);
181
-
182
- // src/features/chess/utils/createOpeningBookColorScheme.ts
183
- function createOpeningBookColorScheme(theme, overrides) {
184
- return {
185
- border: theme.semantics.neutral.divider,
186
- metricSurface: theme.semantics.neutral.surface,
187
- primaryText: theme.semantics.content.default,
188
- secondaryText: theme.semantics.content.muted,
189
- selectedSurface: theme.semantics.action.primary.softBg,
190
- surface: theme.semantics.neutral.surface,
191
- surfaceHover: theme.semantics.neutral.surfaceHover,
192
- titleText: theme.semantics.content.default,
193
- ...overrides
194
- };
195
- }
196
-
197
- // src/features/chess/adapters/inbound/OpeningBook.tsx
198
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
199
- var OpeningBook2 = withZoraThemeScope(OpeningBookInner);
200
- function rate(label, value) {
201
- if (value === undefined || !Number.isFinite(value))
202
- return;
203
- return `${label} ${Math.round(value <= 1 ? value * 100 : value)}%`;
204
- }
205
- function moveKey(move) {
206
- return move.uci ?? move.fen ?? move.san;
207
- }
208
- function OpeningBookInner({
209
- moves = [],
210
- title = "Opening book",
211
- loading = false,
212
- errorText,
213
- emptyText = "No book moves for this position.",
214
- selectedMove = null,
215
- colorScheme,
216
- onMovePress,
217
- interactionPolicy,
218
- testID
219
- }) {
220
- const { theme } = useZoraTheme2();
221
- const colors = createOpeningBookColorScheme(theme, colorScheme);
222
- const stateText = loading ? "Loading opening moves…" : errorText ?? emptyText;
223
- const showState = loading || errorText !== undefined || moves.length === 0;
224
- return /* @__PURE__ */ jsxs2(import_react_native2.View, {
225
- accessibilityLabel: title,
226
- style: [
227
- styles2.root,
228
- {
229
- borderColor: colors.border,
230
- backgroundColor: colors.surface
231
- }
232
- ],
233
- testID,
234
- children: [
235
- /* @__PURE__ */ jsx2(import_react_native2.Text, {
236
- style: [styles2.title, { color: colors.titleText }],
237
- children: title
238
- }),
239
- !showState ? /* @__PURE__ */ jsx2(import_react_native2.View, {
240
- style: styles2.moves,
241
- children: moves.map((move) => {
242
- const selected = selectedMove !== null && (selectedMove === move.san || selectedMove === move.uci || selectedMove === move.fen);
243
- const details = [
244
- move.eco,
245
- move.name,
246
- move.games === undefined ? undefined : `${move.games} games`
247
- ].filter((part) => typeof part === "string" && part.length > 0);
248
- const stats = [
249
- rate("W", move.whiteWinRate),
250
- rate("D", move.drawRate),
251
- rate("B", move.blackWinRate)
252
- ].filter((part) => part !== undefined);
253
- return /* @__PURE__ */ jsxs2(import_react_native2.Pressable, {
254
- accessibilityRole: "button",
255
- disabled: onMovePress === undefined || interactionPolicy === "passive",
256
- onPress: () => {
257
- if (interactionPolicy === "passive")
258
- return;
259
- onMovePress?.(move);
260
- },
261
- style: [
262
- styles2.move,
263
- {
264
- backgroundColor: selected ? colors.selectedSurface : colors.surfaceHover,
265
- borderColor: colors.border
266
- }
267
- ],
268
- testID: testID ? `${testID}-move-${move.san}` : undefined,
269
- children: [
270
- /* @__PURE__ */ jsxs2(import_react_native2.View, {
271
- style: styles2.moveMain,
272
- children: [
273
- /* @__PURE__ */ jsx2(import_react_native2.Text, {
274
- style: [styles2.san, { color: colors.primaryText }],
275
- children: move.san
276
- }),
277
- /* @__PURE__ */ jsx2(import_react_native2.Text, {
278
- style: [styles2.meta, { color: colors.secondaryText }],
279
- children: details.length > 0 ? details.join(" · ") : "Book move"
280
- })
281
- ]
282
- }),
283
- stats.length > 0 ? /* @__PURE__ */ jsx2(import_react_native2.View, {
284
- style: [styles2.metric, { backgroundColor: colors.metricSurface }],
285
- children: /* @__PURE__ */ jsx2(import_react_native2.Text, {
286
- style: [styles2.metricText, { color: colors.secondaryText }],
287
- children: stats.join(" ")
288
- })
289
- }) : null
290
- ]
291
- }, moveKey(move));
292
- })
293
- }) : /* @__PURE__ */ jsx2(import_react_native2.Text, {
294
- style: [styles2.stateText, { color: colors.secondaryText }],
295
- children: stateText
296
- })
297
- ]
298
- });
299
- }
300
- var styles2 = import_react_native2.StyleSheet.create({
301
- root: { borderRadius: 12, borderWidth: import_react_native2.StyleSheet.hairlineWidth, gap: 10, padding: 12 },
302
- title: { fontSize: 15, fontWeight: "700", lineHeight: 20 },
303
- stateText: { fontSize: 13, lineHeight: 18 },
304
- moves: { gap: 8 },
305
- move: {
306
- alignItems: "center",
307
- borderRadius: 10,
308
- borderWidth: import_react_native2.StyleSheet.hairlineWidth,
309
- flexDirection: "row",
310
- gap: 10,
311
- justifyContent: "space-between",
312
- paddingHorizontal: 10,
313
- paddingVertical: 8
314
- },
315
- moveMain: { flex: 1, gap: 2 },
316
- san: { fontSize: 16, fontWeight: "700", lineHeight: 20 },
317
- meta: { fontSize: 12, lineHeight: 16 },
318
- metric: { borderRadius: 999, paddingHorizontal: 8, paddingVertical: 4 },
319
- metricText: { fontSize: 11, fontWeight: "600" }
320
- });
321
- export { ChessBoard2, OpeningBook2 };
@@ -1,3 +0,0 @@
1
- import type React from 'react';
2
-
3
- export declare const ZoraPluginCompositionError: React.ComponentType<Record<string, unknown>>;
@@ -1,17 +0,0 @@
1
- 'use client';
2
- // src/features/plugin/domain/ZoraPluginCompositionError.ts
3
- class ZoraPluginCompositionError extends Error {
4
- code;
5
- packageName;
6
- componentName;
7
- constructor(args) {
8
- super(args.message);
9
- this.name = "ZoraPluginCompositionError";
10
- this.code = args.code;
11
- this.packageName = args.packageName;
12
- this.componentName = args.componentName;
13
- }
14
- }
15
- export {
16
- ZoraPluginCompositionError
17
- };
@@ -1 +0,0 @@
1
- export * from './ZoraPluginCompositionError';
@@ -1,2 +0,0 @@
1
- 'use client';
2
- export * from './ZoraPluginCompositionError.js';