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

@008h/oxs

v0.1.1

Published

Read, write and validate Open Cross Stitch (.OXS) files

Readme

oxs

Read, write and validate Open Cross Stitch (.oxs) files. Pure TypeScript, ESM, no DOM or Node-specific APIs.

Install

npm install @008h/oxs

Usage

Read, validate, write

import { parseOxs, serializeOxs, validateOxs } from '@008h/oxs';

const doc = parseOxs(xmlString);
console.log(doc.properties.chartWidth, doc.properties.chartHeight);

for (const d of validateOxs(doc)) {
  console.warn(d.severity, d.code, d.message);
}

const xml = serializeOxs(doc);

serializeOxs(doc, { sort: true }) orders stitches by x, y and palette index, which gives stable output for diffs and golden files.

Create a chart

Documents are immutable: build a new one instead of changing it in place.

import { createDocument, serializeOxs } from '@008h/oxs';

const empty = createDocument({ width: 8, height: 8, title: 'Heart', author: 'me' });

const doc = {
  ...empty,
  palette: [
    ...empty.palette,
    { index: 1, number: '321', name: 'Red', color: 'C93756', blends: [], extra: [] },
  ],
  fullStitches: [
    { x: 3, y: 2, palindex: 1, extra: [] },
    { x: 4, y: 2, palindex: 1, extra: [] },
  ],
};

const xml = serializeOxs(doc);

palette[0] (index 0) is the cloth colour. createDocument adds it for you.

Inspect

import { chartBounds, paletteUsage, paletteCount } from '@008h/oxs';

chartBounds(doc);   // { minX, maxX, minY, maxY } of the stitches, or null if empty
paletteUsage(doc);  // Set of palette indexes that are actually used
paletteCount(doc);  // number of palette entries, not counting the cloth

Edit as a grid

toDense turns a document into maps keyed by cell, which is convenient for editors. fromDense converts back against the original document, reusing unchanged elements so that unknown attributes survive.

import { toDense, fromDense, cellKey } from '@008h/oxs';

const dense = toDense(doc);

const edited = {
  ...dense,
  fullStitches: new Map(dense.fullStitches).set(cellKey(5, 5), 1),
};

const next = fromDense(edited, doc);

Validation

validateOxs does not throw on odd input. It returns diagnostics, each with a severity (error, warn or info), a stable code, a message and usually a path. It currently reports:

| Code | Severity | Meaning | |---|---|---| | OXS003_OUT_OF_BOUNDS | info | a stitch or ornament lies outside the chart size | | OXS004_UNKNOWN_PALINDEX | warn | a stitch references a palette index that does not exist | | OXS007_FOREIGN_ELEMENT | info | an unknown element was kept verbatim | | OXS009_CLOTH_INDEX_MISSING | info | the palette has no entry at index 0 (cloth) |

Out-of-bounds coordinates are legal in OXS, so they are reported as info, never error. The DiagnosticCode type lists a few more codes that are reserved for later and not reported yet.

Errors

Malformed XML makes parseOxs (and readXml) throw XmlParseError:

import { parseOxs, XmlParseError } from '@008h/oxs';

try {
  parseOxs(text);
} catch (e) {
  if (e instanceof XmlParseError) console.error('not valid XML:', e.message);
  else throw e;
}

Preservation

Unknown attributes are kept in extra and unknown elements in foreign, so a parse → serialize round trip does not drop data written by other software.

Coordinates

The OXS specification does not define the coordinate origin. Based on measurements of real-world files, this library treats coordinates as 0-based and keeps them exactly as written in the file: parsing and serializing never shift values. Out-of-bounds coordinates are therefore legal in the IR and reported by validateOxs instead. Use detectOrigin, toZeroBased and fromZeroBased to interpret a file's origin.

Details and evidence: docs/OXS-DIALECT.md.

Disclaimer

OXS is a file format published by Ursa Software. This project is an independent implementation and is not affiliated with or endorsed by Ursa Software.

License

MIT