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

@botfather/units-slack-block-kit

v0.2.1

Published

Convert Units DSL or AST into Slack Block Kit payloads.

Readme

@botfather/units-slack-block-kit

Convert Units DSL, Units AST, or a rendered Units tree into Slack Block Kit payloads.

Install

npm install @botfather/units @botfather/units-slack-block-kit

Usage

import { unitsToSlackBlockKit } from "@botfather/units-slack-block-kit";

const payload = unitsToSlackBlockKit(`
SlackMessage (channel:'C123', name:'Release request') {
  Section (blockId:'summary') {
    Strong { 'Release:' }
    ' ready for approval by '
    Mention (userId:'U012AB3CD')
  }
  Actions {
    Button (name:'Approve', actionId:'approve', style:'primary')
    Button (name:'Reject', actionId:'reject', style:'danger')
  }
}
`);

console.log(payload.blocks);

Use compileUnitsToSlackBlockKit when you want diagnostics:

import { compileUnitsToSlackBlockKit } from "@botfather/units-slack-block-kit";

const result = compileUnitsToSlackBlockKit(source, {
  scope: { approvers },
  strict: true,
});

console.log(result.payload);
console.log(result.warnings);

The adapter evaluates Units directives and expressions through createUnitsRenderer, so #if, #for, expression props, slots, and text interpolation are resolved before Slack serialization.

Supported Units Tags

Block tags:

  • SlackMessage, Message
  • Section, Markdown
  • Header, Heading
  • Context
  • Actions, Group
  • Divider, Separator
  • Image
  • Input
  • File, Video, RichText
  • Block, RawBlock, SlackBlock with type/slackType/payload

Element tags:

  • Button, WorkflowButton
  • Image
  • Overflow
  • DatePicker, TimePicker, DateTimePicker
  • PlainTextInput, EmailInput, UrlInput, NumberInput, RichTextInput
  • StaticSelect, ExternalSelect, UsersSelect, ConversationsSelect, ChannelsSelect
  • MultiStaticSelect, MultiExternalSelect, MultiUsersSelect, MultiConversationsSelect, MultiChannelsSelect
  • Checkboxes, RadioButtons
  • Element, RawElement, SlackElement with type/slackType/payload

Inline mrkdwn tags:

  • Strong, Emphasis, Strike
  • Code, Pre
  • Blockquote
  • Link
  • Mention, Channel, UserGroup, SpecialMention
  • Date
  • Emoji
  • Field, Label, Hint

Camel-case Slack props are converted to Slack snake-case fields where useful, for example blockId -> block_id, actionId -> action_id, src -> image_url, and alt -> alt_text.

LLM Structured Output

For model-generated messages, prefer schema-constrained structured output over free-form DSL. The emitter can only render valid input; it cannot make a model produce valid .ui syntax.

import {
  SLACK_UNITS_STRUCTURED_OUTPUT_SCHEMA,
  compileStructuredSlackToBlockKit,
} from "@botfather/units-slack-block-kit";

// Pass SLACK_UNITS_STRUCTURED_OUTPUT_SCHEMA to your model provider as the
// required JSON schema. Then validate and render the returned object.
const result = compileStructuredSlackToBlockKit(modelJson, {
  strict: true,
});

console.log(result.payload);

Structured output shape:

{
  "type": "SlackMessage",
  "channel": "C123",
  "text": "Release request",
  "blocks": [
    {
      "type": "Section",
      "blockId": "summary",
      "children": [
        { "type": "Strong", "text": "Release:" },
        " ready for approval by ",
        { "type": "Mention", "userId": "U012AB3CD" }
      ],
      "accessory": {
        "type": "Button",
        "name": "Open request",
        "actionId": "open",
        "href": "https://example.com/release"
      }
    }
  ]
}

Use validateStructuredSlack(modelJson) if you want validation without rendering. Keep compileUnitsToSlackBlockKit(source, { strict: true }) for human-authored DSL, migrations, tests, or fallback repair flows:

const { payload, warnings } = compileUnitsToSlackBlockKit(source, {
  strict: true,
});