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

anycode-base

v1.0.7

Published

Anycode Editor component

Downloads

270

Readme

anycode-base

Core code editor component with tree-sitter support for syntax analysis and code highlighting. Serves as the foundation of the anycode editor and can be used as a standalone library.

Description

anycode-base is a high-performance code editor for web applications, built on top of tree-sitter for parsing and virtual rendering. The editor supports multiple programming languages, integrates with LSP for code completion and navigation, and provides a flexible API for customization.

Key Features

  • Syntax Analysis: Uses web-tree-sitter for code parsing and syntax highlighting
  • Virtual Rendering: Efficient rendering of large files with scroll virtualization
  • Multi-language Support: JavaScript, TypeScript, Python, Rust, Go, C/C++, Java, Kotlin, C#, HTML, CSS, JSON, YAML, TOML, Lua, Zig, Bash, and more
  • LSP Integration: Language Server Protocol support for code completion, go-to-definition, and hover information
  • Change History: Undo/redo functionality
  • Search: Built-in text search
  • Text Selection: Support for multiple selections and cursor operations
  • Theme Customization: Flexible theme system for appearance customization

Installation

npm install anycode-base

Usage

Basic Example

import { AnycodeEditor } from 'anycode-base';

const code = `// Hello from Anycode Editor!
function greet(name) {
    return \`Hello, \${name}!\`;
}

console.log(greet('World'));
`;

async function init() {
    const editor = new AnycodeEditor(code, 'example.js', 'javascript');
    await editor.init();
    editor.render();
    document.getElementById('editor')
        .appendChild(editor.getContainer());
}

init();

Main Methods

Initialization & Lifecycle:

  • async init(): Promise<void> - Initialize the editor (must be called before use)
  • clean(): void - Clean up and remove the editor from DOM
  • getContainer(): HTMLDivElement - Get the editor's DOM container

Rendering:

  • render(): void - Render the editor
  • renderCursorOrSelection(): void - Render cursor or selection only

Text Operations:

  • getText(): string - Get all text content
  • setText(newText: string): void - Set text content
  • getTextLength(): number - Get the length of text content
  • applyChange(change: Change): void - Apply a change object to the editor

Cursor & Focus:

  • getCursor(): { line: number, column: number } - Get current cursor position
  • setCursor(line: number, column: number): void - Set cursor position
  • requestFocus(line: number, column: number, center?: boolean): void - Request focus at position
  • requestedFocus(): boolean - Check if focus was requested

Scroll:

  • hasScroll(): boolean - Check if editor has scroll position
  • restoreScroll(): void - Restore previous scroll position

LSP Integration:

  • setCompletionProvider(provider: (request: CompletionRequest) => Promise<Completion[]>): void - Set completion provider
  • setGoToDefinitionProvider(provider: (request: DefinitionRequest) => Promise<DefinitionResponse>): void - Set go-to-definition provider
  • setCompletions(completions: Completion[]): void - Set completions manually
  • async toggleCompletion(): Promise<void> - Toggle completion popup
  • async showCompletion(): Promise<void> - Show completion popup
  • applyCompletion(index: number): void - Apply completion at index

Callbacks & Events:

  • setOnChange(func: (change: Change) => void): void - Set callback for text changes
  • setOnCursorChange(callback: (newState: Position, oldState: Position) => void): void - Set callback on cursor change

UI Customization:

  • setRunButtonLines(lines: number[]): void - Set lines that show run buttons
  • setErrors(errors: { line: number, message: string }[]): void - Set error markers for lines

Supported Languages

  • JavaScript / TypeScript
  • Python
  • Rust
  • Go
  • C / C++
  • Java
  • Kotlin
  • C#
  • HTML / CSS
  • JSON / YAML / TOML
  • Lua
  • Zig
  • Bash

A complete list of languages can be found in the src/langs/ directory.

Dependencies

  • web-tree-sitter - Tree-sitter parser for syntax analysis
  • vscode-textbuffer - Efficient text buffer management
  • typescript - Type definitions

License

MIT