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

@nice2dev/spatial-core

v1.0.15

Published

Unified spatial/floor-plan/CAD core logic for Nice2Dev UI components

Readme

@nice2dev/spatial-core

Unified spatial/floor-plan/CAD core logic for Nice2Dev UI components.

Overview

@nice2dev/spatial-core provides framework-agnostic core functionality for spatial editing applications:

  • Grid System — Snap-to-grid, alignment guides, intelligent snapping
  • Spatial Objects — Unified object model for devices, furniture, network equipment
  • Floor Plan Model — Walls, rooms, zones, layers, floors
  • Measurement — Distance, angle, area calculations with unit conversion
  • Serialization.nsp.json format for saving/loading spatial documents

Installation

npm install @nice2dev/spatial-core
# or
pnpm add @nice2dev/spatial-core

Usage

Grid System

import { 
  snapToGrid, 
  generateAlignmentGuides, 
  performSnap,
  DEFAULT_GRID_CONFIG 
} from '@nice2dev/spatial-core/grid';

// Snap point to grid
const snapped = snapToGrid({ x: 123, y: 456 }, DEFAULT_GRID_CONFIG);

// Generate alignment guides while dragging
const guides = generateAlignmentGuides(draggedBounds, otherObjects, 10);

// Intelligent snap with multiple modes
const result = performSnap(mousePos, targetObjects, gridConfig);

Object Catalog

import { 
  OBJECT_CATALOG, 
  getCatalogByCategory, 
  searchCatalog 
} from '@nice2dev/spatial-core/objects';

// Get all smart home devices
const devices = getCatalogByCategory('smart-home');

// Search catalog
const results = searchCatalog('camera');

Floor Plan

import { 
  createFloorPlanDocument, 
  createFloor, 
  addObjectToLayer,
  calculatePolygonArea 
} from '@nice2dev/spatial-core/floor-plan';

// Create new floor plan
const doc = createFloorPlanDocument('My House', 'floor-plan');

// Add a floor
const floor = createFloor('Ground Floor', 0, { x: 0, y: 0, width: 20, height: 15 });
doc.floors.push(floor);

// Calculate room area
const area = calculatePolygonArea(roomBoundary);

Measurement

import { 
  distance2D, 
  polygonArea, 
  formatLength, 
  autoFormatArea,
  convertLength 
} from '@nice2dev/spatial-core/measurement';

// Calculate distance
const dist = distance2D({ x: 0, y: 0 }, { x: 3, y: 4 }); // 5

// Format with units
const formatted = autoFormatArea(150.5, 'metric'); // "150.50 m²"

// Convert units
const feet = convertLength(10, 'm', 'ft'); // 32.8084

Serialization

import { 
  serialize, 
  deserialize, 
  validate,
  downloadNSP,
  exportFloorToSVG 
} from '@nice2dev/spatial-core/serialization';

// Save document
const json = serialize(document, { pretty: true });

// Load document
const result = deserialize(jsonString);
if (result.success) {
  const doc = result.data;
}

// Validate
const validation = validate(document);
console.log(validation.errors, validation.warnings);

// Download as file
downloadNSP(document, 'my-floor-plan.nsp.json');

// Export to SVG
const svg = exportFloorToSVG(floor, { showGrid: true, showLabels: true });

Document Types

The .nsp.json format supports multiple document types:

| Type | Description | Use Case | |------|-------------|----------| | floor-plan | 2D floor plan | Smart home, building automation | | network-topology | Network diagram | IT infrastructure planning | | infrastructure | Data center layout | Server room, rack planning | | cad | Architectural CAD | Detailed building design | | interior | Interior design | Furniture placement | | game-scene | Game level/scene | Game development |

Object Categories

Unified catalog of placeable objects:

  • smart-home — Lights, thermostats, cameras, sensors, locks
  • furniture — Sofas, tables, beds, wardrobes, desks
  • network — Routers, switches, servers, access points
  • infrastructure — Racks, UPS, PDU, cooling units
  • building — Walls, doors, windows, stairs
  • game — Spawn points, triggers, pickups

License

MIT