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

@osthelia/bracket-engine

v1.1.1

Published

Tournament bracket engine: generators, validation, standings, match resolution, and React viewer/editor components.

Readme

@osthelia/bracket-engine

Tournament bracket engine used by GC Stats.

  • Engine (@osthelia/bracket-engine): pure TypeScript, no dependency. Bracket generators, graph validation, standings, match resolution, bracket layout and stage structure validation.
  • React components (@osthelia/bracket-engine/react): a read only bracket viewer and a stage structure editor, both built on React Flow.

Install

npm install @osthelia/bracket-engine
# only for the React components
npm install react @xyflow/react

Engine

import { generateDoubleElimination, validateGraph, resolveMatchInGraph } from "@osthelia/bracket-engine";

const graph = generateDoubleElimination({
  upperContainerId: "upper",
  lowerContainerId: "lower",
  grandFinalContainerId: "final",
  entrantCount: 16,
  bestOf: 3,
  grandFinalBestOf: 5,
  lowerFinalBestOf: 5,
});

validateGraph(graph);

| Area | Exports | |---|---| | Model | BracketGraph, MatchNode, BracketEdge, SeedSource | | Generators | generateSingleElimination, generateDoubleElimination, generateTripleElimination, generateRoundRobin, generateGslGroup, Swiss pairing (pairRound, groupByRecord, recomputeBuchholz) | | Validation | validateGraph, validateStageGraph | | Resolution | resolveMatchInGraph | | Standings | createRoundRobinStandings, createSwissStandings | | Layout | layoutBracket (viewer), layoutEditorGrid, snapToGrid (editor) | | Seeding | groupRankOrder, distribute, qualificationOrder, shuffle | | Sets | buildTree, subtreeOf, setChain, checkMove, placeAmongSiblings, resolveStatuses (containers nested in a set; a stage without sets is a flat list) |

Every format option that takes a best of (bestOf, finalBestOf, grandFinalBestOf, lowerFinalBestOf) defaults to bestOf.

React components

The components are styled with Tailwind CSS classes and the shadcn design tokens (background, card, border, primary, muted, destructive, ring) plus two extra tokens, subtle-foreground and status-live. Tell Tailwind to scan the package so the classes are generated:

@source "../node_modules/@osthelia/bracket-engine/dist";

The package imports @xyflow/react/dist/style.css, so your bundler must accept CSS imports from node_modules (Next.js does).

Viewer

import { BracketCanvas } from "@osthelia/bracket-engine/react";

<BracketCanvas
  containers={containers}
  matchHref={(id) => `/match/${id}`}
  labels={{ viewer: { tbd: "A définir" } }}
  renderLink={({ href, className, children }) => <Link href={href} className={className}>{children}</Link>}
  renderLogo={(entrant, className) => <TeamLogo team={entrant} className={className} />}
/>

renderLink and renderLogo are optional. The default logo shows the first letter of the name when there is no image or the image fails to load.

The canvas is heavy, load it on demand in your app (next/dynamic with ssr: false, or React.lazy).

Editor

The editor does not ship form controls. Pass the ones of your design system with ui:

import { StageEditor } from "@osthelia/bracket-engine/react";

<StageEditor
  data={editorData}
  ui={{ Button, Input, Select, Checkbox, Popover, PopoverTrigger, PopoverContent, ConfirmDialog, Spinner }}
  onSave={async (graph) => saveStage(stageId, graph)}
  onSaved={() => router.refresh()}
  errorMessage={(error) => t(error.code, error.params)}
/>

onSave must validate again on the server and return { ok: false, errors } keyed by field path when it refuses the graph. The prop shapes each control must accept are described by the EditorUi type.

Translations

Every text can be replaced through the labels prop, anything missing stays in English. Labels that take a value are functions (errorCount: (count) => ...), so plural rules stay yours.

Development

npm install
npm test
npm run typecheck
npm run build

Release

Releases are manual. Update CHANGELOG.md, bump the version, then:

npm version <patch|minor|major>
npm publish --access public

prepack builds the package, files limits the tarball to dist, the license and the docs. Run npm pack --dry-run first to check the content.

License

MIT, see LICENSE.md.