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

@openseat/core

v0.1.0

Published

Framework-independent layout schema, validation, geometry and generators for OpenSeat.

Readme

@openseat/core

Layout schema, validation, serialisation, migrations, geometry, generators and layout operations for OpenSeat. No React, Konva, DOM or network dependencies; runs in browsers, Node and workers.

Layout documents

import { createLayout, validateLayout, parseLayout, serializeLayout } from "@openseat/core";

const layout = createLayout({ id: "hall", name: "Main hall", width: 1200, height: 900 });

const result = validateLayout(layout); // { valid, layout, errors, warnings }
const json = serializeLayout(layout); // canonical key order: same layout, same text
const reloaded = parseLayout(json); // JSON errors are reported, never thrown

validateLayout and parseLayout never throw: an unexpected internal failure becomes an INVALID_DOCUMENT error ("Internal validation error: …"). serializeLayout does not validate; it throws a TypeError only for input nested deeper than MAX_SERIALIZE_DEPTH (256) levels, which no valid document is. An own __proto__ key survives serialisation as data.

Importing @openseat/core sets z.config({ jitless: true }) once, so Zod never probes for eval (which would raise CSP violation reports under a script-src without 'unsafe-eval').

Size limits

LAYOUT_LIMITS bounds what an untrusted document can make validation, rendering and the generators do. Values beyond a limit fail validation with a readable message (sizes as INVALID_DIMENSION, the rest as SCHEMA_VIOLATION):

| Limit | Value | Applies to | | --------------------------------------- | ----------- | --------------------------------------------------------- | | maxObjects | 250,000 | objects | | maxPolygonPoints | 5,000 | polygon, section and GA boundaries, aisle and path points | | maxTotalShapePoints | 200,000 | the points of all those shapes together | | maxSectionSeats | 20,000 | seats one section's parametric seating may generate | | maxGroupSeats | 5,000 | seatObjectIds of a row or table | | maxCategories | 1,000 | categories | | maxTableCapacity / maxSeatsPerEdge | 500 / 500 | table capacity, each edge of a rect arrangement | | maxCoordinate | 1e7 | |x| and |y| of every point | | maxDimension | 1e6 | widths, heights, radii, spacings, gaps and offsets | | maxFontSize | 10,000 | label fontSize, section labelSize | | maxMetadataBytes / maxMetadataDepth | 64 KiB / 16 | metadata as UTF-8 JSON, and its nesting |

metadata may not contain the keys __proto__, constructor or prototype at any level. Fill seating also needs rowSpacing and seatSpacing of at least 1 and aisleEvery / minSeatsPerRow of at most 2,000.

Validation stays fast on hostile input: the overlap check sizes its grid from the median seat, keeps at most 32 seats per cell and stops after 8,000,000 comparisons, compares a few oversized seats linearly (skipped work is reported with an OVERLAP_CHECK_SKIPPED warning), the simple-polygon checks of a document share a budget of 8,000,000 candidate edge pairs (a shape past it is a MALFORMED_GEOMETRY error), and SpatialIndex keeps entries wider than MAX_CELLS_PER_ENTRY (4,096) cells, or at non-finite coordinates, in a list scanned on every query.

Every issue has a code, severity, message, dotted path (for example objects.12.seatObjectIds.3) and, when it belongs to an object, objectId.

| Errors | Warnings | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | INVALID_DOCUMENT, UNSUPPORTED_SCHEMA_VERSION, SCHEMA_VIOLATION, NON_FINITE_VALUE, INVALID_DIMENSION, MALFORMED_GEOMETRY, DUPLICATE_OBJECT_ID, DUPLICATE_SEAT_ID, DUPLICATE_CATEGORY_ID, UNRESOLVED_REFERENCE | SEAT_OUTSIDE_SECTION, OBJECT_OUTSIDE_CANVAS, DUPLICATE_SEAT_POSITION, CAPACITY_MISMATCH, SEAT_OVERLAP, OVERLAP_CHECK_SKIPPED |

Object types: seat, row, section, table, booth, stage, aisle, label, polygon, path, entrance, ga.

A stage may carry style?: { fill?, stroke?: "#rrggbb"; strokeWidth?: 0..50 } and markings?: "rink" | "court" | "pitch" (sport markings drawn on its surface). Both are optional; documents without them serialise exactly as before.

Visibility and locks

visible and locked are inherited: a seat is hidden when it, its row or table, or their section is hidden (isEffectivelyHidden), and likewise locked (isEffectivelyLocked). setFlags(layout, ids, { visible, locked }) writes only the given objects, so a row hidden on its own stays hidden when its section is hidden and shown again. Validation, the booking SDK and moves use the effective state. The inventory manifest lists hidden seats too: hiding is a drawing state, not an inventory change.

Two kinds of ID

  • object.id identifies an object inside the document. Rows and tables reference their seats by object ID in seatObjectIds.
  • seat.seatId is the public identifier your inventory system uses.

Layouts hold geometry only. Booking status belongs to your backend and is passed to the renderer separately.

Coordinates

position is an object's origin in layout space; rotation is in degrees, clockwise on screen, around that origin. Rectangles and circles are centred on the origin. Polygon and path points are relative to it.

Generators

All generators are pure and deterministic: the same options produce the same IDs.

import { generateCurvedRows, generateRectTable, generateRoundTable, generateStraightRows } from "@openseat/core";

const origin = { x: 100, y: 100 };
const center = { x: 600, y: 600 };
generateStraightRows({
  idPrefix: "stalls",
  rowCount: 10,
  seatsPerRow: 20,
  origin,
  seatSpacing: 24,
  rowSpacing: 30,
  aisleAfter: [10],
  stagger: 12,
});
generateCurvedRows({
  idPrefix: "balcony",
  rowCount: 3,
  seatsPerRow: 24,
  center,
  innerRadius: 400,
  rowSpacing: 34,
  startAngle: 30,
  endAngle: 150,
  tangentRotation: true,
});
generateRoundTable({ idPrefix: "vip", label: "T1", center, tableRadius: 40, seatCount: 8 });
generateRectTable({
  idPrefix: "vip",
  label: "T2",
  center,
  width: 200,
  height: 80,
  seatsPerEdge: { top: 4, bottom: 4 },
});

Generated IDs: seat ID ${idPrefix}:${rowOrTableLabel}:${number}, seat object ID ${idPrefix}:seat:${label}:${number}. The seat ID uses the raw number, not the formatted label, so changing a label prefix does not break inventory mapping. Invalid options throw GeneratorInputError.

Section fills (planFillRows, generateSectionSeating, fill seating) refuse more than 500 rows, more than 2,000 seats in one span and boundary coordinates beyond maxCoordinate, before doing any work. applySectionSeating then throws that GeneratorInputError (a RangeError) and the layout is unchanged.

Arenas

import { arenaPreset, createArenaLayout, estimateArenaSeats } from "@openseat/core";

const layout = createArenaLayout({
  ...arenaPreset("hockey"),
  idPrefix: "a",
  center: { x: 0, y: 0 },
  layoutId: "arena",
});
// name defaults to the preset title, "Ice hockey arena"
estimateArenaSeats({ ...arenaPreset("hockey"), idPrefix: "a", center: { x: 0, y: 0 } }); // 9,758, without generating

The hockey preset follows the seatmap.pro reference: a white rink (style, markings: "rink") inside a 16-row lower bowl 101–119 (straight long-side and short-end blocks, fan corners, three in the top-left), a ring of single-row 200-level boxes and an 18-row upper bowl 301–321, numbered clockwise with row A nearest the ice. extraCornerSections adds fans to individual corners. ARENA_LIMITS caps the options (8 tiers, 100 rows per tier, 50 sections per side or corner, a 1e5 field, 2,000 seats per row); generateArena throws a GeneratorInputError when estimateArenaSeats exceeds 200,000.

Rows, sections and tables

  • extendRow and insertSeats never renumber existing seats: they keep their labels and seat IDs. New seats continue the numbering (never 0 or below; when numbering down would go below 1 they continue after the highest number and the result carries a message), and their seat IDs follow the row's own pattern (prefix + label).
  • Row label skip lists apply only to the alpha and alpha-lower formats.
  • minBlockCurvature(rows, rowSpacing, seatSpacing, longestRow?) and maxBlockCurvature(seatSpacing, longestRow?) bound a block's curvature so the longest row bends through at most 162° and its seats stay at least 0.95 × the spacing apart; stronger curvature is refused by applySectionSeating. For an existing block, blockCurvatureRange(seating) returns the exact { min, max } that applySectionSeating accepts, counting per-row lengths (rowSeats) and aisles; use it to bound a curvature slider.
  • Round tables keep the gap between table edge and seats when their radius changes (floored at the seat radius). minRoundTableRadiusForSeats(seatCount, { seatShape, gap }) is the smallest radius that still fits the seats, for clamping radius inputs.

Venue templates

@openseat/core/templates is a separate entry point with 104 ready-made setups for 45 venues in 10 categories (auditoriums, open grounds, cricket grounds, banquet halls, expo halls, amphitheatres, campus grounds and more), each a complete, editable layout at 50 layout units per metre. Load it with a dynamic import() so booking bundles, which import only @openseat/core, never include it:

const { buildTemplate, searchTemplates, placeTemplate } = await import("@openseat/core/templates");

searchTemplates("Auditoriums")[0]?.venueId; // "performance.auditorium"
const { layout, summary } = buildTemplate("performance.auditorium.annual-day", null, { targetCapacity: 800 });
summary.seats; // 776: the closest the setup's rows get to 800
const merged = placeTemplate(existing, buildTemplate("sports.cricket.fest-night"), { mode: "insert" }).layout;

Builds are deterministic and never throw for any parameters (out-of-range values are clamped and listed in summary.notes); every combination stays within TEMPLATE_LIMITS (25,000 seats, 40,000 objects). Template layouts use the existing schema: everything template-specific lives under metadata.openseat. Inserted sections whose label clashes get (2) and their seats the IDs <label (2)>-<row>-<seat>.

Three pure helpers in the root package serve templates and hosts: unsellableInventory(layout) lists what must be seeded as blocked (seats of never-sold ticket types such as judges and participants, and anything marked Not for sale), setObjectsCategory and renumberObjects (tables and booths, labels only). See the templates API and the catalogue.

Operations

Immutable edits. Unchanged objects keep their identity, which is what renderers diff on.

import { moveObjects, removeObjects, transformObject, updateObject } from "@openseat/core";

moveObjects(layout, ["stalls:row:A"], { x: 0, y: 30 }); // rows and tables bring their seats
transformObject(layout, "vip:table:T1", { position, rotation: 90, scaleX: 1, scaleY: 1 }); // seats follow
removeObjects(layout, ids); // also removes dangling seat references
updateObject(layout, id, (obj) => ({ ...obj, name: "Front" }));

Locked objects are never moved or transformed.

renameCategory(layout, from, to) changes a category's ID (the key events and the ticketing API use for a ticket type): the category, every object's categoryId and the category-keyed entries of metadata.openseat (unsellableCategories and the byCategory maps of prices and suggestedPrices). It is pure and throws a RangeError when from is not a category, or to is empty, longer than 200 characters or already taken.

Geometry

rotatePoint, localToWorld, worldToLocal, getBounds, boundsIntersect, boundsUnion, boundsContain, polygonArea, isSimplePolygon, pointInPolygon, segmentsIntersect, distanceToSegment, plus per-object getObjectBounds, getObjectHitShape, hitShapeContains, getDrawOrder and a SpatialIndex grid.

Migrations

migrateLayout(doc, migrations?) runs explicit { from, to, migrate } steps up to the current schema version. Newer versions are rejected rather than downgraded. parseLayout migrates before validating.