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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ssi-lib/loading

v1.0.3

Published

Screen loader ligero — eventos globales y marcador DOM

Readme

@ssi-lib/loading

Screen loader ligero para hosts React / Module Federation. Sin dependencias.

Escucha dos fuentes y muestra un overlay compartido:

  1. Evento app:ssi-loading con { active, message }
  2. Marcador DOM #mfe-loading (opcional, activo por defecto)

Instalación

npm install @ssi-lib/loading

1. Básico — mínimo para funcionar

En el <head> del index.html, antes de que React monte:

<script type="module">
  import { initSsiLoadingLib } from '@ssi-lib/loading';

  initSsiLoadingLib();
</script>

Desde cualquier parte de la app (con import):

import { loading } from '@ssi-lib/loading';

loading(true);   // muestra spinner
loading(false);  // oculta

2. Con mensaje

El mensaje admite HTML (innerHTML):

loading(true, '<p>Guardando pedido...</p>');
loading(false);

3. Sin importar la librería — evento en window

Útil en MFEs remotos o scripts que no tienen la dependencia:

window.dispatchEvent(
  new CustomEvent('app:ssi-loading', {
    detail: { active: true, message: '<p>Procesando...</p>' },
  }),
);

window.dispatchEvent(
  new CustomEvent('app:ssi-loading', {
    detail: { active: false },
  }),
);

4. Canal propio

<script type="module">
  import { initSsiLoadingLib, loading } from '@ssi-lib/loading';

  initSsiLoadingLib({ channel: 'vivabox' });
</script>

loading() emite en el canal activo:

vivabox  →  { active, message }

5. Sin observer de #mfe-loading

Solo eventos, sin MutationObserver:

initSsiLoadingLib({ observeMarker: false });

6. Diseño custom

HTML y CSS propios del cliente. Incluye #ssi-msg si quieres mostrar el message del evento:

<script type="module">
  import { initSsiLoadingLib } from '@ssi-lib/loading';

  initSsiLoadingLib({
    html: '<div class="my-ring"></div><div id="ssi-msg"></div>',
    css: `
      #ssi-loading { background: #0f172a; }
      .my-ring {
        width: 48px; height: 48px;
        border: 4px solid #fff3;
        border-top-color: #fff;
        border-radius: 50%;
        animation: spin .8s linear infinite;
      }
      @keyframes spin { to { transform: rotate(360deg); } }
    `,
  });
</script>

Sin html / css → spinner por defecto.


7. Completo — host con Module Federation

index.html

<head>
  <script type="module">
    import { initSsiLoadingLib } from '@ssi-lib/loading';

    initSsiLoadingLib();
  </script>
</head>

Carga de MFE (@ssi-lib/mf-loader)

LoadComponent inserta <div id="mfe-loading" /> mientras carga el remoto. La librería lo detecta y muestra el overlay automáticamente.

import { LoadComponent } from '@ssi-lib/mf-loader';

<LoadComponent
  lazyElement={{ mfe: 'commonsManagementMfe', component: 'PartyIndividualForm' }}
/>

Operación async en el host

import { loading } from '@ssi-lib/loading';

async function save() {
  loading(true, '<p>Guardando...</p>');
  try {
    await fetch('/api/save', { method: 'POST' });
  } finally {
    loading(false);
  }
}

Init con todas las opciones

initSsiLoadingLib({
  channel: 'app:ssi-loading',  // default
  observeMarker: true,         // default — escucha #mfe-loading
  html: '...',                 // opcional
  css: '...',                  // opcional
});

Comportamiento

El overlay se muestra si cualquiera de las dos fuentes está activa:

evento active: true  ──┐
                       ├── overlay ON
#mfe-loading existe  ──┘

evento active: false → apaga solo la fuente evento
quitar #mfe-loading  → apaga solo la fuente DOM

overlay OFF cuando ambas están inactivas

API

| Función | Descripción | |---------|-------------| | initSsiLoadingLib(opts?) | Conecta al canal y opcionalmente al observer | | destroySsiLoadingLib() | Quita listeners, observer y overlay | | loading(active, message?) | Emite el evento del canal activo |

InitOptions

| Campo | Default | Descripción | |-------|---------|-------------| | channel | app:ssi-loading | Nombre del evento en window | | observeMarker | true | Observar #mfe-loading en el DOM | | html | spinner built-in | HTML del overlay | | css | estilos built-in | CSS inyectado en <head> |


Build

npm run build
npm run dev