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

@vit-rin/games-js

v2.1.22

Published

VitRin Games JavaScript SDK

Downloads

140

Readme

VIT-RIN Games JavaScript SDK

This SDK lets developers integrate their game with VIT-RIN which is a digital wallet that collects game scores and rewards players.

Getting Started

Follow these steps to just start integrating:

Install with package manager

Use any package manager like npm or yarn to install the JavaScript SDK.

Npm:

npm i @vit-rin/games-js

Yarn:

yarn add @vit-rin/games-js

Import as ES module:

import { VitGames } from "@vit-rin/games-js";

Import from CDN:

<script src="https://cdn.jsdelivr.net/npm/@vit-rin/games-js@latest/build/vitgames.browser.js"></script>

Instance

Create new instance of VitGames and pass your game ID to it:

const vitrin = new VitGames({ gameId: "YOUR_GAME_ID" });

By default, The SDK automatically checks and handles authentication. If you need to turn it off, set autoCheckAuth to false in the options.

{
    autoCheckAuth: false;
}

By default, The SDK automatically raises and handles ads. If you need to turn it off, set autoOpenAds to false in the options.

{
    autoOpenAds: false;
}

Game controls callbacks

These callbacks used to control the game. They are called when the game is started, paused, resumed, replayed, muted, or unmuted. For best results, You should have at least 3 callbacks for startCallback, pauseCallback, resumeCallback.

If you don't set replayCallback, the startCallback will be called instead.

By ignoring the pauseCallback or resumeCallback or muteCallback or unmuteCallback callbacks, the relevant controls in UI such as the pause button or the mute button will be disabled.

var vitrin = new VitGames({
    startCallback: myStartGame,
    pauseCallback: myPauseGame,
    resumeCallback: myResumeGame,
    replayCallback: myResetGame,
    muteCallback: myMuteGame,
    unmuteCallback: myUnmuteGame,
});

Methods

Let SDK be synced with current score by setting it in every score increment. Call set() method of the score object and pass the score number.

vitrin.score.set(SCORE_NUMBER);

When the game is ended, call ended() method of the game object to end the game and send the score to server and get the result.

vitrin.game.ended();

Options

Here is the default options:

export const DefaultOptions: OptionsType = {
    gameId: null,

    startCallback: undefined,

    pauseCallback: undefined,
    resumeCallback: undefined,

    replayCallback: undefined,

    muteCallback: undefined,
    unmuteCallback: undefined,

    useUI: true,

    preventDefault: true,

    autoCheckAuth: true,

    autoOpenAds: true,
};

Development and contribution

Install

git clone [email protected]:vit-rin/vitrin-games-js.git
cd ./vitrin-games-js/
npm i

Build

To build UMD bundles, run:

npm run build