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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@enigma-lake/mines-play-controller-sdk

v2.1.8

Published

A React component library for building gameplay interfaces

Readme

Mines Play Controller SDK

A React SDK that renders a full play controller for Mines-style games.

It includes:

  • manual play and autoplay modes
  • play amount controls
  • mines difficulty selector (classic mode)
  • extensible widget slots
  • external styling for controller buttons and autoplay switch

Install

npm install @enigma-lake/mines-play-controller-sdk

Exports

import {
  AutoManualPlayProvider,
  AUTO_PLAY_STATE,
  GAME_MODE,
  WIDGET,
  format,
} from "@enigma-lake/mines-play-controller-sdk";

import "@enigma-lake/mines-play-controller-sdk/dist/style.css";

Quick Start

import React from "react";
import {
  AutoManualPlayProvider,
  AUTO_PLAY_STATE,
  WIDGET,
} from "@enigma-lake/mines-play-controller-sdk";

const config = {
  panel: {
    bgColorHex: "#081E64",
    bottom: "15px",
    opacity: 0.5,
  },

  classicGame: {
    dropdown: { bgColorHex: "#01243A" },
    forceLeftStyle: false,
  },

  isClassicGame: true,

  currencyOptions: {
    current: { code: "USD", symbol: "$", name: "US Dollar" },
    available: [{ code: "USD", symbol: "$", name: "US Dollar" }],
  },

  playOptions: {
    isPlaying: false,
    canCashout: false,
    disabledController: false,
    displayController: true,

    classicGame: {
      disabledMenu: false,
      currentMines: 4,
      numberOfMines: 24,
      onMinesChange: (mines: number) => {
        console.log("Selected mines:", mines);
      },
    },

    showAutoPlayToast: ({ type, message }) => {
      console.log(type, message);
    },

    playHook: () => ({
      playAmount: 1,
      setPlayAmount: (value: number) => console.log("set amount", value),
      playLimits: {
        amount: { min: 1, max: 1000 },
      },
    }),

    autoPlayDelay: 300,
    totalBalance: 1000,
  },

  onPlay: () => console.log("play"),
  onAutoPlay: (selection, next, stop, state) => {
    console.log("autoplay", selection, state);
    next();
  },
  onAutoPlayStop: () => console.log("autoplay stopped"),
  onCashout: () => console.log("cashout"),

  leftWidgets: [],
  centerWidgets: [],
  rightWidgets: [],
};

export default function Example() {
  return (
    <AutoManualPlayProvider config={config}>
      <></>
    </AutoManualPlayProvider>
  );
}

How It Works

AutoManualPlayProvider stores controller state and renders the whole UI when playOptions.displayController is true.

Main internal states:

  • mode: manual/autoplay (GAME_MODE)
  • autoplay lifecycle: IDLE, SELECTING, PLAYING (AUTO_PLAY_STATE)
  • selected tiles for autoplay
  • number of autoplay rounds

You provide business logic through callbacks (onPlay, onAutoPlay, onCashout) and data through playOptions + currencyOptions.

Config Reference

config is PlayControllerProps and is composed of these parts.

1) Styling Props

panel: {
  bgColorHex: string;
  bottom?: string;
  opacity?: number;
}

classicGame?: {
  dropdown: {
    bgColorHex: string;
  };
  forceLeftStyle: boolean;
}

2) Actions Props

onPlay: () => void;
onAutoPlay: (
  selection: number[],
  next: () => void,
  stop: () => void,
  state: AUTO_PLAY_STATE,
) => void;
onAutoPlayStop?: () => void;
onCashout: () => void;

3) Play Settings

playOptions: {
  isPlaying: boolean;
  canCashout: boolean;
  disabledController: boolean;
  displayController: boolean;

  classicGame?: {
    disabledMenu: boolean;
    currentMines: number;
    numberOfMines?: number; // default: 24
    onMinesChange: (mines: number) => void;
  };

  showAutoPlayToast: (props: {
    type: "success" | "error" | "warning" | "info";
    message: string;
  }) => void;

  playHook: () => {
    playLimits?: PlayLimitsV2;
    playAmount: number;
    setPlayAmount: (value: number) => void;
  };

  autoPlayDelay?: number;
  totalBalance: number;
}

Classic mines selector behavior:

  • selector values are auto-generated from 1..numberOfMines
  • if numberOfMines is omitted, it defaults to 24
  • selected value is currentMines
  • selection change calls onMinesChange

4) Widgets

leftWidgets: Widget[];
centerWidgets: Widget[];
rightWidgets: Widget[];

Widget shape:

type Widget = {
  type: WIDGET;
  renderElement: ({
    state,
    displayPlayAmountView,
  }: {
    state: AUTO_PLAY_STATE;
    displayPlayAmountView: boolean;
  }) => ReactNode;
};

5) Optional Flags

isClassicGame?: boolean;

When isClassicGame is true, the controller shows classic-game-specific layout and mines difficulty selector.

Button Customization (playControllerButtons)

Use this to control button labels and styles without editing SDK CSS.

type ControllerButtonConfig = {
  label: string;
  labelDisabled?: string; // only for "play"
  variant?: string;
  backgroundColor?: string;
  pressedBackgroundColor?: string;
  textTransform?: "none" | "uppercase" | "lowercase" | "capitalize";
  style?: React.CSSProperties;
  pressedStyle?: React.CSSProperties;
  disabledStyle?: React.CSSProperties;
};

playControllerButtons: {
  textStyle?: {
    color?: string;
    fontSize?: string | number;
    fontWeight?: string | number;
    lineHeight?: string | number;
    letterSpacing?: string | number;
    textTransform?: "none" | "uppercase" | "lowercase" | "capitalize";
    disableOpacity?: number;
  };

  variants?: Record<string, {
    backgroundColor: string;
    pressedBackgroundColor?: string;
    textTransform?: "none" | "uppercase" | "lowercase" | "capitalize";
    style?: React.CSSProperties;
    pressedStyle?: React.CSSProperties;
    disabledStyle?: React.CSSProperties;
  }>;

  buttons: {
    play?: ControllerButtonConfig;
    startAutoplay?: ControllerButtonConfig;
    stopAutoplay?: ControllerButtonConfig;
    cashout?: ControllerButtonConfig;
    selectPlayAmount?: ControllerButtonConfig;
  };
}

Notes:

  • button-level values override variant values
  • variant values override SDK defaults
  • labelDisabled is only used for play when disabled during play

Switch Customization (playControllerSwitcher)

playControllerSwitcher: {
  checked?: {
    thumb?: string;
    slider?: string;
  };
  unchecked?: {
    thumb?: string;
    slider?: string;
  };
}

If omitted, SDK default switch colors are used.

Utility

format is exported for number formatting helpers used by the SDK UI.

Children

AutoManualPlayProvider accepts:

  • normal React children (ReactNode)
  • a render-function child receiving provider state

Minimal Checklist

To render the controller successfully, you must provide:

  • panel.bgColorHex
  • currencyOptions.current and currencyOptions.available
  • playOptions with playHook, showAutoPlayToast, and state flags
  • onPlay, onAutoPlay, onCashout
  • widget arrays (leftWidgets, centerWidgets, rightWidgets), can be empty