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

@smartrocket/smart-rocket-unit

v1.4.8

Published

SmartRocket test case transformer and API client

Readme

@smartrocket/smart-rocket-unit

SmartRocket 嵌入式软件测试工具的核心公共库,提供测试用例数据转换和 HTTP API 客户端。

安装

npm install @smartrocket/smart-rocket-unit

主要功能

1. 测试用例转换器 (TestCaseTransformer)

将原始测试用例数据转换为结构化的树形输出,用于 SmartRocket 测试界面渲染。

import { TestCaseTransformer } from '@smartrocket/smart-rocket-unit';

const transformer = new TestCaseTransformer();

transformer.setVariablesData({
  variables: { /* 函数变量元数据 */ },
  stubs:   { /* 桩函数数据 */ },
});

transformer.setTypeSystemData({
  /* 类型系统定义 */
});

// 执行转换
transformer.run({
  /* TestCaseData */
});

IntegrationTestCaseTransformer 继承自 TestCaseTransformer,支持多文件集成测试场景。

2. HTTP API 客户端 (SmartRocketClient)

封装了 SmartRocket 后端服务的 HTTP 请求。

import { SmartRocketClient } from '@smartrocket/smart-rocket-unit';

const client = new SmartRocketClient({
  accessToken: 'your-token',
});

// 用户服务
await client.user.loginByPassword();
await client.user.getMyInfo();

// 测试人员服务
await client.tester.projects.getProjects();
await client.tester.functions.getFunctions({ projectId: 'xxx' });
await client.tester.tests.getTestsByFunction({ functionId: 'xxx' });

// 管理员服务
await client.administrator.users.getUsers();

服务层级结构:

SmartRocketClient
├── user: UserService
│     ├── loginByPassword()
│     ├── getMyInfo()
│     ├── edit()
│     └── changePassword()
├── tester: TesterService
│     ├── projects: ProjectsService
│     ├── functions: FunctionsService
│     └── tests: TestsService
└── administrator: AdministratorService
      └── users: UsersService

3. 枚举常量

import {
  VARIABLE_KIND,
  VARIABLE_TYPE,
  VARIABLE_SCOPE_KIND,
  STUB_KIND,
} from '@smartrocket/smart-rocket-unit';

| 枚举 | 值 | 说明 | |---|---|---| | VARIABLE_KIND.field | 0 | 字段(未使用) | | VARIABLE_KIND.global | 1 | 全局变量 | | VARIABLE_KIND.param | 2 | 形参 | | VARIABLE_KIND.mallocVariable | 3 | 指针目标 | | VARIABLE_KIND.return | 4 | 返回值 | | VARIABLE_KIND.stub | 10 | 桩函数 | | VARIABLE_TYPE.basic | 1 | 基本类型 | | VARIABLE_TYPE.pointer | 2 | 指针类型 | | VARIABLE_TYPE.array | 3 | 数组类型 | | VARIABLE_TYPE.record | 4 | 结构体类型 | | VARIABLE_TYPE.functionPointer | 5 | 函数指针 | | VARIABLE_TYPE.enumeration | 6 | 枚举类型 | | VARIABLE_SCOPE_KIND.input | 1 | 输入 | | VARIABLE_SCOPE_KIND.output | 2 | 输出 | | STUB_KIND.value | 1 | 赋值打桩 | | STUB_KIND.code | 2 | 代码打桩 |

开发

# 安装依赖(在仓库根目录)
pnpm install

# 构建
pnpm --filter @smartrocket/smart-rocket-unit build

# 发布
npm publish --registry https://registry.npmjs.org --access public

调试

生产环境代码经过压缩混淆,客户现场报错时无法直接定位源码。使用内置的 decode-stack 工具可将堆栈位置还原。

# 单个位置
node scripts/decode-stack.mjs --pretty dist/sru.esm.js.map 1:2345
# → ✓ 1:2345 → ../src/interface/common.ts:45:2

# 批量还原(客户提供的多个报错位置)
node scripts/decode-stack.mjs --pretty dist/sru.esm.js.map 1:2345 1:1000 1:5000
# → ✓ 1:2345 → ../src/interface/common.ts:45:2
# → ✓ 1:1000 → ../src/utility.ts:149:18
# → ✓ 1:5000 → ../src/test-case-transformer.ts:235:38

# 纯文本输出(适合脚本管道)
node scripts/decode-stack.mjs dist/sru.esm.js.map "1:2345"
# → ../src/interface/common.ts:45:2

工作流:

客户报错: sru.esm.js:1:5000
          ↓
node scripts/decode-stack.mjs --pretty dist/sru.esm.js.map 1:5000
          ↓
test-case-transformer.ts:235:38  ← 直接点击跳转

注意.map 文件仅在发布包和内部开发环境中保留,客户部署时不包含 .map 文件。

技术栈

  • 打包: Rolldown (Rust-based, Rollup-compatible)
  • 语言: TypeScript (target: esnext)
  • 运行时依赖: axios, jshashes (SHA256)

License

ISC