How potahtml/pota works
Project type and purpose
• pota is an open-source, compiler-less Reactive Web Renderer library for building UI with HTML/XML or JSX.
• It provides:
• A Babel preset (transform-time) that converts JSX into highly optimized partial DOM-expression calls.
• A runtime core that handles reactivity (signals, stores), scheduling, and DOM rendering.
• A set of built-in components (Router, Show, For, etc.) and a plugin system for common patterns (useTimeout, useScroll, etc.).
File structure
Top-level directories show distinct architectural layers:
• src/babel-preset → the build-time pipeline (JSX → partials)
• src/core → the runtime engine (renderer, scheduler, XML handling)
• src/lib → the reactive primitives (SignalEmitter, store, reconcile, tracker)
• src/components → the declarative UI components (Router, Portal, Switch, etc.)
• src/plugin → an extensible plugin API (clipboard, fullscreen, useLocation, etc.)
• src/jsx → the jsx-runtime for JSX-style import aliases
• src/exports.js & package.json → packaging and public API surface
README for insights
• Confirms no separate backend, purely a UI library.
• Emphasizes inspiration from SolidJS but with custom preferences.
• Notes documentation site, templates, and Babel-only transformation.
Components
a. Main Components
1. Developer Code (JS/TS + optional JSX)
2. Babel Preset Pipeline
3. Pota Library (layered modules)
• Runtime Core (renderer, scheduler, xml)
• Reactivity Layer (SignalEmitter, store, reconcile, tracker)
• Component Layer (Collapse, For, Router, etc.)
• Plugin Layer (useTimeout, useScroll, etc.)
• JSX Runtime (jsx-runtime.js)
4. Browser DOM / XML host environment
b. Relationships & Interactions
• Developer code → passes through Babel Preset → emits optimized JS partial calls.
• Transformed code imports Pota’s Runtime Core & Reactivity modules.
• At runtime, Reactive Primitives notify the Scheduler → Core Renderer updates the DOM.
• Components and Plugins sit atop Core & Reactivity; they import and invoke core APIs.
c. Architectural Patterns & Principles
• Layered modular architecture: transformation layer, runtime engine, reactive primitives, UI components, plugins.
• Plugin architecture: easy extension without touching core.
• Compiler-less approach: build-time transforms only where needed, minimal coupling to build tools.
• Inspired by MVC in that “View” (components) is separate from “Model” (reactive store), orchestrated by the scheduler.
d. Key Technologies & Frameworks
• Babel (custom preset, rollup config for bundling)
• JavaScript/TypeScript types (pota.d.ts, tsconfig.json)
• Rollup for packaging (rollup.config.js)
• Node/NPM packaging (package.json, .npmignore)