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

@motioncomplex/cosmos-lib

v1.3.6

Published

Reusable astronomical utilities: data, math, media, sky maps, NASA APIs, and UI transitions.

Readme

cosmos-lib

npm version npm downloads license

Reusable TypeScript library for astronomical data, coordinate math, sky maps, NASA/ESA APIs, media loading, and UI transitions. Zero runtime dependencies — Three.js and React support are optional peer dependencies in separate entry points.

Install

npm install @motioncomplex/cosmos-lib

Optional peer dependencies (only install what you use):

npm install three    # for cosmos-lib/three (3D scene helpers)
npm install react    # for cosmos-lib/react (React hooks & components)

Quick start

import Cosmos from '@motioncomplex/cosmos-lib'

// Search the built-in catalog (300+ stars, 110 Messier, 88 constellations)
const results = Cosmos.Data.search('orion')
const nebulae = Cosmos.Data.getByType('nebula')
const near    = Cosmos.Data.nearby({ ra: 83.8, dec: -5.4 }, 20)

// Coordinate transforms
const { alt, az } = Cosmos.Math.equatorialToHorizontal(
  { ra: 101.287, dec: -16.716 },                // Sirius
  { lat: 47.05,  lng: 8.31, date: new Date() }  // Lucerne
)

// Sun, Moon & eclipses
const sunPos    = Cosmos.Sun.position()
const moonPhase = Cosmos.Moon.phase()
const twilight  = Cosmos.Sun.twilight({ lat: 51.5, lng: -0.1 })

// NASA APIs
const apod = await Cosmos.API.NASA.apod()
const imgs = await Cosmos.API.NASA.searchImages('pillars of creation', { pageSize: 5 })

Tree-shakeable named exports

import { AstroMath, Data, NASA, Units, renderSkyMap, staggerIn } from '@motioncomplex/cosmos-lib'

React hooks (optional)

import { useSkyPosition, useMoonPhase, useWhatsUp, useTwilight, SkyMap } from '@motioncomplex/cosmos-lib/react'

// Reactive sky position — auto-updates every 10s
const pos = useSkyPosition('sirius', { lat: 47.05, lng: 8.31 })

// What's visible tonight?
const visible = useWhatsUp({ lat: 47.05, lng: 8.31 }, { magnitudeLimit: 4 })

Three.js helpers (optional)

import { createPlanet, LODTextureManager, CameraFlight } from '@motioncomplex/cosmos-lib/three'
import * as THREE from 'three'

const { group, dispose } = createPlanet({
  radius: 6.5,
  textureUrl: 'earth-bluemarble-4k.jpg',
  atmosphere: { color: 0x4488ff, intensity: 1.3 },
}, THREE)
scene.add(group)

Features

| Module | Description | Docs | |--------|-------------|------| | Data | 300+ bright stars, 110 Messier objects, 88 constellations, 20 meteor showers, solar system bodies. Fuzzy search, proximity queries, image resolution. | Data | | AstroMath | Julian dates, sidereal time, coordinate transforms (equatorial, horizontal, galactic, ecliptic), Kepler solver, planetary ephemeris, precession, nutation, refraction, rise/transit/set. | Math | | Sun / Moon / Eclipse | Solar & lunar positions, moon phases, twilight times, eclipse prediction. | Sun/Moon/Eclipse | | NASA / ESA / Simbad | NASA Image Library, APOD, ESA Hubble archive, CDS Simbad object resolution. | API Integrations | | Planner | "What's up tonight?" — visible objects, best observation windows, visibility curves, moon interference scoring, airmass, planet oppositions/conjunctions. | Planner | | AstroClock | Simulation clock with speed control, forward/reverse playback, snap-to-event, and requestAnimationFrame support. | Clock | | Sky Map | Stereographic, Mollweide, and gnomonic projections. Interactive canvas sky chart with pan, zoom, click-to-identify, FOV overlays, HUD, and real-time tracking. | Sky Map | | React Hooks | useSkyPosition, useMoonPhase, useAstroClock, useWhatsUp, useTwilight, <SkyMap />. SSR-safe. Optional peer dependency. | React | | Equipment | 160+ cameras, telescopes, lenses, and star trackers. Rig builder with FOV, pixel scale, framing, exposure limits, payload check, and target recommendations. | Astrophoto | | AstroPhoto | Session planner, exposure calculators (NPF, rule of 500, sub-exposure), Milky Way tracker, polar alignment, golden/blue hour, light pollution tools. | Astrophoto | | Events | Upcoming events feed: moon phases, eclipses, meteor showers, oppositions, conjunctions, equinoxes, solstices. iCal export. Observer visibility scoring. | Events | | Media | Progressive image loading with fallback chains, Wikimedia/Cloudinary URL builders, responsive srcset generation. | Media | | Transitions | View Transitions API wrappers: morph, stagger reveal, fade, crossfade, hero expand/collapse. | Transitions | | Three.js | Planet/nebula/starfield factories, LOD texture management, camera flights. Optional peer dependency. | Three.js | | Constants & Units | Astronomical constants (IAU 2012), distance/angle conversions, RA/Dec formatters. | Constants & Units |

Documentation

Full documentation lives in the docs/ folder:

  • Getting Started — installation, import patterns, quick start
  • API Reference — per-module docs with signatures, parameters, and examples
  • Guides — conceptual walkthroughs for coordinate systems, catalog data, and Three.js integration
  • Type Reference — quick-reference table of all exported types

Generate HTML API docs from TSDoc comments:

npm run docs

Development

npm install
npm test              # run tests
npm run test:watch    # watch mode
npm run typecheck     # tsc --noEmit
npm run build         # compile to dist/
npm run docs          # generate TypeDoc API reference

License

MIT