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

@wannacode/code-editor-sdk

v2.0.2

Published

React SDK component for online code editing with built-in Node.js runtime, terminal, and GitHub integration

Downloads

1,364

Readme

Code Editor SDK

React SDK компонент для встраивания полнофункционального редактора кода с Node.js runtime в браузере.

✨ Возможности

  • Monaco Editor — редактор кода на базе VS Code с подсветкой синтаксиса и IntelliSense
  • WebContainer — полноценный Node.js runtime в браузере
  • Терминал — интерактивный терминал на базе xterm.js
  • Файловая система — виртуальная файловая система с поддержкой CRUD операций
  • GitHub интеграция — загрузка любых публичных репозиториев

🚀 Быстрый старт

npm install
npm run dev

Откройте http://localhost:5173

📦 Использование SDK

Declarative API

import { CodeEditorSDK } from '@mycompany/code-editor-sdk';

function App() {
  return (
    <CodeEditorSDK
      githubUrl="https://github.com/user/repo"
      onFileChange={(filename, content) => {
        console.log('File changed:', filename);
      }}
      onCommandRun={(command, output) => {
        console.log('Command run:', command);
      }}
      onProjectLoaded={(files) => {
        console.log('Project loaded:', Object.keys(files).length, 'files');
      }}
      config={{
        theme: 'dark',
        editorHeight: '600px',
        terminalHeight: '300px',
        showSidebar: true,
        showTerminal: true,
        showToolbar: true,
        allowFileCreation: true,
        allowFileDeletion: true,
        sidebarWidth: 250,
      }}
    />
  );
}

Imperative API

import { useRef } from 'react';
import { CodeEditorSDK } from '@mycompany/code-editor-sdk';

function App() {
  const editorRef = useRef();

  const handleLoadProject = async () => {
    await editorRef.current.loadProject('https://github.com/facebook/react');
  };

  const handleRunScript = async () => {
    await editorRef.current.runScript('index.js');
  };

  const handleRunCommand = async () => {
    await editorRef.current.runCommand('npm install');
  };

  return (
    <div>
      <button onClick={handleLoadProject}>Load Project</button>
      <button onClick={handleRunScript}>Run Script</button>
      <button onClick={handleRunCommand}>npm install</button>
      
      <CodeEditorSDK ref={editorRef} />
    </div>
  );
}

📚 API Reference

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | githubUrl | string | - | URL GitHub репозитория для автозагрузки | | onFileChange | (filename, content) => void | - | Callback при изменении файла | | onCommandRun | (command, output) => void | - | Callback при выполнении команды | | onProjectLoaded | (files) => void | - | Callback при загрузке проекта | | config | object | - | Конфигурация (см. ниже) |

Config Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | theme | 'dark' \| 'light' | 'dark' | Тема редактора | | editorHeight | string | '100%' | Высота редактора | | terminalHeight | string | '250px' | Высота терминала | | showSidebar | boolean | true | Показывать боковую панель | | showTerminal | boolean | true | Показывать терминал | | showToolbar | boolean | true | Показывать панель инструментов | | allowFileCreation | boolean | true | Разрешить создание файлов | | allowFileDeletion | boolean | true | Разрешить удаление файлов | | sidebarWidth | number | 250 | Ширина боковой панели | | defaultFile | string | 'index.js' | Файл по умолчанию |

Imperative Methods

interface CodeEditorSDKRef {
  // File operations
  openFile(path: string): void;
  createFile(path: string, content?: string): string;
  createFolder(path: string): string;
  deleteFile(path: string): void;
  getFileContent(path: string): string | null;
  updateFile(path: string, content: string): void;
  getFiles(): Record<string, FileData>;
  
  // Runtime operations
  runCommand(command: string): Promise<{ exitCode?: number; error?: string }>;
  runScript(file: string): Promise<{ exitCode?: number; error?: string }>;
  npmInstall(): Promise<number>;
  killProcess(): void;
  syncFiles(): Promise<void>;
  
  // Project operations
  loadProject(githubUrl: string): Promise<void>;
  exportProject(): Record<string, string>;
  importProject(files: Record<string, string>): void;
  
  // UI operations
  setTheme(theme: 'dark' | 'light'): void;
  toggleSidebar(): void;
  toggleTerminal(): void;
  
  // Terminal operations
  clearTerminal(): void;
  
  // State
  isReady: boolean;
  isRunning: boolean;
}

🔌 Hooks

SDK экспортирует отдельные hooks для кастомизации:

import { useRuntime, useFileSystem, useGitHub } from '@mycompany/code-editor-sdk';

function CustomEditor() {
  const runtime = useRuntime();
  const fileSystem = useFileSystem();
  const github = useGitHub();
  
  // Используйте индивидуальные hooks
  await runtime.runCommand('npm start');
  fileSystem.createFile('app.js', 'console.log("Hello")');
  await github.loadProject('github.com/user/repo');
}

🎨 Компоненты

SDK экспортирует отдельные компоненты:

import { 
  FileTree, 
  Editor, 
  Terminal, 
  Toolbar 
} from '@mycompany/code-editor-sdk';

// Создайте собственный layout
function CustomLayout() {
  return (
    <div className="flex">
      <FileTree />
      <div className="flex-1">
        <Toolbar />
        <Editor />
        <Terminal />
      </div>
    </div>
  );
}

🛠 Технологии

  • React — UI framework
  • Monaco Editor — Code editor
  • WebContainer API — Node.js runtime в браузере
  • xterm.js — Terminal emulator
  • Zustand — State management
  • Tailwind CSS — Styling
  • Lucide React — Icons

⚠️ Важно

WebContainer требует специальных HTTP заголовков для работы:

// vite.config.js
export default {
  server: {
    headers: {
      'Cross-Origin-Embedder-Policy': 'require-corp',
      'Cross-Origin-Opener-Policy': 'same-origin',
    },
  },
}

📝 Лицензия

MIT

js-practice-editor-2