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

web-sdk-wrapper

v2.0.2

Published

Unified wrapper for web game distribution platform SDKs (Poki, CrazyGames, CoolMathGames, and more)

Readme

web-sdk-wrapper

Unified wrapper for web game distribution platform SDKs. Write your game once, publish to multiple portals.

Supported Networks

| Network | Ads | Interstitial | Rewarded | Banner | Accounts | Tokens | |---|---|---|---|---|---|---| | Poki | Yes | Yes | Yes | No | Yes | Yes | | CrazyGames | Yes | Yes | Yes | Yes | No | No | | CoolMathGames | Yes | Yes | No | No | No | No | | HoodaMath | No | No | No | No | No | No | | FreezeNova | Yes | Yes | Yes | No | No | No | | Xiaomi | Yes | Yes | Yes | No | No | No |

Install

npm install web-sdk-wrapper

Or include via script tag (UMD):

<script src="dist/web-sdk-wrapper.umd.cjs"></script>
<script>
  const Wrapper = WebSdkWrapper.default;
</script>

Quick Start

import Wrapper from "web-sdk-wrapper";

// Initialize with a network
await Wrapper.init("Poki", false, { poki_gameId: "abc123" });

// Signal loading complete
Wrapper.loadingEnd();

// Start gameplay
Wrapper.gameplayStart();

// Show an interstitial ad (auto-pauses/resumes gameplay)
const shown = await Wrapper.interstitial();

// Show a rewarded ad
const rewarded = await Wrapper.rewarded();
if (rewarded) {
  // Grant the reward
}

// Stop gameplay
Wrapper.gameplayStop();

API

Wrapper.init(name, debug?, data?)

Initialize the wrapper with a specific network.

  • name — Network name (case-insensitive): "Poki", "CrazyGames", "CoolMathGames", "HoodaMath", "FreezeNova", "Xiaomi"
  • debug — Enable debug mode (default: false). Networks with requiresProduction are disabled in debug mode.
  • data — Network-specific configuration object. See Network Configuration.

Returns a Promise<void> that resolves when the SDK is loaded and initialized.

Lifecycle

| Method | Description | |---|---| | Wrapper.loadingStart() | Signal that the game started loading | | Wrapper.loadingEnd() | Signal that the game finished loading | | Wrapper.gameplayStart() | Signal that a gameplay session started (duplicate calls are ignored) | | Wrapper.gameplayStop() | Signal that a gameplay session stopped (duplicate calls are ignored) | | Wrapper.levelStart(level) | Signal that a level started | | Wrapper.replayLevel(level) | Signal that a level is being replayed |

Ads

| Method | Returns | Description | |---|---|---| | Wrapper.interstitial() | Promise<boolean> | Show an interstitial ad. Automatically pauses/resumes gameplay. Returns whether the ad was shown. | | Wrapper.rewarded(size?) | Promise<boolean> | Show a rewarded ad. Automatically pauses/resumes gameplay. Returns whether the reward was earned. | | Wrapper.onAdStarted(fn) | void | Register a callback for when any ad starts. | | Wrapper.hasAds() | boolean | Check if the current network supports ads. | | Wrapper.hasInterstitialAds() | boolean | Check if the current network supports interstitial ads. | | Wrapper.hasRewardedAds() | boolean | Check if the current network supports rewarded ads. |

Accounts

| Method | Returns | Description | |---|---|---| | Wrapper.login() | Promise<any> | Log in via the platform. Rejects if not supported. | | Wrapper.getUser() | Promise<any> | Get the current user. Returns null if not supported. | | Wrapper.getToken() | Promise<string\|null> | Get an auth token. Returns null if not supported. | | Wrapper.hasAccounts() | boolean | Check if the current network supports accounts. | | Wrapper.hasToken() | boolean | Check if the current network supports tokens. |

Misc

| Method | Description | |---|---| | Wrapper.analyticsEvent({ category, action, label? }) | Track an analytics event. | | Wrapper.openExternalLink(url) | Open an external URL through the platform's handler. | | Wrapper.onUnlockAllLevels(fn) | Register a callback for unlocking all levels. | | Wrapper.enabled | boolean getter — whether the wrapper is active. | | Wrapper.currentSdk | Getter — the current network adapter instance. |

Network Configuration

Pass network-specific options via the data parameter in init().

Poki

await Wrapper.init("Poki", false, {
  poki_gameId: "your-game-id",
  poki_doBeacon: true,         // Enable beacon tracking (optional)
  poki_maxBeacons: 6,          // Max beacons to send (default: 6)
  poki_beaconInterval: 60,     // Seconds between beacons (default: 60)
});

Xiaomi

await Wrapper.init("Xiaomi", false, {
  xiaomi_publisherId: "pub-xxxxx",
  xiaomi_bannerEnabled: true,           // Enable banner ads (optional)
  xiaomi_dataAdSlot: "xxxxx",           // Ad slot ID (required if banner enabled)
  xiaomi_bannerConainerId: "adSpace",   // Banner container element ID (default: "adSpace")
});

FreezeNova

await Wrapper.init("FreezeNova", false, {
  freezeNova_id: 12345,
});

CrazyGames, CoolMathGames, HoodaMath

No additional configuration needed.

await Wrapper.init("CrazyGames");

Named Exports

import Wrapper, { networks, NetworkAdapter, preventWeirdInputs } from "web-sdk-wrapper";

| Export | Description | |---|---| | default (Wrapper) | The singleton wrapper instance. | | networks | string[] — List of supported network names. | | NetworkAdapter | Base class for creating custom network adapters. | | preventWeirdInputs() | Opt-in utility that prevents arrow key scrolling, mouse wheel scrolling, and text selection on canvas. Call explicitly if your game needs it. |

Adding a Custom Network

Create a class extending NetworkAdapter and override only what you need:

import { NetworkAdapter } from "web-sdk-wrapper";

export class MyPortalAdapter extends NetworkAdapter {
  name = "MyPortal";

  capabilities = {
    ads: true,
    interstitialAds: true,
    rewardedAds: false,
    bannerAds: false,
    accounts: false,
    tokens: false,
  };

  scriptSources = ["https://sdk.myportal.com/sdk.js"];

  async init(options) {
    this._sdk = globalThis.MyPortalSDK;
    await this._sdk.initialize();
  }

  async showInterstitial() {
    await this._sdk.showAd("interstitial");
    return true;
  }

  onGameplayStart() {
    this._sdk.gameplayStart();
  }

  onGameplayStop() {
    this._sdk.gameplayStop();
  }
}

Then add it to the registry in src/networks/index.js.

License

MIT