npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

librender

v0.1.1

Published

Experimental JavaScript UI rendering library. Render uses a lightweight stack-based VM with minimal opcodes to encode DOM trees and run DOM operations either immediately or in retained mode (by diffing and patching bytecodes). Components are defined as **

Downloads

20

Readme

render

Experimental JavaScript UI rendering library. Render uses a lightweight stack-based VM with minimal opcodes to encode DOM trees and run DOM operations either immediately or in retained mode (by diffing and patching bytecodes). Components are defined as views that serialize their attributes and children into Uint8Array instances.

Installation & usage

This section is incomplete.

Features

  • [ ] Views
    • [x] View - view instance serializer
    • [x] Text - static text view with title
    • [x] Button - static button with label
    • [x] Container - dynamic view with optional attributes (e.g. tag name)
  • [ ] Virtual machine DOM
    • [x] Create DOM nodes (OPCODE_CREATE_ELEMENT)
    • [x] Decode 8-bit entries with static offsets (UTF-16 character codes)
    • [x] Set DOM node attribute to least recent node (OPCODE_SET_ATTRIBUTE)
    • [x] Append least recent nodes as parent-child (OPCODE_APPEND_CHILD)
    • [x] Create DOM text node (OPCODE_TEXT_NODE)
    • [ ] Set innerHTML with in-memory string source
    • [x] Append adjacent DOM nodes as siblings (OPCODE_APPEND_SIBLING)
    • [ ] Diffing and patching arbitrary bytecodes
  • [x] Consistency in rendering with timed requestAnimationFrame
  • [x] Streaming instruction blocks to VM (createBytecodeStream, unsafe_streamBytecodeToVM)
  • [ ] Non-tracking reactive primitives in views
  • [ ] Precompiled bytecode from views (requires build tools)
  • [ ] Off the main thread view serialization (ThreadView)

Quick overview

Render relies on views to return byte arrays with exact alignment of data values and offsets. The VM does not fix program inputs which is why views form safe high-level wrappers representing extendable components. Aside, the default settings are supposed to be configurable.

Portability is the primary goal of this library. I wrote librender expecting that there could be a single optimizing bytecode IR for various web-based rendering libraries. To this effect, there is an imperative-procedural approach when defining view methods that correspond to raw bytecode.

Completeness of the virtual machine

The VM does not fully take the role of a DOM-based model and opcodes are only limited to DOM operations where inputs are serializable (e.g. event handlers are not serializable). It lacks features like pausability and resumability, async batch streaming, per-batch scheduling, and virtual prioritization, that could essentially improve rendering.

The structural description of the VM is:

  • The stack is reserved for holding references to handlers and raw strings
  • The memory applies to enabled shared memory (e.g. temporal view states) between VM instances
  • nodeCount is a counter that allows managing the nodeIndexStack in the DOM operations

Portability of the bytecode IR

WebAssembly modules are loaded as view slices into an array buffer representing a linear memory model. Since modules are precompiled, the bytecode could target librender with virtually no overhead. This would imply that optimizing the VM itself from the JavaScript source would improve existing programs without introducing layers of indirection.

With this enabled, various high-level libraries targeting the bytecode can be used as microfrontends with predictability. Currently, librender is barely useable so this will require major effort to put in place. Additionally, certain data structures can be linearly represented for uniformity, e.g. C-like structs with offsets require no deallocation in WebAssembly. Growing memory is as easy as incrementing a pointer.

Portability allows loading .bin files through a shared worker, which could be useful for monolithic SPAs that depend on server endpoints to fetch and render data in the main UI thread for client-side rendering.

Acknowledgements

Render does not provide unique insights into the approach rendering is done or criteria for commiting DOM nodes for painting. Other libraries such as React (scheduling model) and GlimmerVM (opcode-based rendering) are to be considered prior art in this regard.

License

Copyright © 2024 Elric Neumann. MIT License.