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

siph

v0.0.6

Published

Yet another reactive framework based on Sinuous

Downloads

2

Readme

Yet another reactive framework based on Sinuous

Why?

There is no way to use reactive frameworks for websites because of bad performance (FID, TTI).

Thats why even github use jquery-like libs.

What?

This framework is in pre-alpha and was created to test partial hydration combined with jquery-like reactivity (thanks Sinuous).

Sinuous is fast, but doesnt have modern features like loops, if statements, components (single file components) and... Partial hydration.

Partial hydration is hydration that works only with dynamic and statefull parts of application. It helps to use component and reactive paradigm for website development (not applications and SPA).

How?

  • Partial hydration. hydrate only dynamic parts of components
  • Single file components. webpack loader and compiler (code transpiler) + component system
  • Automagic reactivity. define a reactive variable and all methods/props that use that variable become reactive

Benefits

  • Small. hello world at 7.1kB gzip.
  • Fast. Thanks Sinuous and partial hydration.
  • Truly reactive. automatically derived from the app state.
  • Tips & Tricks. Slots, Loops, Statements and Props as we get used to

Performance

It was dirty check, but +- in similar conditions.

Index page with 10k static components:

<template>
  <div>
    <sbutton v-for="(item, key) in items" :key="key">
      Button {{ item }}
    </sbutton>
  </div>
</template>

sButton:

<template>
  <div class="button">
    <slot />
  </div>
</template>

Metric | SinuousCC | SinuousCC (Fn) | Sinuous | NuxtJS | NuxtJS (Fn) ------- | --------- | --------------------- | ------- | ------ | -------------------------------- Render | 1018ms | 865ms | 297ms (single obj) | 3743ms | 1825ms Hydration | 85ms | 68ms | 5000ms+ | 455ms | 238ms Hydration (with onclick) | 165ms | 117ms | - | 707ms | 390ms Hydration (x1000 dynamic) | 75ms | - | - | 185ms | - Full page size | 43kb | 39kb | 60kb | 169kb | 169kb

That framework is faster then Vue + NuxtJS in:

  1. Full static: x3.5
  2. Static with event: x3
  3. Dynamic: x2.5
  4. Page size: x4

Features

  • [x] Single file components
  • [x] Statements (v-if, v-else-if, v-else)
  • [x] Slots
  • [x] Loops
  • [x] Functional components (automatic)
  • [x] Attributes inheritence to component
  • [x] Props (Can be used as Init data for component)
  • [ ] Component lazy load
  • [ ] Dynamic component
  • [ ] Server side render
  • [ ] Server side data fetching (once)

When Statements, slots, loops and props will be ready i gonna make full page perfromance to understand how Partial hydration works.

Bugs

  • Slots need to be fixed for render function in statement and loops (on refactor step)
  • Component children register is broken (because of loops, need to be fixed)
  • Disallow to use multiple nodes in loops, statements (so everywehere for now)

Problem of multiple nodes Its hard to understand which nodes should be hydrated because there is no tree before hydration/render. On render step its not necessary because of H function. But on hydration step there is no way to understand how many nodes should be replaced with new value.

Component example

<template>
  <div v-if="testProp" v-for="(item) in [1, 2, 3]" @click="reactive_click">
    test {{ visible }} - {{ item }}
  </div>
</template>

<script>
import { d } from 'import-some-thing'

/**
 * Reactive (stateful) data defines with $
 */
let $visible = d;
let $clicks2 = {
  a: 2
};
/**
 * Normal data defines as usual variable
 */
let clicks = 1;
let testProp = false;

/**
 * Will become computed prop
 */
let computed = () {
  let k = [];
  
  for(let d in [1,2,3]) {
    k.push(visible);
  }

  return visible * 2 * 5;
}

/**
 * Usual methods
 */
function click(event) {
  clicks++;
  alert(this._data.clicks + `test ${ computed }`)
}

function reactive_click(event2) {
  // Work with reactive as with usual variable
  visible = visible + 1;
}
</script>

Render

import Sinuous from '@sinuous/i';
import render from '@sinuous/render';
import TestComponent from 'components/test';
import TestPage from 'page/test';

Sinuous.registerComponent(TestComponent);

render(TestPage, document.getElementById('layout'));

Hydration

import Sinuous from '@sinuous/i';
import hydration from '@sinuous/hydration';
import TestComponent from 'components/test';
import TestPage from 'page/test';

Sinuous.registerComponent(TestComponent);

hydration(TestPage, document.getElementById('layout'));

Partial Hydration

All components have 2 functions that create on component compilation step (webpack-loader):

  1. Render
  2. Hydration

Thats why on Server side (like NuxtJS) components should be imported with ?ssrOnly and on client side with ?runtimeOnly You can use ?ssrOnly and ?runtimeOnlyparams to minify build code.

Server side

import TestComponent from 'components/test?ssrOnly';
import TestPage from 'page/test?ssrOnly';

Client side

import TestComponent from 'components/test?runtimeOnly';
import TestPage from 'page/test?runtimeOnly';

Webpack

Use @sinuous/loader to compile SFC. Use parseName to make component autonaming

{
  test: /\.sin/,
  use: [
      {
    loader: '@sinuous/loader',
    options: {
      parseName(file) {
        file = camelize(file);
        let rootPath = camelize(path.resolve(__dirname, '../'));

          let componentPath = file
            .split(rootPath)
            .join('')
            .replace(/\.sin/i, '')
            .replace(/Components/, '')
            .replace(/(\s|\/)/g, '');

          return componentPath;
        }
      }
      }
  ]
},