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

@antender/thisisfine

v1.0.0

Published

Microframework for microfrontends, glues superfine, htm and classcat together

Downloads

1

Readme

Thisisfine

Thisisfine is an attempt to make simple to use microfrontend JS framework that can be used without the need to build anything. Just serve thisisfine.dist.js from node_modules/thisisfine as a type=module ES module thing and you are good to go! This bundle is superfine + classcat + htm glued together by a small 50 LOC module with super simple API inspired by MithrilJS and without the whole hyperapp effect/subscription complexity.

Basic usage:

Sample app is available here: https://github.com/Antender/thisisfine-sample

  1. ln node_modules/thisisfine.dist.js thisisfine.js

  2. Then import thisisfine like this import {thisisfine, h} from './thisisfine.js'; in your index.js

  3. Create an "app" that will redraw selected DOM node: const app = thisisfine(document.getElementById('app'))

  4. Create aliases to redraw and autoredraw functions (optional):

const redraw = app.redraw
const ar = app.autoredraw
  1. Use redraw when you update your data layer or use autoredraw to decorate your state objects and redraw on field change:
let counters = [ar({value: 0}), ar({value: 0})] // Counters will autoredraw on value change
  1. Build some views using included JSX (htm) syntax, they must be pure functions a-la React (Elm, Mithril) stateless components. Pass state from root component to child ones using "prop drilling":
const Counter = (state) => h`
	<div class="horizontal-box spacing">
		<input type="text" value="${state.value}" class=spacing></input>
		<div class=pure-button-group>
			<button onclick=${() => state.value+=1} class=${['pure-button', 'spacing']}>Up</button>
			<button onclick=${() => state.value-=1} class=${['pure-button', 'spacing']}>Down</button>
		</div>
	</div>
`

const App = () => h`
	<main id="app">
		${counters.map((counter) => Counter(counter))}
		<button onclick=${() => {counters.push(ar({value: 0})); redraw()}} class=spacing style="margin-left: 10px;">Add counter</button>
	</main>
`
  1. Mount your app:
app.mount(App)
  1. ????!!!!!

  2. PROFIT!!!!

Things worth mentioning

  1. Multiple "apps" can exist independently on a single page. So if you should split your site into multiple independendent views that communicate using data layer if your experience speed or maintenance problems instead of doing React-like microoptimizations in a monolitic SPA app.

  2. Routing should be handled server-side

  3. You should structure your project using classic HTML/CSS/JS separation. Don't be shy to just use static HTML instead of thisisfine where it is appropriate.

  4. JSX is parsed at runtime in browser and cached, more info about syntax here: htm

  5. This framework assumes that some modern browser goodies like ES modules, Proxy and fetch are available

  6. Class attribute in JSX supports classcat optional class objects

API

h(jsx)

h function is supposed to be used using ES string template syntax h`<main class=${ ['main'] }>Hello, world!</main>` and produces superfine VDOM nodes.

app(ref) -> appinstance

app binds thisisfine to provided DOM node (acquired using getElementById, getElementsByTagName, document.body etc...)

appinstance.redraw()

signals to redraw this appinstance, redraws are throttled to RequestAnimationFrame

appinstance.autoredraw(object)

makes object properties redraw this app when updated