@dcl/quests-client

中文文档
1.0.3发布于 2023/10/25Apache-2.0TypeScriptCommonJS近 30 天下载 5941

Quests Client

原始使用文档
文档目录3 节
  1. Install
  2. Example
  3. Scene Example: Quests Tracking

Decentraland

Quests Client - SDK7

Quests Client for SDK7 is a RPC Client which interacts with the Quests Server to track quests states and send events to make progress.

Setup

If you want to contribute to this project, you will need to install the dependencies and build the project.

Start by installing NPM dependecies:

$ npm install

The project uses the Quests Service proto definition to generate the code required to compile, so before start the development, make sure you run:

$ make build

Usage

This library is intended to be used in a Decentraland Scene and uses SDK7 features like user authentication to initialize the client.

You can find the documentation to start using the library here.

Install

Add dependency to your project

$ npm add @dcl/quests-client

Example

Create the Quests Client inside the executeTask and if the wallet based authentication is OK you will be ready to use the client to subscribe to updates or send new events that may make progress on a quest.

For this example we registered two observables to make use of the client from any other part of your code: questEventsObservable and questStartObservable

executeTask(async () => {
  // retrieve websocket url from env
  const ws = 'wss://quests-rpc.decentraland.zone'

  const questID = 'q123-u456-e789-s012-t345'

  // create quests client
  try {
    const client = await createQuestsClient(ws, questID)

    questEventsObservable.on('message', async (action) => {
      await client.sendEvent({ action })
    })

    questStartObservable.on('start', async () => {
      await client.startQuest()
    })

    client.onStarted((quest) => {
      // update your state here or react to the quest started event
    })

    client.onUpdate((quest) => {
      // update your state here or react to the quest updates
    })

    // retrieve all quest instances and their state
    const userInstance = client.getQuestInstance()
    ...
  } catch (e) {
    console.log(`[Your Scene] connection to ${ws} failed! ${e}`)
  }
})

Scene Example: Quests Tracking

In this repository you may find a scene that makes use of all the Quests Client features.

Or you can go and check out the library documentation here

版本与发布记录

@dcl/quests-client 共发布 23 个版本,首次发布于 2023/06/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2023/10/253 年前
1.0.3-20231025131529.commit-ab10531next2023/10/253 年前
1.0.22023/10/253 年前
1.0.2-20231024193022.commit-5a9b8892023/10/253 年前
1.0.12023/10/253 年前
1.0.1-20231024191537.commit-4091ac72023/10/253 年前

关于 @dcl/quests-client 的常见问题

@dcl/quests-client 是什么?

Quests Client

如何安装 @dcl/quests-client?

在项目目录运行 npm install @dcl/quests-client,或使用 pnpm add / yarn add / bun add。

@dcl/quests-client 支持 TypeScript 吗?

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

@dcl/quests-client 支持 ESM 还是 CommonJS?

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

@dcl/quests-client 可以商用吗?

@dcl/quests-client 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dcl/quests-client 的下载量有多少?

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

@dcl/quests-client 还在维护吗?

最新版本 1.0.3 发布于 2023/10/25(3 年前);至今共发布 23 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/06/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。