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

@butlerov-chemistry/core

v0.1.6

Published

Draw chemical structures with js and Konva

Readme

@butlerov-chemistry/core

Butlerov core is the Konva-based chemical structure editor. Use it from npm in bundled apps or from a single script tag on vanilla HTML pages.

The UMD build exposes the global name butlerov (see Build output).


Install

npm i @butlerov-chemistry/core

ES modules (bundlers, type="module")

import {
  MoleculeEditor,
  MolConverter,
  SmilesConverter,
  MW,
  Formula,
  defaultStyle,
  lightTheme,
} from "@butlerov-chemistry/core";

const stageEl = document.getElementById("editor");
const mol = new MolConverter();

const editor = new MoleculeEditor({
  stage: stageEl,
  mode: "structure",
  theme: "light",
  style: defaultStyle,
  autofocus: true,
});

editor.onchange = () => {
  const mw = new MW(editor.graph).compute();
  console.log("Molecular weight:", mw != null ? mw.toFixed(2) : "—");
};

// Optional: load / save MOL text
// editor.load(molString, mol);
// const molText = editor.save(mol);

MoleculeEditor expects a stage that is either an HTMLDivElement (Konva creates the stage inside it) or an existing Konva Stage. You must pass mode: "structure" for molecule editing, or "scheme" for document-style canvases.


Vanilla HTML page (UMD script)

After npm run build in this package, the browser bundle is:

| File | Role | |------|------| | dist/butlerov.umd.cjs | UMD bundle, global butlerov | | dist/butlerov.es.cjs | ES module |

Copy dist/butlerov.umd.cjs into your site (or consume it from npm and serve from node_modules), then:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Butlerov</title>
    <script src="./butlerov.umd.cjs"></script>
  </head>
  <body>
    <div id="stage" style="width: 800px; height: 500px; border: 1px solid #ccc"></div>
    <script>
      const editor = new butlerov.MoleculeEditor({
        stage: document.getElementById("stage"),
        mode: "structure",
      });
      editor.onchange = function () {
        const g = editor.graph;
        const mw = new butlerov.MW(g).compute();
        console.log("MW", mw);
      };
    </script>
  </body>
</html>

From a CDN (adjust version as needed):

<script src="https://unpkg.com/@butlerov-chemistry/core@latest/dist/butlerov.umd.cjs"></script>

Main API (quick reference)

| Member | Purpose | |--------|---------| | new MoleculeEditor({ stage, mode, ... }) | Create editor; mode is "structure" or "scheme". | | editor.graph / editor.graph = graph | Read/write native Graph model. | | editor.document | Read/write full Document (scheme mode / multi-object). | | editor.load(string, converter) | Load from MOL/SMILES/etc. via a Converter. | | editor.save(converter) | Serialize with MolConverter, SmilesConverter, etc. | | editor.onchange | Callback after edits. | | editor.readonly | When true, view-only (no editing). | | editor.clear(fromUserspace?) | Clear canvas. | | new MW(graph).compute() | Molecular weight. | | new Formula(graph).compute_as_html() | Formula HTML. | | new MolConverter() / new SmilesConverter() | MOL V2000/V3000 and SMILES interop where implemented. |

For themes and styling, import defaultStyle, lightTheme, darkTheme, and pass theme / style in the constructor or assign editor.theme / editor.style after creation.


Development server (this package)

npm run dev

Vite dev server with HMR (default http://localhost:5173/).


Repository layout

Monorepo root: README.md. Related packages: Vue component, desktop app.