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

delegua-wasm

v0.0.1

Published

Compilador Delégua para WebAssembly via WAT e wat2wasm, sem LLVM.

Downloads

94

Readme

delegua-wasm

Compilador Delégua para WebAssembly, sem LLVM. Utiliza o tradutor WAT da biblioteca @designliquido/delegua e o wat2wasm (WABT) para gerar binários .wasm portáteis.

Pipeline de compilação

arquivo.delegua → Lexador → AvaliadorSintatico → TradutorWebAssembly → arquivo.wat → wat2wasm → arquivo.wasm

Pré-requisitos

WABT (WebAssembly Binary Toolkit)

| Sistema | Comando de instalação | |----------|----------------------------------------| | Linux | apt install wabt | | macOS | brew install wabt | | npm | npm install -g wabt | | Windows | choco install wabt |

Ferramenta necessária no PATH:

| Ferramenta | Função | |-------------|-------------------------------------------| | wat2wasm | Compila o arquivo WAT gerado para .wasm |

Instalação

npm install -g delegua-wasm
# ou
yarn global add delegua-wasm

Uso (CLI)

npx delegua-wasm <arquivo.delegua> [opções]

Opções

| Opção | Descrição | |------------------------|-----------------------------------------------------------------| | -o <nome> | Nome do arquivo de saída (sem extensão). Padrão: nome do arquivo de entrada. | | --gerar-host | Gera um arquivo host .mjs para execução direta no Node.js. | | --manter-temporarios | Mantém o arquivo intermediário .wat após compilar. |

Exemplos

# Compilar para WebAssembly
npx delegua-wasm programa.delegua

# Compilar com nome de saída personalizado
npx delegua-wasm programa.delegua -o meu-programa

# Compilar e gerar host Node.js para execução imediata
npx delegua-wasm programa.delegua --gerar-host

# Inspecionar o WAT gerado sem remover os temporários
npx delegua-wasm programa.delegua --manter-temporarios

Executando o WASM gerado

Sem --gerar-host, use qualquer runtime Wasm:

wasmtime programa.wasm
wasmer programa.wasm

Com --gerar-host, use o Node.js diretamente:

node programa.mjs

Uso (API)

import { CompiladorWasm } from 'delegua-wasm';

const compilador = new CompiladorWasm();
const resultado = await compilador.compilar({
    arquivoEntrada: 'programa.delegua',
    nomeSaida: 'programa',        // opcional
    gerarHost: true,              // opcional, gera arquivo .mjs para Node.js
    manterTemporarios: false,     // opcional
});

if (resultado.sucesso) {
    console.log('WASM gerado em:', resultado.caminhoWasm);
    if (resultado.caminhoHost) {
        console.log('Host gerado em:', resultado.caminhoHost);
    }
} else {
    console.error('Erro:', resultado.erro);
}

OpcaoesCompilacao

| Campo | Tipo | Obrigatório | Descrição | |----------------------|-----------|-------------|----------------------------------------------------| | arquivoEntrada | string | Sim | Caminho para o arquivo .delegua. | | nomeSaida | string | Não | Nome do arquivo de saída (sem extensão). | | gerarHost | boolean | Não | Gera arquivo .mjs host para Node.js. | | manterTemporarios | boolean | Não | Preserva o arquivo .wat após compilar. |

ResultadoCompilacao

| Campo | Tipo | Descrição | |----------------|-----------|------------------------------------------------------| | sucesso | boolean | true se a compilação foi bem-sucedida. | | caminhoWasm | string | Caminho para o arquivo .wasm gerado. | | caminhoHost | string | Caminho para o arquivo .mjs host (se solicitado). | | erro | string | Mensagem de erro (se mal-sucedido). |

Desenvolvimento

# Instalar dependências
yarn install

# Compilar o pacote
yarn empacotar

# Executar testes
yarn testes-unitarios

# Executar direto via ts-node
yarn executar programa.delegua

Comparação com outros pacotes

| Aspecto | delegua-x64 | delegua-arm | delegua-risc-v | delegua-wasm | |-----------------------|-----------------------|-------------------------|---------------------------|--------------------------| | Tradutor | TradutorAssemblyX64 | TradutorAssemblyARM | TradutorAssemblyRISCV | TradutorWebAssembly | | Alvos | linux, windows | linux-arm, android | linux-riscv64, linux-riscv32 | Qualquer plataforma | | Montador/Compilador | nasm | *-as | *-as | wat2wasm | | Arquivo intermediário | .asm | .s | .s | .wat | | Saída | binário nativo | binário nativo | binário nativo | .wasm portátil |

Licença

MIT