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

@swifttui/web

v0.1.6

Published

**Browser runtime for [SwiftTUI](https://swifttui.sh) apps — draw a Swift-authored UI into a `<canvas>`, no terminal emulator.**

Readme

@swifttui/web

Browser runtime for SwiftTUI apps — draw a Swift-authored UI into a <canvas>, no terminal emulator.

npm License

@swifttui/web is the browser host for SwiftTUI. A SwiftTUI app compiles to wasm32-wasi and streams a structured raster surface on stdout; this package loads the scene manifest, renders that surface into a canvas, mounts an ARIA tree for accessibility, and bridges input back to the running app — so the same view code you run in a terminal runs on a web page. It does not load a terminal emulator.

The build side — compiling your Swift app to wasm and capturing its manifest — lives in the sibling @swifttui/build package.

Installation

Published to npm as an ESM package with bundled TypeScript declarations — no TypeScript toolchain required to consume it:

npm install @swifttui/web

The package ships compiled dist/ JavaScript (.js + .d.ts); consuming it does not require Bun or a TypeScript build step. Subpath entrypoints (./wasi, ./wasi-worker, ./manifest, ./websocket, ./testing) and the ./style.css asset are declared in package.json exports.

API

import { createWebHostApp } from "@swifttui/web";

const controller = await createWebHostApp({
  mount: document.getElementById("app")!,
  manifestUrl: new URL("./scene-manifest.json", import.meta.url),
  style: {
    palette: {
      foreground: "#eceff4",
      background: "#1e222a",
      cursor: "#56b6c2",
      selectionBackground: "#2e3440",
      selectionForeground: "#eceff4",
    },
    theme: {
      foreground: "#eceff4",
      background: "#1e222a",
      tint: "#56b6c2",
      link: "#5ba3ff",
    },
  },
});

await controller.switchScene("dashboard");
controller.setStyle({ cursorBlink: true, theme: { tint: "#79c0ff" } });

For a static WASI-hosted app, use the WASI subpath:

import { createWasmSceneRuntimeFactory } from "@swifttui/web/wasi";

Worker entrypoints can delegate to:

import { startWasmSceneWorker } from "@swifttui/web/wasi-worker";

startWasmSceneWorker();

The page that hosts the WASI runtime must serve Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp so the SharedArrayBuffer-backed stdin works.

Surface transport

This package uses SwiftTUI's web-surface WASI transport. The Swift runner emits structured raster-surface records on stdout, and the browser host draws rectangles and text into a canvas. It does not load a terminal emulator and does not depend on ghostty-web or ghostty-vt.wasm.

web-surface is the default SwiftTUIWASI browser transport. WebHost still sets TUIGUI_TRANSPORT=surface explicitly so generated app environments are self-describing.

Notes

  • Scene switching is controller-managed and retains existing scene runtimes.
  • Terminal styling is host-owned through WebHostTerminalStyle, which carries one active palette/theme pair plus the runtime payload sent into SwiftTUI.
  • Hosts that want multiple themes swap entire WebHostTerminalStyle objects; the library does not provide a built-in mode switcher.
  • BrowserWASIBridge sets TUIGUI_TRANSPORT=surface and decodes surface frames before handing them to the canvas runtime.
  • Hyperlink cells published by the app (links/linkTargets on the frame) are clickable: a click opens the target in a new tab (http(s) only) or through the onOpenHyperlink runtime option; the pointer cursor signals linked cells. Accessibility nodes the app marks hidden stay out of the ARIA tree, and the runtime exposes the frame's focusPresentation and preferredGridSize for embedders.

Developing this package

Only needed if you are working on @swifttui/web itself. Consuming the package from an app needs only npm install (above) — not Bun or the Swift toolchain.

Use Bun for repo-local development, and the repo-default swiftly Swift 6.3.1 toolchain for any Swift command the build pipeline triggers (swiftly run swift --version). Run bun install from the repo root or any workspace package directory; Bun maintains one root bun.lock.

  • bun test
  • bun run build — compile the publishable package to dist/ with tsdown (ESM .js + .d.ts). Run automatically on publish via prepublishOnly.
  • bun run build:manifest -- --app <AppExecutable>
  • bun run build:wasm -- --app <AppExecutable>
  • bun run build:web
  • bun run build:app -- --app <AppExecutable>
  • bun run dev

build produces the published library. build:manifest, build:wasm, and build:app delegate manifest/WASI packaging to @swifttui/build; build:wasm and build:app default to --configuration release (pass --configuration debug for local debug-oriented wasm builds). The demo/app pipeline writes its artifacts to dist-demo/ so they stay separate from the published dist/ library output.

The demo/app build flow is intentionally small:

  1. build:manifest captures TUIGUI_MODE=manifest output from the Swift app by invoking swiftly run swift.
  2. build:wasm copies the app's wasm artifact into dist-demo/assets/app.wasm, validates it with the browser WebAssembly API, then keeps the stripped artifact only if stripping still produces browser-parseable wasm.
  3. build:web bundles index.html and the browser entrypoint with Bun.

License

MIT — see LICENSE.