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

@kookapp/kook-bridge-channel

v1.0.8

Published

``` npm install @kookapp/kook-bridge-channel ```

Downloads

83

Readme

KOOK-Bridge-Channel

安装

npm install @kookapp/kook-bridge-channel

Server 端

import { createChannelServer } from 'kook-bridge-channel'

const server = createChannelServer({ originList: ['实际应用的 location.origin'] })

server.on('request', ({ eventName, data }, send) => {
  // router
  // switch eventName ...
  // response  send()
})

server.on('subscribe', ({ eventName, data }, send, { client }) => {
  // switch eventName ...
  // client.subscribeNotify
  // 示例:
  function callback() {
    client.subscribeNotify(eventName, { date: Date.now() })
  }
  eleButton.addEventListener('click', callback)
  client.listenDestroy(() => {
    eleButton.removeEventListener('click', callback)
  })
})

Client 端

import { createChannelClient } from 'kook-bridge-channel'

const client = createChannelClient()

await client.createChannel({ originList: ['实际应用的 location.origin'] })

client.request(eventName, data).then(() => {})

client.subscribe(eventName, (data) => {
  console.log(eventName, data)
})

client.on('error', () => {
  // 心跳超时可以尝试重新创建 Channel ( request 响应超时同样可以尝试重新创建 Channel )
  // ** 新 channel 之前的 subscribe 需要重新订阅
  // client.closeChannel()
  // client.createChannel({ originList: [] })
})

中间层传递创建 Channel 消息

import { KOOKChannelHelper } from 'kook-bridge-channel'

KOOKChannelHelper.createPipe(win1, win2, { originList: [] })

History version

  • v1.0.8
    • 升级依赖 @kookapp/k-jsbridge 版本
  • v1.0.7
    • 修改 npm 依赖
  • v1.0.6
    • 增加 test 测试页面
    • 增加 subscribe 逻辑
    • 增加 server client 超时 destroy 逻辑
  • v1.0.5
    • 修复移动端环境判断必须是在顶级窗口才可使用 Bridge
  • v1.0.4
    • 修改移动端 BridgeClient.createChannel 统一返回 Promise
    • 修复 Electron KOOKChannelHelper.createPipe 无法正确处理创建 channel