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 🙏

© 2025 – Pkg Stats / Ryan Hefner

axe4js

v0.1.2

Published

axe interface using in javascript

Downloads

11

Readme

axe-js

使用 WebViewJavaScriptBridge 以支持在h5页面中使用 axe.

使用

npm install axe4js --save

接口声明

main.d.ts文件

数据类型说明

基础数据类型

  • Number : 数字
  • String : 字符串
  • Array: 列表
  • Object : 对象

需要注意,如果要在js模块中使用原生设置的 ArrayObject对象,就要求原生传入的是纯基础数据类型,其中不能设置特殊类型。

特殊类型

  • Image : 图片,js中设置和获取的图片类型为 , data:image/jpeg;base64,xxx 这种形式的URI形式的字符串。
  • Data: 数据类型, 对于ios中的NSData类型。 js中设置和获取的是 base64字符串.
  • Date: 时间类型
  • Boolean:

这里我们实现了 js模块和原生模块之间的特殊类型传递。

Model类型

在Axe中提及的 Model类型,指可以进行序列化,且一般从后台获取的Model类型。

JS中设置的Model类型,是一个Object对象,键值需要是基础数据类型,不能嵌套一些特殊类型。

如果声明了一个model类型, 在设置时,一定要包含所有的key值, 对于空值,一定要设置为null类型。

如,我们在文档中声明了一个model

{
	userName,
}

当设置的model类型,userName为空时, 必须要设置为null,而不是默认的undefined 。 否则原生模块获取时会出错。

如果一个原生模块要传递ModelJS模块,则该Model类型,必须是纯基础数据类型构成,不能包含特殊类型。

注意Event

事件回调是一个闭包, 而闭包会持有对象,容易导致内存泄漏 (当路由跳转时,新页面监听了事件,然后在路由返回到之前页面,则这个监听没有释放,就可能导致内存泄漏,且事件发送时会产生异常)。

所以事件监听要特别注意,在 demo-test-h5 中,我们实现了两种 基于Vue单页面应用的Event封装, 以避免 重复注册和内存泄漏。

使用示例

注意事项

  1. 所有的js模块注册的监听,都是UI监听,即只有当页面在前台展示时,才会调用。
  2. axe主要用于业务模块间的信息传递和数据共享,不要用于模块内的业务逻辑。
  3. sharedData的get接口是异步接口
  4. 在模块声明时,要说明跳转是否支持回调,以及是否必须拥有回调。
  5. 路由信息的获取,与路由回调,都是跟随webview的,所以如果是单页面应用,需要注意这一点,避免在B页面错误地获取了A页面的信息和回调了A页面的回调函数。