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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gg-game-sdk

v1.3.0

Published

JavaScript SDK for Goama tournament platform communication

Readme

GG Game SDK

A JavaScript SDK for seamless communication between games and the Goama tournament platform through iframe messaging.

Features

  • 🎮 Easy integration with Goama tournament platform
  • 📦 Works with ES5, ES6, CommonJS, and UMD
  • 🔧 Full TypeScript support
  • ⚡ Next.js compatible
  • 🌐 Cross-browser compatibility (including IE11)
  • 📱 Lightweight and performant

Installation

npm install gg-game-sdk

Quick Start

ES6/TypeScript Import

import ggSDK, { gameOver, saveGameData } from 'gg-game-sdk';

// Using default export
ggSDK.gameOver(1000);

// Using named exports
gameOver(1000);
saveGameData({ level: 5, coins: 100 });

CommonJS (Node.js)

const ggSDK = require('gg-game-sdk');

ggSDK.gameOver(1000);
ggSDK.saveGameData({ level: 5, coins: 100 });

UMD (Browser Script Tag)

<script src="https://unpkg.com/gg-game-sdk/dist/index.umd.js"></script>
<script>
  // All of these work:
  GGSDK.gameOver(1000);
  window.GGSDK.gameOver(1000);
  GGSDK.saveGameData({ level: 5, coins: 100 });
</script>

Next.js Usage

import { useEffect } from 'react';
import ggSDK from 'gg-game-sdk';

export default function GameComponent() {
  useEffect(() => {
    // Initialize game
    ggSDK.gameLoaded();
    
    // Listen for pause events
    ggSDK.listenPaused(() => {
      console.log('Game paused by parent');
      // Pause your game logic here
    });

    // Listen for resume events
    ggSDK.listenResumed(() => {
      console.log('Game resumed by parent');
      // Resume your game logic here
    });

    // Get saved game data
    ggSDK.getGameData({ level: 1, score: 0 }, (data) => {
      console.log('Loaded game data:', data);
      // Initialize game with loaded data
    });
  }, []);

  const handleGameOver = (finalScore: number) => {
    ggSDK.gameOver(finalScore);
  };

  const handleSaveProgress = (gameData: any) => {
    ggSDK.saveGameData(gameData);
  };

  return (
    <div>
      {/* Your game component */}
    </div>
  );
}

API Reference

Core Methods

gameLoaded()

Notify the platform that the game has finished loading.

ggSDK.gameLoaded();

gameOver(score: number)

Send the final score when the game ends.

ggSDK.gameOver(1500);

saveGameData(data: object)

Save game progress data.

ggSDK.saveGameData({
  level: 3,
  score: 750,
  powerUps: ['shield', 'speed'],
  timestamp: Date.now()
});

getGameData(defaultData: object, callback: function)

Retrieve saved game data with fallback to default values.

ggSDK.getGameData(
  { level: 1, score: 0 }, // default data
  (data) => {
    console.log('Game data:', data);
    // Initialize game with data
  }
);

Game State Methods

gamePaused()

Notify the platform that the game was paused by the player.

ggSDK.gamePaused();

gameResumed()

Notify the platform that the game was resumed by the player.

ggSDK.gameResumed();

Event Listeners

listenPaused(callback: function)

Listen for pause events from the platform.

ggSDK.listenPaused(() => {
  // Pause game logic
  pauseGameEngine();
  showPauseScreen();
});

listenResumed(callback: function)

Listen for resume events from the platform.

ggSDK.listenResumed(() => {
  // Resume game logic
  resumeGameEngine();
  hidePauseScreen();
});

listenQuit(callback: function)

Listen for quit events from the platform.

ggSDK.listenQuit(() => {
  // Clean up and save progress
  saveCurrentProgress();
  cleanupResources();
});

TypeScript Support

The SDK includes comprehensive TypeScript definitions:

import ggSDK, { GameData, EventCallback } from 'gg-game-sdk';

interface MyGameData extends GameData {
  level: number;
  score: number;
  playerName: string;
}

const saveProgress = (data: MyGameData) => {
  ggSDK.saveGameData(data);
};

const handlePause: EventCallback = () => {
  // Type-safe pause handler
};

Error Handling

The SDK includes built-in error handling and will log warnings when:

  • Called outside of an iframe context
  • Communication with parent frame fails
// The SDK handles iframe detection automatically
ggSDK.gameOver(score); // Will log error if not in iframe

Browser Compatibility

  • ✅ Chrome (all versions)
  • ✅ Firefox (all versions)
  • ✅ Safari (all versions)
  • ✅ Edge (all versions)
  • ✅ Internet Explorer 11+

Multiple Access Methods

The SDK provides multiple ways to access it depending on your environment:

// ES6 Module
import ggSDK from 'gg-game-sdk';
ggSDK.gameOver(100);

// CommonJS
const ggSDK = require('gg-game-sdk');
ggSDK.gameOver(100);

// Browser Global (UMD)
GGSDK.gameOver(100);
window.GGSDK.gameOver(100);

// Named exports
import { gameOver, saveGameData } from 'gg-game-sdk';
gameOver(100);

Framework Compatibility

  • ✅ React / Next.js
  • ✅ Vue.js / Nuxt.js
  • ✅ Angular
  • ✅ Svelte / SvelteKit
  • ✅ Vanilla JavaScript
  • ✅ jQuery

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions:


Made with ❤️ for the gaming community