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

@mochart/editor

v1.0.1

Published

Framework-neutral JSON editor with Mochart config intelligence

Downloads

261

Readme

@mochart/editor

A framework-neutral, strict JSON editor with optional Mochart config intelligence. It powers the JSON editing tabs in the Mochart demos.

Docs: mochart.org — start with the editor guide.

Install

npm install @mochart/editor @mochart/core

@mochart/core is a peer dependency: the config diagnostics run against your app's copy of the library, so they always agree with the chart you render.

Completions and hover documentation work differently. They come from a config model generated from @mochart/core when this package is built, so they describe the config surface of the core release the editor was built against. Pair the editor with a newer core and a section that core added validates cleanly but has no completions and no hover text. The model records the core version it was generated from — read it as mochartConfigEditorModel.coreVersion — and createMochartConfigSupport() logs one console.warn naming both versions when the installed core reports a different major or minor version. A patch difference is not reported, because a patch release cannot add or remove config properties. Installing the @mochart/editor release built against your core version clears the warning.

import { createJsonEditor, createMochartConfigSupport } from '@mochart/editor';
import '@mochart/editor/editor.css';

const editor = createJsonEditor(document.querySelector('#editor')!, {
  value: JSON.stringify(config, null, 2),
  ariaLabel: 'Mochart configuration',
  ariaDescribedBy: 'config-editor-help',
  support: createMochartConfigSupport(),
  onChange(value) {
    // Keep application state in control of the current value.
  },
  onDiagnostics(diagnostics) {
    // Includes JSON syntax and Mochart validation diagnostics.
  }
});

editor.format();
editor.setValue(nextValue);
editor.setTheme('dark');
editor.showFocusRange(diagnostic.from, diagnostic.to);
editor.destroy();

The Mochart support provides:

  • completions for top-level, section, and nested properties;
  • enum, boolean, and configured-ID value completions;
  • hover documentation, defaults, and validation rules;
  • syntax and path-aware Mochart validation diagnostics.

Keys repeated within one object are syntax errors on the later occurrence, because JSON.parse would keep only the last value; format() refuses such text rather than dropping the earlier copy. The @mochart/editor/json entry exposes the same rule without the editor: parseJson(text) throws a JsonDuplicateKeyError (a SyntaxError naming every repeat) where JSON.parse would succeed, and findDuplicateJsonKeys(text) lists them as DuplicateJsonKey records (key, path, and the from/to offsets of the later name token); duplicateJsonKeyMessage(duplicate) renders one as the editor's message, and formatJsonPath(path) renders any JsonPath as series[0].property.

Pass theme: 'dark' for the bundled dark syntax treatment, then use setTheme('light' | 'dark') to change it without replacing the document or undo history. Both themes use CSS custom properties, so hosts can override the editor surface, focus, border, gutter, selection, and selection-match colors. The editable element receives aria-invalid as diagnostics change, and ariaDescribedBy can connect it to keyboard instructions or other help text.

Run npm run dev:editor from the repository root for the isolated editor and live-chart playground.

The development export condition

In this repository's manifest, the exports map has a development entry pointing at this package's TypeScript sources; the repo's own dev servers, tests and tsx scripts run the library from source through it. It never reaches npm: publishing goes through pnpm publish, which replaces the map with the dist-only publishConfig.exports, so installed copies of this package always resolve the built dist/.