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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@odogames/js-sdk

v1.0.1

Published

Welcome to the ODO JS SDK. This library is meant for interacting with the ODO app via our JavaScript/App bridge and helps with communication with ODO, recording analytics and saving/retieving data.

Downloads

4

Readme

ODO JS SDK

Welcome to the ODO JS SDK. This library is meant for interacting with the ODO app via our JavaScript/App bridge and helps with communication with ODO, recording analytics and saving/retieving data.

Installation

There are 2 ways to install ODO.

via NPM/Yarn

npm install @odogames/js-sdk
// or
yarn add @odogames/js-sdk

Or Download It (save this JS file)

Use the following link to download the ODO JS SDK. Do not hot link to it. We like to make our games fully operational without the internet. This allows people to play games on the go more easily.

Download: https://www.unpkg.com/@odogames/[email protected]/build/odo.js

Initialization/Usage

When using npm you should import ODO as follows:

import ODO from '@odogames/js-sdk';

const odo = ODO.init({ useLocalStorageInDev: true });
odo.on(ODO.Events.start, () => {});

When downloading you should add the script file locally, maybe place it in a vendor file and access the "ODO" variable globally.

<script src="vendor/odo.js">
<script>
  const odo = ODO.init({ useLocalStorageInDev: true });
  odo.on(ODO.Events.start, () => {});
</script>

Events

The following functions are available when listening to events.

  odo.events.on(event: ODO.Events, callback: (data?: object) => void): void
  odo.events.off(event: ODO.Events, callback: (data?: object) => void): void
  odo.events.once(event: ODO.Events, callback: (data?: object) => void): void

Event Types

ODO.Events.start: (Required) Is executed when the player wants to start a game. The start event is required to be listened to.

ODO.Events.restart: For replayable games, after the "finish" trigger is executed, the player may "restart" the game. This action would initiate a restart event. Optionally, games can implement their own "restart" behavior. This is provided as a convenience.

Triggers

A trigger is used to signal to ODO that the game is prepared for further player interaction. For instance, the game should fire an ODO.Triggers.ready trigger when all assets are loaded.

  odo.trigger(event: ODO.Triggers, data?: object): void

Trigger Types

ODO.Triggers.ready: (Required) Indicate to ODO that the game is loaded and ready to be played. ODO.Triggers.finish: For replayable games, you can indicate to ODO that a playthrough is complete. This will cause ODO to a show a UI that asks the player if they'd like to replay. This is provided as a convenience.

NOTE In dev environments, triggers will automatically fire their "event" counterparts.

Data Saving/Retrieval

Use the following methods to save/retrieve data. getForPlayer/saveForPlayer are used to store data for just this player, while get/save is for non-player specific information.

  odo.data.get(key: string, (data: object) => void): Promise<object>
  odo.data.save(key: string, (data: object) => void): Promise<object>
  odo.data.getForPlayer(key: string, (data: object) => void): Promise<object>
  odo.data.saveForPlayer(key: string, (data: object) => void): Promise<object>

Analytics

You may track certain player activities like "checkpoints" reached in order to get insights into how people playing your game are doing.

  odo.track(event: string, data?: object): void

Testing/Configuration

The ODO JS SDK is designed to work within both the ODO app and in local development. When using the app, we save data via ODOs APIs. In local environments (or out on the web elsewhere), we use local storage as the persistence layer. This persistence is volatile, but allows developers to have an easy testing/development experience.

ODO.init(config?: object) takes some optional params that are mostly useful in testing scenarios.

config = {
  global?: Global, // A simulated global object as defined from our "Global" type. Great for unit testing.
  useLocalStorageInDev: boolean, // Provides a useful simulation of persistance using localStorage
}

Getting Help

If you need any help, please hop into our Discord: https://discord.gg/SDSsGBP