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

@amoy/webridge

v0.0.24

Published

# 使用方式

Downloads

28

Readme

Webridge

使用方式

容器方

import { webridge } from '@amoy/webridge'

// 打开一个页面
// @ url:  需要打开的页面地址
// @ data:  传递给新开页面的数据
// @ config: 配置 iframe
webridge.open(url: string, data: any, config: {
    // iframe 宽度
    width?: number
    // 高度
    height?: number
    // 坐标
    x?: number
    y?: number
    // 背景颜色
    backgroundColor?: string | number
    // 是否自动显示
    autoShow?: boolean
    // 加载完成
    onload?: (ifr: HTMLIFrameElement) => void
})

// 预加载页面
// 会提前在后台创建一个 iframe 并缓存
// 参数与 open 一致
webridge.preload(url: string, data, config)

// 关闭指定 iframe
// @refresh: 是否彻底关闭 iframe,用于适配不同场景
//      true: 彻底关闭,下次 open 需重新加载;
//      false: 保持状态隐藏,下次 open 会直接显示;
webridge.close(iframe: HTMLIFrameElement, refresh: boolean)

// 事件机制,可用于父子级 双向交互
webridge.on(evName: string, callback: (...data: any) => any)

webridge.emit(evName: string, data: any)

页面方

页面方同样可调用容器方 API, 例如 on / emit / open;

import { webridge } from '@amoy/webridge'

// 兼容性生命周期
//      - 当在容器中, 则 当页面显示时被调用,ready 外的代码会再显示前被执行;
//      - 当不在容器中, 则在 DOMContentLoad 时触发
//
// @ data: 容器 open 时传递的数据
webridge.pageReady(cbk: (...data: any) => void)
webridge.pageShow(cbk: (...data: any) => void)

// 加载完成, 调用后会触发 pageReady
// 配合父级 open 时 autoShow: false 时使用
webridge.loaded(show: boolean = true)
// 当 show = false 时,pageReady 会被触发,但页面不会展示
// 显示页面
webridge.show()

// 关闭自身页面,回到容器页面
// @refresh: 是否彻底关闭 iframe,用于适配不同场景
//      true: 彻底关闭,下次 open 需重新加载;
//      false: 保持状态隐藏,下次 open 会直接显示;
webridge.close(refresh?: boolean)