{"_id":"@1-/proto2js","_rev":"6-7fc4499c4478d3d21db6a0a1479f4d55","name":"@1-/proto2js","dist-tags":{"latest":"0.1.6"},"versions":{"0.1.1":{"name":"@1-/proto2js","version":"0.1.1","keywords":["codegen","grpc","javascript","proto","protobuf"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/proto2js@0.1.1","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","bugs":{"url":"https://github.com/webc-site/npm/issues"},"bin":{"proto2js":"cli.js"},"dist":{"shasum":"be1f7c6d640523579b3576e97cada4e1700fddd6","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.1.tgz","fileCount":8,"integrity":"sha512-vq34wnU+z65cpq6YPg30dFe3Yl2rlrJeouarVn3tpmqZjU1ILrN/la730g2Y+Beuco0UhZpPDyABr9Paem3t7Q==","signatures":[{"sig":"MEUCIQClReL7jzCNoo3+efa2xFoUZ62Hf+HgZb5DU0qVOkkIOwIgRfpyxFs3FgNGkJwR7jqzqsssRj5EdXW9wBK8gafmobM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17809},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","directories":{},"_nodeVersion":"26.2.0","dependencies":{"yargs":"^18.1.0","@3-/read":"^0.1.4","@3-/write":"^0.1.2","proto-parser":"^0.0.9","@3-/proto_remove_comment":"^0.1.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/proto2js_0.1.1_1786704144761_0.6131826540350374","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@1-/proto2js","version":"0.1.2","keywords":["codegen","grpc","javascript","proto","protobuf"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/proto2js@0.1.2","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","bugs":{"url":"https://github.com/webc-site/npm/issues"},"bin":{"proto2js":"cli.js"},"dist":{"shasum":"b785dfd7dca2873c0068985afd1e3341defccbf5","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.2.tgz","fileCount":8,"integrity":"sha512-sa7xpEPIuRCJh4plFKTEO7lIWPFLQTy87J6OjzuBKybusOhY1PLNmmw71hjIw5VJDna5xy191KXrIwceSyo3jQ==","signatures":[{"sig":"MEUCIGCB0y3ccDjY4qpxXvBYUcg+AA+0m+ci2IXHT462xYcbAiEA4A5mW1hidlKjTBZCgKbEH8Fa44GxVU1BOun5iATnubQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18453},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","directories":{},"_nodeVersion":"26.2.0","dependencies":{"yargs":"^18.1.0","@3-/read":"^0.1.4","@3-/write":"^0.1.2","proto-parser":"^0.0.9","@3-/proto_remove_comment":"^0.1.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/proto2js_0.1.2_1786706559070_0.17865522589762484","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@1-/proto2js","version":"0.1.3","keywords":["codegen","grpc","javascript","proto","protobuf"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/proto2js@0.1.3","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","bugs":{"url":"https://github.com/webc-site/npm/issues"},"bin":{"proto2js":"cli.js"},"dist":{"shasum":"9246437595c2f93d294eb76e88a9af0aa33e4369","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.3.tgz","fileCount":8,"integrity":"sha512-tqiY06wcuqKIiIvHT5r5jARZtXIg33Giu1q+Vk6kOfcEPRTjXnQ/w0vjGu0ixR69nDhi9PfVxllt0a75asMbJA==","signatures":[{"sig":"MEUCIQCU+JZ+bpxHHP/YnU51GTqAEr1P1s/BiyEpF7SG3B8YbQIgSdOUMvnYTqIPhPPSvLTHeFPAk9AjW49rjYQxzNyCDA4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20708},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","directories":{},"_nodeVersion":"26.2.0","dependencies":{"yargs":"^18.1.0","@3-/read":"^0.1.4","@3-/walk":"^0.2.2","@3-/write":"^0.1.2","proto-parser":"^0.0.9","@3-/proto_remove_comment":"^0.1.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/proto2js_0.1.3_1786951018952_0.30922207940289925","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@1-/proto2js","version":"0.1.4","keywords":["codegen","grpc","javascript","proto","protobuf"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/proto2js@0.1.4","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","bugs":{"url":"https://github.com/webc-site/npm/issues"},"bin":{"proto2js":"cli.js"},"dist":{"shasum":"68dc0977ffe5ed4f2d90012593fffb5ede0aa6e8","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.4.tgz","fileCount":8,"integrity":"sha512-UmDCkCIOU+yWVOuKQ0pTDP7RbZU24oVWGzLw1FetyQSYe1H52BRXGiqF84duuDitvOUcjyt0HrmvffiBD8izaA==","signatures":[{"sig":"MEUCIQDI4YS2AQuJZ+Dx/wAySBQ4wK5eMCpcJDNJkYqI0hxu0QIgCWvSNkDxlhWNbYrPWs5y1p9yQ8lpO+JO50hz7hH6M4I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19695},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","directories":{},"_nodeVersion":"26.2.0","dependencies":{"yargs":"^18.1.0","@3-/log":"^0.1.9","@3-/read":"^0.1.4","@3-/walk":"^0.2.2","@3-/write":"^0.1.2","proto-parser":"^0.0.9","@3-/proto_remove_comment":"^0.1.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/proto2js_0.1.4_1786959005416_0.5440437376550225","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@1-/proto2js","version":"0.1.5","keywords":["codegen","grpc","javascript","proto","protobuf"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/proto2js@0.1.5","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","bugs":{"url":"https://github.com/webc-site/npm/issues"},"bin":{"proto2js":"cli.js"},"dist":{"shasum":"33daa9aaef4263b7ea996ed855c02f20d1b5ed89","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.5.tgz","fileCount":8,"integrity":"sha512-lnFa29aMdgwZMvqM0dJorDPSMZmv2n/c25LRBiqDPfw2bKdGWyhgTxvx5GxyxCGA2mTfsRVeiRB96WWbxua+TA==","signatures":[{"sig":"MEUCIQCdLMjlvFCwy2F6Ki+dSQpGg9d3WhiA8MDQ7/lP1B/r8wIgZjCGf8FlQG0PIVP5fwVDDzeUDXyLPjAY2eirvFgBFfY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19394},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.16.0","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","directories":{},"_nodeVersion":"26.2.0","dependencies":{"yargs":"^18.1.0","@3-/log":"^0.1.9","@3-/read":"^0.1.4","@3-/walk":"^0.2.2","@3-/write":"^0.1.2","proto-parser":"^0.0.9","@3-/proto_remove_comment":"^0.1.5"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/proto2js_0.1.5_1787035546725_0.7115176503701857","host":"s3://npm-registry-packages-npm-production"}},"0.1.6":{"name":"@1-/proto2js","version":"0.1.6","description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","keywords":["codegen","grpc","javascript","proto","protobuf"],"homepage":"https://github.com/webc-site/npm/tree/main/proto2js","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"bin":{"proto2js":"cli.js"},"type":"module","exports":{".":"./_.js","./*":"./*"},"dependencies":{"@3-/log":"^0.1.9","@3-/proto_remove_comment":"^0.1.5","@3-/read":"^0.1.4","@3-/walk":"^0.2.2","@3-/write":"^0.1.2","proto-parser":"^0.0.9","yargs":"^18.1.0"},"_id":"@1-/proto2js@0.1.6","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-aXbNRW0jL3SD31MVfFEowBOueoawvDIRZlMDzVjq0M2UH2YITG2ePwrBus/Z+LqG4+WOA2AmCml9ix6/Bka8fQ==","shasum":"b4b10a022e9878833c58441e8c3f7010c0cd136e","tarball":"https://registry.npmjs.org/@1-/proto2js/-/proto2js-0.1.6.tgz","fileCount":8,"unpackedSize":19845,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDCt01ro6uSFNMaZhkSMLFGE/rjCxBQN3C80HhDsX3HhQIgJlfsveaZRzavMCPqJzp01lw/tW6jZxDM9i50yRI16+w="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/proto2js_0.1.6_1787665937869_0.8591392013520434"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-14T10:42:24.633Z","modified":"2026-08-25T13:52:18.225Z","0.1.1":"2026-08-14T10:42:24.887Z","0.1.2":"2026-08-14T11:22:39.195Z","0.1.3":"2026-08-17T07:16:59.105Z","0.1.4":"2026-08-17T09:30:05.582Z","0.1.5":"2026-08-18T06:45:46.883Z","0.1.6":"2026-08-25T13:52:18.001Z"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","homepage":"https://github.com/webc-site/npm/tree/main/proto2js","keywords":["codegen","grpc","javascript","proto","protobuf"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"description":"Protobuf to JavaScript converter / 将 Protobuf 转换为 JavaScript","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/proto2js : Convert Protocol Buffer definitions to JavaScript modules\n\n- [@1-/proto2js : Convert Protocol Buffer definitions to JavaScript modules](#1-proto2js-convert-protocol-buffer-definitions-to-javascript-modules)\n  - [Functionality](#functionality)\n  - [Usage demonstration](#usage-demonstration)\n  - [Design rationale](#design-rationale)\n  - [Technology stack](#technology-stack)\n  - [Code structure](#code-structure)\n  - [Historical background](#historical-background)\n  - [About](#about)\n\n## Functionality\n\nConvert Protocol Buffer (.proto) definition files into modular JavaScript code. Supports message, enum, and service definitions with RPC client generation. Implements dependency-aware parsing that recursively resolves proto imports before code generation. Generated JavaScript modules support ESM imports and work in modern JavaScript environments.\n\n## Usage demonstration\n\nInstall as a CLI tool (Bun environment):\n\n```bash\nbun add -g @1-/proto2js\n```\n\nGenerate JavaScript from a .proto file:\n\n```bash\nproto2js example.proto -o ./generated\n```\n\nOr use programmatically:\n\n```javascript\nimport gen from \"@1-/proto2js/src/_.js\";\n\n// Generate JavaScript modules from proto file\nconst pkg = gen(\"./path/to/file.proto\", \"./output/directory\");\n```\n\nSupports directory batch processing and multi-level import paths:\n\n```bash\nproto2js ./protos/ -o ./generated -I ./protos/external -I ./protos/shared\n```\n\n## Design rationale\n\nThe generator uses a three-stage pipeline architecture:\n\n![](https://cdn.jsdmirror.com/gh/webc-fs/-@ma/AivveQrz-vyGanCJ7P0w.svg)\n\nKey implementation features:\n\n- Dependency-aware: `merge.js` implements recursive import resolution, building complete dependency graphs\n- Type resolution: `findType.js` provides nested type lookup capability for deep nested references\n- Path intelligence: `gen.js` uses Node.js `relative()` to compute module paths, ensuring correct ESM import statements\n- RPC clients: Service methods generate `$` function calls with automatic request/response type import handling\n- Error localization: Parse errors include precise line numbers and context information\n- Multi-level includes: Support multiple `-I` parameters for import search paths\n\n## Technology stack\n\n- Runtime: Bun (default) or Node.js (ESM modules)\n- Core parser: proto-parser library (v0.0.9)\n- File system: Node.js path and fs modules\n- CLI framework: yargs (v18.1.0)\n- Utility libraries: @3-/write, @3-/read, @3-/proto_remove_comment, @3-/walk\n- Development dependencies: @1-/proto (RPC runtime)\n\n## Code structure\n\n```\nsrc/\n├── _.js          # Main entry point and orchestration logic, handles file/directory input, path resolution, error handling\n├── cli.js        # Command-line interface implementation, yargs-based parameter parsing and command dispatch (Bun script)\n├── gen.js        # Core code generation logic, handles messages, enums, services JavaScript generation\n├── findType.js   # Nested type resolution utility, implements deep proto type lookup\n├── merge.js      # Import merging and dependency resolution, recursively resolves all proto imports\n└── importLi.js   # Import statement parsing and package extraction, handles package declarations and import statements\n```\n\n## Historical background\n\nProtocol Buffers were developed by Google in 2001 as an efficient alternative to XML for serializing structured data. Initially designed for internal RPC systems, they evolved into an open standard supporting multiple languages. The @1-/proto2js tool continues this legacy by enabling seamless integration of Protocol Buffer schemas into modern JavaScript ecosystems, with specific optimizations for ESM module systems. The project uses the Mulan Permissive Software License v2 (MulanPSL-2.0) and is maintained by the WebC.site team.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n\n---\n\n<a id=\"zh\"></a>\n# @1-/proto2js : Convert Protocol Buffer definitions to JavaScript modules\n\n- [@1-/proto2js : Convert Protocol Buffer definitions to JavaScript modules](#1-proto2js-convert-protocol-buffer-definitions-to-javascript-modules)\n  - [功能介绍](#功能介绍)\n  - [使用演示](#使用演示)\n  - [设计思路](#设计思路)\n  - [技术栈](#技术栈)\n  - [代码结构](#代码结构)\n  - [历史故事](#历史故事)\n  - [关于](#关于)\n\n## 功能介绍\n\n将 Protocol Buffer (.proto) 定义文件转换为模块化 JavaScript 代码。支持消息、枚举和服务定义，生成符合 ESM 规范的可直接导入模块。采用依赖感知解析策略，递归解析 proto 导入依赖后执行代码生成。生成的模块包含类型定义与 RPC 客户端函数，可在 Bun 或现代 Node.js 环境中直接使用。\n\n## 使用演示\n\n安装为命令行工具（Bun 环境）：\n\n```bash\nbun add -g @1-/proto2js\n```\n\n生成 JavaScript 从 .proto 文件：\n\n```bash\nproto2js example.proto -o ./generated\n```\n\n或以编程方式使用：\n\n```javascript\nimport gen from \"@1-/proto2js/src/_.js\";\n\n// 从 proto 文件生成 JavaScript 模块\nconst pkg = gen(\"./path/to/file.proto\", \"./output/directory\");\n```\n\n支持目录批量处理与多级导入路径：\n\n```bash\nproto2js ./protos/ -o ./generated -I ./protos/external -I ./protos/shared\n```\n\n## 设计思路\n\n生成器采用三阶段流水线架构：\n\n![](https://cdn.jsdmirror.com/gh/webc-fs/-@Z3/vR0nxPnwe0HcGUE_YyWg.svg)\n\n关键实现特性：\n\n- 依赖感知：`merge.js` 实现递归导入解析，构建完整的依赖图\n- 类型解析：`findType.js` 提供嵌套类型查找能力，支持深度嵌套引用\n- 路径智能：`gen.js` 使用 `relative()` 计算模块路径，确保正确的 ESM import 语句\n- RPC 客户端：服务方法生成 `$` 函数调用，自动处理请求/响应类型导入\n- 错误定位：解析错误包含精确的行号和上下文信息\n- 多级 includes：支持多个 `-I` 参数指定导入搜索路径\n\n## 技术栈\n\n- 运行时：Bun（默认）或 Node.js（ESM 模块）\n- 核心解析器：proto-parser 库（v0.0.9）\n- 文件系统：Node.js path 和 fs 模块\n- CLI 框架：yargs（v18.1.0）\n- 工具库：@3-/write、@3-/read、@3-/proto_remove_comment、@3-/walk\n- 开发依赖：@1-/proto（RPC 运行时）\n\n## 代码结构\n\n```\nsrc/\n├── _.js          # 主入口点与编排逻辑，处理文件/目录输入、路径解析、错误处理\n├── cli.js        # 命令行接口实现，基于 yargs 的参数解析和命令分发（Bun 脚本）\n├── gen.js        # 核心代码生成逻辑，处理消息、枚举、服务的 JavaScript 生成\n├── findType.js   # 嵌套类型解析工具，实现 proto 类型的深度查找\n├── merge.js      # 导入合并与依赖解析，递归解析所有 proto imports\n└── importLi.js   # 导入语句解析与包提取，处理 package 声明和 import 语句\n```\n\n## 历史故事\n\nProtocol Buffers 由 Google 于 2001 年开发，作为 XML 的高效替代方案用于结构化数据序列化。最初设计用于内部 RPC 系统，后演变为支持多种语言的开放标准。@1-/proto2js 工具延续这一传统，实现 Protocol Buffer 模式与现代 JavaScript 生态系统的无缝集成，特别针对 ESM 模块系统进行了优化设计。项目采用木兰宽松许可证（MulanPSL-2.0），由 WebC.site 团队维护。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n\n","readmeFilename":"README.md"}