Skip to content

Latest commit

 

History

History
368 lines (255 loc) · 6.2 KB

File metadata and controls

368 lines (255 loc) · 6.2 KB

HexaCore

A Web-Style Native Application Runtime (Electron Replacement)


1. Overview

HexaCore Runtime is a cross-platform desktop runtime designed to replace Electron for large-scale applications. It preserves the web paradigm (declarative tree + CSS-like styling) while removing Chromium, WebView, and the browser DOM from the stack.

Goals:

  • consistent native performance,
  • smaller footprint than Electron,
  • deep OS integration,
  • and incremental migration from existing Electron apps.

2. Project Goals

2.1 Primary goals

  • Replace Electron without full app rewrites.
  • Keep CSS-like styling and layout.
  • Run UI and logic in a custom runtime (no browser).
  • Enforce security via sandbox and explicit permissions.
  • Scale to Discord/Slack/Teams-level apps.

2.2 Non-goals (explicitly out of scope)

  • Full HTML/CSS/JS compliance per W3C.
  • Embedded browser behavior.
  • Running arbitrary web code without sandboxing.

3. Target Audience

  • Companies with large, mature Electron apps.
  • Products that require rich UI + real-time media.
  • Teams that want the web model with native performance and control.

4. Core Concepts

4.1 UI Model

  • UI built on a custom declarative tree, inspired by DOM/React.
  • Primitive components controlled by the runtime.
  • Direct GPU rendering (no HTML layout).

4.2 Styling

  • CSS-like subset, including:

    • cascade,
    • specificity,
    • variables,
    • themes.
  • Styles apply to runtime primitives, not arbitrary HTML tags.

4.3 Execution

  • App logic runs inside a sandbox (WASM or isolated JS).
  • Host communication via a Native Bridge with explicit permissions.

5. High-Level Architecture

flowchart TD
  A["Dev writes App (DSL or TS/JSX)"] --> B["Compiler: Parser -> AST -> IR"]
  B --> C["App Bundle"]

  C --> D["Desktop Host"]

  subgraph R["HexaCore Runtime"]
    E["App Runtime (WASM or JS sandbox)"]
    F["UI Runtime (tree + diff)"]
    G["Style Engine (CSS subset)"]
    H["Layout Engine (flexbox)"]
    I["Text Engine (shaping, selection)"]
    J["GPU Renderer"]
    K["Input & A11y"]
    L["Native Bridge"]
  end

  D --> R
  E --> F
  F --> G --> H --> I --> J
  K --> F
  E --> L --> D
Loading

6. Runtime Components

6.1 App Runtime

Responsible for:

  • executing app logic,
  • state management,
  • UI event dispatch.

Characteristics

  • sandboxed by default,
  • async communication with UI,
  • hot reload in development.

6.2 UI Runtime

  • maintains the real UI tree,
  • applies diffs (reconciliation),
  • controls component lifecycle.

6.3 Style Engine (CSS Subset)

Initial support

  • selectors: .class, #id, type, simple descendant.
  • box model: margin, padding, border.
  • full flexbox.
  • colors, backgrounds, images.
  • opacity, transform.
  • variables (--var).

Out of initial scope

  • advanced CSS Grid.
  • complex pseudo-elements.
  • table-based layout.

6.4 Layout Engine

  • flexbox-based.
  • incremental, cached calculation.
  • scroll and virtualization support.

6.5 Text Engine

  • font fallback.
  • full Unicode.
  • emoji.
  • selection, cursor, copy/paste.
  • IME (Japanese, Chinese, etc.).

Note: This is critical for Discord-level apps.


6.6 GPU Renderer

  • modern graphics API (Vulkan/Metal/D3D).
  • display lists.
  • layered composition.
  • aggressive glyph and image caching.

6.7 Input and Accessibility

  • mouse, keyboard, touch.
  • keyboard navigation.
  • focus and tab order.
  • semantic tree for screen readers.

6.8 Native Bridge

Exposed APIs:

  • filesystem (sandboxed),
  • notifications,
  • tray,
  • windows,
  • audio/video,
  • auto-update.

All gated by declarative permissions.


7. Permission Model

flowchart LR
  A["App Manifest"] --> B["Permission Resolver"]
  B --> C["Allowed APIs"]
  B --> D["Denied APIs"]
Loading

Example:

permissions:
  filesystem: read-only
  notifications: true
  audio: true
  camera: false

8. App Structure

my-app/
 ├─ manifest.yaml
 ├─ ui/
 │   ├─ app.tsx
 │   └─ styles.css
 ├─ logic/
 │   └─ main.ts
 └─ assets/
     ├─ icons/
     └─ fonts/

9. App Manifest

name: ChatApp
version: 1.0.0
entry: ui/app.tsx

permissions:
  filesystem: sandbox
  notifications: true
  audio: true

window:
  width: 1280
  height: 720
  resizable: true

10. Build Pipeline

flowchart TD
  A["Source App"] --> B["Compiler"]
  B --> C["IR + Assets"]
  C --> D["Runtime Bundle"]
  D --> E["Packager"]
  E --> F["Windows"]
  E --> G["Linux"]
  E --> H["macOS"]
Loading

11. Distribution

11.1 Targets

  • Windows: .exe / .msi
  • Linux: Flatpak, AppImage
  • macOS: .app / .dmg

11.2 Auto-update

  • binary signing,
  • delta updates,
  • safe rollback.

12. Hybrid Mode (Electron Migration)

flowchart TD
  A["HexaCore Window"] --> B["Native Screens"]
  A --> C["Isolated WebView (Legacy)"]
Loading
  • New screens use HexaCore UI.
  • Legacy screens run in isolated WebView.
  • Progressive migration to zero WebView.

13. Required Technical MVPs

MVP-1: Chat View

  • virtualized list (50k messages),
  • basic Markdown,
  • emojis,
  • selection and copy,
  • stable 60 FPS.

MVP-2: Advanced Input

  • multiline,
  • IME,
  • undo/redo,
  • keyboard shortcuts.

14. Roadmap

v0.1 – Core

  • UI tree
  • basic styles
  • GPU render
  • simple input

v0.2 – Real product

  • full text
  • virtualization
  • permissions
  • packaging

v0.3 – Migration

  • isolated WebView
  • hybrid APIs
  • dev tooling

v1.0 – Electron replacement

  • full accessibility
  • voice/media APIs
  • telemetry and crash reporting
  • mature tooling

15. Competitive Differentiation

Aspect Electron HexaCore
Chromium Yes No
Footprint High Low
Startup Slow Fast
UI Engine DOM/CSS Native GPU
Permissions Weak Strong
Migration Hard Incremental

16. Conclusion

HexaCore Runtime is not "just another framework". It is a native UI infrastructure with a web-style paradigm, designed to replace Electron for large apps without a full rewrite or embedded browser costs.