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

@rackai/domql

v1.2.10

Published

DOM rendering Javascript framework at early stage.

Downloads

46

Readme

DOMQL

DOM rendering Javascript framework.

  • Minimalistic
  • No dependencies
  • Extendable
  • No transpilations, simple ES6 code
  • One-time import and subtrees

You can start with starter-kit as a boilerplate, or jump into the live editor playground.

npm version Build Status Coverage Status

Key features:

  • [x] error reporting
  • [x] virtual DOM tree
  • [x] create
    • [x] create using prototype class
    • [x] support multiple level prototypes
    • [x] DOM caching
  • [x] state
  • [x] binding
    • [x] with other component
    • [x] with state
  • [x] update
    • [x] set (recreate)
    • [x] only iterate with diff
  • [x] events
    • [x] event handling
    • [ ] bubbling and propogation
  • [ ] run changes inside animationFrame

Getting started

To install all dependencies and run dev server, run:

yarn && yarn start

Examples

Initialization:

import DOM from '@rackai/domql'

DOM.create({ text: 'Rendered' })

Attributes:

var link = {
  tag: 'a',
  class: 'menu link',
  attr: {
    href: '#'
  }
}
var img = {
  tag: 'img',
  class: 'avatar',
  attr: {
    src: '...'
  }
}

Reusing:

var Link = {
  tag: 'a'
}

var ListItem = {
  proto: Link,
  class: 'ui link',
  attr: {
    href: '#'
  }
}

var menu = {
  childProto: ListItem,
  home: 'Home',
  text: 'About'
}

var header = {
  logo: {},
  menu
}

Array Support:

var navItems = ['Home', 'About', 'FAQ', 'Contact']

var menu = {
  proto: ListItem,
  ...navItems
}

Update:

var val = {
  text: 0
}

var Increment = {
  tag: 'button',
  text: 'Increment',
  on: {
    click: (e) => {
      val.update({ text: val.text++ })
    }
  }
}

API

Properties

| Property | Type | Description | Default | | --- | --- | --- | --- | | key | Number String | Defines the key of the Element | The key of the object, or randomly generated name | | proto | Object Array | Clones the other element | undefined | | childProto | Object Array | Specifies the proto for all child elements | undefined | | tag | String | Specifis the HTML tag | div or related HTML tag if the key matches | | class | Any | Specifies the HTML class | undefined | | attr | Object | Specifies the set of HTML attributes | {} | | text | Any | Text inside the element | undefined | | content | Object Array | Fragment wrapper to use dynamic content loading | undefined

To specify your own property per Element, set the function inside define property like:

var User = {
  define: {
    username: param => param.toUpperCase()
  },
  text: element => element.username
}

var Contact = {
  proto: User,
  username: 'nikoloza'
}

Methods

| Method | Description | Params | | --- | --- | --- | | update | Updates element by passed object | properties: Object Array | | set | Sets passed element in the content property | element: Object Array |

Events

All native DOM events are supported and can be specified inside on parameter. Additionally, init and render can be also invoked. All events except these two receive event object as a first parameter, following the element object itself.

Reserved keywords

key
tag
node
proto
on
class
text
data
style
attr
update
set
define

Anything except these keywords will create a new nested child element. The easier method to specify HTML tag is to use related nodeName as a key, for example:

var layout = { // this will be <div>
  header: {}, // will create <header>
  aside: {}, // will create <aside>
  main: { // will create <main>
    childProto: {
      article: { // will create <article>
        title: {}, // will create <div>
        description: {}, // will create <div>
        _rating: {} // will create <div class="rating">
      }
    }
  },
  footer: {} //  will create <footer>
}

Credits

Inspired by brisky