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

super-jssdk

v1.0.0

Published

a jssdk for cordova plugins

Downloads

1

Readme

super-jssdk 使用文档

概述

super-jssdk 是一个在 Cordova 插件基础上做二次封装的 SDK,抹平 Cordova 插件不同版本、不同系统之间的差异,提供统一的 API 供外部团队使用。

使用说明

1、下载及引用

  • 使用 npm 安装, import 方式按需引入具体方法
cnpm install @yl/super-jssdk
import { init, getDeviceInfo, …… } from @yl/super-jssdk
  • 使用 script 标签,设置全局变量 MYSDK 挂载到 window
<script src="https://scp-minio-test.myyscm.com/test-cgsaas/d17a4897-6b0e-41a2-bee3-56892999981c/12bac0bf43ba6b7186dd83ab2aa81bde.js"></script>

window.MYSDK.init()
window.MYSDK.getDeviceInfo()
……

2、通过 init 接口注入初始化配置并初始化 SDK

使用 SDK 前必须先初始化 SDK,否则将无法调用,全局调用一次即可,并可传入初始化配置。

  • 默认初始化配置
{
  mock: false  // 非 Cordova 环境下是否需要模拟数据,默认 false
}
  • 初始化方法调用示例
init({mock: true})
  .then(res => {
    console.log('SDK 初始化成功');
    // TODO 调用插件
    // ……
  })
  .catch(err => {
    console.log('SDK 初始化失败');
  })

3、接口调用入参

所有入参统一由一个对象传入,包括必填参数和可扩展参数,具体参数详情查看具体插件使用文档。

4、接口返回参数

所有接口返回统一为一个 promise,插件成功调用后的结果通过 then 方法获取,失败的接口由 catch 方法获取,其他过程中的结果通过传入回调函数执行获取。其中错误数据定义标准数据格式进行描述,具体格式如下:

{
  errCode: xxx,
  errMsg: xxx
}

错误code定义

errCode: -1 // 插件内部错误
errCode: 10000 // 插件未安装
errCode: 10001 // 设备绑定失败
errCode: 10002 // 插件初始化错误
errCode: 10003 // 超时
errCode: 10004 // 参数不合法
errCode: 10008 // 插件方法不存在

5、注意事项

提供的 npm 包未设置垫片,若有需求需自行设置

API 列表

1、初始化

SDK 初始化:init

2、设备信息

获取设备信息:getDeviceInfo 判断是否是 IOS:isIOS 判断是否是 Android:isAndroid 运行环境从后台切换到前台:resume 运行环境从前台切换到后台:pause

3、获取路径相关信息

获取大文件文件夹路径:getBigFileDir 获取临时文件的路径:getOccasionalFilePath 获取完整路径:getFullPath 获取路径前缀:getPrefixPath 获取Web代码所在的目录:getWebCodeDir 获取在ios的wkWebview上使用的路径:getWebViewPath

4、通用方法

通用方法:MUtils

5、具体插件

mpush消息推送:PushNotification 下载插件:MDownloader 数据存储:MMKV 数据库:SqlitePlus 图片预览:MImageBrowser 图片选择:MImagePicker