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

@keqi.gress/plugin-bridge

v1.0.0

Published

Gress 插件桥接核心包 - 提供插件与宿主应用通信的标准 API

Downloads

16

Readme

@gress/plugin-bridge

Gress 插件桥接核心包 - 提供插件与宿主应用通信的标准 API

📦 安装

npm install @gress/plugin-bridge
# or
yarn add @gress/plugin-bridge
# or
pnpm add @gress/plugin-bridge

🚀 快速开始

在主应用中创建插件桥

import { createPluginBridge, exposePluginBridge } from '@gress/plugin-bridge'

const bridge = createPluginBridge({
  app,
  router,
  pinia,
  http: requestClient,
  permissions: [
    PluginPermission.NETWORK_ACCESS,
    PluginPermission.ROUTER_NAVIGATE,
    // ... 其他权限
  ]
})

// 暴露给插件使用
exposePluginBridge(bridge)

在插件中使用桥接功能

import { useHostBridge, useIcon } from '@gress/plugin-bridge'

// 获取宿主能力
const { router, message, http, events } = useHostBridge()

// 路由导航
router.push('/some-path')

// 显示消息
message.success('操作成功')

// HTTP 请求
const data = await http.get('/api/data')

// 使用图标
const HomeIcon = useIcon('HomeOutline')

📚 API 文档

Composables

useHostBridge()

获取宿主桥接对象,提供对主应用能力的访问。

返回值:

  • bridge - 完整的桥接对象
  • router - 路由 API
  • route - 当前路由
  • message - 消息提示 API
  • dialog - 对话框 API
  • notification - 通知 API
  • loadingBar - 加载条 API
  • http - HTTP 客户端
  • events - 事件总线
  • utils - 工具函数

useIcon(iconName: string)

获取图标组件。

const HomeIcon = useIcon('HomeOutline')

useIcons(iconNames: string[])

批量获取图标组件。

const icons = useIcons(['HomeOutline', 'AddOutline', 'SearchOutline'])

核心功能

createPluginBridge(options)

创建插件桥实例(主应用使用)。

createPluginContext(pluginId, manifest, bridge)

创建插件上下文(插件系统内部使用)。

createEventEmitter()

创建事件发射器。

🔒 权限系统

插件需要声明所需权限:

export const manifest: PluginManifest = {
  id: 'my-plugin',
  name: 'My Plugin',
  version: '1.0.0',
  permissions: [
    PluginPermission.NETWORK_ACCESS,
    PluginPermission.ROUTER_NAVIGATE,
    PluginPermission.DATA_READ
  ]
}

可用权限:

  • NETWORK_ACCESS - 网络访问
  • ROUTER_NAVIGATE - 路由导航
  • ROUTER_REGISTER - 注册路由
  • COMPONENT_REGISTER - 注册组件
  • DATA_READ - 读取数据
  • DATA_WRITE - 写入数据
  • SYSTEM_NOTIFICATION - 系统通知

📄 License

MIT