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

luks-sdk

v1.1.0

Published

```bash npm i luks-sdk ```

Readme

安装

npm i luks-sdk

用法

import LuksSdk from 'luks-sdk';
/**
 * appId: LUKSDK提供的渠道id
 * language: 游戏内使用的语言
 * apiUrl: api地址
 * wsUrl: websocket地址
 */
const luksSdk = new LuksSdk(1, 'zh-CN', 'https://api.xxxx', 'https://xxxxx/websocket');

CDN 用法

<script src="https://unpkg.com/[email protected]/dist/luksSdk-iife.js"></script>
<script>
    const luksSdk = new LuksSDK(1, 'zh-CN', false)
</script>

Api 方法

初始化

    // (appId: number, language: string, product: boolean)
    const luksSdk = new LuksSDK(1, 'zh-CN', false)

设置用户信息(Promise)

    // (userId: string, userCode: string)
    luksSdk.setUserInfo('123', '123')

设置业务回调接口

    /**
     * 
    * export interface ICFBizCallback {
        onOpenChargePage?: () => void | Promise<void>
        onGetCurrentRoomId?: () => string | Promise<string>
        onIsRoomOwner?: () => boolean | Promise<boolean>
        onWindowSafeArea?: () => SafeArea | Promise<SafeArea>
        getBaseInfo?: () => BaseInfo | Promise<BaseInfo>
    }
    * export interface SafeArea {
        left?: number,
        top?: number,
        right?: number,
        bottom?: number,
        scaleMinLimit: number
    }

    export interface BaseInfo {
        cid: string,     //渠道id
        gid: string,     //游戏id
        uid: string,     //渠道用户id
        token: string,   //sdk平台令牌
        version: string, //客户端sdk版本号
        language: string,//语言
        widow: string,   //窗囗大小->"宽度x高度'
        rid: string,     //当前房间号
        room_owner: boolean, //是否房主
        ext: string, // 接入方透传数据
    }
    */
   luksSdk.setBizCallback(callback: ICFBizCallback)

拉起一个游戏列表弹窗,其中包含接入方已获得授权的所有游戏

  • 待完善

从服务端获取游戏列表信息(Promise)

    luksSdk.getGameList()

加载半屏游戏(Promise)

    // container: '.className' || document.getElementById('receiver')
    luksSdk.startHalfWindowGame(container: string | HTMLElement, gameId: string, url: string)

加载全屏游戏(Promise)

    // container: '.className' || document.getElementById('receiver')
    luksSdk.startFullWindowGame(container: string | HTMLElement, gameId: string, url: string)

加载横屏游戏(Promise)

    // container: '.className' || document.getElementById('receiver')
    luksSdk.startLandscapeWindowGame(container: string | HTMLElement, gameId: string, url: string)

日志回调

    /**
     * export type LogFn = (tag: string, msg: string) => void
        export interface ICFLogger {
            onDebug?: LogFn
            onInfo?: LogFn
            onWarn?: LogFn
            onError?: LogFn
        }
     */
    luksSdk.setLogger(logger: ICFLogger)

游戏生命周期回调

    /**
     * export interface PreJoinGameRes {
        is_ready: boolean;
        seat: number;
    }

    export interface ICFGameLifecycle {
        onGameLoadFail?: () => void | Promise<void>
        onPreJoinGame?: (userId: string, seat: number) => PreJoinGameRes | Promise<PreJoinGameRes>
        onJoinGame?: (userId: string) => void | Promise<void>
        onGamePrepare?: (userId: string) => void | Promise<void>
        onCancelPrepare?: (userId: string) => void | Promise<void>
        onGameTerminated?: (userId: string) => void | Promise<void>
        onGameOver?: () => void | Promise<void>
        onGameDidFinishLoad?: () => void | Promise<void>
        getGameloadProgress?: (progress: number) => void | Promise<void>
        onSeatAvatarTouch?: (userId: string, seat: number) => void | Promise<void>
        closeGamePage?: () => void | Promise<void>
        gameStateChange?: (parameter: string) => void | Promise<void>
        playerStateChange?: (parameter: string) => void | Promise<void>
        gameLoadSuccess?: () => void | Promise<void>
    }
     */
    luksSdk.setCFGameLifecycle(lifecycle: ICFGameLifecycle)

推拉流接口

    /**
     *  export interface RTCRes {
            complete: boolean;
        }
     *  export interface ICFRTCCallback {
            onCFGamePushSelfRTC?: (push: boolean) => RTCRes | Promise<RTCRes>
            onCFGamePullOtherRTC?: (userId: string, pull: boolean) => RTCRes | Promise<RTCRes>
        }
     */
    luksSdk.setRTCCallback(callback: ICFRTCCallback)

销毁游戏

    luksSdk.destroyGame()

销毁游戏

    luksSdk.gameReload(): void;

刷新用户信息

    luksSdk.refreshUserInfo()

开始游戏

    luksSdk.gameStart()

移除游戏玩家

    luksSdk.playerRemove(userId: string)

是否关闭游戏背景音乐

    luksSdk.gameBackgroundMusicSet(open: boolean)

是否关闭游戏音效

    luksSdk.gameSoundSet(open: boolean)

设置游戏角色

    luksSdk.setPlayerRole(role: number)

退出游戏

    luksSdk.quitGame(userId: string)

终止游戏

    luksSdk.terminateGame(userId: string)

加入游戏

    luksSdk.joinGame(seatIndex: number)

暂停游戏

    luksSdk.pauseGame()

继续游戏 (用于结束暂停的状态)

    luksSdk.playGame()

SDK控制游戏专题接口

    appCallGame<T extends keyof AppCallGameDataType>({ state, data }: {state: T, data?: AppCallGameDataType[T]}): void;

傻瓜化接入方式

  • 方法一
    import LuksSdk from 'luks-sdk';
    import 'luks-sdk/dist/index.css';
    const luksSdk = new LuksSdk(1, 'zh-CN', false);
    /**
     * container 展示列表容器,打开游戏后容器会被游戏覆盖
     * instance sdk实例
     */
    luksSdk.showGameListDialogshowGameListDialog(container: string, instance: LuksSDK)
  • 方法二(CND)
    <body>
        <div id="receiver" style="width:100%;height:200px;"></div>
    </body>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/index.css"/>
    <script src="https://unpkg.com/[email protected]/dist/luksSdk-iife.js"></script>
    <script>
        window.onload = function() {
            const luksSdk = new LuksSDK(1, 'zh-CN', false)
            luksSdk.showGameListDialog('#receiver', luksSdk)
        }
    </script>