{"id":13901360,"url":"https://github.com/AlloyTeam/alloy-worker","last_synced_at":"2025-07-17T22:30:29.899Z","repository":{"id":38410542,"uuid":"248209536","full_name":"AlloyTeam/alloy-worker","owner":"AlloyTeam","description":"面向事务的高可用 Web Worker 通信框架","archived":false,"fork":false,"pushed_at":"2021-11-10T07:43:20.000Z","size":853,"stargazers_count":641,"open_issues_count":6,"forks_count":52,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-07T21:45:26.808Z","etag":null,"topics":["channel","comunication","postmessage","thread","web-worker","webworker","worker"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlloyTeam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-18T11:11:13.000Z","updated_at":"2024-06-19T10:58:19.000Z","dependencies_parsed_at":"2022-07-16T23:30:40.763Z","dependency_job_id":null,"html_url":"https://github.com/AlloyTeam/alloy-worker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloyTeam%2Falloy-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloyTeam%2Falloy-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloyTeam%2Falloy-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloyTeam%2Falloy-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlloyTeam","download_url":"https://codeload.github.com/AlloyTeam/alloy-worker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226305361,"owners_count":17603797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["channel","comunication","postmessage","thread","web-worker","webworker","worker"],"created_at":"2024-08-06T21:01:16.272Z","updated_at":"2024-11-25T09:31:21.343Z","avatar_url":"https://github.com/AlloyTeam.png","language":"TypeScript","readme":"# alloy-worker\n\n\u003e 面向事务的高可用 Web Worker 通信框架.\n\n腾讯 [AlloyTeam](https://github.com/AlloyTeam) 出品, 经受住腾讯文档等大型前端项目的考验.\n\n## 特点\n\n* 面向事务及命名空间的通信封装, 支持大规模业务的场景.\n* Promise 化调用代替跨线程事件监听, 无缝支持 async/await.\n* 完整的 Worker 可用性监控指标; 全周期 Worker 错误监控.\n* 源码全 TypeScript, 跨线程数据类型一致性校验.\n* 跨线程请求和响应的数据流调试.\n* 良好支持 IE10+ 浏览器.\n* 独立打包的构建支持, 无需自行配置.\n\n## 业界方案对比\n\n| 项目 | 简介 | 构建打包 | 底层API封装 | 跨线程调用申明 | 可用性监控 | 易拓展性 |\n| - | - | :-: | :-: | :-: | :-: | :-: |\n| [worker-loader](https://github.com/webpack-contrib/worker-loader) | Webpack 官方,源码打包能力 | ✔️ | ✘ | ✘ | ✘ | ✘ |\n| [promise-worker](https://github.com/nolanlawson/promise-worker) | 封装基本 API 为 Promise 化通信 | ✘ | ✔️ | ✘ | ✘ | ✘ |\n| [comlink](https://github.com/GoogleChromeLabs/comlink) | Chrome 团队, 通信 RPC 封装 | ✘ | ✔️ | 同名函数(基于Proxy) | ✘ | ✘ |\n| [workerize-loader](https://github.com/developit/workerize-loader) | 社区目前比较完整的方案 | ✔️ | ✔️ | 同名函数(基于AST生成) | ✘ | ✘ |\n| [alloy-worker](https://github.com/AlloyTeam/alloy-worker) | 面向事务的高可用 Worker 通信框架 | 提供构建脚本 | 通信️控制器 | 同名函数(基于约定), TS 声明 | 完整监控指标, 全周期错误监控 | 命名空间, 事务生成脚本 |\n\n## Demo\n* [Web Worker 能力测试](https://alloyteam.github.io/alloy-worker/index.html)\n\n![](https://user-images.githubusercontent.com/4598445/87221688-8a423580-c3a0-11ea-9aef-d8028fdc4969.gif)\n\n* [图像处理 Demo](https://alloyteam.github.io/alloy-worker/image.html)\n\n[![](https://user-images.githubusercontent.com/4598445/87221671-61ba3b80-c3a0-11ea-9a13-d43f271519af.jpg)](https://alloyteam.github.io/alloy-worker/docs/img/image-demo.mp4)\n*(图片上右键新窗口打开可查看视频)*\n\n## 代码示例\n\n以 Worker 线程发起跨线程调用到主线程取页面 cookie 为例.\n\n![](https://user-images.githubusercontent.com/4598445/87221679-7696cf00-c3a0-11ea-865c-66b174a8744a.jpg)\n\n## 用法\n### 本地调试\n```sh\n$ git clone https://github.com/AlloyTeam/alloy-worker.git\n$ git checkout demo\n$ npm install \u0026\u0026 npm run dist\n$ npx http-server -c0 ./dist\nAvailable on:\n  http://127.0.0.1:8080\n```\n\n打开 http://127.0.0.1:8080 和 http://127.0.0.1:8080/image.html 进行本地调试.\n\n### 接入\n\nalloy-worker 需要你手动将它融合到你的项目里, 并成为项目源码的一部分. 好在手动也不复杂, 而且不会影响现有业务.\n\n接入步骤, [请查看这里][alloy-worker 接入教程].\n\n### 使用\n\nalloy-worker 对原始 Web Worker 通信能力进行了 RPC 封装, **约定了 Worker 代码组织方式**. 使用 alloy-worker 开发 Worker 侧业务时, 需对齐 [alloy-worker 的约定][alloy-worker 代码约定].\n\n约定不复杂, [请查看这里][alloy-worker 使用教程].\n\n## 使用反馈\n\n如果你的项目使用 alloy-worker 并觉得它不错, 请到 [这里](https://github.com/AlloyTeam/alloy-worker/issues/1) 告诉我们.\n\n## 贡献源码\n\n请查看[参与开发](./CONTRIBUTING.md).\n\n## 相关文档\n\n[alloy-worker 接入教程]: https://github.com/AlloyTeam/alloy-worker/wiki/alloy-worker-%E6%8E%A5%E5%85%A5%E6%95%99%E7%A8%8B\n* [alloy-worker 接入教程][alloy-worker 接入教程]\n\n[alloy-worker 代码约定]: https://github.com/AlloyTeam/alloy-worker/wiki/alloy-worker-%E4%BB%A3%E7%A0%81%E7%BA%A6%E5%AE%9A\n* [alloy-worker 代码约定][alloy-worker 代码约定]\n\n[alloy-worker 使用教程]: https://github.com/AlloyTeam/alloy-worker/wiki/alloy-worker-%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B\n* [alloy-worker 使用教程][alloy-worker 使用教程]\n\n[alloy-worker 技术细节]: https://github.com/AlloyTeam/alloy-worker/wiki/alloy-worker-%E6%8A%80%E6%9C%AF%E7%BB%86%E8%8A%82\n* [alloy-worker 技术细节][alloy-worker 技术细节]\n\n* [Web Worker 文献综述](https://github.com/CntChen/cntchen.github.io/issues/19)\n\n* [朝花夕拾: Web Worker 大型前端项目实践](https://github.com/CntChen/for-slides/blob/master/webworker.pdf)\n\n## TODO\n* 兼容 webpack5 构建\n* 解决纯 worker 侧代码更新的 hash 问题\n* sourcemap 区分不同线程的源码\n\n## EOF\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlloyTeam%2Falloy-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlloyTeam%2Falloy-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlloyTeam%2Falloy-worker/lists"}