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

@game-zone/api

v1.0.21

Published

### Install MOMO SDK

Downloads

20

Readme

Documents

Install MOMO SDK

//install  with  npm
npm  i  @game-zone/api
//or  yarn
yarn  add  @game-zone/api

Usage

import { sdk } from '@game-zone/api';
// Initialization
sdk.init({ gameId: 'sdk-demo-app' });
//--------------------or-----------------
import '@game-zone/api';
// Initialization
window.sdk.init({ gameId: 'sdk-demo-app' });

**Functions**

Start Feature Code

Open other mini-app by feature code Example:

sdk.startFeatureCode('code', { refId: 'screen-refId' });

Get Profile

response

{
	id: string,
	token: string,
	refreshToken: string;
	name: string,
	displayName: string,
	gender: string,
	avatar: string,
	platform: 'android' | 'ios',
	devicePerformance: 'low-end' | 'mid-end' | 'high-end',
	deviceSoftwareVersion: string
}

Example:

sdk.getProfile().then(res => console.log(res));

AppStateListener

const listener = sdk.appStateListener(state => console.log('--------->state', state));
listener.remove();

SensorListener

enum SensorTypes {
    accelerometer = 'accelerometer',
    gyroscope = 'gyroscope',
    magnetometer = 'magnetometer',
    barometer = 'barometer',
    orientation = 'orientation',
    gravity = 'gravity',
}
const  listener = sdk.sensorListener(
	{type:  SensorTypes.accelerometer, updateInterval:  500},
	res  => { console.log('[sdk] sensorListener response: ', res); }
);
...
listener.remove();

Share Popup

sdk.share({ title: 'hello', message: 'share message', url: '' }).then(res => {
    console.log('[sdk] share response: ', res);
});

Go Back

Close and go back to prev mini-app

sdk.goBack();

Send Tracking (deprecated)

sdk.sendTracking(event: string, params: any)

onBackKey

onBackKey event

sdk.onBackKey(callback:()=>any);

getToken

getToken function

sdk.getToken(): string;

getRefreshToken

getRefreshToken function

sdk.getRefreshToken(): string;

refreshToken

refreshToken function

sdk.refreshToken(token: string);

Game Login

Thời điểm user bắt đầu session. Phiên chơi game của người chơi.

  • Mỗi lần user vào game sẽ có mỗi session_id khác nhau.
  • Session chỉ bắt đầu tính khi user đã vào được tới màn hình chính có thể tương tác, không tính ở các bước trước đó (xác nhận điều khoản, chờ game load..)
  • Session kết thúc khi user nhấn nút Xác nhận thoát game hoặc lúc game có reload.
  • Một session có thể gắn với nhiều event_id khác nhau.
sdk.gameLogin();

Stage Start

  • Thời điểm nhấn nút bắt đầu màn chơi, ván chơi hoặc sử dụng lượt chơi.
  • Một session có thể bao gồm nhiều stage.
  • Các game cho phép user bắt đầu màn chơi ngay thời điểm load game thành công thì stage_start chính là thời điểm bắt đầu session.
sdk.stageStart();

Game Item Change

  • Thời điểm tăng giảm lượt chơi game, hoặc nhận và dùng item game, hoặc sử dụng currency nào đó trong game.
  • Params:
    • action: thao tác gây thay đổi, ví dụ: shake, openchest.
    • amount: số lượng item ảnh hưởng.
    • item_id: mã item.
    • is_added: user được tăng item với thao tác này hay ngược lại (giảm item)
sdk.gameItemChange(action: string, amount: number, itemId: string, is_added: boolean);

Stage End

  • Tời điểm kết thúc màn chơi tức chiếu thắng, thua cuộc hoặc chuyển sang màn chơi khác.
  • Params:
    • is_win: chiến thắng hay thua, các game dạng endless thì kết quả luôn là false.
    • stage_point: điểm số ghi được từ stage.
    • stage_level: cấp độ màn chơi, thứ tự màn chơi tại thời điểm kết thúc.
sdk.stageEnd(is_win: boolean, stage_point: number, stage_level: number);

Game Logout

  • Thời điểm user kết thúc session.
  • Params:
    • win_count: tổng số lần chiến thắng trong session.
    • lose_count: tổng số lần thua trong session.
    • best_session_point: điểm số cao nhất ghi được từ session.
sdk.gameLogout(win_count: number, lose_count: number, best_session_point: number);