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

@kazuhi-ra/turnbox-core

v0.4.0

Published

Core logic for TurnBox — pure functions for 3D box animation geometry, state, and transitions (no DOM dependency)

Readme

@kazuhi-ra/turnbox-core

Pure geometry and navigation functions for TURNBOX.js. No DOM dependency.

For most use cases, prefer @kazuhi-ra/turnbox-dom, @kazuhi-ra/turnbox-react, or @kazuhi-ra/turnbox-vue.

Installation

npm install @kazuhi-ra/turnbox-core

API

normalizeOptions(options)

Fills in defaults and returns a NormalizedOptions object.

import { normalizeOptions } from "@kazuhi-ra/turnbox-core";

const opts = normalizeOptions({ faces: 4, duration: 400 });

calcFaceTransform(currentFace, faceNum, opts)

Returns the CSS transform values for faceNum relative to currentFace.

import { normalizeOptions, calcFaceTransform } from "@kazuhi-ra/turnbox-core";

const opts = normalizeOptions({ faces: 4 });
const t = calcFaceTransform(1, 2, opts);
// { axis: "X", deg: 90, x: 0, y: -25, z: 25, zIndex: 10, transformOrigin: "50% 50%" }

const css = `rotate${t.axis}(${t.deg}deg) translate3d(${t.x}px, ${t.y}px, ${t.z}px)`;

DEFAULT_SIZE / DEFAULT_HEIGHT

import { DEFAULT_SIZE, DEFAULT_HEIGHT } from "@kazuhi-ra/turnbox-core";
// DEFAULT_SIZE = 200
// DEFAULT_HEIGHT = 50

Internal API

@kazuhi-ra/turnbox-core/internal is used across the @kazuhi-ra/turnbox-* packages and may have breaking changes in minor releases. Direct use from outside the monorepo is not recommended.

State machine

Shared reducer for @kazuhi-ra/turnbox-dom, -react, and -vue.

import {
  INITIAL_STATE,
  reducer,
  toPhase,
  buildGoStepAction,
  buildGoInstantAction,
  type TurnBoxState,
  type TurnBoxAction,
  type AnimationPhase,
  type PendingNav,
} from "@kazuhi-ra/turnbox-core/internal";

| Export | Kind | Description | | --- | --- | --- | | TurnBoxState | type | Union of IdleState \| SettlingState \| AnimatingState | | TurnBoxAction | type | Union of all dispatchable action types | | AnimationPhase | type | { kind: "idle" } \| { kind: "animating" } — coarser view of state for isAnimating | | PendingNav | type | { face: number; animation: boolean } — item stored in the queue | | INITIAL_STATE | const | Initial TurnBoxState (face 1, idle) | | reducer | function | (state, action) => TurnBoxState | | toPhase | function | (state) => AnimationPhase — collapses settling into idle | | buildGoStepAction | function | (to, from) => TurnBoxAction — animated step | | buildGoInstantAction | function | (displayFace, from) => TurnBoxAction — no-animation jump |

Navigation orchestration

Decision layer that sits above the state machine, shared by all adapters.

import {
  resolveNavigation,
  buildDrainResult,
  type NavigationDecision,
  type DrainResult,
} from "@kazuhi-ra/turnbox-core/internal";

| Export | Kind | Description | | --- | --- | --- | | NavigationDecision | type | "noop" \| "enqueue" \| "abort" \| "go" — what the caller should do | | DrainResult | type | "empty" \| { navigate, enqueue } — result of draining the queue after settle | | resolveNavigation | function | (state, rawTarget, opts, animation) => NavigationDecision | | buildDrainResult | function | (settledFace, queue, opts) => DrainResult |

Other internal exports

| Export | Description | | --- | --- | | shouldAnimate | Whether a transition should run with animation | | resolveTransition | Resolves rawTarget to a canonical face + doAnimate flag | | getFaceParity | Returns "odd" \| "even" for a face number | | MAX_FACE_PCS | Maximum supported face count (4) | | FOCUSABLE | CSS selector string for focusable elements inside a face | | Transition, RotationDeg, FaceVisibility, FaceParity | Shared geometry/navigation types |

License

MIT