Bridge Core
Engine
BridgeEngine factory and module composition.
The BridgeEngine is the main entry point for consuming bridge-core. It composes all modules based on a BridgeContext.
import { createBridgeEngine, createBridgeContext } from '@workspace/bridge-core';
const engine = createBridgeEngine({ teachingMode: 'auction', locale: 'fr' });BridgeContext
The input context that determines how the engine behaves. Both teachingMode and locale are required.
Prop
Type
createBridgeContext
Creates a BridgeContext with defaults for any omitted fields. Defaults to teachingMode: "auction" and locale: "en".
import { createBridgeContext } from '@workspace/bridge-core';
// Full defaults
const ctx = createBridgeContext();
// { teachingMode: "auction", locale: "en" }
// Override specific fields
const ctx2 = createBridgeContext({ locale: 'fr' });
// { teachingMode: "auction", locale: "fr" }getCtx
The engine exposes a getCtx() method that returns the BridgeContext it was created with:
const engine = createBridgeEngine({ teachingMode: 'auction', locale: 'fr' });
engine.getCtx();
// { teachingMode: "auction", locale: "fr" }Module Configs
Each module receives a derived configuration from the context:
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Available Modules
The engine exposes these modules:
| Module | Description |
|---|---|
engine.hands | Hand distribution, validation, queries, transforms |
engine.auction | Bid parsing, contract calculation, auction state |
engine.notation | Locale-aware rank parsing, formatting, suit mappings |
engine.teaching | Teaching mode logic and pedagogy |
engine.player | Player navigation, rotation, partnerships |
engine.play | Trick evaluation, card follow rules |
engine.rotation | Hands/auction/vulnerability rotation |
engine.pbn | PBN format parsing |
engine.format | Display formatting (contracts) |
engine.validation | Full deal validation |
engine.schemas | Zod validation schemas |
engine.constants | Game constants and defaults |
engine.parse | Card and bid parsing utilities |
engine.stats | Hand analysis (HCP, distribution) |