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

jetstart

v0.3.3

Published

Small, simple, functional JavaScript library for building web interfaces

Downloads

41

Readme

jetstart

Small, simple, functional JavaScript library for building web interfaces.

Jetstart integrates lit-html, page.js, and statezero.

See the jetstart-boilerplate project to get started.

Getting Started

Install from npm.

npm install jetstart --save

Jetstart is packaged using the Universal Module Definition pattern, so it can be loaded in various environments:

Browser Global

<script src="./node_modules/jetstart/dist/jetstart.js"></script>
<script>
  const { action, router, view } = window.jetstart;
</script>

ES6 Module

import { action, router, view } from 'jetstart';

Node

const { action, router, view } = require('jetstart');

Concepts

Views

Views are invoked with a context argument, which can be destructured like so:

view(({ render, state }) => render`${state}`);

The context object contains all of the names exported by lit-html, including all of its directives, as well as a few Jetstart-specific properties:

| Name | Type | Description | | ---------- | -------- | ------------------------------------------------------------------------------------------------- | | html | Function | Wraps lit-html's html() to add support for Jetstart views | | render | Function | Views in jetstart typically return the result of calling render on a tagged template literal | | repeatView | Function | Like repeat, but called with a function that returns a view instead of a template | | state   | Object | The result of calling statezero's getState() function |

Views can also accept arbitrary parameters, such as the text parameter of the span view below:

import { renderView, view } from 'jetstart';

const span = view(({ render }, text) => render`<span>${text}</span>`);

const header = view(({ render }, left, right) => render`<h1>${span(left)} ${span(right)}</h1>`);

renderView(header('hello', 'world'), document.body);

See lit-html for more information.

State

Jetstart uses statezero to manage a single, global, immutable state graph. Changes to state can be applied by calling commit(newState), which causes all views to be (efficiently) re-rendered.

import { action, renderView, view } from 'jetstart';

const time = view(({ render, state }, placeholder) => render`<time>${state.time || placeholder}</time>`);

const updateTime = action(({ commit, state }) => {
  state.time = new Date();
  commit(state);
});

renderView(time('Loading...'), document.body);

setInterval(updateTime);

See statezero for more information.

Routing

import { router, view } from 'jetstart';

const foo = view(({ render }) => render`<h1>foo</h1><a href="/bar">bar</a>`);

const bar = view(({ render }) => render`<h1>bar</h1><a href="/foo">foo</a>`);

router(document.body, ['/', '/foo'], ['/foo', foo], ['/bar', bar]).start();

See page.js for more information.

Developing

npm install
npm run build