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

@lumilla/aphelion

v1.1.0

Published

Aphelion - A beautiful, interactive math editor for the web

Downloads

58

Readme

Aphelion

A beautiful, interactive math editor for the modern web.

Tests npm codecov TypeScript License: LGPL v3

Aphelion is a LaTeX-based math input library that renders editable mathematical expressions in the browser.

Note: Aphelion is an inspired modern reimplementation of the fantastic mathquill/mathquill (MPL licensed). It is not a derivative work. The codebase has been written from scratch.

Installation

npm install @lumilla/aphelion

Usage

Vanilla JavaScript

import { Aphelion } from "@lumilla/aphelion";
import "@lumilla/aphelion/styles.css";

const AP = Aphelion.getInterface(3);

// Create an editable math field
const mathField = AP.MathField(document.getElementById("math-field"), {
  handlers: {
    edit: (mf) => {
      console.log("LaTeX:", mf.latex());
    },
  },
});

// Set content programmatically
mathField.latex("\\frac{a}{b}");

Static Math Display

import { StaticMath } from "@lumilla/aphelion";
import "@lumilla/aphelion/styles.css";

function App() {
  return <StaticMath>{"\\frac{1}{2}"}</StaticMath>;
}

API

MathField Instance Methods

| Method | Description | | ------------------ | -------------------------------------------- | | latex() | Get the current LaTeX content | | latex(value) | Set the LaTeX content | | text() | Get plain text representation | | html() | Get the HTML content | | focus() | Focus the field | | blur() | Blur the field | | write(latex) | Write LaTeX at cursor position | | cmd(command) | Execute a command (e.g., \\frac, \\sqrt) | | select() | Select all content | | clearSelection() | Clear the selection | | moveToRightEnd() | Move cursor to end | | moveToLeftEnd() | Move cursor to start | | keystroke(key) | Simulate a keystroke | | typedText(text) | Simulate typing text | | config(options) | Update configuration | | reflow() | Recalculate layout |

Configuration Options

interface AphelionConfig {
  restrictMismatchedBrackets?: boolean;
  autoOperatorNames?: string;
  autoCommands?: string;
  supSubsRequireOperand?: boolean;
  sumStartsWithNEquals?: boolean;
  maxDepth?: number;
  spaceBehavesLikeTab?: boolean;
  leftRightIntoCmdGoes?: "up" | "down";
  handlers?: {
    edit?: (mathField: MathFieldInstance) => void;
    enter?: (mathField: MathFieldInstance) => void;
    moveOutOf?: (
      direction: "left" | "right",
      mathField: MathFieldInstance,
    ) => void;
    selectOutOf?: (
      direction: "left" | "right",
      mathField: MathFieldInstance,
    ) => void;
    deleteOutOf?: (
      direction: "left" | "right",
      mathField: MathFieldInstance,
    ) => void;
    upOutOf?: (mathField: MathFieldInstance) => void;
    downOutOf?: (mathField: MathFieldInstance) => void;
  };
}

Features

Aphelion supports a large subset of LaTeX commands including, but not limited to:

  • Fractions & Roots: \frac{a}{b}, \sqrt{x}, \sqrt[n]{x}
  • Subscripts & Superscripts: x^{n}, x_{n}, x_{a}^{b}
  • Greek Letters: All lowercase and uppercase Greek symbols (\alpha, \pi, \omega, etc.)
  • Operators: Binary operators (\pm, \times, \div), large operators (\sum, \prod, \int)
  • Brackets: Automatic bracket balancing and nesting
  • Text Modes: \text, \mathbf, \mathcal, \mathbb, and more
  • Matrices: Multiple matrix formats (\pmatrix, \bmatrix, \vmatrix, etc.)
  • Accents: Decorations like \hat, \bar, \vec, \overline

For a complete list of supported commands, see latexCommandInput.ts.

Examples

Quadratic Formula

mathField.latex("x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}");

Euler's Identity

mathField.latex("e^{i\\pi}+1=0");

Summation

mathField.latex("\\sum_{i=1}^{n}i=\\frac{n(n+1)}{2}");

Development

Scripts

npm run dev          # Start development server
npm run build        # Build for production
npm run build:lib    # Build as library
npm test             # Run tests
npm run test:ui      # Run tests with UI
npm run test:coverage # Run tests with coverage
npm run lint         # Lint source files
npm run typecheck    # Type check without emitting

Building

The library builds to both ES modules and UMD formats:

  • dist/aphelion.es.js - ES module
  • dist/aphelion.js - UMD bundle (for dinosaurs, will probably be dropped in the future)
  • dist/styles.css - Stylesheet (Obviously)

Testing

For this repository, Vitest is used for testing. Run the test suite with

npm run test

To test (most of) the examples in the documentation, Accudoc is used.

npm run doctest

CI & Nightly artifacts

CI runs on every PR with GitHub Actions (.github/workflows/test.yml). When tests and checks succeed a job runs and uploads an artifact containing dist/. Code coverage is automatically updated during the test build.

Publishing

Publishing to npm is handled by .github/workflows/publish.yml which runs on pushes with tags matching v* or manual dispatch. Published on npm under scope @lumilla

Browser Support

Aphelion should work in all modern browsers, so Internet Explorer is not supported. Intentionally.

License

LGPL-3.0 - see LICENSE for details.