xcore-casino
v1.0.9
Published
Casino Core module
Maintainers
Readme
casino-wasm-core
Core WASM module for casino games implementation.
Installation
npm install xcore-casinoWASM Loading
The package uses WebAssembly to interact with the casino core functionality. To properly initialize the WASM module:
import { WasmLoader } from 'xcore-casino';
// Set the correct path to your WASM file (very important!)
WasmLoader.wasmPath = '/path/to/casino.wasm';
// Optional: Enable debug mode for verbose logging
WasmLoader.debug = true;
// Optional: Increase timeout duration for slow connections
WasmLoader.timeoutDuration = 15000; // 15 seconds
// Load the WASM module
try {
await WasmLoader.asyncLoad();
console.log('WASM module loaded successfully!');
// Get the casino instance
const casino = WasmLoader.getCasino();
// Use the casino instance
// ...
} catch (error) {
console.error('Failed to load WASM module:', error);
// Get diagnostics
const diagnostics = WasmLoader.getDiagnostics();
console.log('WASM Loader Diagnostics:', diagnostics);
// Check WASM file availability
const fileCheck = await WasmLoader.checkWasmFileAvailability();
console.log('WASM File Check:', fileCheck);
}WASM Caching
The WASM loader automatically caches the WASM file to prevent multiple downloads of the same file. This improves performance and reduces network usage. If you need to force a fresh download:
// Clear the WASM cache
WasmLoader.clearCache();
// Or force a complete reload including cache clearing
await WasmLoader.forceReload();Troubleshooting WASM Loading Issues
If you encounter issues loading the WASM module:
Ensure the WASM file is accessible - Check that the path to your WASM file is correct and that the file is being served with the appropriate MIME type (
application/wasm).Enable debug mode - Set
WasmLoader.debug = truebefore callingasyncLoad()to get detailed logging.Increase timeout duration - If you're on a slow connection, increase the timeout duration with
WasmLoader.timeoutDuration = 15000(15 seconds).Check browser compatibility - Use
checkWasmSupport()to verify that the browser supports WebAssembly.Force reload - If the WASM module gets stuck, you can try forcing a reload with
WasmLoader.forceReload().
Development
Prerequisites
- Node.js >= 16
- npm >= 7
- Rust toolchain (for WASM compilation)
Setup
- Clone the repository
- 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:typesTest
npm testLint
npm run lintFormat
npm run formatLicense
MIT
