1.0.5 • Published 10 months ago

casino-wasm-core v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

casino-wasm-core

Core WASM module for casino games implementation.

Installation

npm install casino-wasm-core

Usage

import { BaccaratGame, WasmLoader } from 'casino-wasm-core';

// Load the WASM module first
WasmLoader.load().then(() => {
  // Create a new Baccarat game instance
  const game = new BaccaratGame();

  // Deal cards
  game.deal();

  // Get game state
  const state = game.getState();
});

WASM Loading

The package now automatically detects and loads the required WASM files. You don't need to manually configure paths or copy files to your public directory.

// Enable debug mode for detailed logging
WasmLoader.debug = true;

// Increase timeout if needed (default is 10 seconds)
WasmLoader.initTimeout = 20000; // 20 seconds

// Load the WASM module
WasmLoader.load().then(() => {
  console.log('WASM loaded successfully');
}).catch(error => {
  console.error('Failed to load WASM:', error);
});

Manual Configuration (if needed)

If auto-detection doesn't work in your environment, you can manually configure the paths:

// Disable auto-detection and set paths manually
WasmLoader.wasmPath = '/path/to/casino.wasm';
WasmLoader.wasmExecPath = '/path/to/wasm_exec.js';

WasmLoader.load().then(() => {
  // Use the WASM module
});

Development

Prerequisites

  • Node.js >= 16
  • npm >= 7
  • Rust toolchain (for WASM compilation)

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install

Build

# Build WASM module and TypeScript
npm run build:all

# Build only TypeScript
npm run build

# Generate TypeScript declaration files
npm run build:types

Test

npm test

Lint

npm run lint

Format

npm run format

License

MIT

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago