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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dialute

v0.0.38

Published

A highly declarative framework for building SberSalute apps

Downloads

54

Readme

🧶 Dialute

The way you will want to create Chat and Canvas Apps for SberSalute. Use the power of generator based scripts and simple interface of the framework. Based on SmartApp API

⚙️ Install

The framework is published in NPM, thus you can simply install it into your existing

$: npm install dialute

The preferred way to initialize the project is to clone needed template and immediately start development.

$: git clone https://github.com/Dikower/dialute-starter-svelte
# or simply
$: npx degit dikower/dialute-starter-svelte

🚀 Startup

Dialute uses Express behind to handle requests from SmartMarket. Thanks to the framework, you can skip all boring and routine stuff about parsing request bodies and managing sessions of users and focus on logic and dialog creation using JavaScript Generators. If you are using example or template and familiar with ngrok, just run

# Shell №1
$: npm run dev

#-------------
# Shell №2
$: ngrok http 8000

💎 Concept

The generator represents a dialog. When a user sends a message it triggers the update of SberRequest object, that is passed to the generator as reference. That's why you can easily read the updated message from the same variable. On the other hand, yield will return the content, you pass to user, and then will wait until next message to continue executing script. The generator saves context inside, so it helps us to construct state dependent dialog using just plain JavaScript or TypeScript

  • Import the framework starter and SberRequest for type annotation

    import { Dialute, SberRequest } from 'dialute';
  • Write a generator, that describes the dialog. It must have one required argument: SberRequest and one optional argument Context, you can

      // You can use any name for generator you want
      // r: this is a ref for SberRequest, it will be updated after each user message
      // ctx: Optional argument for advanced techniques, you can skip it for now
      // function* script(r: SberRequest, ctx: any) {
      function* script(r: SberRequest) { // Also possible
        while (true) {
          // send the message to user 
          yield 'Hello world from Dialute!';
          // yield r.msg  // This will make echo-bot, that repeats user input
        }
      }
  • Set the entrypoint of dialog and start the server

    // Creates ready to start server from generator
    const d = Dialute.fromEntrypoint(script as GeneratorFunction);
    // Starts listening for requests from SmartMarket
    d.start();
  • Use nodemon in package.json scripts to enable hot reload

    "scripts": {
      "dev": "nodemon --exec npx ts-node src/index.ts",
    }
  • Run ngrok tunnel on port 8000. Paste https link into Webhook field in SmartApp settings.

    $: ngrok http 8000
  • The whole code can be found inside example directory

📋 Docs

https://dialute.vercel.app

🥰 Support

You can always click on the ⭐️ of the repo and donate. I will be very glad for any support

"Buy Me A Coffee"