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

miaoda-game-rpg-battle-react

v0.3.2

Published

React DOM bindings for turn-based RPG battle planning and resolution.

Readme

miaoda-game-rpg-battle-react

Use this React DOM adapter for turn-based RPG command menus, action playback, battle logs, and outcome panels. The core remains authoritative for planning, validation, ranking, resolution, and phase transitions.

Install

pnpm add miaoda-game-rpg-battle-react miaoda-game-rpg-battle-core

Minimal battle screen

import { useRpgBattleController, useRpgBattleView } from 'miaoda-game-rpg-battle-react';

export function BattlePanel({ world, rules, random }) {
  const game = useRpgBattleController(world, rules, random);
  const view = useRpgBattleView(game);

  const chooseAttack = () => game.plan({
    id: 'hero-1', actorId: 'hero', actionId: 'slash', targetIds: ['goblin'], payload: {},
  });

  return (
    <section>
      <p>Phase: {view.state.phase}</p>
      <button onClick={chooseAttack}>Slash</button>
      <button onClick={() => game.beginResolution()}>Resolve turn</button>
      {view.state.phase === 'resolving' && <button onClick={() => game.resolveNext()}>Next action</button>}
      {view.lastEvents.map((event, index) => <pre key={index}>{JSON.stringify(event)}</pre>)}
    </section>
  );
}

Each operation returns { ok: false, error } when the core rejects a command or phase transition. Use view.lastEvents for animation and logs; map stable rule validation codes to player-facing text in your BattleRules layer.

Do not call plan, cancel, beginResolution, or resolveNext synchronously from onChange; defer the operation until the callback returns.

Save and determinism

Persist view.state together with the current position of the injected random source. The controller does not own storage, network authority, or RNG serialization. Do not send hidden target information or full authoritative world state to an untrusted client.

Public API

RpgBattleController, useRpgBattleController, useRpgBattleView, RpgBattleView, operation result types, and all battle-core exports are available. React 18.2+ is required.