gigaboard 1.5.2 → 1.5.4

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/server.cjs CHANGED
@@ -45,6 +45,7 @@ function StaticChessboard(props) {
45
45
  style: containerStyle,
46
46
  "data-gb-orientation": orientation,
47
47
  "data-gb-static": "true",
48
+ dir: "ltr",
48
49
  children: [
49
50
  /* @__PURE__ */ jsxRuntime.jsx(
50
51
  "div",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.tsx"],"names":["defaultTheme","defaultPieces","parseFenPlacement","jsxs","jsx","CSS_VARS"],"mappings":";;;;;;;;AAoCA,SAAS,YAAY,KAAA,EAA4B;AAC/C,EAAA,MAAM,OAAO,KAAA,GAAQ,CAAA;AACrB,EAAA,MAAM,OAAO,KAAA,IAAS,CAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAO,YAAA,CAAa,EAAA,GAAO,IAAI,CAAC,CAAA,EAAG,OAAO,CAAC,CAAA,CAAA;AACvD;AAEA,SAAS,UAAA,CAAW,OAAoB,WAAA,EAAoD;AAC1F,EAAA,MAAM,OAAO,KAAA,GAAQ,CAAA;AACrB,EAAA,MAAM,OAAO,KAAA,IAAS,CAAA;AACtB,EAAA,MAAM,GAAA,GAAM,WAAA,KAAgB,OAAA,GAAU,IAAA,GAAO,CAAA,GAAI,IAAA;AACjD,EAAA,MAAM,GAAA,GAAM,WAAA,KAAgB,OAAA,GAAU,CAAA,GAAI,IAAA,GAAO,IAAA;AACjD,EAAA,OAAO,EAAE,CAAA,EAAG,GAAA,GAAM,IAAA,EAAM,CAAA,EAAG,MAAM,IAAA,EAAK;AACxC;AAqCO,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,WAAA,GAAc,OAAA;AAAA,IACd,KAAA,GAAQA,8BAAA;AAAA,IACR,MAAA,GAASC,+BAAA;AAAA,IACT,eAAA,GAAkB,IAAA;A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,CAAA,CAAA;AAAA,eACpF;AAAA,cAEC,QAAA,EAAA,IAAA,GAAO;AAAA,aAAA;AAAA,YARH,QAAQ,IAAI,CAAA;AAAA,WASnB;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"server.cjs","sourcesContent":["/**\n * `gigaboard/server` — server-only static board.\n *\n * Ships **zero** client JavaScript. No hooks, no state, no event handlers,\n * no imports of any client module. Imports only:\n *\n * - `default-theme.ts`\n * - `default-pieces.tsx`\n * - `types.ts` (types only)\n *\n * Perfect for PGN viewers, position diagrams in blog posts, shareable\n * board URLs, and anywhere a board doesn't need interaction. Renders\n * produce identical markup between Node and the browser so they hydrate\n * cleanly under an interactive `<Chessboard/>` if you later attach one.\n *\n * @example\n * ```tsx\n * import { StaticChessboard } from \"gigaboard/server\";\n *\n * export default function Page() {\n * return (\n * <StaticChessboard fen=\"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1\" />\n * );\n * }\n * ```\n */\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { BoardCell, SquareIndex } from \"./core/index.js\";\nimport { CSS_VARS, defaultTheme } from \"./default-theme.js\";\nimport { parseFenPlacement } from \"./fen.js\";\nimport { defaultPieces } from \"./pieces/default-pieces.js\";\nimport type { Orientation, PieceRenderer, Theme } from \"./types.js\";\n\n/* ============================================================ geometry */\n\nfunction algebraicOf(index: SquareIndex): string {\n const file = index & 7;\n const rank = index >> 3;\n return `${String.fromCharCode(0x61 + file)}${rank + 1}`;\n}\n\nfunction positionOf(index: SquareIndex, orientation: Orientation): { x: number; y: number } {\n const file = index & 7;\n const rank = index >> 3;\n const col = orientation === \"white\" ? file : 7 - file;\n const row = orientation === \"white\" ? 7 - rank : rank;\n return { x: col * 12.5, y: row * 12.5 };\n}\n\n/* ============================================================ component */\n\n/** Props for {@link StaticChessboard}. */\nexport interface StaticChessboardProps {\n /** Piece-placement FEN (first whitespace-delimited field is enough). */\n readonly fen: string;\n\n /** Board orientation. Defaults to `\"white\"`. */\n readonly orientation?: Orientation;\n\n /** Theme — defaults to the green palette from `gigaboard/themes`. */\n readonly theme?: Theme;\n\n /** Piece renderer — defaults to the `neo` set from `gigaboard/pieces`. */\n readonly pieces?: PieceRenderer;\n\n /** Show algebraic coordinate labels on the edges. Default `true`. */\n readonly showCoordinates?: boolean;\n\n /** Optional container style overrides. */\n readonly style?: CSSProperties;\n\n /** Optional class name on the outer container. */\n readonly className?: string;\n\n /** Accessible label. Default `\"Chess position\"`. */\n readonly ariaLabel?: string;\n}\n\n/**\n * Static board for server rendering. No interactivity; no client JS\n * shipped. Exactly the same visual layout as the interactive\n * `<Chessboard/>`, so a static SSR board can be swapped for an\n * interactive one on hydration without the markup shifting.\n */\nexport function StaticChessboard(props: StaticChessboardProps): ReactNode {\n const {\n fen,\n orientation = \"white\",\n theme = defaultTheme,\n pieces = defaultPieces,\n showCoordinates = true,\n style,\n className,\n ariaLabel = \"Chess position\",\n } = props;\n\n const board = parseFenPlacement(fen);\n const squares = buildSquareOrder(orientation);\n\n const containerStyle: CSSProperties = {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"100%\",\n ...(theme as CSSProperties),\n ...style,\n };\n\n return (\n <div\n className={className}\n style={containerStyle}\n data-gb-orientation={orientation}\n data-gb-static=\"true\"\n >\n {/* 8×8 grid of static squares — no event handlers, no tabindex. */}\n <div\n role=\"grid\"\n aria-label={ariaLabel}\n aria-rowcount={8}\n aria-colcount={8}\n aria-readonly=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"grid\",\n gridTemplateColumns: \"repeat(8, 1fr)\",\n gridTemplateRows: \"repeat(8, 1fr)\",\n }}\n >\n {squares.map((index) => {\n const file = index & 7;\n const rank = index >> 3;\n const isLight = (file + rank) % 2 === 1;\n return (\n <div\n key={index}\n role=\"gridcell\"\n aria-label={algebraicOf(index)}\n aria-rowindex={rank + 1}\n aria-colindex={file + 1}\n data-square={algebraicOf(index)}\n data-gb-square=\"\"\n data-light={isLight ? \"true\" : \"false\"}\n style={{\n position: \"relative\",\n backgroundColor: `var(${isLight ? CSS_VARS.SQ_LIGHT : CSS_VARS.SQ_DARK})`,\n backgroundImage: `var(${isLight ? CSS_VARS.SQ_LIGHT_IMAGE : CSS_VARS.SQ_DARK_IMAGE},none)`,\n backgroundSize: `var(${CSS_VARS.SQ_IMAGE_SIZE},cover)`,\n backgroundBlendMode: `var(${CSS_VARS.SQ_BLEND_MODE},normal)`,\n userSelect: \"none\",\n outline: \"none\",\n containerType: \"size\",\n }}\n />\n );\n })}\n </div>\n\n {/* Piece overlay — one div per occupied square. */}\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n }}\n >\n {Array.from({ length: 64 }, (_, i) => {\n const cell = board[i] as BoardCell;\n if (cell === 0) return null;\n const idx = i as SquareIndex;\n const square = algebraicOf(idx);\n const { x, y } = positionOf(idx, orientation);\n return (\n <div\n key={square}\n data-piece-square={square}\n data-piece-cell={cell}\n style={{\n position: \"absolute\",\n left: `${x}%`,\n top: `${y}%`,\n width: \"12.5%\",\n height: \"12.5%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n containerType: \"size\",\n filter: `var(${cell <= 6 ? CSS_VARS.PIECE_FILTER_WHITE : CSS_VARS.PIECE_FILTER_BLACK}, none)`,\n }}\n >\n {pieces({ cell, square: idx })}\n </div>\n );\n })}\n </div>\n\n {showCoordinates ? <StaticCoordinates orientation={orientation} /> : null}\n </div>\n );\n}\n\n/* ======================================================== subsidiary helpers */\n\n/** Same rank-first ordering used by the interactive BoardGrid. */\nfunction buildSquareOrder(orientation: Orientation): SquareIndex[] {\n const squares: SquareIndex[] = [];\n if (orientation === \"white\") {\n for (let rank = 7; rank >= 0; rank--) {\n for (let file = 0; file < 8; file++) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n } else {\n for (let rank = 0; rank < 8; rank++) {\n for (let file = 7; file >= 0; file--) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n }\n return squares;\n}\n\nconst FILE_LETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"] as const;\n\n/** Pure coordinate overlay — identical output to the interactive version. */\nfunction StaticCoordinates({ orientation }: { orientation: Orientation }): ReactNode {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n fontSize: \"min(1.6vmin, 11px)\",\n fontWeight: 600,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n }}\n >\n {FILE_LETTERS.map((letter, idx) => {\n const col = orientation === \"white\" ? idx : 7 - idx;\n const bottomRank = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (col + bottomRank) % 2 === 1;\n return (\n <span\n key={`file-${letter}`}\n style={{\n position: \"absolute\",\n left: `${col * 12.5 + 10}%`,\n bottom: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {letter}\n </span>\n );\n })}\n {FILE_LETTERS.map((_, idx) => {\n const rank = idx;\n const row = orientation === \"white\" ? 7 - rank : rank;\n const leftFile = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (leftFile + rank) % 2 === 1;\n return (\n <span\n key={`rank-${rank}`}\n style={{\n position: \"absolute\",\n top: `${row * 12.5 + 1}%`,\n left: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {rank + 1}\n </span>\n );\n })}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/server.tsx"],"names":["defaultTheme","defaultPieces","parseFenPlacement","jsxs","jsx","CSS_VARS"],"mappings":";;;;;;;;AAoCA,SAAS,YAAY,KAAA,EAA4B;AAC/C,EAAA,MAAM,OAAO,KAAA,GAAQ,CAAA;AACrB,EAAA,MAAM,OAAO,KAAA,IAAS,CAAA;AAC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,aAAA;AAAA,YARI,QAAQ,MAAM,CAAA;AAAA,WASrB;AAAA,QAEJ,CAAC,CAAA;AAAA,QACA,YAAA,CAAa,GAAA,CAAI,CAAC,CAAA,EAAG,GAAA,KAAQ;AAC5B,UAAA,MAAM,IAAA,GAAO,GAAA;AACb,UAAA,MAAM,GAAA,GAAM,WAAA,KAAgB,OAAA,GAAU,CAAA,GAAI,IAAA,GAAO,IAAA;AACjD,UAAA,MAAM,QAAA,GAAW,WAAA,KAAgB,OAAA,GAAU,CAAA,GAAI,CAAA;AAC/C,UAAA,MAAM,aAAA,GAAA,CAAiB,QAAA,GAAW,IAAA,IAAQ,CAAA,KAAM,CAAA;AAChD,UAAA,uBACED,cAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cAEC,KAAA,EAAO;AAAA,gBACL,QAAA,EAAU,UAAA;AAAA,gBACV,GAAA,EAAK,CAAA,EAAG,GAAA,GAAM,IAAA,GAAO,CAAC,CAAA,CAAA,CAAA;AAAA,gBACtB,IAAA,EAAM,IAAA;AAAA,gBACN,OAAO,CAAA,IAAA,EAAO,aAAA,GAAgBC,0BAAA,CAAS,gBAAA,GAAmBA,2BAAS,eAAe,CAAA,CAAA;AAAA,eACpF;AAAA,cAEC,QAAA,EAAA,IAAA,GAAO;AAAA,aAAA;AAAA,YARH,QAAQ,IAAI,CAAA;AAAA,WASnB;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"server.cjs","sourcesContent":["/**\n * `gigaboard/server` — server-only static board.\n *\n * Ships **zero** client JavaScript. No hooks, no state, no event handlers,\n * no imports of any client module. Imports only:\n *\n * - `default-theme.ts`\n * - `default-pieces.tsx`\n * - `types.ts` (types only)\n *\n * Perfect for PGN viewers, position diagrams in blog posts, shareable\n * board URLs, and anywhere a board doesn't need interaction. Renders\n * produce identical markup between Node and the browser so they hydrate\n * cleanly under an interactive `<Chessboard/>` if you later attach one.\n *\n * @example\n * ```tsx\n * import { StaticChessboard } from \"gigaboard/server\";\n *\n * export default function Page() {\n * return (\n * <StaticChessboard fen=\"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1\" />\n * );\n * }\n * ```\n */\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { BoardCell, SquareIndex } from \"./core/index.js\";\nimport { CSS_VARS, defaultTheme } from \"./default-theme.js\";\nimport { parseFenPlacement } from \"./fen.js\";\nimport { defaultPieces } from \"./pieces/default-pieces.js\";\nimport type { Orientation, PieceRenderer, Theme } from \"./types.js\";\n\n/* ============================================================ geometry */\n\nfunction algebraicOf(index: SquareIndex): string {\n const file = index & 7;\n const rank = index >> 3;\n return `${String.fromCharCode(0x61 + file)}${rank + 1}`;\n}\n\nfunction positionOf(index: SquareIndex, orientation: Orientation): { x: number; y: number } {\n const file = index & 7;\n const rank = index >> 3;\n const col = orientation === \"white\" ? file : 7 - file;\n const row = orientation === \"white\" ? 7 - rank : rank;\n return { x: col * 12.5, y: row * 12.5 };\n}\n\n/* ============================================================ component */\n\n/** Props for {@link StaticChessboard}. */\nexport interface StaticChessboardProps {\n /** Piece-placement FEN (first whitespace-delimited field is enough). */\n readonly fen: string;\n\n /** Board orientation. Defaults to `\"white\"`. */\n readonly orientation?: Orientation;\n\n /** Theme — defaults to the green palette from `gigaboard/themes`. */\n readonly theme?: Theme;\n\n /** Piece renderer — defaults to the `neo` set from `gigaboard/pieces`. */\n readonly pieces?: PieceRenderer;\n\n /** Show algebraic coordinate labels on the edges. Default `true`. */\n readonly showCoordinates?: boolean;\n\n /** Optional container style overrides. */\n readonly style?: CSSProperties;\n\n /** Optional class name on the outer container. */\n readonly className?: string;\n\n /** Accessible label. Default `\"Chess position\"`. */\n readonly ariaLabel?: string;\n}\n\n/**\n * Static board for server rendering. No interactivity; no client JS\n * shipped. Exactly the same visual layout as the interactive\n * `<Chessboard/>`, so a static SSR board can be swapped for an\n * interactive one on hydration without the markup shifting.\n */\nexport function StaticChessboard(props: StaticChessboardProps): ReactNode {\n const {\n fen,\n orientation = \"white\",\n theme = defaultTheme,\n pieces = defaultPieces,\n showCoordinates = true,\n style,\n className,\n ariaLabel = \"Chess position\",\n } = props;\n\n const board = parseFenPlacement(fen);\n const squares = buildSquareOrder(orientation);\n\n const containerStyle: CSSProperties = {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"100%\",\n ...(theme as CSSProperties),\n ...style,\n };\n\n return (\n <div\n className={className}\n style={containerStyle}\n data-gb-orientation={orientation}\n data-gb-static=\"true\"\n dir=\"ltr\"\n >\n {/* 8×8 grid of static squares — no event handlers, no tabindex. */}\n <div\n role=\"grid\"\n aria-label={ariaLabel}\n aria-rowcount={8}\n aria-colcount={8}\n aria-readonly=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"grid\",\n gridTemplateColumns: \"repeat(8, 1fr)\",\n gridTemplateRows: \"repeat(8, 1fr)\",\n }}\n >\n {squares.map((index) => {\n const file = index & 7;\n const rank = index >> 3;\n const isLight = (file + rank) % 2 === 1;\n return (\n <div\n key={index}\n role=\"gridcell\"\n aria-label={algebraicOf(index)}\n aria-rowindex={rank + 1}\n aria-colindex={file + 1}\n data-square={algebraicOf(index)}\n data-gb-square=\"\"\n data-light={isLight ? \"true\" : \"false\"}\n style={{\n position: \"relative\",\n backgroundColor: `var(${isLight ? CSS_VARS.SQ_LIGHT : CSS_VARS.SQ_DARK})`,\n backgroundImage: `var(${isLight ? CSS_VARS.SQ_LIGHT_IMAGE : CSS_VARS.SQ_DARK_IMAGE},none)`,\n backgroundSize: `var(${CSS_VARS.SQ_IMAGE_SIZE},cover)`,\n backgroundBlendMode: `var(${CSS_VARS.SQ_BLEND_MODE},normal)`,\n userSelect: \"none\",\n outline: \"none\",\n containerType: \"size\",\n }}\n />\n );\n })}\n </div>\n\n {/* Piece overlay — one div per occupied square. */}\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n }}\n >\n {Array.from({ length: 64 }, (_, i) => {\n const cell = board[i] as BoardCell;\n if (cell === 0) return null;\n const idx = i as SquareIndex;\n const square = algebraicOf(idx);\n const { x, y } = positionOf(idx, orientation);\n return (\n <div\n key={square}\n data-piece-square={square}\n data-piece-cell={cell}\n style={{\n position: \"absolute\",\n left: `${x}%`,\n top: `${y}%`,\n width: \"12.5%\",\n height: \"12.5%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n containerType: \"size\",\n filter: `var(${cell <= 6 ? CSS_VARS.PIECE_FILTER_WHITE : CSS_VARS.PIECE_FILTER_BLACK}, none)`,\n }}\n >\n {pieces({ cell, square: idx })}\n </div>\n );\n })}\n </div>\n\n {showCoordinates ? <StaticCoordinates orientation={orientation} /> : null}\n </div>\n );\n}\n\n/* ======================================================== subsidiary helpers */\n\n/** Same rank-first ordering used by the interactive BoardGrid. */\nfunction buildSquareOrder(orientation: Orientation): SquareIndex[] {\n const squares: SquareIndex[] = [];\n if (orientation === \"white\") {\n for (let rank = 7; rank >= 0; rank--) {\n for (let file = 0; file < 8; file++) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n } else {\n for (let rank = 0; rank < 8; rank++) {\n for (let file = 7; file >= 0; file--) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n }\n return squares;\n}\n\nconst FILE_LETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"] as const;\n\n/** Pure coordinate overlay — identical output to the interactive version. */\nfunction StaticCoordinates({ orientation }: { orientation: Orientation }): ReactNode {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n fontSize: \"min(1.6vmin, 11px)\",\n fontWeight: 600,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n }}\n >\n {FILE_LETTERS.map((letter, idx) => {\n const col = orientation === \"white\" ? idx : 7 - idx;\n const bottomRank = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (col + bottomRank) % 2 === 1;\n return (\n <span\n key={`file-${letter}`}\n style={{\n position: \"absolute\",\n left: `${col * 12.5 + 10}%`,\n bottom: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {letter}\n </span>\n );\n })}\n {FILE_LETTERS.map((_, idx) => {\n const rank = idx;\n const row = orientation === \"white\" ? 7 - rank : rank;\n const leftFile = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (leftFile + rank) % 2 === 1;\n return (\n <span\n key={`rank-${rank}`}\n style={{\n position: \"absolute\",\n top: `${row * 12.5 + 1}%`,\n left: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {rank + 1}\n </span>\n );\n })}\n </div>\n );\n}\n"]}
package/dist/server.js CHANGED
@@ -43,6 +43,7 @@ function StaticChessboard(props) {
43
43
  style: containerStyle,
44
44
  "data-gb-orientation": orientation,
45
45
  "data-gb-static": "true",
46
+ dir: "ltr",
46
47
  children: [
47
48
  /* @__PURE__ */ jsx(
48
49
  "div",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.tsx"],"names":[],"mappings":";;;;;;AAoCA,SAAS,YAAY,KAAA,EAA4B;AAC/C,EAAA,MAAM,OAAO,KAAA,GAAQ,CAAA;AACrB,EAAA,MAAM,OAAO,KAAA,IAAS,CAAA;AACtB,EAAA,OAAO,CAAA,EAAG,OAAO,YAAA,CAAa,EAAA,GAAO,IAAI,CAAC,CAAA,EAAG,OAAO,CAAC,CAAA,CAAA;AACvD;AAEA,SAAS,UAAA,CAAW,OAAoB,WAAA,EAAoD;AAC1F,EAAA,MAAM,OAAO,KAAA,GAAQ,CAAA;AACrB,EAAA,MAAM,OAAO,KAAA,IAAS,CAAA;AACtB,EAAA,MAAM,GAAA,GAAM,WAAA,KAAgB,OAAA,GAAU,IAAA,GAAO,CAAA,GAAI,IAAA;AACjD,EAAA,MAAM,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CAAA;AAChD,UAAA,uBACE,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cAEC,KAAA,EAAO;AAAA,gBACL,QAAA,EAAU,UAAA;AAAA,gBACV,GAAA,EAAK,CAAA,EAAG,GAAA,GAAM,IAAA,GAAO,CAAC,CAAA,CAAA,CAAA;AAAA,gBACtB,IAAA,EAAM,IAAA;AAAA,gBACN,OAAO,CAAA,IAAA,EAAO,aAAA,GAAgB,QAAA,CAAS,gBAAA,GAAmB,SAAS,eAAe,CAAA,CAAA;AAAA,eACpF;AAAA,cAEC,QAAA,EAAA,IAAA,GAAO;AAAA,aAAA;AAAA,YARH,QAAQ,IAAI,CAAA;AAAA,WASnB;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"server.js","sourcesContent":["/**\n * `gigaboard/server` — server-only static board.\n *\n * Ships **zero** client JavaScript. No hooks, no state, no event handlers,\n * no imports of any client module. Imports only:\n *\n * - `default-theme.ts`\n * - `default-pieces.tsx`\n * - `types.ts` (types only)\n *\n * Perfect for PGN viewers, position diagrams in blog posts, shareable\n * board URLs, and anywhere a board doesn't need interaction. Renders\n * produce identical markup between Node and the browser so they hydrate\n * cleanly under an interactive `<Chessboard/>` if you later attach one.\n *\n * @example\n * ```tsx\n * import { StaticChessboard } from \"gigaboard/server\";\n *\n * export default function Page() {\n * return (\n * <StaticChessboard fen=\"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1\" />\n * );\n * }\n * ```\n */\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { BoardCell, SquareIndex } from \"./core/index.js\";\nimport { CSS_VARS, defaultTheme } from \"./default-theme.js\";\nimport { parseFenPlacement } from \"./fen.js\";\nimport { defaultPieces } from \"./pieces/default-pieces.js\";\nimport type { Orientation, PieceRenderer, Theme } from \"./types.js\";\n\n/* ============================================================ geometry */\n\nfunction algebraicOf(index: SquareIndex): string {\n const file = index & 7;\n const rank = index >> 3;\n return `${String.fromCharCode(0x61 + file)}${rank + 1}`;\n}\n\nfunction positionOf(index: SquareIndex, orientation: Orientation): { x: number; y: number } {\n const file = index & 7;\n const rank = index >> 3;\n const col = orientation === \"white\" ? file : 7 - file;\n const row = orientation === \"white\" ? 7 - rank : rank;\n return { x: col * 12.5, y: row * 12.5 };\n}\n\n/* ============================================================ component */\n\n/** Props for {@link StaticChessboard}. */\nexport interface StaticChessboardProps {\n /** Piece-placement FEN (first whitespace-delimited field is enough). */\n readonly fen: string;\n\n /** Board orientation. Defaults to `\"white\"`. */\n readonly orientation?: Orientation;\n\n /** Theme — defaults to the green palette from `gigaboard/themes`. */\n readonly theme?: Theme;\n\n /** Piece renderer — defaults to the `neo` set from `gigaboard/pieces`. */\n readonly pieces?: PieceRenderer;\n\n /** Show algebraic coordinate labels on the edges. Default `true`. */\n readonly showCoordinates?: boolean;\n\n /** Optional container style overrides. */\n readonly style?: CSSProperties;\n\n /** Optional class name on the outer container. */\n readonly className?: string;\n\n /** Accessible label. Default `\"Chess position\"`. */\n readonly ariaLabel?: string;\n}\n\n/**\n * Static board for server rendering. No interactivity; no client JS\n * shipped. Exactly the same visual layout as the interactive\n * `<Chessboard/>`, so a static SSR board can be swapped for an\n * interactive one on hydration without the markup shifting.\n */\nexport function StaticChessboard(props: StaticChessboardProps): ReactNode {\n const {\n fen,\n orientation = \"white\",\n theme = defaultTheme,\n pieces = defaultPieces,\n showCoordinates = true,\n style,\n className,\n ariaLabel = \"Chess position\",\n } = props;\n\n const board = parseFenPlacement(fen);\n const squares = buildSquareOrder(orientation);\n\n const containerStyle: CSSProperties = {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"100%\",\n ...(theme as CSSProperties),\n ...style,\n };\n\n return (\n <div\n className={className}\n style={containerStyle}\n data-gb-orientation={orientation}\n data-gb-static=\"true\"\n >\n {/* 8×8 grid of static squares — no event handlers, no tabindex. */}\n <div\n role=\"grid\"\n aria-label={ariaLabel}\n aria-rowcount={8}\n aria-colcount={8}\n aria-readonly=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"grid\",\n gridTemplateColumns: \"repeat(8, 1fr)\",\n gridTemplateRows: \"repeat(8, 1fr)\",\n }}\n >\n {squares.map((index) => {\n const file = index & 7;\n const rank = index >> 3;\n const isLight = (file + rank) % 2 === 1;\n return (\n <div\n key={index}\n role=\"gridcell\"\n aria-label={algebraicOf(index)}\n aria-rowindex={rank + 1}\n aria-colindex={file + 1}\n data-square={algebraicOf(index)}\n data-gb-square=\"\"\n data-light={isLight ? \"true\" : \"false\"}\n style={{\n position: \"relative\",\n backgroundColor: `var(${isLight ? CSS_VARS.SQ_LIGHT : CSS_VARS.SQ_DARK})`,\n backgroundImage: `var(${isLight ? CSS_VARS.SQ_LIGHT_IMAGE : CSS_VARS.SQ_DARK_IMAGE},none)`,\n backgroundSize: `var(${CSS_VARS.SQ_IMAGE_SIZE},cover)`,\n backgroundBlendMode: `var(${CSS_VARS.SQ_BLEND_MODE},normal)`,\n userSelect: \"none\",\n outline: \"none\",\n containerType: \"size\",\n }}\n />\n );\n })}\n </div>\n\n {/* Piece overlay — one div per occupied square. */}\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n }}\n >\n {Array.from({ length: 64 }, (_, i) => {\n const cell = board[i] as BoardCell;\n if (cell === 0) return null;\n const idx = i as SquareIndex;\n const square = algebraicOf(idx);\n const { x, y } = positionOf(idx, orientation);\n return (\n <div\n key={square}\n data-piece-square={square}\n data-piece-cell={cell}\n style={{\n position: \"absolute\",\n left: `${x}%`,\n top: `${y}%`,\n width: \"12.5%\",\n height: \"12.5%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n containerType: \"size\",\n filter: `var(${cell <= 6 ? CSS_VARS.PIECE_FILTER_WHITE : CSS_VARS.PIECE_FILTER_BLACK}, none)`,\n }}\n >\n {pieces({ cell, square: idx })}\n </div>\n );\n })}\n </div>\n\n {showCoordinates ? <StaticCoordinates orientation={orientation} /> : null}\n </div>\n );\n}\n\n/* ======================================================== subsidiary helpers */\n\n/** Same rank-first ordering used by the interactive BoardGrid. */\nfunction buildSquareOrder(orientation: Orientation): SquareIndex[] {\n const squares: SquareIndex[] = [];\n if (orientation === \"white\") {\n for (let rank = 7; rank >= 0; rank--) {\n for (let file = 0; file < 8; file++) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n } else {\n for (let rank = 0; rank < 8; rank++) {\n for (let file = 7; file >= 0; file--) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n }\n return squares;\n}\n\nconst FILE_LETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"] as const;\n\n/** Pure coordinate overlay — identical output to the interactive version. */\nfunction StaticCoordinates({ orientation }: { orientation: Orientation }): ReactNode {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n fontSize: \"min(1.6vmin, 11px)\",\n fontWeight: 600,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n }}\n >\n {FILE_LETTERS.map((letter, idx) => {\n const col = orientation === \"white\" ? idx : 7 - idx;\n const bottomRank = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (col + bottomRank) % 2 === 1;\n return (\n <span\n key={`file-${letter}`}\n style={{\n position: \"absolute\",\n left: `${col * 12.5 + 10}%`,\n bottom: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {letter}\n </span>\n );\n })}\n {FILE_LETTERS.map((_, idx) => {\n const rank = idx;\n const row = orientation === \"white\" ? 7 - rank : rank;\n const leftFile = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (leftFile + rank) % 2 === 1;\n return (\n <span\n key={`rank-${rank}`}\n style={{\n position: \"absolute\",\n top: `${row * 12.5 + 1}%`,\n left: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COOR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,EAAG,GAAA,GAAM,IAAA,GAAO,EAAE,CAAA,CAAA,CAAA;AAAA,gBACxB,MAAA,EAAQ,IAAA;AAAA,gBACR,OAAO,CAAA,IAAA,EAAO,aAAA,GAAgB,QAAA,CAAS,gBAAA,GAAmB,SAAS,eAAe,CAAA,CAAA;AAAA,eACpF;AAAA,cAEC,QAAA,EAAA;AAAA,aAAA;AAAA,YARI,QAAQ,MAAM,CAAA;AAAA,WASrB;AAAA,QAEJ,CAAC,CAAA;AAAA,QACA,YAAA,CAAa,GAAA,CAAI,CAAC,CAAA,EAAG,GAAA,KAAQ;AAC5B,UAAA,MAAM,IAAA,GAAO,GAAA;AACb,UAAA,MAAM,GAAA,GAAM,WAAA,KAAgB,OAAA,GAAU,CAAA,GAAI,IAAA,GAAO,IAAA;AACjD,UAAA,MAAM,QAAA,GAAW,WAAA,KAAgB,OAAA,GAAU,CAAA,GAAI,CAAA;AAC/C,UAAA,MAAM,aAAA,GAAA,CAAiB,QAAA,GAAW,IAAA,IAAQ,CAAA,KAAM,CAAA;AAChD,UAAA,uBACE,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cAEC,KAAA,EAAO;AAAA,gBACL,QAAA,EAAU,UAAA;AAAA,gBACV,GAAA,EAAK,CAAA,EAAG,GAAA,GAAM,IAAA,GAAO,CAAC,CAAA,CAAA,CAAA;AAAA,gBACtB,IAAA,EAAM,IAAA;AAAA,gBACN,OAAO,CAAA,IAAA,EAAO,aAAA,GAAgB,QAAA,CAAS,gBAAA,GAAmB,SAAS,eAAe,CAAA,CAAA;AAAA,eACpF;AAAA,cAEC,QAAA,EAAA,IAAA,GAAO;AAAA,aAAA;AAAA,YARH,QAAQ,IAAI,CAAA;AAAA,WASnB;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"server.js","sourcesContent":["/**\n * `gigaboard/server` — server-only static board.\n *\n * Ships **zero** client JavaScript. No hooks, no state, no event handlers,\n * no imports of any client module. Imports only:\n *\n * - `default-theme.ts`\n * - `default-pieces.tsx`\n * - `types.ts` (types only)\n *\n * Perfect for PGN viewers, position diagrams in blog posts, shareable\n * board URLs, and anywhere a board doesn't need interaction. Renders\n * produce identical markup between Node and the browser so they hydrate\n * cleanly under an interactive `<Chessboard/>` if you later attach one.\n *\n * @example\n * ```tsx\n * import { StaticChessboard } from \"gigaboard/server\";\n *\n * export default function Page() {\n * return (\n * <StaticChessboard fen=\"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1\" />\n * );\n * }\n * ```\n */\n\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { BoardCell, SquareIndex } from \"./core/index.js\";\nimport { CSS_VARS, defaultTheme } from \"./default-theme.js\";\nimport { parseFenPlacement } from \"./fen.js\";\nimport { defaultPieces } from \"./pieces/default-pieces.js\";\nimport type { Orientation, PieceRenderer, Theme } from \"./types.js\";\n\n/* ============================================================ geometry */\n\nfunction algebraicOf(index: SquareIndex): string {\n const file = index & 7;\n const rank = index >> 3;\n return `${String.fromCharCode(0x61 + file)}${rank + 1}`;\n}\n\nfunction positionOf(index: SquareIndex, orientation: Orientation): { x: number; y: number } {\n const file = index & 7;\n const rank = index >> 3;\n const col = orientation === \"white\" ? file : 7 - file;\n const row = orientation === \"white\" ? 7 - rank : rank;\n return { x: col * 12.5, y: row * 12.5 };\n}\n\n/* ============================================================ component */\n\n/** Props for {@link StaticChessboard}. */\nexport interface StaticChessboardProps {\n /** Piece-placement FEN (first whitespace-delimited field is enough). */\n readonly fen: string;\n\n /** Board orientation. Defaults to `\"white\"`. */\n readonly orientation?: Orientation;\n\n /** Theme — defaults to the green palette from `gigaboard/themes`. */\n readonly theme?: Theme;\n\n /** Piece renderer — defaults to the `neo` set from `gigaboard/pieces`. */\n readonly pieces?: PieceRenderer;\n\n /** Show algebraic coordinate labels on the edges. Default `true`. */\n readonly showCoordinates?: boolean;\n\n /** Optional container style overrides. */\n readonly style?: CSSProperties;\n\n /** Optional class name on the outer container. */\n readonly className?: string;\n\n /** Accessible label. Default `\"Chess position\"`. */\n readonly ariaLabel?: string;\n}\n\n/**\n * Static board for server rendering. No interactivity; no client JS\n * shipped. Exactly the same visual layout as the interactive\n * `<Chessboard/>`, so a static SSR board can be swapped for an\n * interactive one on hydration without the markup shifting.\n */\nexport function StaticChessboard(props: StaticChessboardProps): ReactNode {\n const {\n fen,\n orientation = \"white\",\n theme = defaultTheme,\n pieces = defaultPieces,\n showCoordinates = true,\n style,\n className,\n ariaLabel = \"Chess position\",\n } = props;\n\n const board = parseFenPlacement(fen);\n const squares = buildSquareOrder(orientation);\n\n const containerStyle: CSSProperties = {\n position: \"relative\",\n aspectRatio: \"1 / 1\",\n width: \"100%\",\n ...(theme as CSSProperties),\n ...style,\n };\n\n return (\n <div\n className={className}\n style={containerStyle}\n data-gb-orientation={orientation}\n data-gb-static=\"true\"\n dir=\"ltr\"\n >\n {/* 8×8 grid of static squares — no event handlers, no tabindex. */}\n <div\n role=\"grid\"\n aria-label={ariaLabel}\n aria-rowcount={8}\n aria-colcount={8}\n aria-readonly=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"grid\",\n gridTemplateColumns: \"repeat(8, 1fr)\",\n gridTemplateRows: \"repeat(8, 1fr)\",\n }}\n >\n {squares.map((index) => {\n const file = index & 7;\n const rank = index >> 3;\n const isLight = (file + rank) % 2 === 1;\n return (\n <div\n key={index}\n role=\"gridcell\"\n aria-label={algebraicOf(index)}\n aria-rowindex={rank + 1}\n aria-colindex={file + 1}\n data-square={algebraicOf(index)}\n data-gb-square=\"\"\n data-light={isLight ? \"true\" : \"false\"}\n style={{\n position: \"relative\",\n backgroundColor: `var(${isLight ? CSS_VARS.SQ_LIGHT : CSS_VARS.SQ_DARK})`,\n backgroundImage: `var(${isLight ? CSS_VARS.SQ_LIGHT_IMAGE : CSS_VARS.SQ_DARK_IMAGE},none)`,\n backgroundSize: `var(${CSS_VARS.SQ_IMAGE_SIZE},cover)`,\n backgroundBlendMode: `var(${CSS_VARS.SQ_BLEND_MODE},normal)`,\n userSelect: \"none\",\n outline: \"none\",\n containerType: \"size\",\n }}\n />\n );\n })}\n </div>\n\n {/* Piece overlay — one div per occupied square. */}\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n }}\n >\n {Array.from({ length: 64 }, (_, i) => {\n const cell = board[i] as BoardCell;\n if (cell === 0) return null;\n const idx = i as SquareIndex;\n const square = algebraicOf(idx);\n const { x, y } = positionOf(idx, orientation);\n return (\n <div\n key={square}\n data-piece-square={square}\n data-piece-cell={cell}\n style={{\n position: \"absolute\",\n left: `${x}%`,\n top: `${y}%`,\n width: \"12.5%\",\n height: \"12.5%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n containerType: \"size\",\n filter: `var(${cell <= 6 ? CSS_VARS.PIECE_FILTER_WHITE : CSS_VARS.PIECE_FILTER_BLACK}, none)`,\n }}\n >\n {pieces({ cell, square: idx })}\n </div>\n );\n })}\n </div>\n\n {showCoordinates ? <StaticCoordinates orientation={orientation} /> : null}\n </div>\n );\n}\n\n/* ======================================================== subsidiary helpers */\n\n/** Same rank-first ordering used by the interactive BoardGrid. */\nfunction buildSquareOrder(orientation: Orientation): SquareIndex[] {\n const squares: SquareIndex[] = [];\n if (orientation === \"white\") {\n for (let rank = 7; rank >= 0; rank--) {\n for (let file = 0; file < 8; file++) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n } else {\n for (let rank = 0; rank < 8; rank++) {\n for (let file = 7; file >= 0; file--) {\n squares.push((rank * 8 + file) as SquareIndex);\n }\n }\n }\n return squares;\n}\n\nconst FILE_LETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"] as const;\n\n/** Pure coordinate overlay — identical output to the interactive version. */\nfunction StaticCoordinates({ orientation }: { orientation: Orientation }): ReactNode {\n return (\n <div\n aria-hidden=\"true\"\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n fontSize: \"min(1.6vmin, 11px)\",\n fontWeight: 600,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n }}\n >\n {FILE_LETTERS.map((letter, idx) => {\n const col = orientation === \"white\" ? idx : 7 - idx;\n const bottomRank = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (col + bottomRank) % 2 === 1;\n return (\n <span\n key={`file-${letter}`}\n style={{\n position: \"absolute\",\n left: `${col * 12.5 + 10}%`,\n bottom: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {letter}\n </span>\n );\n })}\n {FILE_LETTERS.map((_, idx) => {\n const rank = idx;\n const row = orientation === \"white\" ? 7 - rank : rank;\n const leftFile = orientation === \"white\" ? 0 : 7;\n const isLightSquare = (leftFile + rank) % 2 === 1;\n return (\n <span\n key={`rank-${rank}`}\n style={{\n position: \"absolute\",\n top: `${row * 12.5 + 1}%`,\n left: \"1%\",\n color: `var(${isLightSquare ? CSS_VARS.COORDINATE_LIGHT : CSS_VARS.COORDINATE_DARK})`,\n }}\n >\n {rank + 1}\n </span>\n );\n })}\n </div>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gigaboard",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Ultra-fast React chessboard with owned state, byte-scoped subscriptions, refs-only drag, polished default theme and pieces, sounds, arrows, premoves, and SSR static rendering.",
5
5
  "license": "MIT",
6
6
  "author": "Yahor Barkouski (forked as gigaboard)",
@@ -142,7 +142,7 @@
142
142
  "react-dom": "^18.3.0 || ^19.0.0"
143
143
  },
144
144
  "dependencies": {
145
- "gigachess": "^0.4.1",
145
+ "gigachess": "^0.4.1 || ^0.5.0",
146
146
  "web-haptics": "^0.0.6"
147
147
  },
148
148
  "devDependencies": {