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

@eduzz-automacoes/webchat-widget

v0.4.0

Published

Eduzz Webchat library for React/npm and CDN integration

Readme

@eduzz-automacoes/webchat-widget

Biblioteca oficial do webchat da Eduzz para:

  • uso em apps React via npm
  • publicação de bundle standalone em CDN
  • integração com o backend/proxy do Service Hub

Uso via React

import { Webchat } from "@eduzz-automacoes/webchat-widget";
import "@eduzz-automacoes/webchat-widget/style.css";

export function Example() {
  return (
    <Webchat
      clientId="SEU_CLIENT_ID"
      userCredentials={{
        userId: "user_123",
        userToken: "token_gerado_no_backend",
      }}
      config={{
        botName: "Eduzzinho",
        brandColor: "#18181b",
        accentColor: "#f36f21",
        showWelcomeScreen: true,
      }}
    />
  );
}

Posição e afastamento da borda

A prop config.position ancora o widget em um canto (bottom-right — padrão — ou bottom-left). O afastamento da borda é controlado por offsetX (distância da borda lateral) e offsetY (distância da borda inferior). Ambos aceitam qualquer comprimento CSS e têm padrão "24px" — movem o FAB e o painel juntos, mantendo o alinhamento.

<Webchat
  clientId="SEU_CLIENT_ID"
  config={{
    position: "bottom-right",
    offsetX: "40px",
    offsetY: "40px",
  }}
/>

No modo CDN, os mesmos valores podem ser passados via EduzzWebchat.init({ offsetX, offsetY }) ou por data-attributes no script (data-offset-x="40px" / data-offset-y="40px").

No mobile o painel ocupa a tela inteira, então offsetX/offsetY não se aplicam nesse caso.

Sessão autenticada com auto-renovação

Em vez de injetar userCredentials estático, o produto pode fornecer getSession: o widget busca as credenciais no backend do próprio produto e renova o userToken automaticamente pouco antes de expirar. Os dois modos são mutuamente exclusivos — quando getSession é informado, userCredentials é ignorado.

import { Webchat } from "@eduzz-automacoes/webchat-widget";
import "@eduzz-automacoes/webchat-widget/style.css";

export function Example({ authId }: { authId: string }) {
  return (
    <Webchat
      clientId="SEU_CLIENT_ID"
      // chamado pelo widget; renove/recrie a sessão a partir do SEU backend
      getSession={async () => {
        const { userId, userToken, expiresAt } = await fetch(
          "/api/webchat/session",
          {
            method: "POST",
          },
        ).then((res) => res.json());

        return { userId, userToken, expiresAt }; // expiresAt: epoch em ms
      }}
      // recria a sessão quando este valor muda (ex.: troca de usuário autenticado)
      sessionKey={authId}
      // (opcional) observabilidade da sessão capturada — null quando ausente
      onSessionChange={(session) => console.log("webchat session", session)}
    />
  );
}

Se getSession rejeitar ou resolver sem userToken, o widget cai em modo anônimo.

Controle programático do painel

No modo React, a prop opcional onPanelApiChange entrega uma API imperativa para abrir/fechar o painel (e null quando o widget desmonta):

import { useRef } from "react";
import { Webchat } from "@eduzz-automacoes/webchat-widget";

export function Example() {
  const panelApiRef = useRef(null);

  return (
    <>
      <button onClick={() => panelApiRef.current?.open()}>
        Falar com suporte
      </button>
      <Webchat
        clientId="SEU_CLIENT_ID"
        onPanelApiChange={(panelApi) => {
          panelApiRef.current = panelApi;
        }}
      />
    </>
  );
}

A API tem open(), close(), toggle(), hide() e show()toggle() equivale ao clique no FAB. hide() oculta o widget inteiro (FAB + painel) via CSS preservando o estado (conversa, painel aberto/fechado); show() reexibe exatamente como estava.

No modo CDN (global window.EduzzWebchat), os mesmos métodos ficam disponíveis na API global:

EduzzWebchat.open(); // abre o painel (no-op se já aberto ou não montado)
EduzzWebchat.close(); // fecha o painel (no-op se já fechado ou não montado)
EduzzWebchat.toggle(); // alterna o painel
EduzzWebchat.hide(); // oculta o widget inteiro (FAB + painel), preservando o estado
EduzzWebchat.show(); // reexibe o widget como estava antes do hide()

Chamadas feitas antes do bundle carregar (via loader script.js) são enfileiradas e executadas quando o runtime fica pronto. Sem init() prévio, são no-op silencioso.

Publicação manual no npm

pnpm --filter @eduzz-automacoes/webchat-widget build
cd packages/webchat-widget
pnpm pack