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

@sewdn/slides-tools

v0.1.0

Published

Plumbing for interactive slide tools: define a tool, host it in a deck, keep what the room captures, walk views, export the minutes.

Readme

@sewdn/slides-tools

Plumbing for interactive slide tools: boards, polls, tables the room fills in during a deck. A tool declares what it is once; a deck lists it; the host does the rest — registers its MDX components, checks and seeds its definitions, keeps what the room captures in one persisted store, gives it its words in the deck's language, and collects its minutes and counts on the export slide.

@sewdn/slides-tool-lifecycle is the reference tool built on it.

Concepts

| Concept | What it is | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Tool | defineSlideTool({ id, key, definitions, components, copy, validate, seed, minutes, tiles }). Everything a deck needs to host it. | | Definitions | What a deck gives a tool under its key (lifecycles: [...]), typed by the tool and checked by its validate when the deck is defined. | | Deck config | defineToolDeck({ storageKey, tools, ...definitions, copy }). Typed by the tools it lists: a key no tool reads, or definitions of the wrong shape, do not compile. | | Store | One flat map of strings per deck, in localStorage under <storageKey>:notes. A tool writes under its namespace: <namespace>:<key>. A document seeded from the deck carries seeded:<namespace>:<key>: the seed went in once, the room owns it since. A blocked or full storage never breaks the deck. Same layout as the workshop notes, so captures already in browsers keep reading. | | Copy | A tool's words per deck language (en required, nl / fr when it has them; missing languages fall back to English). A deck overrides any of them, per tool and per language, partially: copy: { lifecycle: { nl: { states: "Fasen" } } }. The host's shared words (add, remove, undo, export buttons) are overridden under copy.tools. | | Host | <ToolDeck deck config /> (or <SlideToolsProvider config> around your own deck): seeds once before the store is read, provides the store, the definitions and the copy, and registers every tool's components plus <ToolsExport>. | | Minutes and tiles | Each tool returns Markdown lines and counts from its definitions and its part of the store. <ToolsExport title reset> shows a tile per tool that has something, and downloads or copies all minutes as one document. |

Write a new tool in one short file

A poll: the deck names the question and the options, the room picks one.

import {
  defineSlideTool,
  toolDefinitions,
  ToolSurface,
  Chip,
  useToolCopy,
  useToolDefinitions,
  useToolValue,
} from "@sewdn/slides-tools";

type Poll = { id: string; question: string; options: readonly string[] };

function PollBoard({ id }: { id: string }) {
  const poll = useToolDefinitions(pollTool)?.find((entry) => entry.id === id);
  const words = useToolCopy(pollTool);
  const [choice, setChoice] = useToolValue(pollTool, `${id}:choice`); // stored as "poll:<id>:choice"
  if (!poll) return <div className="ws-empty">{words.unknown}</div>;
  return (
    <ToolSurface fill={false}>
      <b>{poll.question}</b>
      {poll.options.map((option) => (
        <Chip
          key={option}
          onClick={() => setChoice(option === choice ? "" : option)}
          pressed={option === choice}
          tone="work"
        >
          {option}
        </Chip>
      ))}
    </ToolSurface>
  );
}

export const pollTool = defineSlideTool({
  id: "poll",
  key: "polls",
  definitions: toolDefinitions<readonly Poll[]>(),
  components: { PollBoard },
  copy: {
    en: { polls: "Polls", open: "open", unknown: "Unknown poll" },
    nl: { polls: "Peilingen", open: "open", unknown: "Onbekende peiling" },
  },
  validate: (polls) =>
    polls.forEach((poll) => {
      if (poll.options.length < 2) throw new Error(`poll ${poll.id}: two options at least`);
    }),
  minutes: ({ definitions = [], store, copy }) =>
    definitions.length
      ? [
          `## ${copy.polls}`,
          "",
          ...definitions.map(
            (p) => `- ${p.question}: ${store.value(`${p.id}:choice`) || copy.open}`,
          ),
          "",
        ]
      : [],
  tiles: ({ definitions = [], store, copy }) =>
    definitions.length
      ? [
          {
            key: "polls",
            label: copy.polls,
            tone: "time",
            value: definitions.filter((p) => store.value(`${p.id}:choice`)).length,
          },
        ]
      : [],
});

And the deck:

export const deckConfig = defineToolDeck({
  storageKey: "kickoff",
  tools: [pollTool, lifecycleTool],
  polls: [{ id: "store", question: "Which store?", options: ["Postgres", "SQLite"] }],
  lifecycles: [certificate],
});

export default function App() {
  return <ToolDeck config={deckConfig} deck={deck} />; // slides: <PollBoard id="store" />, <ToolsExport title="Kick-off" reset />
}

What the tool did not write: a provider, a store, a seeding effect, a registration in a deck component, a branch in an export component, a section in a shared minutes function, a field in a shared definition type, a locale lookup. Adding the tool to a deck is one entry in tools and its definitions.

API

Defining

  • defineSlideTool(spec) → SlideTool. Spec fields:
    • id — unique per deck; also the store namespace unless namespace is given. "tools" is reserved.
    • key?, definitions?: toolDefinitions<D>() — the deck config property the tool reads, and its type.
    • namespace? — store namespace (<namespace>:<key>); defaults to id. Use it to keep keys a tool wrote under another name.
    • requires?: [otherTool] — tools this one builds on (it reads their documents, or its components use their hooks). A deck that lists the tool without them is refused; its minutes and tiles read them with context.tool(otherTool) → { definitions, store }, and reading a tool it does not require throws.
    • components? — MDX components by the name slides use. Two tools in one deck may not register the same name.
    • copy?: ToolCopy<C> — { en: C, nl?: C, fr?: C }. Type C with ToolWords<typeof EN> to widen literal strings.
    • validate?(definitions, { storageKey }) — throw to refuse a deck; runs in defineToolDeck.
    • seed?({ definitions, storageKey, store }) — once per mount, before the store is first read; store.seedOnce(key, value) writes a value and its flag the first time only. Lazy seeding (read the seed until the room changes it) needs no seed: use useToolJson with a codec whose seed() is the definition's draft.
    • minutes?(context) → Markdown lines; tiles?(context) → ToolTile[] ({ key, value, label, tone? }). Return [] when there is nothing. context = { definitions, copy, locale, storageKey, store, tool }, store a reader of the tool's namespace (value(key), json(key, codec), seeded(key)), tool(other) the same for a tool it requires.
  • defineToolDeck({ storageKey, tools, copy?, ...definitions }) — typed by tools; checks duplicate ids, namespaces, keys and component names, required tools, then every tool's validate. checkToolDeck(config) runs the same checks on a config built elsewhere.

Hosting

  • <ToolDeck deck config components? deckConfig? /> — StructuredDeck with the tools' components and ToolsExport registered (deck components win on a name clash).
  • toolDeckHost(config) — the same as a host for defineDeck({ host }) in a deck on the slidesDeck() convention (see @sewdn/slides-vite): export default defineDeck({ host: toolDeckHost(deckConfig) }), no App.tsx needed.
  • <SlideToolsProvider config> — the same host around any deck; toolMdxComponents(config) gives the components to register yourself.
  • <ToolStoreProvider storageKey> — the store alone (used by slides-workshop's NotesProvider).
  • <ToolsExport title reset? /> — tiles, Markdown download, copy, optional "clear everything".

Hooks (inside a host)

  • useToolDefinitions(tool) → the deck's definitions for the tool, typed; undefined when the deck has none.
  • useToolCopy(tool) → the tool's words in the deck's language with overrides (works outside a host, without overrides). useToolsCopy() → the shared words.
  • useToolValue(tool, key) → [string, set]; "" removes the value.
  • useToolJson(tool, key, codec) → [value, change]. codec = { parse, serialize, seed, empty? }; the seed until the room changes the document, the room's version (and the seeded: flag) after; empty once the room's version went missing. change(operation) applies a pure operation to the latest value, so two changes in one tick build on each other. Pass a stable codec.
  • useToolDocuments(tool, codec) → { read(key), change(key, operation) } — documents under keys picked at run time (one per application, per board), stored without a seeded: flag (withDocument), for a tool whose seed puts its seed in: the flag keeps meaning "the seed went in".
  • useToolStore() → { storageKey, values, set, update, clear } — the raw deck store.
  • useToolDeck() → { config, locale }; useToolsMinutes() → { tiles, markdown(title) }.

Interaction and atoms

  • <ToolSurface className fill? …div props> — root of a tool: st-root ws-root (+ is-fill), and the deck-safe handlers. deckSafeHandlers / useDeckSafeHandlers(onKeyDown?) — wheel, pointer and touch stay in the tool; typing, Space, Enter and a select's keys never move the slide; arrows elsewhere still navigate.
  • <ToolViews views>{(view, step) => …}</ToolViews> + resolveViews(all, view?, views?) — one slide walks several views with the deck's next and previous; print shows the last.
  • usePrintMode() — true under ?print-pdf.
  • useUndo() + <UndoToast undo className? /> — one undo at a time: undo.offer(name, restore) right after a removal.
  • Button (variant="quiet"), IconButton, Chip (a toggle with onClick + pressed), Field (label around an input or select), AddForm, Avatar, initials.

Pure helpers (testable without React)

readStore, writeStore, withValue, withDocument, toolKey, seededKey, storeKey, readJson, withJson, storeReader, storeWriter, newId, resolveCopy, mergeCopy, toolCopy, seedValues, seedTools, toolsMinutes, toolsTiles, toolContext, minutesDocument, minutesFileName, TOOLS_COPY.

Styles

The shared styles load with the components (ToolSurface, the atoms): tools.css (the ws-* classes and data-tone → --st-* tokens of the kit) and export.css. prose.css (the workshop look for Markdown tables) is opt-in, because it restyles every Markdown table of a deck: a workshop deck imports it (WorkshopDeck does), a presentation deck leaves it out. All three are exported as @sewdn/slides-tools/tools.css, /prose.css and /export.css.

Tool packages that use Tailwind classes ship them as built code, which a deck's Tailwind does not scan on its own (it skips node_modules and does not follow symlinks). Each package therefore ships a tailwind.css with @source "./dist": a deck imports @sewdn/<package>/tailwind.css for the tools it uses, and @sewdn/slides-workshop/capture-panels.css imports them for the tools it hosts. A Tailwind deck scans node_modules/@sewdn/slides-tools/dist with @source.