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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vibegameengine/platform

v1.0.1

Published

Cross-platform game service layer with mock and provider adapters

Readme

@vibegameengine/platform

Cross-platform game platform layer for web games.

The package provides:

  • a unified platform interface (IPlatformService<TSaveData>)
  • a platform registry (setPlatform, getPlatform, platformLoader)
  • a development mock provider (MockPlatformService)
  • a Yandex Games provider (YandexPlatformService)

Install

npm i @vibegameengine/platform

Core idea

Define your game save model once and keep game logic independent from SDK details.

import { IPlatformService } from '@vibegameengine/platform';

type SaveModel = {
  credits: number;
  highScore: number;
};

function runGame(platform: IPlatformService<SaveModel>) {
  // Your game code depends on the interface, not on specific SDKs
}

API

IPlatformService<TSaveData>

interface IPlatformService<TSaveData = unknown> {
  init(): Promise<void>;
  getPlayerName(): string;
  getLanguage(): string;
  saveData(data: TSaveData): Promise<boolean>;
  loadData(): Promise<TSaveData | null>;
  showInterstitial(): Promise<void>;
  showRewardedAd(): Promise<boolean>;
  setLeaderboardScore(score: number): Promise<void>;
  getLeaderboardEntries(): Promise<LeaderboardEntry[]>;
}

Registry helpers

setPlatform(service)
getPlatform<TSaveData>()
platformLoader // Promise resolved after setPlatform

Detailed usage example (Mock in development)

1) Define your game save data model

// save-model.ts
export interface SaveModel {
  credits: number;
  cores: number;
  highScore: number;
  adFreeUntil: number;
}

export const DEFAULT_SAVE: SaveModel = {
  credits: 0,
  cores: 0,
  highScore: 0,
  adFreeUntil: 0
};

2) Initialize platform before app render

// bootstrap.ts
import { MockPlatformService, setPlatform } from '@vibegameengine/platform';
import { SaveModel } from './save-model';

const platform = new MockPlatformService<SaveModel>({
  storageKey: 'mygame_save_v1',
  languageKey: 'mygame_lang_v1',
  highScoreKey: 'mygame_hs_v1',
  adDurationMs: 2000,
  initDelayMs: 300,
  loadDelayMs: 150,
  playerName: 'DevPlayer'
});

await platform.init();
setPlatform<SaveModel>(platform);

3) Wait for platform and render app

// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { platformLoader } from '@vibegameengine/platform';
import App from './App';

platformLoader.then(() => {
  ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
});

4) Use platform inside game logic

// game-service.ts
import { getPlatform } from '@vibegameengine/platform';
import { SaveModel, DEFAULT_SAVE } from './save-model';

export async function loadProfile(): Promise<SaveModel> {
  const platform = getPlatform<SaveModel>();
  return (await platform.loadData()) ?? DEFAULT_SAVE;
}

export async function saveProfile(profile: SaveModel): Promise<void> {
  const platform = getPlatform<SaveModel>();
  await platform.saveData(profile);
}

export async function tryRewarded(): Promise<boolean> {
  const platform = getPlatform<SaveModel>();
  return platform.showRewardedAd();
}

export async function showInterstitial(): Promise<void> {
  const platform = getPlatform<SaveModel>();
  await platform.showInterstitial();
}

Yandex provider example

import {
  YandexPlatformService,
  YandexSDK,
  setPlatform
} from '@vibegameengine/platform';

type SaveModel = {
  credits: number;
  highScore: number;
};

declare global {
  interface Window {
    YaGames: {
      init(): Promise<YandexSDK>;
    };
  }
}

const sdk = await window.YaGames.init();

const platform = new YandexPlatformService<SaveModel>(sdk, {
  storageKey: 'mygame_save_v1',
  leaderboardName: 'mygame_scores'
});

await platform.init();
setPlatform<SaveModel>(platform);

Notes

  • Keep TSaveData stable and versioned in your game.
  • Platform methods are O(1) from app-side perspective; SDK/network latency dominates real time.
  • Always resolve ad errors gracefully (do not block gameplay on ad failure).
  • Use game-specific wrapper services if you want strict domain boundaries.