texasholdem 1.0.3 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "texasholdem",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Modular, functional Texas Hold'em poker engine built with Effect-TS",
5
5
  "type": "module",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
12
12
  "scripts": {
13
- "build": "tsc",
13
+ "build": "tsup",
14
14
  "test": "vitest run",
15
15
  "test:watch": "vitest",
16
16
  "typecheck": "tsc --noEmit",
@@ -33,6 +33,7 @@
33
33
  "eslint-config-prettier": "^10.1.8",
34
34
  "fast-check": "^3.23.0",
35
35
  "prettier": "^3.8.1",
36
+ "tsup": "^8.5.1",
36
37
  "typescript": "^5.7.0",
37
38
  "typescript-eslint": "^8.56.0",
38
39
  "vitest": "^3.0.0"
package/src/action.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
  import { Data, Either, Match, Option, Schema, pipe } from "effect";
8
- import type { Chips } from "./brand.js";
9
- import { Chips as makeChips, chipsToNumber, ChipsSchema } from "./brand.js";
10
- import { InvalidAction } from "./error.js";
8
+ import type { Chips } from "./brand";
9
+ import { Chips as makeChips, chipsToNumber, ChipsSchema } from "./brand";
10
+ import { InvalidAction } from "./error";
11
11
 
12
12
  // ---------------------------------------------------------------------------
13
13
  // Action — Data.TaggedEnum (type-level) + Data.tagged (constructors)
package/src/betting.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Array as A, Either, HashSet, Match, Option, pipe } from "effect";
2
2
 
3
- import type { Chips, SeatIndex } from "./brand.js";
3
+ import type { Chips, SeatIndex } from "./brand";
4
4
  import {
5
5
  Chips as makeChips,
6
6
  ZERO_CHIPS,
@@ -9,14 +9,14 @@ import {
9
9
  chipsToNumber,
10
10
  seatIndexToNumber,
11
11
  SeatIndexOrder,
12
- } from "./brand.js";
13
- import type { Player } from "./player.js";
14
- import { canAct, placeBet, fold as foldPlayer } from "./player.js";
15
- import type { Action, LegalActions } from "./action.js";
16
- import { computeLegalActions, validateAction } from "./action.js";
17
- import type { GameEvent } from "./event.js";
18
- import { PlayerActed, BettingRoundEnded } from "./event.js";
19
- import { InvalidAction, NotPlayersTurn } from "./error.js";
12
+ } from "./brand";
13
+ import type { Player } from "./player";
14
+ import { canAct, placeBet, fold as foldPlayer } from "./player";
15
+ import type { Action, LegalActions } from "./action";
16
+ import { computeLegalActions, validateAction } from "./action";
17
+ import type { GameEvent } from "./event";
18
+ import { PlayerActed, BettingRoundEnded } from "./event";
19
+ import { InvalidAction, NotPlayersTurn } from "./error";
20
20
 
21
21
  // ---------------------------------------------------------------------------
22
22
  // BettingRoundState
package/src/card.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import { Array as A, Data, Either, Schema, pipe } from "effect";
12
- import { InvalidCard } from "./error.js";
12
+ import { InvalidCard } from "./error";
13
13
 
14
14
  // ---------------------------------------------------------------------------
15
15
  // Rank
package/src/deck.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Array as A, Chunk, Effect, Either, HashMap, Random } from "effect";
2
- import type { Card } from "./card.js";
3
- import { ALL_CARDS } from "./card.js";
4
- import type { SeatIndex } from "./brand.js";
5
- import { DeckExhausted } from "./error.js";
2
+ import type { Card } from "./card";
3
+ import { ALL_CARDS } from "./card";
4
+ import type { SeatIndex } from "./brand";
5
+ import { DeckExhausted } from "./error";
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  // Deck type
package/src/error.ts CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import { Data } from "effect";
14
14
 
15
- import type { Chips, SeatIndex } from "./brand.js";
15
+ import type { Chips, SeatIndex } from "./brand";
16
16
 
17
17
  // ---------------------------------------------------------------------------
18
18
  // Action / turn errors
package/src/evaluator.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Array as A, Either, Order, pipe } from "effect";
2
- import { Hand as PokersolverHand } from "pokersolver";
3
- import type { Card } from "./card.js";
4
- import { toPokersolverString } from "./card.js";
5
- import { InvalidGameState } from "./error.js";
2
+ import pokersolver from "pokersolver";
3
+ const { Hand: PokersolverHand } = pokersolver;
4
+ import type { Card } from "./card";
5
+ import { toPokersolverString } from "./card";
6
+ import { InvalidGameState } from "./error";
6
7
 
7
8
  // ---------------------------------------------------------------------------
8
9
  // HandRank — our public type that does NOT leak pokersolver internals
package/src/event.ts CHANGED
@@ -9,9 +9,9 @@
9
9
  */
10
10
 
11
11
  import { Data } from "effect";
12
- import type { Chips, SeatIndex, HandId } from "./brand.js";
13
- import type { Card } from "./card.js";
14
- import type { Action } from "./action.js";
12
+ import type { Chips, SeatIndex, HandId } from "./brand";
13
+ import type { Card } from "./card";
14
+ import type { Action } from "./action";
15
15
 
16
16
  // ---------------------------------------------------------------------------
17
17
  // GameEvent — Data.TaggedEnum (type-level) + Data.tagged (constructors)
package/src/hand.ts CHANGED
@@ -6,21 +6,21 @@
6
6
 
7
7
  import { Array as A, Effect, Either, HashMap, Option, pipe } from "effect";
8
8
 
9
- import type { Chips, SeatIndex, HandId } from "./brand.js";
9
+ import type { Chips, SeatIndex, HandId } from "./brand";
10
10
  import {
11
11
  ZERO_CHIPS,
12
12
  minChips,
13
13
  SeatIndexOrder,
14
- } from "./brand.js";
15
- import type { Card } from "./card.js";
16
- import type { Deck } from "./deck.js";
17
- import { shuffled, dealHoleCards, dealFlop, dealOne } from "./deck.js";
18
- import type { HandRank } from "./evaluator.js";
19
- import { evaluateHoldem } from "./evaluator.js";
20
- import type { Player } from "./player.js";
21
- import { placeBet, winChips, collectBet, dealCards, canAct } from "./player.js";
22
- import type { Action, LegalActions } from "./action.js";
23
- import type { GameEvent } from "./event.js";
14
+ } from "./brand";
15
+ import type { Card } from "./card";
16
+ import type { Deck } from "./deck";
17
+ import { shuffled, dealHoleCards, dealFlop, dealOne } from "./deck";
18
+ import type { HandRank } from "./evaluator";
19
+ import { evaluateHoldem } from "./evaluator";
20
+ import type { Player } from "./player";
21
+ import { placeBet, winChips, collectBet, dealCards, canAct } from "./player";
22
+ import type { Action, LegalActions } from "./action";
23
+ import type { GameEvent } from "./event";
24
24
  import {
25
25
  HandStarted,
26
26
  BlindsPosted,
@@ -30,18 +30,18 @@ import {
30
30
  ShowdownStarted,
31
31
  PotAwarded,
32
32
  HandEnded,
33
- } from "./event.js";
34
- import type { PokerError } from "./error.js";
35
- import { InvalidGameState } from "./error.js";
36
- import type { Pot } from "./pot.js";
37
- import { collectBets, awardPots } from "./pot.js";
38
- import type { BettingRoundState } from "./betting.js";
33
+ } from "./event";
34
+ import type { PokerError } from "./error";
35
+ import { InvalidGameState } from "./error";
36
+ import type { Pot } from "./pot";
37
+ import { collectBets, awardPots } from "./pot";
38
+ import type { BettingRoundState } from "./betting";
39
39
  import {
40
40
  createBettingRound,
41
41
  applyAction as bettingApplyAction,
42
42
  getLegalActions as bettingGetLegalActions,
43
43
  activePlayer as bettingActivePlayer,
44
- } from "./betting.js";
44
+ } from "./betting";
45
45
 
46
46
  // ---------------------------------------------------------------------------
47
47
  // ForcedBets
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
- export * from "./brand.js";
2
- export * from "./card.js";
3
- export * from "./deck.js";
4
- export * from "./evaluator.js";
5
- export * from "./player.js";
6
- export * from "./action.js";
7
- export * from "./event.js";
8
- export * from "./error.js";
9
- export * from "./pot.js";
1
+ export * from "./brand";
2
+ export * from "./card";
3
+ export * from "./deck";
4
+ export * from "./evaluator";
5
+ export * from "./player";
6
+ export * from "./action";
7
+ export * from "./event";
8
+ export * from "./error";
9
+ export * from "./pot";
10
10
 
11
11
  // Re-export betting with namespace prefix to avoid conflicts with hand/table
12
12
  export {
@@ -17,9 +17,9 @@ export {
17
17
  activePlayer as bettingActivePlayer,
18
18
  getPlayer as bettingGetPlayer,
19
19
  updatePlayer as bettingUpdatePlayer,
20
- } from "./betting.js";
20
+ } from "./betting";
21
21
 
22
- export * from "./hand.js";
22
+ export * from "./hand";
23
23
 
24
24
  // Re-export table with explicit names to avoid conflicts with hand module
25
25
  export {
@@ -32,9 +32,9 @@ export {
32
32
  act as tableAct,
33
33
  getActivePlayer,
34
34
  getTableLegalActions,
35
- } from "./table.js";
35
+ } from "./table";
36
36
 
37
- export * from "./position.js";
37
+ export * from "./position";
38
38
 
39
39
  export {
40
40
  type Strategy,
@@ -52,4 +52,4 @@ export {
52
52
  stopWhenFewPlayers,
53
53
  alwaysFold,
54
54
  passiveStrategy,
55
- } from "./loop.js";
55
+ } from "./loop";
package/src/loop.ts CHANGED
@@ -8,19 +8,19 @@
8
8
 
9
9
  import { Duration, Effect, Either, HashMap, Option, Schema, pipe, identity } from "effect";
10
10
 
11
- import type { Action } from "./action.js";
12
- import { Fold, Check, Call } from "./action.js";
13
- import type { GameEvent } from "./event.js";
14
- import type { PokerError } from "./error.js";
15
- import type { SeatIndex } from "./brand.js";
16
- import type { TableState } from "./table.js";
11
+ import type { Action } from "./action";
12
+ import { Fold, Check, Call } from "./action";
13
+ import type { GameEvent } from "./event";
14
+ import type { PokerError } from "./error";
15
+ import type { SeatIndex } from "./brand";
16
+ import type { TableState } from "./table";
17
17
  import {
18
18
  startNextHand,
19
19
  act as tableAct,
20
20
  getActivePlayer,
21
- } from "./table.js";
22
- import type { StrategyContext } from "./position.js";
23
- import { buildStrategyContext } from "./position.js";
21
+ } from "./table";
22
+ import type { StrategyContext } from "./position";
23
+ import { buildStrategyContext } from "./position";
24
24
 
25
25
  // ---------------------------------------------------------------------------
26
26
  // Function types — plain TypeScript (Schema can't represent functions)
package/src/player.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Option } from "effect";
2
- import type { Chips, SeatIndex } from "./brand.js";
2
+ import type { Chips, SeatIndex } from "./brand";
3
3
  import {
4
4
  ZERO_CHIPS,
5
5
  addChips,
6
6
  subtractChips,
7
7
  chipsToNumber,
8
- } from "./brand.js";
9
- import type { Card } from "./card.js";
8
+ } from "./brand";
9
+ import type { Card } from "./card";
10
10
 
11
11
  // ---------------------------------------------------------------------------
12
12
  // Player interface — immutable snapshot of a player's state within a hand
@@ -12,4 +12,7 @@ declare module "pokersolver" {
12
12
  static winners(hands: Hand[]): Hand[];
13
13
  toString(): string;
14
14
  }
15
+ const _default: { Hand: typeof Hand };
16
+ export default _default;
17
+ export { Hand };
15
18
  }
package/src/position.ts CHANGED
@@ -8,22 +8,22 @@
8
8
 
9
9
  import { Option, Schema } from "effect";
10
10
 
11
- import type { SeatIndex } from "./brand.js";
11
+ import type { SeatIndex } from "./brand";
12
12
  import {
13
13
  Chips as makeChips,
14
14
  SeatIndexSchema,
15
15
  ChipsSchema,
16
16
  chipsToNumber,
17
17
  ZERO_CHIPS,
18
- } from "./brand.js";
19
- import { CardSchema } from "./card.js";
20
- import { LegalActionsSchema } from "./action.js";
21
- import type { LegalActions } from "./action.js";
22
- import type { Player } from "./player.js";
23
- import type { HandState } from "./hand.js";
24
- import { getLegalActions as handGetLegalActions } from "./hand.js";
25
- import type { GameEvent } from "./event.js";
26
- import type { TableState } from "./table.js";
18
+ } from "./brand";
19
+ import { CardSchema } from "./card";
20
+ import { LegalActionsSchema } from "./action";
21
+ import type { LegalActions } from "./action";
22
+ import type { Player } from "./player";
23
+ import type { HandState } from "./hand";
24
+ import { getLegalActions as handGetLegalActions } from "./hand";
25
+ import type { GameEvent } from "./event";
26
+ import type { TableState } from "./table";
27
27
 
28
28
  // ---------------------------------------------------------------------------
29
29
  // PositionalRole
package/src/pot.ts CHANGED
@@ -5,15 +5,15 @@
5
5
  */
6
6
 
7
7
  import { Array as A, pipe } from "effect";
8
- import type { Chips, SeatIndex } from "./brand.js";
8
+ import type { Chips, SeatIndex } from "./brand";
9
9
  import {
10
10
  Chips as makeChips,
11
11
  ZERO_CHIPS,
12
12
  addChips,
13
13
  chipsToNumber,
14
14
  SeatIndexOrder,
15
- } from "./brand.js";
16
- import type { HandRank } from "./evaluator.js";
15
+ } from "./brand";
16
+ import type { HandRank } from "./evaluator";
17
17
 
18
18
  // ---------------------------------------------------------------------------
19
19
  // Pot type
package/src/table.ts CHANGED
@@ -6,18 +6,18 @@
6
6
 
7
7
  import { Array as A, Effect, Either, HashMap, Option, pipe } from "effect";
8
8
 
9
- import type { Chips, SeatIndex } from "./brand.js";
9
+ import type { Chips, SeatIndex } from "./brand";
10
10
  import {
11
11
  HandId as makeHandId,
12
12
  chipsToNumber,
13
13
  seatIndexToNumber,
14
14
  SeatIndexOrder,
15
- } from "./brand.js";
16
- import type { Player } from "./player.js";
17
- import { createPlayer, clearHand } from "./player.js";
18
- import type { Action, LegalActions } from "./action.js";
19
- import type { GameEvent } from "./event.js";
20
- import { PlayerSatDown, PlayerStoodUp } from "./event.js";
15
+ } from "./brand";
16
+ import type { Player } from "./player";
17
+ import { createPlayer, clearHand } from "./player";
18
+ import type { Action, LegalActions } from "./action";
19
+ import type { GameEvent } from "./event";
20
+ import { PlayerSatDown, PlayerStoodUp } from "./event";
21
21
  import {
22
22
  SeatOccupied,
23
23
  SeatEmpty,
@@ -26,10 +26,10 @@ import {
26
26
  HandInProgress,
27
27
  NoHandInProgress,
28
28
  InvalidConfig,
29
- } from "./error.js";
30
- import type { PokerError } from "./error.js";
31
- import type { ForcedBets, HandState } from "./hand.js";
32
- import * as hand from "./hand.js";
29
+ } from "./error";
30
+ import type { PokerError } from "./error";
31
+ import type { ForcedBets, HandState } from "./hand";
32
+ import * as hand from "./hand";
33
33
 
34
34
  // ---------------------------------------------------------------------------
35
35
  // TableConfig
package/tsconfig.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
6
  "declaration": true,
7
7
  "declarationMap": true,
8
8
  "sourceMap": true,
package/tsup.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm"],
6
+ dts: true,
7
+ sourcemap: true,
8
+ clean: true,
9
+ });