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 🙏

© 2024 – Pkg Stats / Ryan Hefner

s2client-api-typescript

v1.2.2

Published

The StarCraft 2 API for TypeScript

Downloads

5

Readme

s2client-api-typescript

npm version

This is a package that allows you to communicate with the StarCraft 2 API with a bot written in TypeScript.

It uses protobuf-ts to convert the official protocol files to TypeScript interfaces, enums, and serialization methods.

This project is similar to @node-sc2/core and @node-sc2/proto, which are written in JavaScript and use pbjs to convert the official proto files to JSON (instead of TypeScript).

Usage

This library provides several things:

1) The StarCraft2Client Class

StarCraft 2 exposes its API via a WebSocket server built-in to the game. (It is only available if you launch the game with some specific flags.) The StarCraft2Client class is an abstraction that can be used to easily send messages over the WebSocket connection.

For example:

import { launchStarCraft2, StarCraft2Client } from "s2client-api-typescript";

main().catch((err) => {
  console.error("Failed to run the program:", err);
});

async function main() {
  await launchStarCraft2();

  const client = new StarCraft2Client();
  await client.connect(); // Establishes a WebSocket connection with the game.

  const pingResponse = await client.ping();
  console.log(pingResponse);
}

2) StarCraft 2 API Interfaces and Enums

The official StarCraft 2 protocol files contain the interfaces and enums that are used in the API. These are automatically converted to TypeScript with the protobuf-ts tool and are exported from this library your use.

import { Race } from "s2client-api-typescript";

const MY_RACE = Race.Protoss;

3) Helper Functions

When writing your bot, this library offers some helper functions that can get you up and running faster:

  • launchStarCraft2
  • getMapPath

The helper functions are described in more detail in the documentation; see below.

Docs

See the automatically generated TypeDoc documentation for every export that this library provides.