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

@valschr/resheet

v0.4.0

Published

Agent-first spreadsheet component for Preact and React: JSON operations, A1 addressing, Excel-style formulas.

Readme

Why resheet

Most spreadsheet components are built for people and bolt an API on later. resheet starts from the other side: a headless core that an AI agent drives with small, validated JSON operations (set, insertRows, filter, …) in A1 notation, with Excel-style formulas and error messages written for a model to act on. The UI is a thin, fast layer on top, so a person and an agent can work on the same sheet at the same time.

[
  {
    "op": "set",
    "tab": "Budget",
    "range": "A1",
    "values": [
      ["Item", "Cost"],
      ["Rent", 1200],
      ["Food", 450]
    ]
  },
  { "op": "set", "tab": "Budget", "range": "B4", "values": [["=SUM(B2:B3)"]] },
  { "op": "format", "tab": "Budget", "range": "A1:B1", "bold": true }
]

Features

For agents

  • JSON operations applied as one atomic, undoable batch; invalid batches change nothing
  • Error messages that name the fix: unknown tab "Budgte". Tabs: Budget, Q2. Did you mean "Budget"?
  • formulaErrors in every result, so broken formulas surface without a second call
  • AGENT_GUIDE (under 400 tokens) for the system prompt, opsSchema / opsToolSchema for tool definitions
  • A headless core (@valschr/resheet/core) that runs in Node with no DOM

For people

  • Text, numbers, booleans, formulas and tags (coloured chips)
  • 42 Excel functions (plus an AVG alias) and HASTAG / COUNTTAG, cross-tab references, function autocomplete
  • Keyboard editing, click-to-reference while typing a formula, copy and paste as TSV
  • Fill handle: drag to continue series (1, 2, Item 1, dates) or copy with shifted formulas; Ctrl/Cmd+D and Ctrl/Cmd+R
  • Find and replace (Ctrl/Cmd+F, Ctrl/Cmd+H)
  • Right-click menus for rows, columns and cells; tabs; filters and view-only sort; freeze panes
  • Bold, italic, strikethrough, number formats (number, percent, currency, date, time), column resizing, undo and redo
  • Tag manager: rename, recolour and delete a tag across a tab
  • CSV import and export, Excel (.xlsx) export
  • Virtualized grid for 50,000 rows by 50 columns
  • Light and dark themes that follow shadcn/ui CSS variables

Try it

The live demo is the playground from examples/demo: a task tracker and a budget with tags, formulas and a cross-tab reference, next to an agent console where you can paste operation batches, read ranges, view the snapshot and load 50,000 rows.

Everything stays in your browser: the workbook is saved to localStorage after each change and restored on the next visit. Reset brings back the example. Workbooks above 100,000 cells are not saved (browsers cap storage at about 5 MB).

Status: early release (0.4.0) on npm as @valschr/resheet. See plan.md for the build plan.

Quick start

Preact

pnpm add @valschr/resheet preact
import { render } from "preact";
import { createWorkbook, Spreadsheet } from "@valschr/resheet";
import "@valschr/resheet/styles.css";

const workbook = createWorkbook();
workbook.apply([
  {
    op: "set",
    range: "A1",
    values: [
      ["Item", "Cost"],
      ["Rent", 1200],
    ],
  },
]);

render(
  <Spreadsheet workbook={workbook} height={480} onChange={(snapshot, ops) => save(snapshot)} />,
  document.getElementById("app")!,
);

Props: workbook or initialSnapshot, onChange(snapshot, ops, { source, origin }), readOnly, undoScope ("all" or "user"), height (pixels or any CSS length, default 480), class, and toolbar, formulaBar, tabs (set false to hide). A ref gives the imperative handle: apply(ops, { origin }), snapshot, read, undo({ origin }), redo({ origin }), flash(ranges), select(range), focus() and workbook.

Working alongside an agent

const res = sheet.apply(ops, { origin: "agent" }); // tag the agent's edits
if (res.ok) sheet.flash(res.changed); // highlight what it changed

<Spreadsheet undoScope="user" onChange={(snap, ops, { origin }) => {}} />;
  • Origins. apply(ops, { origin }) tags a batch. Change events and onChange report it; edits made in the UI are tagged "user".
  • Undo per origin. undo({ origin: "user" }) undoes the person's last edit even when the agent changed the sheet since; undoScope="user" makes Ctrl/Cmd+Z and the toolbar do that. It returns false (and the button is disabled) when a later edit depends on that step: it touched the same cells, inserted or deleted rows, columns or tabs, or both changed layout.
  • Flash. flash(ranges, { duration }) briefly outlines ranges such as "B2:C4" or "Budget!B4" (1.5 s by default).
  • Diff. diffSnapshots(before, after) lists tabs added, removed and renamed, changed cells (with before/after, and whether the input, style or computed value changed), and changed sheet settings. Inserting a row reports the cells below it as changed.

readOnly blocks people, not the host: the ref handle (and the handle that Resheet.mount() returns) still applies operations, so an agent can drive a sheet the user can only view. Gate apply in your own code if it must not.

React

@valschr/resheet/react is a React 18+ component that bundles Preact internally, so a React app installs only @valschr/resheet (with react as the peer). It re-exports the whole core API.

pnpm add @valschr/resheet
import { useRef } from "react";
import { createWorkbook, Spreadsheet, type SpreadsheetHandle } from "@valschr/resheet/react";
import "@valschr/resheet/styles.css";

const workbook = createWorkbook();

export function Budget() {
  const sheet = useRef<SpreadsheetHandle>(null);
  return (
    <>
      <button onClick={() => sheet.current?.apply({ op: "sort", column: "B", dir: "desc" })}>
        Sort by cost
      </button>
      <Spreadsheet ref={sheet} workbook={workbook} height={400} className="budget" />
    </>
  );
}

Same props as the Preact component, with className instead of class.

Script tag and HTML artifacts

dist/resheet.umd.js is one file with Preact and the stylesheet inside. It defines the global Resheet and fetches nothing at runtime.

<div id="app"></div>
<script src="resheet.umd.js"></script>
<script>
  const workbook = Resheet.createWorkbook();
  const sheet = Resheet.mount(document.getElementById("app"), { workbook, height: 480 });
  // An agent script drives the mounted sheet through the returned handle:
  sheet.apply([{ op: "set", range: "A1", values: [["Hello"]] }]);
  sheet.read("A1"); // { values: [["Hello"]], ... }
  // sheet.unmount() removes it.
</script>
  • Load it from jsDelivr at a pinned version: https://cdn.jsdelivr.net/npm/@valschr/resheet@<version>/dist/resheet.umd.js.
  • Until then, inline the file into the page. vp run artifact writes dist/artifact.html: examples/umd.html with the UMD bundle inlined, a single self-contained page that works from file:// or as an HTML artifact.
  • A React (.jsx) artifact cannot import this package (only a fixed list of libraries is available there); use an HTML artifact.

Operations

Agents send an array of operations. apply validates the whole batch first; if any operation is invalid, nothing changes. Each batch is one undo step.

| op | Fields | Effect | | ------------- | --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | | set | range, values (2D array) | Writes a block starting at the top-left of range | | clear | range | Removes values and styles | | format | range, bold?, italic?, strike?, numberFormat?, decimals?, currency? | Sets the given style flags (false removes one) and number format; see below | | insertRows | at (1-based), count? | Inserts before row at; formula references shift | | deleteRows | at, count? | References to deleted cells become #REF! | | insertCols | at (letter), count? | | | deleteCols | at (letter), count? | | | setColWidth | col, width | Width in pixels | | addTab | name, index? | New tab; becomes the active tab and default target | | renameTab | tab, name | Rewrites formula references to the old name | | deleteTab | tab | References to it become #REF! | | moveTab | tab, index | | | filter | column, one of equals, contains, gt, lt, hasTag, in | Adds or replaces the filter on that column (view only) | | clearFilter | column? | One column, or all | | sort | column, dir (asc / desc); column: null removes the sort | View-only sort; row 1 stays on top as the header | | setTagColor | tag, color | Palette key: gray, red, orange, yellow, green, teal, blue, purple | | freeze | rows?, cols? (0 unfreezes) | Keeps the top rows / left columns in view while scrolling |

Every operation takes an optional tab; a range may also carry it ("Budget!A1:C3"). Cell values are text, numbers, booleans, null (clears) and { "tags": [...] }. "12" stays text; 12 is a number. A leading = makes a formula, a leading ' forces text.

numberFormat is "general" (removes the format), "number", "percent", "currency", "date", "datetime" or "time". decimals (0-10) applies to number (default 2), percent (0) and currency (2); currency is an ISO code (default "USD"). Given without numberFormat, decimals and currency adjust each cell's current format. Dates and times are serial numbers (=DATE(2026,12,20)), shown as 2026-12-20, 2026-12-20 14:30 or 14:30.

[
  { "op": "addTab", "name": "Budget" },
  {
    "op": "set",
    "range": "A1",
    "values": [
      ["Item", "Cost", "Status"],
      ["Rent", 1200, { "tags": ["paid"] }],
      ["Food", 450, { "tags": ["open", "urgent"] }]
    ]
  },
  { "op": "set", "range": "B4", "values": [["=SUM(B2:B3)"]] },
  { "op": "format", "range": "A1:C1", "bold": true },
  { "op": "filter", "column": "C", "hasTag": "open" }
]

opsSchema is the JSON Schema of the operations array; opsToolSchema wraps it as { ops: [...] } for a tool definition.

Headless API

@valschr/resheet/core has no Preact and no DOM; it runs in Node.

import { createWorkbook, diffSnapshots, toXLSX } from "@valschr/resheet/core";

const wb = createWorkbook(snapshot?, { limits? }); // a WorkbookSnapshot object or JSON text
wb.apply(ops, { origin: "agent" });    // atomic batch -> ApplyResult (origin optional)
await wb.applyAsync(ops, { sliceMs: 5, signal }); // same, in slices on a draft (see below)
wb.snapshot();                          // WorkbookSnapshot (plain JSON)
wb.read("Budget!A1:C10", { maxRows }); // inputs, computed values, styles
wb.undo(); wb.redo();                   // or undo({ origin: "user" }): that origin's last step
diffSnapshots(before, after);           // { addedTabs, removedTabs, renamedTabs, cells, settings, same }
const off = wb.subscribe((event) => {}); // after every batch
wb.toCSV("Budget"); wb.fromCSV(text, "Budget");
await toXLSX(wb.state);                 // Uint8Array: .xlsx with every tab

The snapshot is the storage format: { version: 1, activeTab, sheets: [{ name, cells: { "A1": "Item", "B4": { "input": "=SUM(B2:B3)", "value": 1650 } }, ... }] }. A styled cell carries style: { bold?, italic?, strike?, numFmt?: { kind, decimals?, currency? } }; a sheet with frozen panes carries frozenRows / frozenCols.

Formats of whole rows, whole columns and blocks over 4,096 cells are stored as ranges, not per cell: formats: [{ "range": "A:A", "style": { "bold": true } }], oldest first. Formatting a column or the whole sheet costs about as much as formatting one cell, and clear cuts the cleared block out of the ranges. A cell's own style wins over ranges; there false turns a range's flag off and numFmt: null resets its number format.

Limits

createWorkbook(snapshot, {
  limits: { maxRows, maxCols, maxCells, maxTabs, maxTouchedCells, maxFormatRanges },
});

The engine checks them while it works, so a batch is rejected (code limit_exceeded, nothing changes) before it builds what would pass a limit. maxCells counts stored cells across all tabs (wb.cellCount), maxTouchedCells the cells one batch writes, and maxFormatRanges format ranges per tab (default 10,000). Rows and columns default to Excel's limits; the others are unlimited. A snapshot over a limit throws on load.

Large batches without stalls

await wb.applyAsync(ops, { sliceMs: 5, origin, signal }) executes on a draft and yields to the event loop every sliceMs, then commits at once: readers only ever see the workbook before or after the batch, and it is all-or-nothing like apply. Calls queue in order; sync apply, undo and redo return busy / false while one is pending. signal aborts until recalculation starts. Its undo step restores the sheets as they were, so per-origin undo cannot skip it. The UI uses it for pastes over 20,000 cells.

Fluent API

A thin wrapper that builds the same operations (names follow Google Apps Script and ExcelJS):

wb.addSheet("Q2");
wb.sheet("Q2")
  .range("A1:B1")
  .setValues([["Item", "Cost"]])
  .setBold(true);
wb.sheet("Q2").range("B4").setFormula("=SUM(B2:B3)");
wb.sheet("Q2").range("B2:B4").setNumberFormat("currency", { currency: "EUR" });
wb.sheet("Q2").insertRows(3, 2).sort("B", "desc").freeze(1); // freeze(rows, cols?)
wb.sheet("Q2").range("A1:B4").getValues();

Reading results and errors

apply returns either

{ ok: true, changed: ["Budget!B4", ...], formulaErrors: [{ cell: "Budget!B5", error: "#DIV/0!" }] }
{ ok: false, errors: [{ index: 2, op: {...}, code: "unknown_tab", message: 'ops[2]: unknown tab "Budgte". Tabs: Budget, Q2. Did you mean "Budget"?' }] }
  • Messages say what was wrong and what is valid, so an agent can fix the batch.
  • formulaErrors lists formulas that evaluate to an error after the batch, so formula mistakes show up without a second call.
  • read returns { tab, range, values, inputs, styles, errors }; it stops at 200 rows by default and then sets truncated, totalRows and a note.
  • Error values are { error: "#DIV/0!" | "#VALUE!" | "#REF!" | "#NAME?" | "#N/A" | "#NUM!" | "#CYCLE!", message? }.
  • Formula messages name the fix too: unknown tab "Sheet2". Tabs: Budget, Tasks., unknown function SUMM. Did you mean SUM?, sheet names with spaces must be quoted: 'Project Tracker'!D7.

Agent guide

AGENT_GUIDE is a short system-prompt text (under 400 tokens) describing the operations. Paste it into the prompt of an agent that edits a sheet:

Ops: a JSON array, run in order as one atomic batch.
"tab" defaults to the active tab; addTab makes the new tab active.
Ranges: Budget!A1, 'My Sheet'!A1; quote names with spaces, in formulas too.
Values: text, number, bool, null (clears), {"tags":["a"]} (no commas); "12" is text, "=..." a formula.
Dates: =DATE(y,m,d), numberFormat date; date text stays text.
Excel formulas plus HASTAG(cell,tag) COUNTTAG(range,tag).
Row 1 is the header; view-only filter/sort move rows below it, totals too: keep totals above or on another tab.
set range values(2D) | clear range | format range bold? italic? strike? numberFormat?(general|number|percent|currency|date|datetime|time) decimals? currency?(EUR)
insertRows/deleteRows at(row) count? | insertCols/deleteCols at(letter) count?
setColWidth col(letter) width | addTab name index?(0=first) | renameTab tab name | deleteTab tab | moveTab tab index
filter column +one of equals|contains|gt|lt|hasTag|in(array) | clearFilter column?
sort column dir(asc|desc); "column":null removes it
setTagColor tag color(gray|red|orange|yellow|green|teal|blue|purple) | freeze rows? cols?(0=off)
Returns {ok:true,changed,formulaErrors} or {ok:false,errors}; filter/sort are in the snapshot.
Example:
[{"op":"set","range":"A1","values":[[900,"=A1*12"]]}]

Notes for agents

  • addTab makes the new tab active, and ops without tab target the active tab. Pass tab (or a Tab!A1 range) on every op.
  • Tab names with spaces must be quoted in formulas: ='Project Tracker'!D7.
  • Dates are serial numbers made with =DATE(2026,12,20) and display as numbers; the text "2026-12-20" stays text.
  • Row 1 is the header. Filters and sorts cover every row below it, including a totals row, so put totals above the data or on another tab.
  • index is 0-based, in takes an array, setColWidth.col is a letter, and tag names cannot contain commas.
  • read returns values; filter and sort state is in snapshot().
  • Functions (the guide leaves the list out to stay under 400 tokens; an unknown name's error suggests the closest): SUM AVERAGE AVG MIN MAX COUNT COUNTA ROUND ROUNDUP ROUNDDOWN ABS INT MOD POWER SQRT IF IFS AND OR NOT IFERROR SUMIF COUNTIF AVERAGEIF VLOOKUP INDEX MATCH CONCAT LEFT RIGHT MID LEN TRIM UPPER LOWER TEXTJOIN SUBSTITUTE TODAY NOW DATE YEAR MONTH DAY HASTAG COUNTTAG. Add this line to the prompt if your token budget allows.

Theming

The stylesheet reads the shadcn/ui CSS variables, each with a built-in fallback, so it matches a shadcn app without configuration:

--background, --foreground, --muted, --muted-foreground, --border, --primary, --ring, --destructive, --radius, --font-sans.

Dark mode follows a .dark class on an ancestor (as shadcn does) or prefers-color-scheme. All class names start with ss-. No Tailwind and no font files are needed; the grid uses the host's sans font.

Bundle size

Measured with vp run size (gzip level 9) on Nov 28, 2026.

| File | Contents | Raw | Gzip | | --------------------- | ---------------------------------------------------------- | -----: | ------: | | dist/resheet.umd.js | core + UI + Preact + CSS, minified | 185 kB | 64.1 kB | | dist/index.js | @valschr/resheet: core + UI, not minified, no Preact | 283 kB | 84.7 kB | | dist/core.js | @valschr/resheet/core, not minified | 156 kB | 49.0 kB | | dist/react.js | @valschr/resheet/react: core + UI + Preact, not minified | 300 kB | 90.5 kB | | dist/styles.css | @valschr/resheet/styles.css | 18 kB | 3.7 kB |

The ESM files are left unminified for app bundlers, which minify them. CI fails when the UMD file grows past 68 kB (scripts/size.ts).

Performance

Measured in Chromium on the demo's 50,000 rows by 50 columns sheet (Apple M1 Mac mini):

| Measurement | Result | | ----------------------------------------- | -------------------------------------------------------------------- | | DOM size while scrolling | about 38 rows, 456 cells | | Steady scrolling (140 px per frame) | median frame 16.7 ms, p95 17.7 ms, max 19.8 ms, no frames over 50 ms | | Fast scrolling (1,400 px per frame) | median 16.7 ms, max 25.8 ms, no blank areas | | Type and commit one cell | 15 to 17 ms including re-render | | Load 2.5 million cells in one set batch | 1.2 to 1.3 s | | Sort or filter 50,000 rows | 4 to 14 ms |

In Node 26 on the same machine (apply in one call; applyAsync with 5 ms slices):

| Measurement | Before (0.3.0) | Now | | ------------------------------------------------------------ | --------------------------------------- | ---------------------- | | format A1:Z100000 bold over 2.5M filled cells | 4.3 s | 107 ms | | format A:A (whole column) | per cell | 47 ms | | Undo that format | 1.0 s | under 1 ms | | Heap after loading 2.5M cells and formatting them | 2.2 GB | 0.8 GB | | applyAsync 2.5M cells: longest event-loop stall | (sync: 4.1 s) | 72 ms (3.2 s in total) | | applyAsync 50,000 formulas: longest stall | (sync: 0.36 s) | 16 ms | | Recalculate after editing one cell in a 10,000-formula chain | only the dependent cells are recomputed |

Examples

| Path | Run | | ------------------------------------------------------------------------------------- | -------------------------------------- | | examples/demo — playground with an agent console | pnpm exec vp run dev | | examples/react-demo — React app using @valschr/resheet/react | pnpm exec vp dev examples/react-demo | | examples/umd.html — single file, UMD build only | vp run build, then open the file | | dist/artifact.html — the UMD inlined into one page | vp run build && vp run artifact |

Hosting the demo on GitHub Pages

vp run demo:build writes the playground to site/ as static files with relative paths, so it works under any sub-path. The Pages workflow builds and publishes it on every push to main. Enable it once under Settings → Pages → Source: GitHub Actions.

Development

Requires Node 26 and pnpm. Tooling is Vite+ (vp). With the global vp CLI installed, drop the pnpm exec prefix. resheet lives in apps/resheet of a pnpm workspace: install and check from the repository root, run the rest from apps/resheet.

pnpm install                   # at the repository root
pnpm exec vp check             # at the root: format, lint, type check
cd apps/resheet
pnpm exec vp test              # unit and component tests (Node + happy-dom)
pnpm exec vp run dev           # playground at examples/demo
pnpm exec vp run demo:build    # static playground in site/ (GitHub Pages)
pnpm exec vp run build         # dist/: ESM, types, styles.css, react.js, resheet.umd.js
pnpm exec vp run smoke:umd     # mount the UMD bundle and drive it like an agent
pnpm exec vp run size          # gzip size report; fails above the UMD limit
pnpm exec vp run pack:check    # pack the tarball and check files and exports
pnpm exec vp run artifact      # write dist/artifact.html
pnpm exec vp run readme:guide  # refresh the agent guide in this README

License

MIT, see LICENSE. The toolbar icons are copied from Lucide under the ISC License; the notice is kept in src/ui/icons.tsx.