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

@miy2/xml-api

v0.9.1

Published

An XML library that faithfully synchronizes documents and AST.

Readme

XML API

An XML synchronization engine that maintains full fidelity between source code and the Document Object Model (DOM).

This project provides a foundational XML parser and manipulation API designed for WYSIWYG editors and Integrated Development Environments (IDEs). It features a DOM-compatible interface that bidirectionally synchronizes intuitive application edits and source code modifications, all while preserving details like whitespace and indentation.

Key Features

  • Full Fidelity: Edits preserve all whitespace, indentation, and comments automatically in unmodified parts of the code.
  • Bidirectional Sync: Instantly synchronizes changes between the source code and the in-memory model, ensuring consistent state across operations.
  • DOM Compatibility: Provides a familiar interface (Element, Document, setAttribute, etc.) for intuitive application development.
  • Incremental Updates: High performance through incremental parsing and minimal text patching.

Architecture

The system is built on a robust synchronization engine orchestrated by the XMLAPI:

  1. SyncEngine: The core engine that manages state via Transactions and orchestrates updates.

  2. CST (Concrete Syntax Tree): Captures the exact physical structure of the source code, including formatting.

  3. Model: The authoritative internal representation that maintains object identity, coordinates synchronization, and provides a semantic view for traversal.

Additionally, a DOM-compatible Interface wraps the Model for familiar application development.

Basic Usage

Initialization

import { XMLAPI } from '@miy2/xml-api';

const xml = `<root>
  <item id="1">Original Value</item>
</root>`;

const api = new XMLAPI(xml);

Manipulating via DOM API (Recommended)

You can use standard DOM methods to manipulate the XML. These changes are automatically reflected back to the source code with minimal patches.

const doc = api.getDocument(); // Returns a DOM-like Document
const item = doc.querySelector('item');

if (item) {
  item.setAttribute('status', 'active');
  item.textContent = 'Updated Value';
}

console.log(api.source);
/* 
Output:
<root>
  <item id="1" status="active">Updated Value</item>
</root>
*/

Low-level Incremental Updates

// Update the source code directly at specific offsets
api.updateSource(14, 28, "New Content");

Schema Projection (New in v0.9.1)

Create a filtered view of the document that adheres to a specific schema (e.g. XHTML). The view preserves the underlying model's full fidelity (including comments and custom tags) while presenting a simplified DOM for editing.

const api = new XMLAPI(source);
const view = api.createView({
  // Only show 'p' and 'div' elements
  filter: (node) => 
    node.getType() === 'Element' && 
    ['p', 'div'].includes((node as ModelElement).tagName)
});

const root = view.getRoot(); // Returns a filtered DOM-like element
const p = view.getDocument().createElement('p');
p.textContent = "New Paragraph";
root.appendChild(p); // Updates source automatically with smart formatting

Documentation

Development

This project uses pnpm.

pnpm install
pnpm test
pnpm docs:gen-api

License

MIT