Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aiot-toolkit/emulator

Package Overview
Dependencies
Maintainers
0
Versions
59
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.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
182
increased by225%
Maintainers
0
Weekly downloads
 
Created
Source

emulator

Vela 模拟器 SDK

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

目录结构

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

安装

npm install @aiot/emulator

使用

创建 VVD

import os from 'os'
import path from 'path'
import { IAvdArchType, VelaAvdCls, VelaImageType } from '@aiot/emulator'

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

/** 创建一个 466 × 466 带 miwear 的模拟器 */
export async function createVVd() {
  velaAvdCls.createVvd({
    avdName: 'test',
    avdArch: IAvdArchType.arm64,
    avdHeight: '466',
    avdWidth: '466',
    imageType: VelaImageType.REL
  })
}

启动 VVD

import os from 'os'
import path from 'path'
import { IAvdArchType, VelaAvdCls, VelaImageType } from '../src'

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

export async function startVvd(vvdName: string) {
  velaAvdCls.startVvd({
    avdName: vvdName
  })
}

初始化环境

import os from 'os'
import path from 'path'
import { VelaAvdCls } from '@aiot/emulator'

async function main() {
  const sdkHome = path.resolve(os.homedir(), '.export_dev')
  const velaAvdCls = new VelaAvdCls({ 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()

完整示例

// 安装 npm install @aiot/emulator
import { IAvdArchType, VelaAvdCls, VelaImageType } from '@aiot/emulator'

const velaAvdCls = new VelaAvdCls({})

/** 创建一个 466 × 466 带 miwear 的模拟器 */
velaAvdCls.createVvd({
  avdName: 'O62',
  avdArch: IAvdArchType.arm64,
  avdHeight: '466',
  avdWidth: '466',
  imageType: VelaImageType.REL
})

/** 启动名为 'O62' 的模拟器 */
velaAvdCls.startVvd({
  avdName: '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

FAQs

Package last updated on 17 Dec 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc