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

pg-release

v0.0.21

Published

new u51 pg sdk.

Readme

New phonegap module

全新的壳交互SDK。

Usage

npm install --save pg-release

cmd调用:

引用文件为:

build/index.js

import { logger, gapper } from 'pg-release';

const pg = new gapper();
const log = new logger();

你也可以这样使用:

<script src="pg-release.js"></script>

pc调用:

引用文件为:

build/pc.js

const gapper = NativeScript.logger;
const logger = NativeScript.gapper;

const pg = new gapper();
const log = new logger();

壳交互使用方法

pg.exec(name[, args[, errors]]);

  • 输入:

    • Arguments:
      • name: {string} 方法名
      • args: {object|*} 参数
      • errors: 错误代码{json}描述
  • 输出:

    • 统一返回Promise对象。

壳交互使用普通写法

var Alert = pg.exec('alert');
Alert.then(function(result){
    console.log(result.index);
}).catch(function(e){
    console.log(e.message);
})

壳交互使用es7写法

const fn = async function(){
    return await pg.exec('alert');
}

fn().then(...).catch(...);

内置公司PG交互方法集合

点击查看方法集合

示例:

const fn = async function(){
    return await pg.shareToAll(title, content, url, iconLink);
}

fn().then(...).catch(...);

每个独立方法都是一个async函数,也就是Promise对象。

安卓回退按钮触发事件绑定

事件名:androidBackKeyPress

针对安卓特殊的回退按钮,我们使用事件机制来同步绑定,请看代码:

pg.on('androidBackKeyPress', function(){
    // ...
    // 这里处理你自己的回退方法
})

使用公司埋点

var logger = new window.NativeScript.logger();
var pg = new window.NativeScript.gapper();
logger.modify(function(result){
    result.service = 'guangjia';
    //console.log(result);
});
pg.onLogEvent(
        {
            "current_event": "当前事件编码,H5页面时等效老的type",
            "previous_event": "来源事件",
            "current_page": "当前页面",
            "previous_page": "来源页面",
            "start_time": "开始时间long型",
            "end_time": "结束时间long型",
            "msg": "备注消息"
        },
        {  /*保留对象*/
            "rqd": {},
            "rsd": {}
        }
);

onLogEvent 接受2个参数eventsretention.

logger.modify

用来全局改变配置参数

logger.modify(function(result){
    result.service = 'guangjia';
    //console.log(result);
    // 你可以查看result数据结构来改变数据
    // 具体数据结构请参阅文档
});

文档地址

埋点将自动匹配设备类型,如果在我们51的app中,将使用pg壳交互发送。否则会检测当前可用的fetch函数来发送。

注意: 我们在一些安卓机器上使用来函数window.navigator.sendBeacon来后台发送请求,增强容错率。

与老的PG结合实现兼容方法

import { gapper } from 'pg-release';

const pg = new gapper();
window.PG = pg;

请注意最后一句代码,必须写!