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

@slidejs/dsl

v0.1.8

Published

Slide DSL 语法解析器和编译器

Downloads

250

Readme

@slidejs/dsl

Slide DSL 语法解析器和编译器。

特性

  • 基于 Peggy 的语法解析器
  • 类型安全的 AST 定义
  • 支持表达式计算和 for 循环
  • 完整的错误处理

使用示例

解析 DSL

import { parseSlideDSL } from '@slidejs/dsl';

const source = `
present quiz "my-quiz" {
  rules {
    rule start "intro" {
      slide {
        content text {
          "Welcome to the quiz!"
        }
        behavior {
          transition zoom {
            duration: 500
          }
        }
      }
    }

    rule content "questions" {
      for section in quiz.sections {
        for question in section.questions {
          slide {
            content dynamic {
              name: "wsx-quiz-question"
              attrs {
                title: section.title
                question: question.text
              }
            }
          }
        }
      }
    }

    rule end "thanks" {
      slide {
        content text {
          "Thank you!"
        }
      }
    }
  }
}
`;

const ast = await parseSlideDSL(source);
console.log(ast);

编译为可执行的 SlideDSL

import { compile } from '@slidejs/dsl';
import { SlideEngine } from '@slidejs/core';
import { quizToSlideContext } from '@slidejs/dsl';

// 解析 DSL
const ast = await parseSlideDSL(source);

// 编译为 SlideDSL 对象
const slideDSL = compile(ast);

// 创建 Context
const context = quizToSlideContext(quizDSL);

// 生成 Slides
const engine = new SlideEngine(slideDSL);
const slides = engine.generate(context);

语法参考

Presentation

present <type> "<name>" {
  rules {
    // 规则定义
  }
}

Rules

rule start "<name>" {
  // slides
}

rule content "<name>" {
  // for 循环或 slides
}

rule end "<name>" {
  // slides
}

Slide

slide {
  content <type> {
    // 内容
  }
  behavior {
    // 行为
  }
}

Content

// 动态内容(组件)
content dynamic {
  name: "<component-name>"
  attrs {
    key: value
  }
}

// 静态文本
content text {
  "line 1"
  "line 2"
}

Behavior

behavior {
  transition <type> {
    option: value
  }
}

For Loop

for item in collection {
  // slides
}

// 嵌套 for 循环
for outer in collection1 {
  for inner in outer.collection2 {
    // slides
  }
}

开发

生成 Parser

pnpm generate:parser

构建

pnpm build

测试

pnpm test

License

MIT