gigaboard 1.4.0 → 1.4.2

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/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkK7D2C72S_cjs = require('./chunk-K7D2C72S.cjs');
3
+ var chunkUBD62NOI_cjs = require('./chunk-UBD62NOI.cjs');
4
4
  var chunkD45G3J5E_cjs = require('./chunk-D45G3J5E.cjs');
5
5
  require('./chunk-G6ZFOJZR.cjs');
6
6
  require('./chunk-AYVQCHSG.cjs');
@@ -161,11 +161,12 @@ function computeDynamicAeroGeometry(text, style, fontSize, isTerminal = true) {
161
161
  const resolvedStyle = style ?? "aero_chisel";
162
162
  const hasText = Boolean(text && text.trim().length > 0);
163
163
  if (!hasText) {
164
- const tipX = 2.8;
165
- const shoulderX = 0.2;
166
- const rearX = -1.2;
167
- const dockX2 = -1.8;
168
- const halfH2 = 2.2;
164
+ const scale2 = Math.max(1, fontSize / 2.45);
165
+ const tipX = 2.8 * scale2;
166
+ const shoulderX = 0.2 * scale2;
167
+ const rearX = -1.2 * scale2;
168
+ const dockX2 = -1.8 * scale2;
169
+ const halfH2 = 2.2 * scale2;
169
170
  const path2 = `M ${rearX},${-halfH2} L ${shoulderX},${-halfH2} L ${tipX},0 L ${shoulderX},${halfH2} L ${rearX},${halfH2} C ${dockX2},${halfH2} ${dockX2},${-halfH2} ${rearX},${-halfH2} Z`;
170
171
  return {
171
172
  path: path2,
@@ -178,16 +179,17 @@ function computeDynamicAeroGeometry(text, style, fontSize, isTerminal = true) {
178
179
  const charWidth = fontSize * 0.6;
179
180
  const textWidth = text.length * charWidth;
180
181
  const halfTextW = textWidth / 2;
181
- const padX = 0.75;
182
- const cabinW = Math.max(3.2, halfTextW + padX);
182
+ const scale = Math.max(1, fontSize / 2.45);
183
+ const padX = 0.75 * scale;
184
+ const cabinW = Math.max(3.2 * scale, halfTextW + padX);
183
185
  const halfH = Math.max(2.3, fontSize * 0.9);
184
- const rearInset = 0.65;
186
+ const rearInset = 0.65 * scale;
185
187
  const dockX = -cabinW - rearInset;
186
188
  let frontLen = 0;
187
189
  let path = "";
188
190
  if (resolvedStyle === "aero_chisel") {
189
191
  if (isTerminal) {
190
- const noseLead = 1.25;
192
+ const noseLead = 1.25 * scale;
191
193
  const tipX = cabinW + noseLead;
192
194
  frontLen = tipX;
193
195
  path = `M ${-cabinW},${-halfH} L ${cabinW},${-halfH} L ${tipX},0 L ${cabinW},${halfH} L ${-cabinW},${halfH} C ${dockX},${halfH} ${dockX},${-halfH} ${-cabinW},${-halfH} Z`;
@@ -1033,7 +1035,7 @@ function pieceName(cell) {
1033
1035
  }
1034
1036
  }
1035
1037
  function announcementFor(lastMove, board, wasCapture) {
1036
- const { from, to, kind, promotion } = chunkK7D2C72S_cjs.decodePackedMove(lastMove);
1038
+ const { from, to, kind, promotion } = chunkUBD62NOI_cjs.decodePackedMove(lastMove);
1037
1039
  if (kind === "castle") {
1038
1040
  const isKingside = (to & 7) > (from & 7);
1039
1041
  return isKingside ? "Castles kingside." : "Castles queenside.";
@@ -1258,20 +1260,20 @@ function positionOf4(index, orientation) {
1258
1260
  return { x: col * 12.5, y: row * 12.5 };
1259
1261
  }
1260
1262
  var CHOICE_ORDER = [
1261
- chunkK7D2C72S_cjs.PieceType.Queen,
1262
- chunkK7D2C72S_cjs.PieceType.Knight,
1263
- chunkK7D2C72S_cjs.PieceType.Rook,
1264
- chunkK7D2C72S_cjs.PieceType.Bishop
1263
+ chunkUBD62NOI_cjs.PieceType.Queen,
1264
+ chunkUBD62NOI_cjs.PieceType.Knight,
1265
+ chunkUBD62NOI_cjs.PieceType.Rook,
1266
+ chunkUBD62NOI_cjs.PieceType.Bishop
1265
1267
  ];
1266
1268
  var SHORTCUTS = {
1267
- q: chunkK7D2C72S_cjs.PieceType.Queen,
1268
- r: chunkK7D2C72S_cjs.PieceType.Rook,
1269
- b: chunkK7D2C72S_cjs.PieceType.Bishop,
1270
- n: chunkK7D2C72S_cjs.PieceType.Knight,
1271
- Q: chunkK7D2C72S_cjs.PieceType.Queen,
1272
- R: chunkK7D2C72S_cjs.PieceType.Rook,
1273
- B: chunkK7D2C72S_cjs.PieceType.Bishop,
1274
- N: chunkK7D2C72S_cjs.PieceType.Knight
1269
+ q: chunkUBD62NOI_cjs.PieceType.Queen,
1270
+ r: chunkUBD62NOI_cjs.PieceType.Rook,
1271
+ b: chunkUBD62NOI_cjs.PieceType.Bishop,
1272
+ n: chunkUBD62NOI_cjs.PieceType.Knight,
1273
+ Q: chunkUBD62NOI_cjs.PieceType.Queen,
1274
+ R: chunkUBD62NOI_cjs.PieceType.Rook,
1275
+ B: chunkUBD62NOI_cjs.PieceType.Bishop,
1276
+ N: chunkUBD62NOI_cjs.PieceType.Knight
1275
1277
  };
1276
1278
  function PromotionOverlay({
1277
1279
  from: _from,
@@ -1289,7 +1291,7 @@ function PromotionOverlay({
1289
1291
  [getPromotionPieceAriaLabel, color]
1290
1292
  );
1291
1293
  const [activeAnnouncement, setActiveAnnouncement] = react.useState(
1292
- () => getLabel(CHOICE_ORDER[0] ?? chunkK7D2C72S_cjs.PieceType.Queen)
1294
+ () => getLabel(CHOICE_ORDER[0] ?? chunkUBD62NOI_cjs.PieceType.Queen)
1293
1295
  );
1294
1296
  react.useEffect(() => {
1295
1297
  buttonRefs.current[0]?.focus();
@@ -1387,7 +1389,7 @@ function PromotionOverlay({
1387
1389
  overflow: "hidden"
1388
1390
  },
1389
1391
  children: CHOICE_ORDER.map((piece, index) => {
1390
- const cell = chunkK7D2C72S_cjs.encodeBoardCell(color, piece);
1392
+ const cell = chunkUBD62NOI_cjs.encodeBoardCell(color, piece);
1391
1393
  const label = getLabel(piece);
1392
1394
  return /* @__PURE__ */ jsxRuntime.jsx(
1393
1395
  "button",
@@ -1439,13 +1441,13 @@ var srOnlyStyle2 = {
1439
1441
  };
1440
1442
  function pieceName2(t) {
1441
1443
  switch (t) {
1442
- case chunkK7D2C72S_cjs.PieceType.Queen:
1444
+ case chunkUBD62NOI_cjs.PieceType.Queen:
1443
1445
  return "Queen";
1444
- case chunkK7D2C72S_cjs.PieceType.Rook:
1446
+ case chunkUBD62NOI_cjs.PieceType.Rook:
1445
1447
  return "Rook";
1446
- case chunkK7D2C72S_cjs.PieceType.Bishop:
1448
+ case chunkUBD62NOI_cjs.PieceType.Bishop:
1447
1449
  return "Bishop";
1448
- case chunkK7D2C72S_cjs.PieceType.Knight:
1450
+ case chunkUBD62NOI_cjs.PieceType.Knight:
1449
1451
  return "Knight";
1450
1452
  default:
1451
1453
  return "Piece";
@@ -1725,7 +1727,7 @@ function useArrowGesture(options) {
1725
1727
  function wouldPromote(fromCell, toIndex) {
1726
1728
  if (fromCell === 0) return false;
1727
1729
  const pieceType = (fromCell - 1) % 6;
1728
- if (pieceType !== chunkK7D2C72S_cjs.PieceType.Pawn) return false;
1730
+ if (pieceType !== chunkUBD62NOI_cjs.PieceType.Pawn) return false;
1729
1731
  const toRank = toIndex >> 3;
1730
1732
  return toRank === 0 || toRank === 7;
1731
1733
  }
@@ -1736,7 +1738,7 @@ function useClickToMove(model, onMove, onPromotionNeeded, enabled = true) {
1736
1738
  if (model === null) return;
1737
1739
  const snap = model.getSnapshot();
1738
1740
  const cell = snap.board[index] ?? 0;
1739
- const pieceColour = cell === 0 ? -1 : cell > 6 ? chunkK7D2C72S_cjs.Color.Black : chunkK7D2C72S_cjs.Color.White;
1741
+ const pieceColour = cell === 0 ? -1 : cell > 6 ? chunkUBD62NOI_cjs.Color.Black : chunkUBD62NOI_cjs.Color.White;
1740
1742
  if (snap.selected === null) {
1741
1743
  if (pieceColour === snap.turn) model.selectSquare(index);
1742
1744
  return;
@@ -1752,7 +1754,7 @@ function useClickToMove(model, onMove, onPromotionNeeded, enabled = true) {
1752
1754
  onPromotionNeeded(snap.selected, index);
1753
1755
  return;
1754
1756
  }
1755
- const played2 = model.tryMove(snap.selected, index, chunkK7D2C72S_cjs.PieceType.Queen);
1757
+ const played2 = model.tryMove(snap.selected, index, chunkUBD62NOI_cjs.PieceType.Queen);
1756
1758
  if (played2 !== null && onMove !== void 0) onMove(played2);
1757
1759
  return;
1758
1760
  }
@@ -1886,7 +1888,7 @@ function useDrag(options) {
1886
1888
  if (!enabled) return;
1887
1889
  const container = containerRef.current;
1888
1890
  if (container === null || game === null) return;
1889
- const controller = chunkK7D2C72S_cjs.createDragController(
1891
+ const controller = chunkUBD62NOI_cjs.createDragController(
1890
1892
  activationDistance === void 0 ? {} : { activationDistance }
1891
1893
  );
1892
1894
  let originEl = null;
@@ -2664,7 +2666,7 @@ function parseTransitionMove(transition) {
2664
2666
  };
2665
2667
  }
2666
2668
  function isPawn(cell) {
2667
- return !chunkK7D2C72S_cjs.isEmptyCell(cell) && chunkK7D2C72S_cjs.pieceTypeOf(cell) === 0;
2669
+ return !chunkUBD62NOI_cjs.isEmptyCell(cell) && chunkUBD62NOI_cjs.pieceTypeOf(cell) === 0;
2668
2670
  }
2669
2671
  function controlledFeedbackDescriptors(transition, previousBoard, nextBoard) {
2670
2672
  if (transition === null || transition === void 0) return null;
@@ -2673,25 +2675,25 @@ function controlledFeedbackDescriptors(transition, previousBoard, nextBoard) {
2673
2675
  const before = transition.direction === "forward" ? previousBoard : nextBoard;
2674
2676
  const after = transition.direction === "forward" ? nextBoard : previousBoard;
2675
2677
  const movingPiece = before[parsed.from] ?? 0;
2676
- if (chunkK7D2C72S_cjs.isEmptyCell(movingPiece)) return null;
2678
+ if (chunkUBD62NOI_cjs.isEmptyCell(movingPiece)) return null;
2677
2679
  const fromFile = parsed.from & 7;
2678
2680
  const toFile = parsed.to & 7;
2679
2681
  const targetBefore = before[parsed.to] ?? 0;
2680
2682
  const targetAfter = after[parsed.to] ?? 0;
2681
- if (chunkK7D2C72S_cjs.pieceTypeOf(movingPiece) === 5 && Math.abs(toFile - fromFile) === 2) {
2683
+ if (chunkUBD62NOI_cjs.pieceTypeOf(movingPiece) === 5 && Math.abs(toFile - fromFile) === 2) {
2682
2684
  return [{ kind: "castle" }];
2683
2685
  }
2684
- if (parsed.promotion !== null || isPawn(movingPiece) && (parsed.to >> 3 === 0 || parsed.to >> 3 === 7) && !chunkK7D2C72S_cjs.isEmptyCell(targetAfter) && chunkK7D2C72S_cjs.pieceTypeOf(targetAfter) !== 0) {
2686
+ if (parsed.promotion !== null || isPawn(movingPiece) && (parsed.to >> 3 === 0 || parsed.to >> 3 === 7) && !chunkUBD62NOI_cjs.isEmptyCell(targetAfter) && chunkUBD62NOI_cjs.pieceTypeOf(targetAfter) !== 0) {
2685
2687
  return [{ kind: "promotion" }];
2686
2688
  }
2687
- if (!chunkK7D2C72S_cjs.isEmptyCell(targetBefore) && chunkK7D2C72S_cjs.colorOf(targetBefore) !== chunkK7D2C72S_cjs.colorOf(movingPiece)) {
2689
+ if (!chunkUBD62NOI_cjs.isEmptyCell(targetBefore) && chunkUBD62NOI_cjs.colorOf(targetBefore) !== chunkUBD62NOI_cjs.colorOf(movingPiece)) {
2688
2690
  return [{ kind: "capture" }];
2689
2691
  }
2690
- if (isPawn(movingPiece) && fromFile !== toFile && chunkK7D2C72S_cjs.isEmptyCell(targetBefore)) {
2692
+ if (isPawn(movingPiece) && fromFile !== toFile && chunkUBD62NOI_cjs.isEmptyCell(targetBefore)) {
2691
2693
  const capturedSquare = parsed.from & -8 | toFile;
2692
2694
  const capturedBefore = before[capturedSquare] ?? 0;
2693
2695
  const capturedAfter = after[capturedSquare] ?? 0;
2694
- if (!chunkK7D2C72S_cjs.isEmptyCell(capturedBefore) && chunkK7D2C72S_cjs.colorOf(capturedBefore) !== chunkK7D2C72S_cjs.colorOf(movingPiece) && chunkK7D2C72S_cjs.isEmptyCell(capturedAfter)) {
2696
+ if (!chunkUBD62NOI_cjs.isEmptyCell(capturedBefore) && chunkUBD62NOI_cjs.colorOf(capturedBefore) !== chunkUBD62NOI_cjs.colorOf(movingPiece) && chunkUBD62NOI_cjs.isEmptyCell(capturedAfter)) {
2695
2697
  return [{ kind: "en-passant" }];
2696
2698
  }
2697
2699
  }
@@ -3198,15 +3200,15 @@ function useChessGame(options = {}) {
3198
3200
  const { fen, ...modelOptions } = options;
3199
3201
  const [initialModelOptions] = react.useState(() => modelOptions);
3200
3202
  const [model, setModel] = react.useState(() => {
3201
- const adapter = chunkK7D2C72S_cjs.createGigachessAdapter(fen);
3202
- return chunkK7D2C72S_cjs.createBoardModel(adapter, modelOptions);
3203
+ const adapter = chunkUBD62NOI_cjs.createGigachessAdapter(fen);
3204
+ return chunkUBD62NOI_cjs.createBoardModel(adapter, modelOptions);
3203
3205
  });
3204
3206
  const prevFenRef = react.useRef(fen);
3205
3207
  react.useEffect(() => {
3206
3208
  if (prevFenRef.current !== fen) {
3207
3209
  prevFenRef.current = fen;
3208
- const adapter = chunkK7D2C72S_cjs.createGigachessAdapter(fen);
3209
- const nextModel = chunkK7D2C72S_cjs.createBoardModel(adapter, initialModelOptions);
3210
+ const adapter = chunkUBD62NOI_cjs.createGigachessAdapter(fen);
3211
+ const nextModel = chunkUBD62NOI_cjs.createBoardModel(adapter, initialModelOptions);
3210
3212
  setModel((prev) => {
3211
3213
  prev.dispose();
3212
3214
  return nextModel;
@@ -3226,31 +3228,31 @@ var PACKAGE_VERSION = "1.3.3";
3226
3228
 
3227
3229
  Object.defineProperty(exports, "Color", {
3228
3230
  enumerable: true,
3229
- get: function () { return chunkK7D2C72S_cjs.Color; }
3231
+ get: function () { return chunkUBD62NOI_cjs.Color; }
3230
3232
  });
3231
3233
  Object.defineProperty(exports, "PieceType", {
3232
3234
  enumerable: true,
3233
- get: function () { return chunkK7D2C72S_cjs.PieceType; }
3235
+ get: function () { return chunkUBD62NOI_cjs.PieceType; }
3234
3236
  });
3235
3237
  Object.defineProperty(exports, "createBoardModel", {
3236
3238
  enumerable: true,
3237
- get: function () { return chunkK7D2C72S_cjs.createBoardModel; }
3239
+ get: function () { return chunkUBD62NOI_cjs.createBoardModel; }
3238
3240
  });
3239
3241
  Object.defineProperty(exports, "createGigachessAdapter", {
3240
3242
  enumerable: true,
3241
- get: function () { return chunkK7D2C72S_cjs.createGigachessAdapter; }
3243
+ get: function () { return chunkUBD62NOI_cjs.createGigachessAdapter; }
3242
3244
  });
3243
3245
  Object.defineProperty(exports, "packMove", {
3244
3246
  enumerable: true,
3245
- get: function () { return chunkK7D2C72S_cjs.packMove; }
3247
+ get: function () { return chunkUBD62NOI_cjs.packMove; }
3246
3248
  });
3247
3249
  Object.defineProperty(exports, "preloadGigachessAdapter", {
3248
3250
  enumerable: true,
3249
- get: function () { return chunkK7D2C72S_cjs.preloadGigachessAdapter; }
3251
+ get: function () { return chunkUBD62NOI_cjs.preloadGigachessAdapter; }
3250
3252
  });
3251
3253
  Object.defineProperty(exports, "unpackMove", {
3252
3254
  enumerable: true,
3253
- get: function () { return chunkK7D2C72S_cjs.unpackMove; }
3255
+ get: function () { return chunkUBD62NOI_cjs.unpackMove; }
3254
3256
  });
3255
3257
  Object.defineProperty(exports, "CSS_VARS", {
3256
3258
  enumerable: true,