v0.6.22

Architecture

Last updated


This page shows how QuickUI's modules are layered and where each one lives in the source, in a single overview diagram, plus how QuickUI relates to similar libraries.

System Overview


graph TB
    T["Template: element referenced by id / render()"] --> V["vDOM: :for → :if → :path → {{ }}"]
    D["data (Proxy)"] -->|"set triggers"| L["Lifecycle: 300 ms debounce"]
    L --> V
    I["i18n locale data"] --> V
    V --> P["diff → Patch[]"]
    P -->|"requestAnimationFrame"| R["Real DOM"]
    R --> O["Listeners: lazyload / temp-svg"]
  1. graph TB
  2. T["Template: element referenced by id / render()"] --> V["vDOM: :for → :if → :path → {{ }}"]
  3. D["data (Proxy)"] -->|"set triggers"| L["Lifecycle: 300 ms debounce"]
  4. L --> V
  5. I["i18n locale data"] --> V
  6. V --> P["diff → Patch[]"]
  7. P -->|"requestAnimationFrame"| R["Real DOM"]
  8. R --> O["Listeners: lazyload / temp-svg"]

Layers


LayerSourceResponsibility
Entrysrc/model (QUI.ts)Creates the instance, loads i18n, wraps reactive data, applies patches, handles attribute and event binding
Virtual DOMsrc/model (vDOM.ts)Turns elements into tag / props / children / data, expands :for, :if, :path, replaces {{ }}, produces patches
Lifecyclesrc/model (Lifecycle.ts)Wraps the timing of the initial render and updates, runs when hooks, debounces updates by 300 ms
Utilitiessrc/functioncreateReactiveObject, htmlParser, createElement, getElement, calc, dateFormat and more
Listenerssrc/listenerIntersectionObserver-driven image lazy loading and SVG inlining
Shared constantssrc/*.tsGlobal aliases, regular expressions, directive names, the effect CSS injected into the page

tsc concatenates every file into one script, src/QuickUI.debug.js, through the outFile setting in tsconfig.json; there are no module imports. Public names are attached to the global object as window.QUI, window._ and window.$.

Cross-cutting Principles


PrincipleImplementation
Zero dependenciesOnly native browser APIs (Proxy, fetch, IntersectionObserver, requestAnimationFrame)
The template is the DOMTemplates are plain HTML on the page with no compile step; every render rebuilds the vDOM from a copy of the original template
Data snapshotsEach render takes a snapshot with JSON.parse(JSON.stringify(data)), so functions, Date objects and undefined never reach the template
Batched writesPatches are always applied inside requestAnimationFrame

Relation to Similar Libraries


LibraryIts stated positioningHow QuickUI relates
htmxGives HTML access to AJAX, CSS Transitions, WebSockets and Server Sent Events through attributesBoth load from one script tag and are driven by HTML attributes; htmx swaps in HTML returned by the server, while QuickUI renders on the client from a JavaScript data object
Vue.jsThe Progressive JavaScript FrameworkQuickUI's attribute style (:if, :for, :model, @click) reads much like Vue templates; QuickUI has no component system and uses the page's own HTML as the single template
PreactFast 3kB alternative to React with components and a virtual DOMBoth diff a virtual DOM; Preact describes UI as components, while QuickUI builds its virtual DOM from plain HTML and aligns children by index without keys
Alpine.jsA rugged, minimal framework for composing behavior directly in your markupBoth put behavior in markup and need no build step; QuickUI applies updates through a virtual DOM diff and ships runtime i18n, image lazy loading and SVG inlining

Further Reading


中文