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

@nilvn/engine

v0.19.0

Published

NilVN — a tiny DOM-based ADV / visual-novel engine with story-like script syntax and a capability-sandboxed plugin host

Readme

@nilvn/engine

A small visual-novel (ADV / galgame) engine for the browser. Scripts read like a story — yuki: Hi! plus a few bracket commands — and everything expressive (screen shake, text effects, sprite animation, choice styling, camera moves) is a plugin you can write in plain JavaScript. The engine is the mechanism: parser, stage, audio, saves, languages, the finished game's shell (title and ending pages, the in-game menu with saves / backlog / auto / skip / settings, themeable without CSS) and a capability-sandboxed plugin host. The first-party plugins live in @nilvn/plugins and are written against the same public surface as yours. TypeScript, DOM + CSS rendering, no framework; the only runtime dependency is a TOML parser that the single-file build drops.

pnpm add @nilvn/engine @nilvn/plugins
import { createEngine } from '@nilvn/engine'
import { withFirstParty } from '@nilvn/plugins'

const engine = createEngine({ ...withFirstParty(), container: document.getElementById('app')! })
await engine.loadConfig('./nilvn.config.toml')   // plugins, actors, title / ending pages, menu, theme
await engine.showTitle()                         // the title page; New game plays the config's entry script

start() plays at once and resolves when the story ends; a host without a title page calls it instead. From an empty folder to a deployed game: Getting started.

The content language defaults to en; a multi-language game passes lang, defaultLang, languages and per-language catalogs (see the engine API).

A script:

[use textfx screenfx charfx]
[actor yuki name=Yuki color=#ff7eb6 sprites=assets/char/yuki-{face}.svg]

[bg assets/bg/street.svg fade=1.5]
An evening street. Shadows stretch long.
[char yuki happy]
yuki: You came! {wave:I've been waiting~}
yuki(angry): You're late again!
[shake strength=14 duration=0.5]

[choice Apologize -> apologize]
[choice Make an excuse -> excuse if=courage>=2]

[label apologize]
me: I'm sorry...
[end]

The player clicks, or presses Space / Enter, to advance; [keys] in the config rebinds the shell's keyboard (auto, skip, quick save / load, …).

Three ways to load a game

| | Call | Good for | |---|---|---| | Config + script | loadConfig('./nilvn.config.toml') then start() | Hand-written games: one TOML file declares plugins, actors, path aliases, macros and defaults; the script stays pure story. | | Script only | load('./story.nvn') or loadSource(text) | Quick embeds; the script declares what it needs with [use] / [actor] / [alias]. | | Script package | load('./my-game/'), load(zipBytes), load(inlinePackage(payload)) | Works exported by NilVN Studio or packed with npx nilvn pack: nilvn.json plus chunked scripts, per-language text and assets — streamed on demand, switchable language, saves. |

npx nilvn pack turns a config-driven work into a package — a folder to upload, a .nvs zip, or one double-clickable .html — and reports what would fail in play before anyone plays it (script-package.md). npx nilvn playtest then plays it — explore runs to its endings, or scripted routes — in a headless Chrome with real clicks and keys (playtest.md).

Documentation

| | | |---|---| | Getting started | An empty folder to a deployed game with a title page, endings, saves and settings; npm-user vs contributor commands. | | Script syntax | Lines, inline markup, @key text references, variables and conditions, macros, actors, plugins, paths. | | Config file | Every section of nilvn.config.toml. | | Command reference | Built-in commands and object ids (the first-party plugins' commands are in @nilvn/plugins). | | Engine API | createEngine options, loading, playing, saves, languages, diagnostics, audio, plugins, stage, packages, the IIFE build. | | In-game chrome | The built-in title / ending pages, the system menu (saves, backlog, auto / skip, settings), what [title] / [ending.<id>] / [menu] / [settings] / [saves] configure. | | Theming | The --nilvn-* token contract: dialogue box, name tag, choices, panels; [theme] / [window] in the config, setTheme(), the [theme] command. | | Several files, events, transitions | [game] scripts / [include] / [call], clicks that run script commands (panels, hotspots, sprites), [trans …] and rule masks. | | Panels and layered sprites | Declarative HUD / windows ([ui.<id>]), [actors.<id>.layers], [choices], [input], [persist], [preload]; the config schema (CONFIG_SCHEMA / checkConfig). | | Script packages | nilvn pack, the nilvn.json format, the chunk manifest, custom loaders. | | Playtesting | nilvn playtest: explore runs and scripted routes in a headless Chrome, with real input; failures, unreachable objects and diagnostics reported. | | Writing plugins | The plugin package format, permissions and capability objects, lifecycle — in @nilvn/plugin-sdk. |

What the engine guarantees

  • Content never crashes the host. A bad line, an unknown command, a missing plugin, a broken jump target or a chunk that fails to load is reported as a diagnostic (engine.diagnostics, onError) and play degrades around it.
  • Plugins are sandboxed by capability. A plugin declares permissions and receives capability objects for exactly those; it never sees the engine or the DOM, and everything it registers is released when it is deactivated. Plugins can be enabled, disabled and reloaded while a game runs.
  • Saves are stable. A save addresses the script by label and offset and carries the stage, variables, audio and language; incompatible saves are refused rather than misapplied.
  • Text is localizable at runtime. Scripts reference text by key, catalogs ship per language, and the language can switch mid-line without losing state.

Plugins

The engine registers nothing by itself. A host hands it plugins three ways:

  • createEngine({ registry, manifests }) — modules made available to [use id] (or the short name of an app.nilvn.* id), each with its manifest; @nilvn/plugins' withFirstParty() is exactly this pair for the first-party set.
  • createEngine({ plugins }) — the host's own modules, activated at once.
  • [use ./x/plugin.json] / [use ./x.js] in the script — fetched at play time.

The first-party set (textfx, screenfx, charfx, objectfx, spriteanim, choicefx, voicefx, animstudio, abreplay) is documented in @nilvn/plugins; writing your own starts at @nilvn/plugin-sdk.

Two builds

  • ESM (import … from '@nilvn/engine', dist/index.js + .d.ts) for bundled apps.
  • IIFE (@nilvn/engine/iife, dist/nilvn-engine.iife.js): one self-contained script that defines a global ADV with the same exports, for a <script> tag. It has no dependencies, so loadConfig (the TOML parser) is ESM-only. It carries no plugins; the batteries-included bundle that exported games run is @nilvn/plugins/iife.

Working in the repository

pnpm build         # dist/: ESM + .d.ts + the bare IIFE
pnpm typecheck

Tests live in test/ and run with pnpm test from the repository root; test/iife-smoke.test.ts boots the minified bundle. The demo game lives with the first-party plugins in @nilvn/plugins.

License

MIT.