New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

treeforge

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treeforge

TreeForge is a lightweight, dependency-free JS package to render and manage ASCII-based file trees inside browser editors, sandboxes, or learning tools. It supports interactivity + CRUD actions, while remaining agnostic of the data source (local JSON or A

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

🌲 TreeForge - Getting Started

A lightweight, dependency-free JavaScript package for rendering file trees with style.

NPM GitHub

📦 Installation

npm install treeforge

Don't forget the CSS!

Add the TreeForge UI stylesheet to your HTML:

<!-- Option 1: Direct link (CDN) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/treeforge@1.0.2/styles/ui.css">

<!-- Option 2: From node_modules -->
<link rel="stylesheet" href="node_modules/treeforge/styles/ui.css">

<!-- Option 3: Import in JS (with bundler) -->
<script>
import 'treeforge/styles/ui.css';
</script>

🚀 Quick Start (3 Lines)

import TreeForge, { ConfigPresets } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: { name: 'root', type: 'folder', children: [] },
    ...ConfigPresets.GITHUB_CLONE  // That's it!
});

Output:

📁 root
└── (empty folder)

✨ What You Get

🎨 15 Beautiful Styles

import { TreeStyles } from 'treeforge';

settings: TreeStyles.GITHUB            // GitHub style
settings: TreeStyles.VSCODE_DARK       // VS Code dark
settings: TreeStyles.DRACULA           // Dracula theme
settings: TreeStyles.NORD              // Nord theme
// ... and 11 more!

⚙️ 15 Configuration Presets

import { ConfigPresets } from 'treeforge';

...ConfigPresets.GITHUB_CLONE         // GitHub browser
...ConfigPresets.VSCODE_CLONE         // VS Code editor
...ConfigPresets.FILE_MANAGER         // File manager
...ConfigPresets.DOCS_BROWSER         // Documentation
// ... and 11 more!

🪝 10 Lifecycle Hooks

hooks: {
    onCreateFile: (path) => {},
    onDeleteFile: (path) => {},
    onReadFile: (path) => {},
    onWriteFile: (path, content) => {},
    // ... and 6 more!
}

📖 Complete Examples

Example 1: Simple Tree

import TreeForge from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: {
        name: 'my-project',
        type: 'folder',
        children: [
            { name: 'src', type: 'folder', children: [] },
            { name: 'README.md', type: 'file' }
        ]
    }
});

Example 2: With Built-in Style

import TreeForge, { TreeStyles } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    settings: TreeStyles.VSCODE_DARK  // Beautiful VS Code style!
});

Example 3: Complete Configuration Preset

import TreeForge, { ConfigPresets } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    ...ConfigPresets.FILE_MANAGER  // Includes: style, features, shortcuts, menus!
});

Example 4: With API Backend

import TreeForge, { ConfigPresets, RestApiHooks } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    ...ConfigPresets.VSCODE_CLONE,
    onLoad: async () => {
        const res = await fetch('/api/tree');
        return await res.json();
    },
    hooks: RestApiHooks  // Pre-built REST API hooks!
});

Example 5: With LocalStorage

import TreeForge, { TreeStyles, LocalStorageHooks } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    settings: TreeStyles.GITHUB,
    hooks: LocalStorageHooks  // Auto-save to localStorage!
});

🎯 Import Guide

Main Imports

// TreeForge class (default export)
import TreeForge from 'treeforge';

// Everything else (named exports)
import { 
    TreeStyles,           // 15 visual styles
    ConfigPresets,        // 15 complete configs
    LocalStorageHooks,    // Pre-built hooks
    RestApiHooks,         // Pre-built hooks
    combineHooks,         // Utility functions
    getPreset,
    mergePresets
} from 'treeforge';

All Available Exports

import TreeForge, {
    // Styles & Presets
    TreeStyles,              // 15 visual themes
    ConfigPresets,           // 15 complete configurations
    
    // Hook Examples
    LocalStorageHooks,       // Save to localStorage
    RestApiHooks,            // Connect to REST API
    AnalyticsHooks,          // Track events
    ValidationHooks,         // Validate operations
    CacheHooks,              // Cache file content
    AutoSaveHooks,           // Auto-save with debounce
    combineHooks,            // Combine multiple hooks
    
    // Utilities
    getPreset,               // Get specific preset
    mergePresets,            // Merge presets
    listPresets,             // List all presets
    createConfig,            // Create custom config
    validateConfig,          // Validate config
    
    // References
    SettingsReference,
    EditorConfigReference,
    TreeDataStructure
} from 'treeforge';

📚 Documentation

🎨 All 15 Styles

StyleThemeUsage
MINIMALBasicTreeStyles.MINIMAL
GITHUBGitHubTreeStyles.GITHUB
VSCODE_DARKVS Code DarkTreeStyles.VSCODE_DARK
VSCODE_LIGHTVS Code LightTreeStyles.VSCODE_LIGHT
COLORFULVibrantTreeStyles.COLORFUL
MATERIAL_DARKMaterial DarkTreeStyles.MATERIAL_DARK
MATERIAL_LIGHTMaterial LightTreeStyles.MATERIAL_LIGHT
ASCIITerminalTreeStyles.ASCII
ASCII_COMPACTCompactTreeStyles.ASCII_COMPACT
MONOCHROMEB&WTreeStyles.MONOCHROME
SOLARIZED_DARKSolarizedTreeStyles.SOLARIZED_DARK
DRACULADraculaTreeStyles.DRACULA
NORDNordTreeStyles.NORD
ONE_DARKOne DarkTreeStyles.ONE_DARK
HIGH_CONTRASTAccessibleTreeStyles.HIGH_CONTRAST

⚙️ All 15 Configuration Presets

PresetBest ForUsage
MINIMALSimple treesConfigPresets.MINIMAL
GITHUB_CLONERepo browserConfigPresets.GITHUB_CLONE
VSCODE_CLONECode editorConfigPresets.VSCODE_CLONE
FILE_MANAGERFile operationsConfigPresets.FILE_MANAGER
DOCS_BROWSERDocumentationConfigPresets.DOCS_BROWSER
MEDIA_BROWSERPhotos/videosConfigPresets.MEDIA_BROWSER
CODE_EDITORCode playgroundConfigPresets.CODE_EDITOR
TERMINAL_STYLECLI aestheticConfigPresets.TERMINAL_STYLE
COMPACTSidebarConfigPresets.COMPACT
ACCESSIBLEScreen readersConfigPresets.ACCESSIBLE
MOBILE_OPTIMIZEDTouch devicesConfigPresets.MOBILE_OPTIMIZED
LARGE_DATASET10,000+ filesConfigPresets.LARGE_DATASET
COLLABORATIVETeam workspaceConfigPresets.COLLABORATIVE
READ_ONLYView-onlyConfigPresets.READ_ONLY
DRACULA_THEMEDracula colorsConfigPresets.DRACULA_THEME
NORD_THEMENord colorsConfigPresets.NORD_THEME

🪝 All 10 Hooks

hooks: {
    onCreateFile: (path, parentNode) => {},      // File created
    onCreateFolder: (path, parentNode) => {},    // Folder created
    onDeleteFile: (path, node) => {},            // File deleted
    onDeleteFolder: (path, node) => {},          // Folder deleted
    onDeleteNode: (path, node) => {},            // Any node deleted
    onRenameNode: (oldPath, newPath, node) => {},// Node renamed
    onReadFile: (path, node) => 'content',       // Read file
    onWriteFile: (path, content, node) => {},    // Write file
    onLoad: () => treeData,                      // Load data
    onFileOpen: (path, content, node) => {}      // File opened
}

💡 Common Patterns

Pattern: GitHub-style Browser

import TreeForge, { ConfigPresets } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    ...ConfigPresets.GITHUB_CLONE
});

Pattern: VS Code-style Editor

import TreeForge, { ConfigPresets } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    ...ConfigPresets.VSCODE_CLONE
});

Pattern: Custom Style + Hooks

import TreeForge, { TreeStyles, LocalStorageHooks } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    settings: TreeStyles.DRACULA,
    hooks: LocalStorageHooks
});

Pattern: Preset + Override

import TreeForge, { ConfigPresets, TreeStyles } from 'treeforge';

const tree = new TreeForge({
    containerId: 'tree',
    localData: myData,
    ...ConfigPresets.FILE_MANAGER,  // Full features
    settings: TreeStyles.NORD       // But use Nord theme
});

🎯 Key Features

Zero Dependencies - Pure vanilla JavaScript
15 Styles - Beautiful pre-built themes
15 Presets - Complete configurations ready to use
10 Hooks - Full control over CRUD operations
Lightweight - <15KB minified
Type Safe - TypeScript interfaces included
Framework Agnostic - Works with React, Vue, Angular, vanilla JS
Fully Documented - 1600+ lines of documentation

📄 License

ISC © abmercy035

TreeForge - Render trees beautifully in 3 lines of code 🌲✨

Keywords

file-system

FAQs

Package last updated on 06 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts