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

discord-container-ui

v2.1.1

Published

Leichte Container-UI als TypeScript‑Bibliothek – kompatibel mit JS & TS. Enthält Container, TextDisplay, Section, Separator, MediaGallery & FileItem inkl. JSON-Serialisierung.

Readme

discord-container-ui

Leichte Container‑UI als TypeScript‑Bibliothek – kompatibel mit JS und TS.
Beinhaltet folgende Elemente:

  • Container (Wurzel/Composer)
  • TextDisplay (einfacher Textblock)
  • Section (Gruppe von Items)
  • Separator (Trennlinie/Spacing)
  • MediaGallery (Sammlung von Bild/Medien‑URLs)
  • FileItem (beliebige Datei‑URL; optional als Spoiler)

Dual Build (ESM & CJS) – funktioniert out‑of‑the‑box mit modernen Bundlern sowie mit require() in Node.


Installation

npm install discord-container-ui
# oder im Repo:
npm install
npm run build

Das Build erzeugt dist/index.mjs (ESM), dist/index.cjs (CJS) sowie Typdefinitionen.

Schnellstart

JavaScript (CJS)

// Node CommonJS
const { Container } = require("discord-container-ui");

const c = new Container()
  .add_text("Hello world")
  .add_separator()
  .add_text("Another line");

console.log(JSON.stringify(c.toJSON(), null, 2));

JavaScript (ESM) / TypeScript

import { Container } from "discord-container-ui";

const c = new Container();
c.add_text("Hello world");
c.add_separator();
c.add_text("Another line");

console.log(c.copy_text());      // "Hello world\n---\nAnother line"
console.log(c.toJSON());

API (Kurzüberblick)

class Container

  • add_item(item: Item | string | number): this
  • add_text(content: string, id?: number | null): TextDisplay
  • add_separator(opts?: { divider?: boolean; spacing?: SeparatorSpacingSize; id?: number|null }): Separator
  • add_gallery(...media: string[]): MediaGallery
  • add_file(url: string, spoiler?: boolean, id?: number|null): FileItem
  • walk_items(): Iterable<Item> – flache Iteration inkl. Items in Section
  • copy_text(): string
  • toJSON(): SerializedContainer
  • static fromJSON(obj: SerializedContainer): Container

class TextDisplay

  • content: string
  • copy_text(): string

class Section

  • items: Item[]
  • copy_text(): string – verkettet Inhalte der enthaltenen Items

class Separator

  • divider: boolean (Standard: true)
  • spacing: "small" | "medium" | "large" (Standard: "medium")

class MediaGallery

  • media: string[] (URLs)

class FileItem

  • url: string
  • spoiler: boolean

Serialisierung

Die Container können verlustarm in ein neutrales JSON‑Format konvertiert werden:

type SerializedItem =
  | { type: "TextDisplay"; id?: number|null; payload: { content: string } }
  | { type: "Separator";  id?: number|null; payload: { divider: boolean; spacing: "small"|"medium"|"large" } }
  | { type: "Section";    id?: number|null; payload: { items: SerializedItem[] } }
  | { type: "MediaGallery"; id?: number|null; payload: { media: string[] } }
  | { type: "FileItem";   id?: number|null; payload: { url: string; spoiler?: boolean } };

type SerializedContainer = {
  type: "Container";
  id?: number|null;
  colour?: number|null;
  spoiler?: boolean;
  components: SerializedItem[];
};
  • toJSON() erzeugt SerializedContainer.
  • Container.fromJSON() baut eine Instanz daraus wieder auf.

Entwickeln

  • npm run dev – Watch‑Build mit tsup
  • npm run typecheck – TypeScript‑Typprüfung
  • npm run build – ESM & CJS Output inkl. Typen

Lizenz

MIT – siehe LICENSE.