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

falla-game-bridge

v2.8.0

Published

Falla APP 第三方游戏通讯桥

Downloads

21

Readme

falla-game-bridge

Falla APP 第三方游戏客户端通讯桥。

Usage

// Cocos 环境下使用require引入
const fallaGameBridge = require('falla-game-bridge')

// 主动退出当前页面
fallaGameBridge.closeWebView()

// 重新加载webview当前网页(房间半屏webview、全屏webview都支持)
fallaGameBridge.reload()

// 重新加载房间半屏 游戏tab 关联的url(仅房间半屏webview有效)
fallaGameBridge.reloadRoomGameTab()

// 跳转金币充值页面
fallaGameBridge.gotoWallet({
  moduleName: 'Slots',
  index: 0
})

// 充值成功后的回调
fallaGameBridge.onRechargeSuccess(() => {
  // TODO: 获取最新金币更新界面
})

// 监听 webview 显示;如:跳转到充值页面后,返回到webview页面;最小化应用回到当前APP:仅android支持
fallaGameBridge.onWebViewShow(() => {
  // TODO
})

// 监听APP切换到后台:回到系统桌面或切换到其他APP
fallaGameBridge.onAppPause(() => {
  // TODO
})

// 监听APP切回到前台:从系统桌面切回到当前APP的页面
fallaGameBridge.onAppResume(() => {
  // TODO
})

// 监听网页关闭:客户端关闭网页前,先回调web注册的监听事件;执行完成后,在销毁当前页面
fallaGameBridge.onWebviewClose(() => {
  // TODO
})

// 获取用户的设备信息
/**
 * deviceInfo示例:
 {
   "os": "ios",
   "mac": "47b2dd7dc3d31561ef6d4d6ea8835797c8e302f5",
   "platform": 1,
   "language": "zh-Hans",
   "version": "5.0.0",
   "systemVersion": "14.8.1",
   "deviceModel": "iPhone 7 Plus"
 }
 */
const deviceInfo = fallaGameBridge.getUserDeviceInfo()

// 复制字符串,异步方法,返回布尔值
const result = await fallaGameBridge.copy('可复制任意字符');

游戏半屏新增API(12-14)

// Cocos 环境下使用require引入
const fallaGameBridge = require('falla-game-bridge')

// TODO: 检查游戏是否存在金币变
const checkCoinChangeStatus = () => {
  return true
}

// 1、项目初始化成功后,监听金币同步
fallaGameBridge.onCoinSync(() => {
  const coinChangeStatus = checkCoinChangeStatus()
  if (!coinChangeStatus) {
    return fallaGameBridge.notifyCoinFreeze({
      coinChangeStatus
    })
  }
  // NOTE: transactionId 字符预估最长的长度为75,组成规则:uid_设备MAC_随机数_时间戳
  // TODO: 如果担心过长,业务方自行MD5或加密,SDK内部不提供加密处理;业务方如果能保证生成的参数唯一,也可以自行生成
  const transactionId = fallaGameBridge.generateTransactionId()
  fallaGameBridge.notifyCoinFreeze({
    coinChangeStatus,
    transactionId,
    appId: 'xxxx'
  })
  // TODO: 与服务端通讯进行金币结算,需传递上面的 transactionId
})

// 2、项目初始化成功后,监听 webview 显示(半屏游戏在房间最小化,再次激活会触发该事件)
fallaGameBridge.onWebViewShow(() => {
  // TODO:获取最新金币更新界面
})

房间半屏进度加载管理

房间半屏弹窗,在打开和切换的时候,会优先显示APP的loading进度管理,针对APP加载流程,暴露了一套API,需要业务方自行管理好对应的状态。

  • 更新web加载进度:updateWebLoadProgress(progress: number)
  • 网页加载完成:webLoadFinish()
  • 网页加载出错:webLoadError()
  • 主动隐藏房间半屏游戏: closePopupWebView()
// 接收整数,为了更好的体验,游戏的进度条默认从50%开始
// 当传递的值>=100时,会自动触发webLoadFinish()
fallaGameBridge.updateWebLoadProgress(100)

// 网页加载完成,隐藏默认Loading界面
fallaGameBridge.webLoadFinish()

// 显示网页加载出错页面
fallaGameBridge.webLoadError()

// 主动隐藏房间半屏游戏
fallaGameBridge.closePopupWebView()