JSPM

@elschnagoo/local-games

0.4.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q59621F
  • License MIT

A library to get local games from different platforms and launcher

Package Exports

  • @elschnagoo/local-games
  • @elschnagoo/local-games/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@elschnagoo/local-games) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Local-Games

NPM Version NPM Downloads

Read local game launcher config files and launch games

Features

  • Read local game launcher config files
  • Get game info
  • Get game image
  • Get game executable
  • Open Game Launcher
  • Install game (partial [steam, epic])
  • Open shop page (partial [steam, epic])

Currently supported launchers

Docs

Quickstart

Install

Install the package via npm

npm install @elschnagoo/local-games
import { LocalGames, BattleNetLauncher, EpicLauncher, SteamLauncher, UplayLauncher, } from '@elschnagoo/local-games';

(async () => {
    const localGames = new LocalGames();

    // Register a launcher [Battle.net, Epic Games, Steam, Uplay] @see docs for more info
    const report = await localGames.registerLauncher(
        new BattleNetLauncher(),
        new EpicLauncher(),
        new UplayLauncher(),
        new SteamLauncher({
            apiKey: '$STEAM_WEB_API_KEY', // get on https://steamcommunity.com/dev/apikey
            steamVanity: '$STEAM_USER_VANITY', // Show on your steam profile
        })
    );

    if (report.success) {
        console.log('All Launchers registered successfully');
    } else {
        report.result.forEach(([name, success]) => {
            if (!success) {
                console.log(`${name} failed to register`);
            }
        });
    }

    const games = await localGames.getGames();

    const [game] = games;

    console.log('Game Name', game.name);
    console.log('Game is on Wishlist', game.wishList);
    console.log('Game is installed', game.installed);

    // ...

    // Returns the executable path or protocol link
    const cmd = await game.getLauncherCMD();
    console.log(cmd);
    // Returns the shop cmd if exist
    const shop = await game.getOpenShopCMD();
    console.log(shop);
    // Returns a default command to  "Start Game" > "Install" > "Open Shop"
    const def = await game.defaultCMD();
    console.log(def);

    // Returns the game image as base64 encoded string (webp)
    const images = await game.getGameImageBase64(false);
    console.log(images?.portrait);

    // ... pop child process with cmd to start the game from nodejs
    // import * as child_process from 'child_process';
    // if (def) child_process.exec(def);
})();