1.2.3 • Published 9 months ago

@forest-js/core v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

🌲 forest-js

A tiny, real DOM-based UI engine written in pure JavaScript — minimal, fast, and framework-free.


🌐 Official Links

TypeLink
GitHub RepositoryGrangbelrLurain/forest-js
DocumentationForest.js Docs

šŸ“¦ Packages

PackageDescription
@forest-js/coreCore DOM engine (no virtual DOM)
@forest-js/cliInternal CLI logic for scaffolding apps
create-forestLightweight installer for templates via npx

✨ Features

  • āœ… Real DOM (no VDOM diffing)
  • ⚔ Ultra-lightweight (~7kB bundled)
  • šŸ” Explicit update() per element
  • 🧠 Fully JavaScript-based, no JSX, no Babel
  • šŸ›” Tiny reactive store() built-in
  • 🌐 SSR-friendly (with flexibility)
  • 🧰 Framework-free & zero dependency

šŸš€ Getting Started

npx create-forest my-app
cd my-app
pnpm install
pnpm dev

🧩 Core Example

import { createStore, addEvent, decorate, tree, addChild } from "@forest-js/core";

const CountButton = () => {
  const count = createStore(0);

  const ButtonRef = tree("button");

  return decorate(
    ButtonRef,
    addChild({ count }, ({ count }) => count),
    addEvent("click", () => count.update((n) => n + 1))
  );
};

export default CountButton;

🌳 Core API

createForest()

Initializes the application by rendering the root element.

createForest("#app", () => dom("div", { children: "Hello, Forest!" })); // start in target element

or

createForest(() => dom("div", { children: "Hello, Forest!" })); // replace all html

tree()

Creates a single DOM element without attributes.

const div = tree("div"); // create div element example

createStore()

Creates a reactive store for state management.

const counter = createStore(0);
counter.subscribe(() => console.log(counter.get())); // action when counter change
counter.set((last) => last + 5); // count change

šŸ“ Template Project

Default template is based on pure JavaScript, using Vite. The project structure follows the Feature-Sliced Design (FSD) architecture methodology:

Feature-Sliced Design Official Documentation

src/
ā”œā”€ā”€ main.ts                      # Application Entry Point
ā”œā”€ā”€ app/
│   └── global.css
ā”œā”€ā”€ entities/
│   ā”œā”€ā”€ exampeCode/
│   │   └── ui/
│   │       ā”œā”€ā”€ CodeCard/
│   │       │   └── index.ts
│   │       └── CountButton/
│   │           └── index.ts
│   └── layout/
│       └── ui/
│           ā”œā”€ā”€ BackgroundImage/
│           │   └── index.ts
│           └── Header.ts/
│               └── index.ts
ā”œā”€ā”€ pages/
│   ā”œā”€ā”€ 404/
│   │   └── index.ts
│   ā”œā”€ā”€ about/
│   │   └── index.ts
│   └── home/
│       └── index.ts
└── shared/
    ā”œā”€ā”€ constant/
    │   ā”œā”€ā”€ index.ts
    │   └── text-contents.ts
    ā”œā”€ā”€ lib/
    │   └── router/
    │       └── index.ts
    └── ui/
        ā”œā”€ā”€ Button.ts
        ā”œā”€ā”€ Card.ts
        ā”œā”€ā”€ LinkButton.ts
        └── OuterLink.ts

šŸ“– Philosophy

forest-js is not a framework —
it's a small set of rules to control the real DOM in a structured way.

  • Declarative thinking without hiding the DOM
  • Tiny enough to debug by reading the source
  • Encourages learning and composable UI patterns

šŸ“„ License

MIT Ā© lurain grangbelr

1.2.3

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago