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

alloy-worker

v1.4.0

Published

面向事务的高可用 Web Worker 通信框架

Downloads

3

Readme

alloy-worker

面向事务的高可用 Web Worker 通信框架.

腾讯 AlloyTeam 出品, 经受住腾讯文档等大型前端项目的考验.

特点

  • 面向事务及命名空间的通信封装, 支持大规模业务的场景.
  • Promise 化调用代替跨线程事件监听, 无缝支持 async/await.
  • 完整的 Worker 可用性监控指标; 全周期 Worker 错误监控.
  • 源码全 TypeScript, 跨线程数据类型一致性校验.
  • 跨线程请求和响应的数据流调试.
  • 良好支持 IE10+ 浏览器.
  • 独立打包的构建支持, 无需自行配置.

业界方案对比

| 项目 | 简介 | 构建打包 | 底层API封装 | 跨线程调用申明 | 可用性监控 | 易拓展性 | | - | - | :-: | :-: | :-: | :-: | :-: | | worker-loader | Webpack 官方,源码打包能力 | ✔️ | ✘ | ✘ | ✘ | ✘ | | promise-worker | 封装基本 API 为 Promise 化通信 | ✘ | ✔️ | ✘ | ✘ | ✘ | | comlink | Chrome 团队, 通信 RPC 封装 | ✘ | ✔️ | 同名函数(基于Proxy) | ✘ | ✘ | | workerize-loader | 社区目前比较完整的方案 | ✔️ | ✔️ | 同名函数(基于AST生成) | ✘ | ✘ | | alloy-worker | 面向事务的高可用 Worker 通信框架 | 提供构建脚本 | 通信️控制器 | 同名函数(基于约定), TS 声明 | 完整监控指标, 全周期错误监控 | 命名空间, 事务生成脚本 |

Demo

(图片上右键新窗口打开可查看视频)

代码示例

以 Worker 线程发起跨线程调用到主线程取页面 cookie 为例.

用法

本地调试

$ git clone https://github.com/AlloyTeam/alloy-worker.git
$ git checkout demo
$ npm install && npm run dist
$ npx http-server -c0 ./dist
Available on:
  http://127.0.0.1:8080

打开 http://127.0.0.1:8080 和 http://127.0.0.1:8080/image.html 进行本地调试.

接入

alloy-worker 需要你手动将它融合到你的项目里, 并成为项目源码的一部分. 好在手动也不复杂, 而且不会影响现有业务.

接入步骤, 请查看这里.

使用

alloy-worker 对原始 Web Worker 通信能力进行了 RPC 封装, 约定了 Worker 代码组织方式. 使用 alloy-worker 开发 Worker 侧业务时, 需对齐 alloy-worker 的约定.

约定不复杂, 请查看这里.

使用反馈

如果你的项目使用 alloy-worker 并觉得它不错, 请到 这里 告诉我们.

贡献源码

请查看参与开发.

相关文档

https://todo.com

TODO

  • 兼容 webpack5 构建
  • 解决纯 worker 侧代码更新的 hash 问题
  • sourcemap 区分不同线程的源码

EOF