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

@treasureplaynet/js-sdk

v1.0.2

Published

TreasurePlay JavaScript SDK for web games - React components for quest delivery and rewards

Downloads

290

Readme

@treasureplaynet/js-sdk

TreasurePlay JavaScript SDK for web games. Uses the exact same UI components as the TreasurePlay portal, ensuring identical design across all platforms.

Installation

npm install @treasureplaynet/js-sdk @mui/material @emotion/react @emotion/styled

Quick Start

import { TreasurePlayQuests } from '@treasureplaynet/js-sdk';

function Game() {
  return (
    <TreasurePlayQuests
      appKey="your-api-key"
      userId="player_123"
      onRewardClaimed={(questId, amount) => {
        addCoinsToPlayer(amount);
      }}
    />
  );
}

Showing/Hiding Quests

import { useState } from 'react';
import { TreasurePlayQuests } from '@treasureplaynet/js-sdk';

function Game() {
  const [showQuests, setShowQuests] = useState(false);

  return (
    <div>
      <button onClick={() => setShowQuests(true)}>
        🎯 Open Quests
      </button>

      {showQuests && (
        <TreasurePlayQuests
          appKey="your-api-key"
          userId="player_123"
          onClose={() => setShowQuests(false)}
          onRewardClaimed={(questId, amount) => {
            addCoinsToGame(amount);
          }}
        />
      )}
    </div>
  );
}

Props

<TreasurePlayQuests
  // Required
  appKey="your-api-key"
  userId="player_123"
  
  // Optional
  advertisingId="..."
  email="[email protected]"
  environment="production"        // 'production' | 'testnet'
  categories={['engagement', 'monetization', 'progression']}
  tokenType="coins"               // Auto-detected if not provided
  enableLogging={false}
  refreshInterval={0}             // ms, 0 to disable
  
  // Theming (see Theming section below)
  theme={{}}
  
  // Container styling
  style={{}}
  className=""
  
  // Callbacks
  onClose={() => {}}
  onGameClick={(appId) => {}}
  onRewardClaimed={(questId, amount) => {}}
  onQuestCompleted={(questId) => {}}
  onTokensChanged={(tokens) => {}}
  onLoad={() => {}}
  onError={(error) => {}}
/>

Theming

The SDK supports comprehensive theming to match your game's aesthetic. Pass a theme prop to customize colors, typography, and more.

Basic Theming

<TreasurePlayQuests
  appKey="your-api-key"
  userId="player_123"
  theme={{
    colors: {
      primary: '#FF6B6B',        // Main accent color
      secondary: '#4ECDC4',      // Secondary accent
      success: '#2ECC71',        // Claim buttons, completed states
      backgroundColor: '#1a1a2e', // Main background
    }
  }}
/>

Full Theme Configuration

import type { ThemeConfig } from '@treasureplaynet/js-sdk';

const myGameTheme: ThemeConfig = {
  name: 'my-game-theme',
  
  colors: {
    // Brand colors
    primary: '#6360E7',          // Primary accent (progress bars, active states)
    secondary: '#F20CE2',        // Secondary accent (titles, highlights)
    success: '#17DA00',          // Success states (claim buttons, completed)
    warning: '#FFB800',          // Warning states (claimable rewards)
    error: '#FF4444',            // Error states
    
    // Background
    backgroundColor: '#f5f5f7',  // Main container background
    textOverBackgroundColor: '#666666', // Text on background
    
    // Card styling
    card: {
      backgroundColor: '#ffffff',
      titleTextColor: '#333333',
      mainTextColor: '#333333',
      secondaryTextColor: '#666666',
      borderColor: '#eeeeee',
    },
    
    // Header
    header: {
      backgroundColor: '#ffffff',
      textColor: '#333333',
    },
    
    // Quest list
    questList: {
      titleColor: '#F20CE2',     // Section title color
      questCard: {
        stepIndicator: {
          activeColor: '#6360E7',    // In-progress step
          completedColor: '#17DA00', // Completed step
          lockedColor: '#999999',    // Locked step
        },
        progressBar: {
          backgroundColor: '#e0e0e0',
          fillColor: '#6360E7',
        },
      },
    },
    
    // Buttons
    buttons: {
      start: {
        backgroundColor: '#17DA00',
        textColor: '#ffffff',
        borderColor: '#01B723',
      },
      continue: {
        backgroundColor: '#6360E7',
        textColor: '#ffffff',
        borderColor: '#4846BF',
      },
      claim: {
        backgroundColor: '#17DA00',
        textColor: '#ffffff',
        borderColor: '#15c500',
      },
    },
    
    // Banner gradient
    bannerBackground: 'linear-gradient(30deg, #7CB2FC 0%, #F47DE0 50%, #FEB971 100%)',
  },
  
  // Typography
  typography: {
    fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
    displayFontFamily: '"Luckiest Guy", cursive', // For big button text
  },
  
  // Border radius
  borderRadius: {
    small: 8,
    medium: 12,
    large: 16,
  },
};

// Use the theme
<TreasurePlayQuests
  appKey="your-api-key"
  userId="player_123"
  theme={myGameTheme}
/>

Theme Examples

Dark Theme

const darkTheme: Partial<ThemeConfig> = {
  colors: {
    primary: '#BB86FC',
    secondary: '#03DAC6',
    success: '#00E676',
    backgroundColor: '#121212',
    textOverBackgroundColor: '#B3B3B3',
    card: {
      backgroundColor: '#1E1E1E',
      titleTextColor: '#FFFFFF',
      mainTextColor: '#E0E0E0',
      secondaryTextColor: '#B3B3B3',
      borderColor: '#333333',
    },
    header: {
      backgroundColor: '#1E1E1E',
      textColor: '#FFFFFF',
    },
    bannerBackground: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
  },
};

Playful/Colorful Theme

const playfulTheme: Partial<ThemeConfig> = {
  colors: {
    primary: '#FF6B6B',
    secondary: '#4ECDC4',
    success: '#45B7D1',
    backgroundColor: '#FFF9E6',
    card: {
      backgroundColor: '#FFFFFF',
      titleTextColor: '#2D3436',
      borderColor: '#FFE66D',
    },
    buttons: {
      start: {
        backgroundColor: '#FF6B6B',
        borderColor: '#E55555',
      },
      claim: {
        backgroundColor: '#4ECDC4',
        borderColor: '#3DBDB4',
      },
    },
    bannerBackground: 'linear-gradient(135deg, #FF6B6B 0%, #FFE66D 50%, #4ECDC4 100%)',
  },
  borderRadius: {
    small: 12,
    medium: 20,
    large: 28,
  },
};

Minimal/Corporate Theme

const minimalTheme: Partial<ThemeConfig> = {
  colors: {
    primary: '#2563EB',
    secondary: '#3B82F6',
    success: '#10B981',
    backgroundColor: '#F8FAFC',
    card: {
      backgroundColor: '#FFFFFF',
      titleTextColor: '#1E293B',
      mainTextColor: '#334155',
      secondaryTextColor: '#64748B',
      borderColor: '#E2E8F0',
    },
    bannerBackground: '#2563EB',
  },
  typography: {
    fontFamily: '"Inter", -apple-system, sans-serif',
    displayFontFamily: '"Inter", sans-serif',
  },
  borderRadius: {
    small: 4,
    medium: 8,
    large: 12,
  },
};

Using Theme Helpers

import { defaultTheme, mergeTheme } from '@treasureplaynet/js-sdk';

// Get the default theme
console.log(defaultTheme.colors?.primary); // '#6360E7'

// Merge your customizations with defaults
const myTheme = mergeTheme(defaultTheme, {
  colors: {
    primary: '#FF0000',
    // All other values inherit from defaultTheme
  },
});

TypeScript Support

import type { ThemeConfig, ThemeImages } from '@treasureplaynet/js-sdk';

const theme: Partial<ThemeConfig> = {
  // Full type hints and autocomplete
};

Full-Screen Modal Example

function Game() {
  const [showQuests, setShowQuests] = useState(false);

  return (
    <>
      <button onClick={() => setShowQuests(true)}>Open Quests</button>

      {showQuests && (
        <div style={{
          position: 'fixed',
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          backgroundColor: 'rgba(0, 0, 0, 0.8)',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          zIndex: 1000,
        }}>
          <div style={{ 
            width: '400px', 
            height: '90vh', 
            borderRadius: '16px',
            overflow: 'hidden',
          }}>
            <TreasurePlayQuests
              appKey="your-api-key"
              userId="player_123"
              onClose={() => setShowQuests(false)}
            />
          </div>
        </div>
      )}
    </>
  );
}

Using Individual Components

For custom layouts, use components directly:

import { 
  UIProvider,
  GameList,
  GameCard,
  GameDetail,
  RewardOverlay,
  defaultTheme,
} from '@treasureplaynet/js-sdk';

function CustomQuestUI({ quests }) {
  return (
    <UIProvider 
      tokenType="coins" 
      balance={1000}
      theme={{
        colors: {
          primary: '#FF6B6B',
        },
      }}
    >
      <GameList 
        quests={quests} 
        onGameClick={(appId) => navigateToGame(appId)}
        onClaimReward={(questId) => handleClaim(questId)}
      />
    </UIProvider>
  );
}

Architecture

@treasureplaynet/js-sdk
├── TreasurePlayQuests   (main component)
├── GameList / GameCard  (UI components)
├── ApiClient            (API communication)
├── AppService           (app metadata from CDN)
└── SessionManager       (localStorage persistence)

portal/web (TreasurePlay Portal)
└── Similar UI, separate codebase

Unity SDK
└── WebView pointing to portal/web

The JS SDK is a self-contained package with its own UI components that can be fully customized via theming.

Unity SDK Comparison

| Unity SDK | JS SDK | |-----------|--------| | ShowQuestWebView() | <TreasurePlayQuests /> | | HideQuestWebView() | Unmount component / onClose | | CheckRewardsAsync() | onTokensChanged callback | | RedeemAsync() | Automatic via onRewardClaimed |

TypeScript

Full TypeScript support:

import type { 
  TreasurePlayQuestsProps,
  Quest,
  QuestState,
  Environment,
  ThemeConfig,
  ThemeImages,
} from '@treasureplaynet/js-sdk';

// Import theme helpers
import { defaultTheme, mergeTheme } from '@treasureplaynet/js-sdk';

Requirements

  • React 17+
  • Material UI 5+ (@mui/material)
  • Emotion (@emotion/react, @emotion/styled)

Support

License

MIT