You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@aiot-toolkit/emulator

Package Overview
Dependencies
Maintainers
7
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aiot-toolkit/emulator

vela emulator tool.

2.0.5
latest
npmnpm
Version published
Weekly downloads
207
-29.59%
Maintainers
7
Weekly downloads
 
Created
Source

emulator

Vela 模拟器 SDK

模拟器的介绍可参考开发帮助文档里的「模拟器」章节

目录结构

目录描述
avd模拟器的AVD,配置统一放置$HOME/.vela/vvd 目录下
instance模拟器实例,不同的Vela镜像版本会使用不同的instance,通过findInstance确定
static创建AVD时需要用到的静态资源,常量配置文件
typing接口定义
utils工具函数

安装

npm install @aiot-toolkit/emulator

使用

初始化环境

import os from 'os'
import path from 'path'
import { VvdManager } from '@aiot-toolkit/emulator'

async function main() {
  const sdkHome = path.resolve(os.homedir(), '.export_dev')
  const velaAvdCls = new VvdManager({ sdkHome })

  const downloder = await velaAvdCls.downloadSDK({
    force: true,
    cliProgress: false,
    parallelDownloads: 6
  })

  downloder.on('progress', (progress) => {
    console.log(
      `progress: ${progress.formattedSpeed} ${progress.formattedPercentage} ${progress.formatTotal} ${progress.formatTimeLeft}`
    )
  })

  await downloder.downlodPromise

  console.log('download success')
}

main()

创建 VVD

import os from 'os'
import path from 'path'
import { IAvdArchType, VvdManager, VelaImageType, getDefaultImage } from '@aiot-toolkit/emulator'

const velaAvdCls = new VvdManager({
  sdkHome: path.resolve(os.homedir(), '.export_dev')
})

/** 创建一个 466 × 466 带 miwear 的模拟器 */
export async function createVVd() {
  const defaultImage = getDefaultImage()
  velaAvdCls.createVvd({
    name: avdName,
    imageType: defaultImage,
    arch: IVvdArchType.arm,
    imageDir: path.dirname(velaAvdCls.getLocalSystemPath(defaultImage)),
    width: '466',
    height: '466'
  })
}

启动 VVD

import os from 'os'
import path from 'path'
import { IAvdArchType, VvdManager, VelaImageType } from '@aiot-toolkit/emulator'

const velaAvdCls = new VvdManager({
  sdkHome: path.resolve(os.homedir(), '.export_dev')
})

export async function startVvd(vvdName: string) {
  /**
   * coldBoot:boolean 是否冷启动
   * emulatorInstance: EmulatorInstance 模拟器实例, 可以通过它与模拟器进行命令交互
   * getAgent: () => Promise<GrpcEmulator> 获取模拟器的Agent,可以通过它与模拟器进行屏幕交互
   */
  const { coldBoot, emulatorInstance, getAgent } = await velaAvdCls.startVvd({
    vvdName
  })

  // 启动应用
  emulatorInstance.startApp('com.xiaomi.mipicks')

  const velaAgent = await getAgent()
  // 获取模拟器截图
  const imgBuffer = await velaAgent.getScreenshot()
  // 点击模拟器指定位置,
  await velaAgent.sendMouse({
    x: 100,
    y: 100,
    // 按下
    buttons: 1
  })
  await velaAgent.sendMouse({
    x: 100,
    y: 100,
    // 松开
    buttons: 0
  })
}

完整示例

// 安装 npm install @aiot/emulator
import os from 'os'
import path from 'path'
import { IAvdArchType, VvdManager, VelaImageType } from '@aiot-toolkit/emulator'

const velaAvdCls = new VvdManager({
  sdkHome: path.resolve(os.homedir(), '.export_dev')
})

/** 创建一个 466 × 466 带 miwear 的模拟器 */
velaAvdCls.createVvd({
  name: 'O62',
  arch: IAvdArchType.arm64,
  height: '466',
  width: '466',
  imageType: VelaImageType.REL
})

/** 启动名为 'O62' 的模拟器 */
velaAvdCls.startVvd({
  vvdName: 'O62'
})

export async function startVvd(vvdName: string) {}

export async function createVVd() {}

async function main() {
  const downloder = await velaAvdCls.downloadSDK({
    force: true,
    cliProgress: false,
    parallelDownloads: 6
  })

  downloder.on('progress', (progress) => {
    console.log(
      `progress: ${progress.formattedSpeed} ${progress.formattedPercentage} ${progress.formatTotal} ${progress.formatTimeLeft}`
    )
  })

  await downloder.downlodPromise

  console.log('download success')
}

main()

Keywords

aiot

FAQs

Package last updated on 23 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.