v2.0.3

Architecture

Last updated


Module-level layout of RenderJS: a single data.ts constants module underpins both the RJS template engine and the native prototype extensions, with a separate IntersectionObserver-based listener layer for lazyload/SVG.

Overview


graph TB
    A[HTML Template / DOM Node] --> B[RJS Core]
    B --> C[Directive Parser]
    C --> D[Rendered DOM]
    E[Prototype Extensions] -.chainable methods.-> D
    F[Lazyload / SVG Listener] -.IntersectionObserver.-> D
    G[data.ts constants and utilities] --> B
    G --> E
  1. graph TB
  2. A[HTML Template / DOM Node] --> B[RJS Core]
  3. B --> C[Directive Parser]
  4. C --> D[Rendered DOM]
  5. E[Prototype Extensions] -.chainable methods.-> D
  6. F[Lazyload / SVG Listener] -.IntersectionObserver.-> D
  7. G[data.ts constants and utilities] --> B
  8. G --> E

Layers


LayerLocationResponsibility
Constants & utilitiessrc/data.tsMinified property-name aliases ($GET, $ADD, $IS, ...), shared regexes (REGEX_TEXT, REGEX_FOR_VAL0, ...), and globals like requestMap/userHistory used across every other module
RJS coresrc/model/RJS.tsThe RJS class: instance lifecycle (constructor, renew, #init) and the directive-parsing pipeline (#SET_DOM and its #FIT_*/#setIf/#setPath helpers)
Prototype extensionssrc/prototype/*.ts (+ src/interface/*.ts for typings)Each file extends one native constructor's .prototype directly on module load — String, Element, Array, Object, URL, window, Date, Number, Map, Image, HTMLElement, File, HTMLVideoElement, HTMLFormElement, HTMLLinkElement, FormData, DocumentFragment
Listener subsystemsrc/listener/*.ts, src/function/listener.tsGlobal IntersectionObserver instances for image lazyload and SVG inlining, entered through window._Listener(...)
Support functionssrc/function/*.tsgetCamelString (kebab-to-camel for CSS property lookups), printLog/printCopyright (console banner)
Bundle entrysrc/RenderJS.jsCompiled/concatenated output of the above, minified into dist/RenderJS.js via terser (npm run minify)

Cross-Cutting Notes


  • Load-order coupling: prototype files run (_this => { ... })($Type[_prototype]) as an IIFE at import time — there is no explicit init call, so import order in src/RenderJS.js determines which extensions exist when RJS.ts first runs.
  • No virtual DOM: the directive parser (RJS.ts) mutates real DOM nodes in place; re-render is only triggered by an explicit renew() call, never automatically.
  • Property-name obfuscation: data.ts defines every DOM/JS property name used elsewhere as a const _xxx = "xxx" (and further composes them, e.g. _appendChild = "append" + _Child). This is a minification strategy, not a runtime abstraction — treat _ary[_push](x) as ary.push(x) when reading source.

For directive-pipeline detail see Directive Parsing; for the full prototype method list see API Reference; for module-level sequence/state diagrams see the full architecture document.
中文