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

@panda-lingo/goldendict

v0.1.8

Published

Framework-independent GoldenDict article client and renderer

Readme

@panda-lingo/goldendict

Framework-independent client and <goldendict-view> renderer for the GoldenDict REST service. The package preserves GoldenDict-ng article markup and styles inside a sandboxed iframe while exposing typed browser events and brand theme tokens.

import {
  DictionaryClient,
  defineGoldendictView,
} from "@panda-lingo/goldendict";

defineGoldendictView();
const view = document.querySelector("goldendict-view");
view.client = new DictionaryClient({ baseUrl: "/api/v1" });
await view.lookup("example");

baseUrl is the complete public API mount, including a reverse-proxy prefix when one exists. GoldenDict-rooted article resources are rebased through that mount, so a host can expose the service at a route such as /api/v1/mdict without rewriting lookup payloads:

view.client = new DictionaryClient({ baseUrl: "/api/v1/mdict" });

Search-first hosts can request bounded prefix suggestions through the same client and API base before committing an article lookup:

const result = await view.client.suggestions("exam", { limit: 20 });
console.log(result.suggestions);

Importing the package registers <goldendict-view> automatically. Call defineGoldendictView("my-dictionary-view") when a custom tag name is useful.

The component fills the width of its containing layout, uses container-aware host chrome, and remeasures article height whenever its iframe reflows. Article layout defaults to GoldenDict fidelity: the pinned upstream body margin, content-box model, dictionary header flow, and dictionary-authored CSS cascade remain intact.

The optional responsive mode adds a browser override layer that constrains legacy fixed-width media, makes wide tables and preformatted text locally scrollable, unwraps common floated wiki panels on narrow screens, and keeps article headers usable with coarse pointers. Script permission is independent: a dictionary may require both fidelity layout and sandboxed sidecar JavaScript.

view.layoutMode = "responsive";
view.scriptPolicy = "sandboxed";

The default layoutMode is "fidelity". Consumers can opt into the browser safeguards with layout-mode="responsive" on the custom element.

Compare at the same CSS viewport, device scale, and GoldenDict zoom: those host browser settings still affect physical pixel size and line wrapping.

.dictionary-column {
  min-width: 0;
}

goldendict-view {
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
}

Consumer theme.cssText is emitted after the responsive layer and can override it when a particular dictionary requires different behavior. Set --gd-responsive-gutter there to customize the article's fluid inner spacing.

The public API includes:

  • DictionaryClient for dictionary listing, prefix suggestions, and lookup.
  • GoldenDictView and defineGoldendictView for framework-independent use.
  • GoldenDictTheme, light/dark token presets, and themeToCss for branding.
  • GOLDENDICT_EVENTS for lookup, active article, collapse, media, external-link, dictionary-resource failure, and state notifications.
  • Resource/link helpers for hosts that need to inspect GoldenDict URLs.

Dictionary scripts are retained by default (scriptPolicy = "sandboxed") inside the iframe, which never gets allow-same-origin. Set the policy to "none" to remove scripts and inline handlers. Lookup, media, and external-link events are cancelable so a host application can replace the default navigation behavior.

The bundled demo and reusable component both default to "sandboxed" scripts for locally mounted dictionaries, so script-dependent formats such as OALDPE retain their interactions. "fidelity" is likewise the default layout.

In sandboxed mode, external sidecars such as bres://.../Dictionary-UI.js are routed through the article's resourceBaseUrl without changing filename case. Because the iframe has an opaque origin, dictionary XHR/fetch requests send Origin: null; the read-only API must explicitly allow that origin when this compatibility mode is enabled. Classic script element loads do not grant the dictionary access to the host document.

Failed external dictionary stylesheets and scripts are not treated as a successful render. The component keeps the article visible, changes state to "error", exposes the failures through view.resourceErrors, and emits GOLDENDICT_EVENTS.resourceError with the failed URL and resource type:

view.addEventListener(GOLDENDICT_EVENTS.resourceError, (event) => {
  const { detail } = event as CustomEvent;
  console.error("Dictionary sidecar failed", detail);
});

This diagnoses top-level <link rel="stylesheet"> and <script src> failures; font/image failures and exceptions thrown inside dictionary code remain normal browser console/network diagnostics.

Run the package demo from the workspace root with npm run dev. It discovers the dictionaries loaded from the backend's configured local paths at startup.

GoldenDict-ng CSS and icons are pinned and sync-managed. See UPGRADING_GOLDENDICT.md for the one-command local checkout upgrade flow.