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

@weapp-vite/miniprogram-automator

v1.2.2

Published

完全兼容微信 miniprogram-automator 的现代化替代实现

Readme

@weapp-vite/miniprogram-automator

1. 简介

@weapp-vite/miniprogram-automator 是面向 weapp-vite 生态维护的 miniprogram-automator 兼容实现,目标是在保留官方心智模型的前提下,提供更现代的 ESM 导出、类型支持与 headless 调试能力。

它同时服务于:

  • weapp-ide-cli 的自动化能力
  • 仓库内小程序开发者工具相关 e2e 测试
  • 需要直接连接小程序开发者工具自动化协议的 Node 工具

2. 特性

  • 对齐官方常见对象模型:MiniProgramPageElementNative
  • 提供 Launcher 用于启动、连接和复用 DevTools 会话
  • 支持按平台选择自动化后端,默认微信,百度智能小程序提供轻量 TypeScript runtime
  • 支持截图、输入、滚动、点击、页面跳转等自动化操作
  • 默认输出现代 ESM 与完整类型声明
  • 内置二维码打印与解码辅助能力,便于配合登录、连接流程调试
  • 支持 headless 自动化启动入口

3. 安装

pnpm add -D @weapp-vite/miniprogram-automator

注意:运行前仍需要本机安装对应平台的开发者工具,并开启自动化所需服务能力。

4. 快速开始

4.1 连接现有会话

import { Launcher } from '@weapp-vite/miniprogram-automator'

const launcher = new Launcher()
const miniProgram = await launcher.connect({
  wsEndpoint: 'ws://127.0.0.1:9420',
})

const page = await miniProgram.currentPage()
console.log(await page.data())

4.2 启动并打开项目

import { Launcher } from '@weapp-vite/miniprogram-automator'

const launcher = new Launcher()
const miniProgram = await launcher.launch({
  platform: 'wechat',
  projectPath: './dist/build/mp-weixin',
})

await miniProgram.reLaunch('/pages/index/index')

4.3 启动百度智能小程序

import { Launcher } from '@weapp-vite/miniprogram-automator'

const launcher = new Launcher()
const smartProgram = await launcher.launch({
  platform: 'swan',
  cliPath: '/Applications/百度开发者工具.app/Contents/MacOS/cli',
  projectPath: './dist/build/mp-baidu',
})

await smartProgram.reLaunch('/pages/index/index')

platform: 'baidu' 也会按百度智能小程序处理。

如果需要使用百度智能小程序自动化的 runtime 能力,可以直接访问内置入口:

import { SmartappAutomator } from '@weapp-vite/miniprogram-automator'

const devices = await SmartappAutomator.devices?.('simulator')
const device = await SmartappAutomator.launch({
  deviceType: 'simulator',
  wsEndpoint: 'ws://127.0.0.1:9420',
})

await device.close()

4.4 使用页面与元素对象

import { Launcher } from '@weapp-vite/miniprogram-automator'

const launcher = new Launcher()
const miniProgram = await launcher.launch({
  platform: 'wechat',
  projectPath: './dist/build/mp-weixin',
})

const page = await miniProgram.currentPage()
const button = await page.$('.submit')

await button?.tap()
await page.waitFor(500)

5. 主要导出

| 导出 | 说明 | | ------------------------- | ---------------------------------------- | | Launcher | 启动 DevTools、连接 WebSocket、创建会话 | | MiniProgram | 小程序级操作入口,如页面跳转、获取当前页 | | Page | 页面级查询与操作入口 | | Element | 通用节点对象,支持点击、输入、事件触发 | | Native | 原生能力桥接 | | launchHeadlessAutomator | headless 启动辅助函数 |

6. 本地开发

pnpm --filter @weapp-vite/miniprogram-automator build
pnpm --filter @weapp-vite/miniprogram-automator test
pnpm --filter @weapp-vite/miniprogram-automator typecheck

7. 相关链接