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

udomsay

v0.4.19

Published

A stricter, signals driven, ESX based library

Downloads

2,780

Readme

udomsay

EXPERIMENTAL Social Media Image from Know Your Meme

A stricter, signals driven, ESX based library.

What

This library includes, in about 2.2Kb, logic to parse a specialized form of JSX, or its template literal based variant, and use signals from various authors, handling rendering automatically and avoiding side effects when used as SSR.

How

Given the following counter.jsx file:

// grab signals from various libaries, here the simplest I know
import {Signal, signal, effect} from 'https://unpkg.com/@webreflection/signal';

// import the `createRender` utility
import createRender from 'https://unpkg.com/udomsay';
const render = createRender({Signal, effect});

// Counter Cmponent example
function Counter({clicks}) {
  return (
    <div>
      <button onclick={() => { clicks.value--; }}>-</button>
      <span>{clicks}</span>
      <button onclick={() => { clicks.value++; }}>+</button>
    </div>
  );
}

render(
  <Counter clicks={signal(0)} />,
  document.body
);

Providing the following babel.config.json transformer:

{
  "plugins": [
    ["@ungap/babel-plugin-transform-esx"]
  ]
}

The result can be tested in CodePen.io.

Custom Signals Library

Bringing in your favorite signals libraries is almost a no brainer with udomsay: check the fews already tested within this project!

Current udomsay ESX Interpolations Rules

Following the current set of stricter rules around JSX usage and how to avoid/prevent issues:

  • if an interpolation contains a primitive value (e.g. a string, a number, a boolean or undefined) or a signal which value is primitive, every future update of such interpolation will expect a primitive value or signal carrying a primitive value. Conditional primitives values or signals are fine, but {condition ? "string" : <Component />} is not supported.
  • if a signal is used as interpolation and its value is primitive, an effect is used to update its value on the target text node only if the signal changes or its value did. This allows to fine-tune and confine updates per each component or even regular element node, without needing to re-trigger the outer component logic.
  • if a signal is used as interpolation and its value is not primitive, every future update of such interpolation will expect a signal. Conditional signals are fine, but {condition ? signal : (<Component /> || "string")} is not supported.
  • if an interpolation contains an array of items, every future update of such interpolation will expect an array. Conditional arrays are fine, but {condition ? [..items] : (<Component /> || "string")} is not supported.

Library Goals

The goal of this library is:

  • explore if a better instrumented JSX can actually help performance and memory consumption
  • avoid the need of vDOM, still diffing when necessary through arrays in interpolations
  • create once and map on the fly (JIT) templates for both nodes, fragments, and components
  • fine-tune operations per each interpolation, such as spread properties VS known static properties, conditional holes or signals and, last but not least, arrays of items