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

arcaid-sdk

v0.2.1

Published

Arcaid JavaScript SDK for browsers. Includes a lightweight loader that automatically manages the SDK lifecycle.

Readme

ARCAID SDK

A lightweight JavaScript SDK for integrating ARCAID into your web applications.

Installation

Option 1: CDN (Recommended)

Simply add the loader script to your HTML:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/arcaid-loader.min.obf.js"></script>

That's it! The loader will automatically download and initialize the SDK when needed.

Option 2: NPM

npm install arcaid-sdk

Then import the loader:

import 'arcaid-sdk/dist/arcaid-loader.min.obf.js';

Usage

The loader will automatically manage the SDK lifecycle. You don't need to manually include or initialize the core SDK - the loader handles everything for you.

// The loader exposes the global ARCAID object
window.ARCAID.init({
    // your configuration
});

Development

For local development and debugging, run:

pnpm serve

This will start a local server at http://localhost:3100 serving the SDK files.

Basic Usage

Here's a quick example of how to initialize the Arcaid SDK when including it directly via a <script> tag.

  1. Include the arcaid-loader.js script in your HTML:

    This script will handle loading the core SDK and make the Arcaid object available globally.

    <!-- Adjust the path to where you host arcaid-loader.js -->
    <script src="path/to/arcaid-loader.js"></script>
  2. Use the global Arcaid object to initialize and use the SDK:

    Once the loader script is included, you can access Arcaid to initialize and interact with the SDK.

    // This code would typically be in a <script> tag in your HTML, after arcaid-loader.js
    // or in your game's main JavaScript file that runs after the loader.
    
    async function mainArcaidIntegration() {
      try {
        // The Arcaid object is now available globally (window.Arcaid)
        if (!window.Arcaid || !window.Arcaid.init) {
          console.error("Arcaid SDK Loader not found or failed to initialize. Ensure arcaid-loader.js is loaded.");
          return;
        }
    
        // Initialize the SDK.
        // Provide your gameId if you have one. Other configurations can also be passed.
        // If running in an iframe on the Arcaid platform, some configs are auto-provided.
        const sdkInstance = await window.Arcaid.init({
          gameId: 'your-game-id', // Optional: if your game has a specific ID
          // coreSdkUrl: 'path/to/your/self-hosted/arcaid-core-sdk.js' // Optional: if self-hosting the core SDK
        });
    
        console.log("Arcaid SDK Initialized (loader).");
    
        // IMPORTANT: Wait for the SDK to be fully ready before making most calls.
        // This usually means it has received necessary configuration, like user session from the platform.
        await sdkInstance.ready();
        console.log("Arcaid SDK is fully ready for calls.");
    
        // Now you can use the SDK modules, for example, to get user state or balance.
        const userState = await sdkInstance.auth.getUserState();
        console.log("User State:", userState);
    
        if (userState.isLoggedIn) {
          // Example: Get balance for the default/primary token
          try {
            const balanceInfo = await sdkInstance.wallet.getUserBalance(); // No argument needed now
            console.log(`User Balance:`, balanceInfo.balance, balanceInfo.ticker, `(Token: ${balanceInfo.tokenAddress})`);
          } catch (balanceError) {
            console.warn(`Could not fetch user balance:`, balanceError.message);
          }
        }
    
        // You can also use other modules like multiplayer, stats, etc.
        // sdkInstance.multiplayer.createRoom(...);
    
      } catch (error) {
        console.error("Arcaid SDK Initialization or usage failed:", error);
        // Handle initialization errors appropriately
      }
    }
    
    // Call your integration function. 
    // Ensure this runs after the DOM is ready or arcaid-loader.js has had a chance to load.
    mainArcaidIntegration();

Usage

import { something } from 'arcaid-sdk';
// ...

Wallet Operations

Get User Balance

To get a user's balance (typically for their primary or game-specific token), you can use the getUserBalance method available on the wallet module of the SDK instance. This is also shown in the Basic Usage example above.

// Assuming sdkInstance is your initialized and ready Arcaid SDK instance
async function checkUserBalance(sdkInstance) {
  try {
    const balanceInfo = await sdkInstance.wallet.getUserBalance(); // No argument needed
    console.log('User Balance:', balanceInfo.balance);
    console.log('Token Ticker:', balanceInfo.ticker);
    console.log('Token Address:', balanceInfo.tokenAddress); // The platform returns which token this balance is for
    return balanceInfo;
  } catch (error) {
    console.error('Error fetching user balance:', error.message);
    // Handle the error appropriately
  }
}

// Example usage:
// mainArcaidIntegration function from Basic Usage would already show this.
// if (sdkInstance && sdkInstance.ready) { // Ensure sdkInstance is defined and has ready method
//    sdkInstance.ready().then(() => {
//        checkUserBalance(sdkInstance);
//    });
// }

Scripts

  • npm run build — Build the SDK
  • npm run test — Run tests
  • npm run lint — Lint code

License

MIT