A fully composable browser engine built with TypeScript/Deno. Every component can be used independently or combined as needed.
The browser is designed as a composable toolkit with well-defined layers and public APIs for all subsystems:
┌─────────────────────────────────────────────────────────┐
│ Browser Class │
│ (High-level orchestration and configuration) │
└─────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌──────────────┐ ┌────────────┐
│ Request │ │ Rendering │ │ Storage │
│ Pipeline │ │ Pipeline │ │ Systems │
└─────────────┘ └──────────────┘ └────────────┘
│ │ │
▼ ▼ ▼
Network Layer Rendering Layer Data Layer
Every component exposes its subsystems through public getter methods. You can:
- Use the HTTP stack without the rendering engine
- Use the rendering engine without JavaScript execution
- Use the WebGPU engine for custom GPU operations
- Mix and match components for your specific use case
Main entry point for full browser functionality.
import { Browser } from "./mod.ts";
const browser = new Browser({
width: 1024,
height: 768,
enableJavaScript: false,
enableStorage: true,
});
// Access all subsystems
const requestPipeline = browser.getRequestPipeline();
const renderingPipeline = browser.getRenderingPipeline();
const storageManager = browser.getStorageManager();
const cookieManager = browser.getCookieManager();
const quotaManager = browser.getQuotaManager();HTTP networking stack with DNS, connection pooling, and caching.
import { RequestPipeline } from "./mod.ts";
const pipeline = new RequestPipeline();
const result = await pipeline.get("https://example.com");
// Access subsystems
const dnsResolver = pipeline.getDNSResolver();
const dnsCache = pipeline.getDNSCache();
const connectionPool = pipeline.getConnectionPool();
const connectionManager = pipeline.getConnectionManager();
const cacheStorage = pipeline.getCacheStorage();HTML/CSS parsing, layout, and rendering.
import { RenderingPipeline } from "./mod.ts";
const pipeline = new RenderingPipeline({
width: 1024,
height: 768,
});
const result = await pipeline.render("https://example.com");
// Access subsystems
const requestPipeline = pipeline.getRequestPipeline();
const compositor = pipeline.getCompositor();JavaScript execution with V8.
import { ScriptExecutor } from "./mod.ts";
const executor = new ScriptExecutor(document, "https://example.com");
const result = await executor.execute("2 + 2");
// Access subsystems
const isolate = executor.getIsolate();
const context = executor.getContext();
const eventLoop = executor.getEventLoop();
const windowObject = executor.getWindow();
const document = executor.getDocument();GPU-accelerated rendering with WebGPU.
import { WebGPU } from "./mod.ts";
const engine = new WebGPU.WebGPUEngine({ canvas });
await engine.initialize();
// Access subsystems
const driver = engine.getDriver();
const memoryManager = engine.getMemoryManager();
const bufferPool = engine.getBufferPool();
const stagingPool = engine.getStagingPool();
const pipelineManager = engine.getPipelineManager();
const textureManager = engine.getTextureManager();
const compositor = engine.getCompositor();- Deno 2.x+ (https://deno.land)
# Navigate to browser directory
cd browser
# Type check
deno task check
# Run tests
deno task test
# Start browser with URL
deno run --allow-all src/main.ts https://example.com// Import full browser
import { Browser } from "jsr:@browserx/browser";
// Import specific components
import { RenderingPipeline, RequestPipeline } from "jsr:@browserx/browser";
// Import WebGPU separately (namespace export)
import * as WebGPU from "jsr:@browserx/browser";
const engine = new WebGPU.WebGPUEngine({ canvas });See the examples/ directory for comprehensive usage examples:
- Request Pipeline (
01-request-pipeline.ts) - HTTP networking independently - Rendering Pipeline (
02-rendering-pipeline.ts) - HTML/CSS parsing and layout - Script Executor (
03-script-executor.ts) - JavaScript execution with V8 - WebGPU Engine (
04-webgpu-engine.ts) - GPU-accelerated rendering - Storage Systems (
05-storage-systems.ts) - localStorage, cookies, IndexedDB - Composition (
06-composition.ts) - Combining multiple components
Run examples:
deno run --allow-net examples/01-request-pipeline.ts
deno run --allow-net examples/02-rendering-pipeline.ts
deno run examples/03-script-executor.ts
deno run --allow-all examples/04-webgpu-engine.ts
deno run examples/05-storage-systems.ts
deno run --allow-net examples/06-composition.tsAll major classes expose their subsystems through public getter methods with comprehensive JSDoc documentation:
Browser
getRequestPipeline(): RequestPipelinegetRenderingPipeline(): RenderingPipelinegetStorageManager(): StorageManagergetCookieManager(): CookieManagergetQuotaManager(): QuotaManager
RequestPipeline
getDNSResolver(): DNSResolvergetDNSCache(): DNSCachegetConnectionPool(): ConnectionPoolgetConnectionManager(): ConnectionManagergetCacheStorage(): CacheStorage
RenderingPipeline
getRequestPipeline(): RequestPipelinegetCompositor(): CompositorThread
ScriptExecutor
getIsolate(): V8IsolategetContext(): V8ContextgetWindow(): WindowObjectgetEventLoop(): EventLoopgetDocument(): DOMNode
WebGPUEngine
getDriver(): WebGPUDrivergetMemoryManager(): MemoryManagergetBufferPool(): BufferPoolgetStagingPool(): StagingBufferPoolgetPipelineManager(): PipelineManagergetTextureManager(): WebGPUTextureManagergetDevice(): GPUDevicegetGPUDevice(): GPUDevicegetCanvasContext(): GPUCanvasContextgetCompositor(): WebGPUCompositor
All getter methods include:
- Description of the subsystem
- What it provides
- How to use it
- Code examples
- Type information
View documentation in your IDE by hovering over method names.
- DNS Resolution: Async DNS with caching and TTL management
- Connection Pool: Reusable TCP/TLS connections with keep-alive
- HTTP Protocol: HTTP/1.1, HTTP/2, HTTP/3 support
- TLS Security: TLS 1.2/1.3 with certificate validation
- Caching: HTTP caching with ETags and Last-Modified
- HTML Parser: Tokenization and tree building (HTML5 spec compliant)
- CSS Parser: Tokenization, parsing, and CSSOM construction
- Style Resolution: Selector matching, cascade, and inheritance
- Layout Engine: Box model, flexbox, grid, and text layout
- Paint Engine: Display list generation and recording
- Compositor: Layer composition, tiling, and GPU upload
- V8 Integration: Full V8 isolate and context management
- Bytecode Compilation: 11 bytecode operations (CALL, CONSTRUCT, GET/SET_PROPERTY, GET/SET_KEYED, CREATE_OBJECT/ARRAY/CLOSURE, LDA/STA_CONTEXT_SLOT)
- bytecodex FFI: Rust-based optimization pass via
V8Compiler.compile(source, { optimize: true }) - Event Loop: Macro/micro task scheduling
- Web APIs: window, console, setTimeout, DOM manipulation
- Garbage Collection: Automatic memory management
- localStorage: Persistent key-value storage per origin
- sessionStorage: Session-scoped storage per origin
- Cookies: HTTP cookie management with domain/path matching
- IndexedDB: Object stores with indexes and transactions
- Cache API: HTTP response caching for service workers
- Quota Management: Storage quota enforcement
- Driver Management: GPU device initialization and recovery
- Memory Management: Buffer pool, staging pool, allocation tracking
- Buffer Operations: Vertex, index, uniform, storage buffers
- Texture Management: 2D/3D textures, mipmaps, samplers
- Pipeline Management: Render and compute pipeline caching
- Compositor: Layer composition and presentation
# Run all tests
deno task test
# Run specific test file
deno test --allow-all src/engine/network/DNSResolver.test.ts
# Watch mode
deno task test:watch# Check all files
deno task check
# Watch mode
deno task check:watch
# Check specific file
deno check src/main.ts# Lint
deno task lint
# Format
deno task fmt
# Format check (no modifications)
deno task fmt:checkUse RequestPipeline + RenderingPipeline without JavaScript:
const pipeline = new RenderingPipeline({ enableJavaScript: false });
const result = await pipeline.render(url);
const dom = result.dom; // Parse and extract dataUse RequestPipeline directly:
const pipeline = new RequestPipeline();
const result = await pipeline.get("https://api.example.com/data");
console.log(result.response.statusCode, result.timing);Render HTML/CSS without browser UI:
const pipeline = new RenderingPipeline({ width: 1200, height: 800 });
const result = await pipeline.render(url);
const pixels = await pipeline.screenshot();Use WebGPU engine for graphics:
const engine = new WebGPUEngine({ canvas });
await engine.initialize();
// Create buffers, textures, render...Execute untrusted code safely:
const executor = new ScriptExecutor(document, origin);
const result = await executor.execute(untrustedCode);
if (!result.success) {
console.error(result.error);
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run type checking and tests
- Submit a pull request
BrowserX Browser Engine is part of the BrowserX project and is licensed under the MIT License.
See docs/ directory for complete technical documentation.