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

@trismegisto/primitives

v2.0.1

Published

Hermes — comportamento e lógica sem framework (foco, tema, i18n, geometria, classes).

Readme

@trismegisto/primitives

Comportamento e lógica do Hermes sem framework: stores de estado (tema, toast, abas, workspace, data grid, árvore, kanban…), teclado e foco, posicionamento de menus e popovers, datas, máscaras, atalhos e os catálogos de texto (pt-BR embutido, en/es à parte) com formatMessage/pluralMessage.

Na cadeia de camadas (tokens ← icons ← primitives ← core ← angular ← maps · charts · spine) é onde mora toda regra de comportamento. O @trismegisto/angular só liga inputs e outputs a estas funções; um wrapper para outro framework faria o mesmo.

Instalação

npm install @trismegisto/primitives @trismegisto/icons @trismegisto/tokens

@trismegisto/icons e @trismegisto/tokens são peerDependencies. Num app Angular, instale os cinco pacotes base juntos e na mesma versão (ver @trismegisto/angular).

Pontos de entrada

| Import | Conteúdo | | --- | --- | | @trismegisto/primitives | Tudo abaixo, mais a reexportação de @trismegisto/icons (registro e desenho de ícones) e de HERMES_FAMILIES/HermesFamily/HermesThemeName do @trismegisto/tokens | | @trismegisto/primitives/messages/en | HERMES_MESSAGES_EN | | @trismegisto/primitives/messages/es | HERMES_MESSAGES_ES |

Só o catálogo pt-BR (HERMES_MESSAGES_PT_BR) está na entrada principal. en e es ficam em entradas próprias para não pesarem no bundle de quem não usa; o @trismegisto/angular os baixa sob demanda no primeiro setLocale.

Quando usar direto

Num app Angular, quase nunca: use @trismegisto/angular, que já envolve estas funções em serviços, signals e componentes. O uso direto faz sentido para:

  • Funções utilitárias que o app chama em validadores ou formatação: applyMask, unmask, isMaskComplete (máscaras cpf/cnpj/cep/phone ou padrão), toIsoDate, formatDisplayDate, displayDatePattern, addDays, formatMessage, pluralMessage.
  • Overlay que o app move para o <body>: chame copyThemeScope(origem, nó) para o nó levar data-theme, data-family, data-density e data-font do contexto (sem isso ele volta ao tema padrão).
  • Wrapper para outro framework: os stores (createThemeStore, createToastStore, createShortcutRegistry, createWorkspaceStore…) e os montadores de classe CSS (buttonClass, iconButtonClass…) que geram as classes hm-* do @trismegisto/core.

Exemplo sem framework: tema

import { createThemeStore, themeHostProps, DEFAULT_THEME_CONFIG } from '@trismegisto/primitives';

const store = createThemeStore(
  { ...DEFAULT_THEME_CONFIG, storagePrefix: 'meuapp' },
  { storage: localStorage, prefersDark: () => matchMedia('(prefers-color-scheme: dark)').matches },
);

function apply(root: HTMLElement) {
  const { attributes, styles } = themeHostProps(store.getState());
  for (const [name, value] of Object.entries(attributes)) root.setAttribute(name, value);
  for (const [name, value] of Object.entries(styles)) root.style.setProperty(name, value);
}

apply(document.body);
store.subscribe(() => apply(document.body));
store.setMode('system'); // 'light' | 'dark' | 'system'
store.setDensity('compact');

themeHostProps devolve os atributos data-theme/data-family/data-density/data-font e as custom properties de cor da família. É exatamente o que a diretiva hermesTheme do Angular aplica. As escolhas ficam salvas no storage com o prefixo (<prefixo>_theme, <prefixo>_theme_family, <prefixo>_density…).

Exemplo: textos

import { HERMES_MESSAGES_PT_BR, formatMessage, pluralMessage } from '@trismegisto/primitives';

formatMessage('Remover {label}', { label: 'Arquivo.pdf' });
pluralMessage({ one: '{count} item', other: '{count} itens' }, 3, 'pt-BR');

Texto com variável é sempre template nomeado ({nome}) e contagem é PluralMessage com Intl.PluralRules: nunca prefixo + concatenação nem if (n === 1).

Mais

Desenvolvimento do pacote

npm test (Vitest) e npm run build (compila para dist/).