# @dailymotion/vast-client 中文文档

规范地址：https://npmcn.com/package/%40dailymotion/vast-client/

版本：6\.5\.0
npm 元数据更新时间：2026-09-30T14:06:19.182Z
中文译文更新时间：2026-11-11T08:59:53.841Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40dailymotion/vast-client
原文对照：https://npmcn.com/package/%40dailymotion/vast-client/?lang=original
项目主页：https://github.com/dailymotion/vast-client-js#readme
源码仓库：https://github.com/dailymotion/vast-client-js

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.7 MB，201 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=12\.22\.1
- 运行依赖：1 个
- 首次发布：2021-09-21T13:18:32.413Z
- 最新版本发布：2026-09-30T14:06:18.993Z
- 近 30 天下载量：250287（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：18（近 12 个月 5 个）

## 中文简介

JavaScript VAST 客户端

## 安装

```sh
npm install @dailymotion/vast-client
```

也可以使用：`pnpm add @dailymotion/vast-client`、`yarn add @dailymotion/vast-client`、`bun add @dailymotion/vast-client`

## README

[![npm version](https://badgen.net/npm/v/@dailymotion/vast-client)](https://badgen.net/npm/v/@dailymotion/vast-client) [![downloads per week](https://badgen.net/npm/dw/@dailymotion/vast-client)](https://badgen.net/npm/dw/@dailymotion/vast-client) [![license](https://badgen.net/npm/license/@dailymotion/vast-client)](https://badgen.net/npm/license/@dailymotion/vast-client)

# VAST 客户JS

Vast Client JS是一个JavaScript 库,用来获取和解析数字视频AdService模板(VAST)文档.

该图书馆提供三个组成部分:

-   A 类 **VAST 客户端** 以获取和剖析 VAST XML 资源到 JavaScript Objects.
-   A 类 **VAST 解析器** 直接解析 VAST XML.
-   A 类 **VAST 跟踪器** 以批量和调用跟踪 URL.

API的完整文档都去 [这里](https://npmcn.com/package/%40dailymotion/vast-client/#readme-api)。 。 。 . 全班的参赛名单 [这里](https://github.com/dailymotion/vast-client-js/blob/master/docs/api/class-reference.md)

要探索如何在网络应用程序中执行 VAST 客户端的实用实例, 请访问此 [链接](https://githubbox.com/dailymotion/vast-client-js/tree/master/examples/web)此外,使用这个 [链接](https://githubbox.com/dailymotion/vast-client-js/tree/master/examples/node) 以学习如何在基本节点应用程序中使用 VAST 客户端.

遵守 [VAST 4.3 规格](https://iabtechlab.com/wp-content/uploads/2022/09/VAST_4.3.pdf) 规定 [互动广告局(IAB)](https://www.iab.com/)。 。 。 .

## 开始

VAST客户JS作为国家防范机制软件包可供使用,并易于安装:

```Bash
npm i @dailymotion/vast-client
```

然后导入所需的组件 .

### VAST 客户端

如果您需要获取和解析 VAST 文档, 您可以使用 `get` 方法从 **VAST 客户端**数字 :

```javascript
import { VASTClient } from '@dailymotion/vast-client'

const vastClient = new VASTClient();

vastClient.get('https://www.examplevast.com/vast.xml')
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });
```

除了获取和解析 VAST 资源, **VAST 客户端** 提供了根据计数和执行时间过滤调用序列的选项,以及使用 URL 跟踪的可能性 **VASTTRACER 软件**。 。 。 .

如果您需要直接解析一个 VAST XML 并遵循任何包装链, 您可以使用 `parseVAST` 方法从 **VAST 客户端** 数字 :

```javascript
import { VASTClient } from '@dailymotion/vast-client'

const vastClient = new VASTClient();

vastClient.parseVAST(vastXml)
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });
```

### VASTParser 软件

要直接解析 VAST XML 您可以使用 **VASTParser 软件**数字 : 这个 **VASTParser 软件** 将不获取, 最后的回复将只包含第一次遇到的 VAST .

```Javascript
import { VASTParser } from '@dailymotion/vast-client'

const vastParser = new VASTParser();

vastParser.parseVAST(vastXml)
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });
```

### VASTTRACER 软件

要追踪广告的执行,请创建 **VASTTRACER 软件** 实例并使用专用 [方法](https://npmcn.com/package/%40dailymotion/vast-client/docs/api/vast-tracker.md) 致电话 [VAST 跟踪元素](https://iabtechlab.com/wp-content/uploads/2019/06/VAST_4.2_final_june26.pdf#page=28)。 。 。 .

```Javascript
import { VASTTracker } from '@dailymotion/vast-client'

const vastTracker = new VASTTracker(vastClient, ad, creative);

// Track an impression for the given ad. Will call any <Impression> URI from the <InLine> and <Wrapper> tracking elements.
vastTracker.trackImpression();
```

## API 文档

API文件按下列部分编排:

-   [VAST 客户端](https://npmcn.com/package/%40dailymotion/vast-client/docs/api/vast-client.md)
-   [VASTParser 软件](https://npmcn.com/package/%40dailymotion/vast-client/docs/api/vast-parser.md)
-   [VASTTRACER 软件](https://npmcn.com/package/%40dailymotion/vast-client/docs/api/vast-tracker.md)

更改日志和迁移指南可见于 [发布注释](https://github.com/dailymotion/vast-client-js/releases)。 。 。 .

### 预先捆绑的版本

我们提供了客户端的几个预先捆绑的版本(参见: [`dist` 目录](https://npmcn.com/package/%40dailymotion/vast-client/dist/)(中文(简体) )

#### 炸弹

使用包管理器添加 lib( 如 npm 或 rarn ) 时, 默认可以使用 js 捆绑器( 如 Web pack 或 rollup) 的版本 : [`vast-client.js`](https://npmcn.com/package/%40dailymotion/vast-client/dist/vast-client.js) 或者说 [`vast-client.min.js`](https://npmcn.com/package/%40dailymotion/vast-client/dist/vast-client.min.js) \[删除\].

```javascript
const import {
  VASTClient,
  VASTParser,
  VASTTracker
} from '@dailymotion/vast-client'

const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();
```

#### 浏览器脚本

VAST客户JS预装版: [`vast-client.min.js`](https://npmcn.com/package/%40dailymotion/vast-client/dist/vast-client.min.js) \[删除\].

要使用它, 要么在您的CDN上主机, 要么在您的项目中本地运行 。 如果您使用脚本标记, 请确保将类型属性设置为下面的模块 .

_您的索引.html_

```html
<script type="module" src="your-main-file.js"></script>
```

_主语.js_

```javascript
import {VASTClient, VASTParser, VASTTracker} from "vast-client.min.js"

const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();
```

#### 节点

节点预装版也可用: [`vast-client-node.js`](https://npmcn.com/package/%40dailymotion/vast-client/dist/vast-client-node.js) 或者说 [`vast-client-node.min.js`](https://npmcn.com/package/%40dailymotion/vast-client/dist/vast-client-node.min.js) \[删除\].

```javascript
// Method 1: From npm
const VAST = require('@dailymotion/vast-client')

// Method 2: For pre-bundled you must copy first the file inside your project
// then you will be able to require it without the need of npm
const VAST = require('your/path/vast-client-node.min.js')

const vastClient = new VAST.VASTClient();
const vastParser = new VAST.VASTParser();
const vastTracker = new VAST.VASTTracker();
```

## 构建/贡献

见 [捐款](https://npmcn.com/package/%40dailymotion/vast-client/docs/CONTRIBUTING.md)

## 常见问题

### @dailymotion/vast-client 是什么？

JavaScript VAST 客户端

### 如何安装 @dailymotion/vast-client？

在项目目录运行 npm install @dailymotion/vast-client，或使用 pnpm add / yarn add / bun add。

### @dailymotion/vast-client 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @dailymotion/vast-client 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @dailymotion/vast-client 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=12\.22\.1。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @dailymotion/vast-client 可以商用吗？

@dailymotion/vast-client 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @dailymotion/vast-client 的下载量有多少？

根据 npm 官方下载统计，@dailymotion/vast-client 在 2026/10/11 – 2026/11/09 这 30 天内被下载 250,287 次，日均约 8,343 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @dailymotion/vast-client 还在维护吗？

最新版本 6\.5\.0 发布于 2026/09/30（1 个月前）；至今共发布 18 个版本，其中过去 12 个月发布了 5 个；首次发布于 2021/09/21。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

