npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@beincom/bic-miner-adventure

v0.0.39

Published

A Phaser 3 TypeScript template using Vite.

Readme

@beincom/bic-miner-adventure

npm version License: MIT TypeScript

A comprehensive game SDK for the BIC Miner Adventure game, providing seamless integration with React applications and robust API management.

🚀 Features

  • Easy Integration: Simple setup with React applications
  • Type Safety: Full TypeScript support with comprehensive type definitions
  • Automatic Token Refresh: Built-in session management with automatic token renewal
  • Customizable Hooks: Flexible event handling system for game interactions
  • Modern API Client: RESTful API integration with error handling and retry mechanisms
  • Lightweight: Optimized bundle size for production applications

📦 Installation

Choose your preferred package manager:

# npm
npm i @beincom/bic-miner-adventure

# yarn
yarn add @beincom/bic-miner-adventure

# pnpm
pnpm add @beincom/bic-miner-adventure

# bun
bun add @beincom/bic-miner-adventure

🛠️ Quick Start

1. Basic Setup

import React, { useRef, useEffect } from 'react';
import {
  setApiServer,
  GameApi,
  setGameHook,
  StartGame
} from '@beincom/bic-miner-adventure';

// Configure API client
setApiServer(new GameApi({
  baseUrl: 'https://game.beincom.io/v1/miner-adventure',
  baseApiParams: {
    format: 'json',
    headers: {
      'Content-Type': 'application/json',
      // Add your custom headers here
    }
  },
  refreshSession: async () => {
    // Implement your token refresh logic
    const newToken = await refreshAuthToken();
    return newToken;
  }
}));

// Configure game event hooks
setGameHook({
  openShop: (item: string) => {
    // Handle shop opening
    console.log('Opening shop for item:', item);
    // Your shop opening logic here
  },
  reload: () => {
    // Handle game reload on critical errors
    console.log('Reloading game...');
    window.location.reload();
  }
});

// Game container component
export const GameContainer: React.FC = () => {
  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (containerRef.current) {
      StartGame(containerRef.current);
    }
  }, []);

  return (
    <div 
      ref={containerRef}
      style={{ width: '100%', height: '100vh' }}
    />
  );
};

2. Advanced Configuration

import { GameApi, GameHookConfig } from '@beincom/bic-miner-adventure';

// Advanced API configuration
const gameApi = new GameApi({
  baseUrl: process.env.REACT_APP_GAME_API_URL,
  baseApiParams: {
    format: 'json',
    credentials: 'include',
    headers: {
      'Content-Type': 'application/json',
      'X-Client-Version': '1.0.0',
    }
  },
  refreshSession: async () => {
    try {
      const response = await fetch('/api/auth/refresh', {
        method: 'POST',
        credentials: 'include',
      });
      
      if (!response.ok) {
        throw new Error('Token refresh failed');
      }
      
      const { token } = await response.json();
      localStorage.setItem('authToken', token);
      return token;
    } catch (error) {
      console.error('Failed to refresh session:', error);
      // Redirect to login or handle accordingly
      window.location.href = '/login';
      throw error;
    }
  }
});

// Advanced game hooks configuration
const gameHooks: GameHookConfig = {
  openShop: (item: string) => {
    // Track analytics
    analytics.track('shop_opened', { item });
    
    // Open custom shop modal
    openShopModal(item);
  },
  
  reload: () => {
    // Log error before reload
    console.error('Game encountered critical error, reloading...');
    
    // Show loading indicator
    showLoadingSpinner();
    
    // Reload after delay
    setTimeout(() => {
      window.location.reload();
    }, 1000);
  },
};

setApiServer(gameApi);
setGameHook(gameHooks);

📚 API Reference

Core Functions

setApiServer(api: GameApi)

Configures the game API client.

Parameters:

  • api: GameApi instance with configuration

setGameHook(hooks: GameHookConfig)

Sets up event handlers for game interactions.

Parameters:

  • hooks: Object containing event handler functions

StartGame(container: HTMLElement)

Initializes and starts the game in the specified container.

Parameters:

  • container: HTML element where the game will be rendered

GameApi Configuration

interface GameApiConfig {
  baseUrl: string;
  baseApiParams?: {
    format?: 'json' | 'text' | 'blob';
    credentials?: RequestCredentials;
    headers?: Record<string, string>;
  };
  refreshSession?: () => void;
}

Game Hook Configuration

interface GameHookConfig {
  openShop: (item: string) => void;
  reload: () => void;
  // Additional hooks as needed
}

🔧 Environment Variables

Create a .env file in your project root:

REACT_APP_GAME_API_URL=https://game.beincom.io/v1/miner-adventure

🎮 Game Integration Examples

With Next.js

// pages/game.tsx
import dynamic from 'next/dynamic';

const GameContainer = dynamic(
  () => import('../components/GameContainer'),
  { ssr: false }
);

export default function GamePage() {
  return (
    <div>
      <h1>BIC Miner Adventure</h1>
      <GameContainer />
    </div>
  );
}

With Vite

// src/Game.tsx
import { GameContainer } from './components/GameContainer';

function App() {
  return (
    <div className="app">
      <header>
        <h1>BIC Miner Adventure</h1>
      </header>
      <main>
        <GameContainer />
      </main>
    </div>
  );
}

export default App;

Development Setup

# Clone the repository
git clone https://github.com/beincom/bic-mini-games/bic-miner-adventure.git

# Install dependencies
pnpm install

# Run development server
pnpm run dev

🚀 Roadmap

  • [x] Mobile optimization
  • [x] WebGL renderer improvements
  • [x] Offline mode support
  • [x] Advanced analytics integration
  • [x] Multi-language support

Made with ❤️ by the Beincom team