nexus-agents 14.0.0 → 14.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (502) hide show
  1. package/dist/{ast-rule-runner-3PYXOOLH.js → ast-rule-runner-2PEUHSHO.js} +5 -5
  2. package/dist/{child-mcp-config-AKQYBMMC.js → child-mcp-config-AYVMLJDV.js} +4 -4
  3. package/dist/{chunk-YKCJJP5X.js → chunk-236T3AOZ.js} +4 -4
  4. package/dist/{chunk-GCD3OFFM.js → chunk-5QNWRC7B.js} +2 -2
  5. package/dist/{chunk-LD6QCSHT.js → chunk-B5RDZLU3.js} +4 -4
  6. package/dist/{chunk-UZZHLCYW.js → chunk-CZSEUZFE.js} +2 -2
  7. package/dist/{chunk-6FBREJER.js → chunk-DCPN7F5J.js} +2 -2
  8. package/dist/{chunk-XRMP4PP4.js → chunk-DXDKAVWV.js} +5 -5
  9. package/dist/{chunk-K5MAYIHL.js → chunk-FEAWCZ7E.js} +2 -2
  10. package/dist/{chunk-FLIBWADL.js → chunk-GDCIDLUF.js} +36 -25
  11. package/dist/chunk-GDCIDLUF.js.map +1 -0
  12. package/dist/{chunk-CUPOUBBN.js → chunk-GPZQVYKV.js} +2 -2
  13. package/dist/{chunk-IBGLJEW7.js → chunk-GR4BMQAS.js} +9 -7
  14. package/dist/chunk-GR4BMQAS.js.map +1 -0
  15. package/dist/{chunk-MB2UUFF7.js → chunk-H6SGSQJM.js} +2 -2
  16. package/dist/{chunk-KVFNI2UZ.js → chunk-HJJRUYNR.js} +7 -6
  17. package/dist/chunk-HJJRUYNR.js.map +1 -0
  18. package/dist/{chunk-AJBRMUGK.js → chunk-IZSJWIHK.js} +40 -9
  19. package/dist/chunk-IZSJWIHK.js.map +1 -0
  20. package/dist/{chunk-K6CUB3IV.js → chunk-JV3UBRRA.js} +2 -2
  21. package/dist/{chunk-6EUYMTVU.js → chunk-KXWLZDQR.js} +5 -5
  22. package/dist/{chunk-CQ6FAAOO.js → chunk-LBVPKHHU.js} +3 -3
  23. package/dist/{chunk-EFE6ORME.js → chunk-LC34UPDQ.js} +2 -2
  24. package/dist/{chunk-NA55VLER.js → chunk-LE6TQVXF.js} +2 -2
  25. package/dist/{chunk-KZ5R5HL7.js → chunk-MFUJU7RO.js} +3 -3
  26. package/dist/{chunk-7S6ANELD.js → chunk-MQSSTTZU.js} +4 -4
  27. package/dist/{chunk-CP73UYNV.js → chunk-OQR2C64M.js} +5 -5
  28. package/dist/{chunk-UBCGX47E.js → chunk-P3CFDAW5.js} +2 -2
  29. package/dist/{chunk-G2MC6WXA.js → chunk-PG6NTUTS.js} +8 -8
  30. package/dist/{chunk-HQMIDROO.js → chunk-PQ3V2SYP.js} +2 -2
  31. package/dist/{chunk-36B7J7CZ.js → chunk-Q6R3JTXH.js} +3 -3
  32. package/dist/{chunk-PI54VS4I.js → chunk-SNSV6GGV.js} +10 -10
  33. package/dist/{chunk-BSGMAUA4.js → chunk-SQPFJLCI.js} +3 -3
  34. package/dist/{chunk-7VMEUGNV.js → chunk-TV6RX3ZL.js} +4 -4
  35. package/dist/{chunk-7BKOWPKX.js → chunk-TYIIAIXA.js} +7 -7
  36. package/dist/{chunk-2A4P2DX3.js → chunk-VH4T4O5L.js} +2 -2
  37. package/dist/{chunk-ABTRD52Y.js → chunk-WWBYNWYB.js} +4 -4
  38. package/dist/{chunk-BELY4VU4.js → chunk-YE3T4X2U.js} +4 -4
  39. package/dist/{chunk-XU6N5OKA.js → chunk-YSEMHACQ.js} +36 -37
  40. package/dist/{chunk-XU6N5OKA.js.map → chunk-YSEMHACQ.js.map} +1 -1
  41. package/dist/{cli-circuit-breaker-37UQWOAA.js → cli-circuit-breaker-HWMTEEYI.js} +5 -5
  42. package/dist/{cli-readiness-RSBS6FN3.js → cli-readiness-6C6E2T2O.js} +9 -9
  43. package/dist/{cli-server-gateway-C5QPDUWS.js → cli-server-gateway-HHRF22EB.js} +14 -14
  44. package/dist/cli.js +505 -409
  45. package/dist/cli.js.map +1 -1
  46. package/dist/{composite-router-WERJYE7X.js → composite-router-CX2W7RVA.js} +4 -4
  47. package/dist/{consensus-vote-G2MKNTMW.js → consensus-vote-CQGIWMYY.js} +17 -17
  48. package/dist/{context-retriever-H34LHPWB.js → context-retriever-G4LMWEN5.js} +10 -10
  49. package/dist/{doctor-deep-XBUWYYXO.js → doctor-deep-VOX7KVGK.js} +5 -5
  50. package/dist/{doctor-gateway-report-JRENPRNM.js → doctor-gateway-report-GMYX62JU.js} +7 -7
  51. package/dist/{doctor-live-CFUUN5K4.js → doctor-live-AES3PON5.js} +14 -14
  52. package/dist/{expert-bridge-FPFMGB3W.js → expert-bridge-WEZXYIGA.js} +6 -6
  53. package/dist/{factory-RQ5Q2TMY.js → factory-L2DIM3PM.js} +7 -7
  54. package/dist/{factory-HYRMAIGW.js → factory-L6CLXVPW.js} +13 -13
  55. package/dist/{gemini-adapter-EHQUG5QP.js → gemini-adapter-CL7YW7UZ.js} +8 -8
  56. package/dist/{improvement-review-SMUO5UVF.js → improvement-review-EBC3I55P.js} +6 -6
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +27 -27
  59. package/dist/{init-opencode-56GNUSHL.js → init-opencode-F6FV63VR.js} +6 -6
  60. package/dist/{issue-triage-LPX3EU4I.js → issue-triage-3EJ5DSGG.js} +7 -7
  61. package/dist/{model-config-helpers-XBHRUWIC.js → model-config-helpers-27GO3OEU.js} +3 -3
  62. package/dist/{openai-compat-adapter-WEHE5LKH.js → openai-compat-adapter-JJD7VWZC.js} +6 -6
  63. package/dist/{pr-reviewer-helpers-XPT57QHF.js → pr-reviewer-helpers-KGGKESLT.js} +5 -5
  64. package/dist/{registry-command-D5TA6433.js → registry-command-SQQNXDGS.js} +2 -2
  65. package/dist/{repo-security-plan-OH7IPPQU.js → repo-security-plan-CIGD7QBY.js} +4 -4
  66. package/dist/{research-helpers-synthesize-UYICMMMM.js → research-helpers-synthesize-HAQSK2RL.js} +6 -6
  67. package/dist/{routing-memory-PKD2T674.js → routing-memory-AFHV5NDT.js} +4 -4
  68. package/dist/{session-memory-IRR7GLZT.js → session-memory-RBY5SHFK.js} +5 -5
  69. package/dist/{setup-config-N4OYZSCY.js → setup-config-47NNRD4E.js} +5 -5
  70. package/dist/{setup-custom-api-4VLHKKBF.js → setup-custom-api-H74QY7EM.js} +5 -5
  71. package/dist/{tool-memory-MSOEUVUX.js → tool-memory-QESESDGS.js} +7 -7
  72. package/dist/{unified-registry-W2DCYXUT.js → unified-registry-HWZRXFQ6.js} +13 -13
  73. package/dist/{weather-report-FANVIPXZ.js → weather-report-QZLXDT5L.js} +4 -4
  74. package/node_modules/@protobufjs/aspromise/LICENSE +26 -0
  75. package/node_modules/@protobufjs/aspromise/README.md +13 -0
  76. package/node_modules/{protobufjs/src/util/aspromise.d.ts → @protobufjs/aspromise/index.d.ts} +13 -13
  77. package/node_modules/{protobufjs/src/util/aspromise.js → @protobufjs/aspromise/index.js} +52 -52
  78. package/node_modules/@protobufjs/aspromise/package.json +21 -0
  79. package/node_modules/@protobufjs/aspromise/tests/index.js +130 -0
  80. package/node_modules/@protobufjs/base64/LICENSE +26 -0
  81. package/node_modules/@protobufjs/base64/README.md +19 -0
  82. package/node_modules/{protobufjs/src/util/base64.d.ts → @protobufjs/base64/index.d.ts} +32 -32
  83. package/node_modules/{protobufjs/src/util/base64.js → @protobufjs/base64/index.js} +139 -146
  84. package/node_modules/@protobufjs/base64/package.json +21 -0
  85. package/node_modules/@protobufjs/base64/tests/index.js +46 -0
  86. package/node_modules/@protobufjs/codegen/LICENSE +26 -0
  87. package/node_modules/@protobufjs/codegen/README.md +49 -0
  88. package/node_modules/{protobufjs/src/util/codegen.d.ts → @protobufjs/codegen/index.d.ts} +31 -31
  89. package/node_modules/{protobufjs/src/util/codegen.js → @protobufjs/codegen/index.js} +112 -120
  90. package/node_modules/@protobufjs/codegen/package.json +13 -0
  91. package/node_modules/@protobufjs/codegen/tests/index.js +13 -0
  92. package/node_modules/@protobufjs/eventemitter/CHANGELOG.md +8 -0
  93. package/node_modules/@protobufjs/eventemitter/LICENSE +26 -0
  94. package/node_modules/@protobufjs/eventemitter/README.md +22 -0
  95. package/node_modules/{protobufjs/src/util/eventemitter.d.ts → @protobufjs/eventemitter/index.d.ts} +45 -45
  96. package/node_modules/{protobufjs/src/util/eventemitter.js → @protobufjs/eventemitter/index.js} +86 -86
  97. package/node_modules/@protobufjs/eventemitter/package.json +21 -0
  98. package/node_modules/@protobufjs/eventemitter/tests/index.js +83 -0
  99. package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
  100. package/node_modules/@protobufjs/fetch/LICENSE +26 -0
  101. package/node_modules/@protobufjs/fetch/README.md +13 -0
  102. package/node_modules/{protobufjs/src/util/fetch.d.ts → @protobufjs/fetch/index.d.ts} +56 -56
  103. package/node_modules/{protobufjs/src/util/fetch.js → @protobufjs/fetch/index.js} +112 -112
  104. package/node_modules/@protobufjs/fetch/package.json +27 -0
  105. package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
  106. package/node_modules/@protobufjs/fetch/tests/index.js +158 -0
  107. package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
  108. package/node_modules/@protobufjs/float/LICENSE +26 -0
  109. package/node_modules/@protobufjs/float/README.md +102 -0
  110. package/node_modules/@protobufjs/float/bench/index.js +87 -0
  111. package/node_modules/@protobufjs/float/bench/suite.js +46 -0
  112. package/node_modules/{protobufjs/src/util/float.js → @protobufjs/float/index.js} +335 -335
  113. package/node_modules/@protobufjs/float/package.json +26 -0
  114. package/node_modules/@protobufjs/float/tests/index.js +100 -0
  115. package/node_modules/@protobufjs/path/LICENSE +26 -0
  116. package/node_modules/@protobufjs/path/README.md +19 -0
  117. package/node_modules/{protobufjs/src/util/path.d.ts → @protobufjs/path/index.d.ts} +22 -22
  118. package/node_modules/{protobufjs/src/util/path.js → @protobufjs/path/index.js} +65 -100
  119. package/node_modules/@protobufjs/path/package.json +21 -0
  120. package/node_modules/@protobufjs/path/tests/index.js +60 -0
  121. package/node_modules/@protobufjs/pool/.npmignore +3 -0
  122. package/node_modules/@protobufjs/pool/LICENSE +26 -0
  123. package/node_modules/@protobufjs/pool/README.md +13 -0
  124. package/node_modules/{protobufjs/src/util/pool.d.ts → @protobufjs/pool/index.d.ts} +32 -32
  125. package/node_modules/{protobufjs/src/util/pool.js → @protobufjs/pool/index.js} +48 -48
  126. package/node_modules/@protobufjs/pool/package.json +21 -0
  127. package/node_modules/@protobufjs/pool/tests/index.js +33 -0
  128. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  129. package/node_modules/@protobufjs/utf8/LICENSE +26 -0
  130. package/node_modules/@protobufjs/utf8/README.md +20 -0
  131. package/node_modules/{protobufjs/src/util/utf8.d.ts → @protobufjs/utf8/index.d.ts} +24 -24
  132. package/node_modules/@protobufjs/utf8/index.js +115 -0
  133. package/node_modules/@protobufjs/utf8/package.json +21 -0
  134. package/node_modules/@protobufjs/utf8/tests/data/surrogate_pair_bug.txt +207 -0
  135. package/node_modules/@protobufjs/utf8/tests/data/utf8.txt +216 -0
  136. package/node_modules/@protobufjs/utf8/tests/index.js +79 -0
  137. package/node_modules/@types/node/LICENSE +21 -0
  138. package/node_modules/@types/node/README.md +15 -0
  139. package/node_modules/@types/node/assert/strict.d.ts +68 -0
  140. package/node_modules/@types/node/assert.d.ts +1077 -0
  141. package/node_modules/@types/node/async_hooks.d.ts +711 -0
  142. package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  143. package/node_modules/@types/node/buffer.d.ts +1800 -0
  144. package/node_modules/@types/node/child_process.d.ts +1361 -0
  145. package/node_modules/@types/node/cluster.d.ts +432 -0
  146. package/node_modules/@types/node/console.d.ts +93 -0
  147. package/node_modules/@types/node/constants.d.ts +14 -0
  148. package/node_modules/@types/node/crypto.d.ts +3964 -0
  149. package/node_modules/@types/node/dgram.d.ts +652 -0
  150. package/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
  151. package/node_modules/@types/node/dns/promises.d.ts +497 -0
  152. package/node_modules/@types/node/dns.d.ts +876 -0
  153. package/node_modules/@types/node/domain.d.ts +150 -0
  154. package/node_modules/@types/node/events.d.ts +1008 -0
  155. package/node_modules/@types/node/ffi.d.ts +500 -0
  156. package/node_modules/@types/node/fs/promises.d.ts +1477 -0
  157. package/node_modules/@types/node/fs.d.ts +4803 -0
  158. package/node_modules/@types/node/globals.d.ts +150 -0
  159. package/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  160. package/node_modules/@types/node/http.d.ts +2218 -0
  161. package/node_modules/@types/node/http2.d.ts +2498 -0
  162. package/node_modules/@types/node/https.d.ts +400 -0
  163. package/node_modules/@types/node/index.d.ts +116 -0
  164. package/node_modules/@types/node/inspector/promises.d.ts +35 -0
  165. package/node_modules/@types/node/inspector.d.ts +265 -0
  166. package/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  167. package/node_modules/@types/node/module.d.ts +726 -0
  168. package/node_modules/@types/node/net.d.ts +1074 -0
  169. package/node_modules/@types/node/os.d.ts +498 -0
  170. package/node_modules/@types/node/package.json +140 -0
  171. package/node_modules/@types/node/path/posix.d.ts +8 -0
  172. package/node_modules/@types/node/path/win32.d.ts +8 -0
  173. package/node_modules/@types/node/path.d.ts +178 -0
  174. package/node_modules/@types/node/perf_hooks.d.ts +617 -0
  175. package/node_modules/@types/node/process.d.ts +2269 -0
  176. package/node_modules/@types/node/punycode.d.ts +89 -0
  177. package/node_modules/@types/node/querystring.d.ts +139 -0
  178. package/node_modules/@types/node/quic.d.ts +2191 -0
  179. package/node_modules/@types/node/readline/promises.d.ts +158 -0
  180. package/node_modules/@types/node/readline.d.ts +508 -0
  181. package/node_modules/@types/node/repl.d.ts +420 -0
  182. package/node_modules/@types/node/sea.d.ts +47 -0
  183. package/node_modules/@types/node/sqlite.d.ts +1140 -0
  184. package/node_modules/@types/node/stream/consumers.d.ts +114 -0
  185. package/node_modules/@types/node/stream/iter.d.ts +449 -0
  186. package/node_modules/@types/node/stream/promises.d.ts +211 -0
  187. package/node_modules/@types/node/stream/web.d.ts +320 -0
  188. package/node_modules/@types/node/stream.d.ts +1806 -0
  189. package/node_modules/@types/node/string_decoder.d.ts +27 -0
  190. package/node_modules/@types/node/test/reporters.d.ts +60 -0
  191. package/node_modules/@types/node/test.d.ts +2558 -0
  192. package/node_modules/@types/node/timers/promises.d.ts +93 -0
  193. package/node_modules/@types/node/timers.d.ts +149 -0
  194. package/node_modules/@types/node/tls.d.ts +1232 -0
  195. package/node_modules/@types/node/trace_events.d.ts +103 -0
  196. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
  197. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  198. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  199. package/node_modules/@types/node/ts5.6/index.d.ts +118 -0
  200. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  201. package/node_modules/@types/node/ts5.7/index.d.ts +118 -0
  202. package/node_modules/@types/node/tty.d.ts +226 -0
  203. package/node_modules/@types/node/url.d.ts +556 -0
  204. package/node_modules/@types/node/util/types.d.ts +558 -0
  205. package/node_modules/@types/node/util.d.ts +1680 -0
  206. package/node_modules/@types/node/v8.d.ts +1059 -0
  207. package/node_modules/@types/node/vfs.d.ts +211 -0
  208. package/node_modules/@types/node/vm.d.ts +1137 -0
  209. package/node_modules/@types/node/wasi.d.ts +131 -0
  210. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  211. package/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  212. package/node_modules/@types/node/web-globals/console.d.ts +9 -0
  213. package/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  214. package/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
  215. package/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  216. package/node_modules/@types/node/web-globals/events.d.ts +106 -0
  217. package/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  218. package/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  219. package/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  220. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  221. package/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  222. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  223. package/node_modules/@types/node/web-globals/streams.d.ts +119 -0
  224. package/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  225. package/node_modules/@types/node/web-globals/url.d.ts +24 -0
  226. package/node_modules/@types/node/worker_threads.d.ts +672 -0
  227. package/node_modules/@types/node/zlib/iter.d.ts +131 -0
  228. package/node_modules/@types/node/zlib.d.ts +612 -0
  229. package/node_modules/fast-uri/.github/dependabot.yml +2 -42
  230. package/node_modules/fast-uri/.github/workflows/ci.yml +6 -54
  231. package/node_modules/fast-uri/.github/workflows/lock-threads.yml +1 -1
  232. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +24 -0
  233. package/node_modules/fast-uri/.github/workflows/release.yml +2 -1
  234. package/node_modules/fast-uri/README.md +10 -12
  235. package/node_modules/fast-uri/benchmark/benchmark.mjs +0 -71
  236. package/node_modules/fast-uri/index.js +20 -94
  237. package/node_modules/fast-uri/lib/schemes.js +4 -439
  238. package/node_modules/fast-uri/lib/utils.js +113 -230
  239. package/node_modules/fast-uri/package.json +5 -5
  240. package/node_modules/fast-uri/test/equal.test.js +0 -63
  241. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +1 -23
  242. package/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +1 -23
  243. package/node_modules/fast-uri/test/ipv6-validation.test.js +0 -160
  244. package/node_modules/fast-uri/test/parse.test.js +5 -150
  245. package/node_modules/fast-uri/test/relative-normalization-security.test.js +4 -0
  246. package/node_modules/fast-uri/test/scheme-validation.test.js +5 -3
  247. package/node_modules/fast-uri/test/security.test.js +2 -2
  248. package/node_modules/fast-uri/test/serialize.test.js +0 -144
  249. package/node_modules/fast-uri/test/uri-js-compatibility.test.js +3 -0
  250. package/node_modules/fast-uri/test/uri-js.test.js +9 -11
  251. package/node_modules/fast-uri/test/urn-full-input.test.js +0 -18
  252. package/node_modules/fast-uri/test/util.test.js +0 -9
  253. package/node_modules/fast-uri/tsconfig.json +7 -8
  254. package/node_modules/fast-uri/types/index.d.ts +9 -20
  255. package/node_modules/fast-uri/types/index.test-d.ts +17 -0
  256. package/node_modules/hono/README.md +2 -3
  257. package/node_modules/hono/dist/cjs/helper/css/common.js +8 -3
  258. package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
  259. package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
  260. package/node_modules/hono/dist/cjs/jsx/base.js +1 -1
  261. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +8 -0
  262. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +3 -1
  263. package/node_modules/hono/dist/cjs/router/trie-router/node.js +2 -2
  264. package/node_modules/hono/dist/cjs/utils/url.js +11 -6
  265. package/node_modules/hono/dist/helper/css/common.js +8 -3
  266. package/node_modules/hono/dist/helper/css/index.js +1 -1
  267. package/node_modules/hono/dist/helper/route/index.js +3 -1
  268. package/node_modules/hono/dist/jsx/base.js +1 -1
  269. package/node_modules/hono/dist/middleware/bearer-auth/index.js +8 -0
  270. package/node_modules/hono/dist/middleware/serve-static/index.js +3 -1
  271. package/node_modules/hono/dist/router/trie-router/node.js +2 -2
  272. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
  273. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
  274. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
  275. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
  276. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
  277. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
  278. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
  279. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
  280. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
  281. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
  282. package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
  283. package/node_modules/hono/dist/types/hono-base.d.ts +21 -9
  284. package/node_modules/hono/dist/types/index.d.ts +1 -1
  285. package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
  286. package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
  287. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
  288. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
  289. package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
  290. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
  291. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
  292. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
  293. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
  294. package/node_modules/hono/dist/utils/url.js +11 -6
  295. package/node_modules/hono/package.json +1 -1
  296. package/node_modules/ip-address/dist/common.js +2 -2
  297. package/node_modules/ip-address/dist/common.js.map +1 -1
  298. package/node_modules/ip-address/package.json +2 -2
  299. package/node_modules/path-to-regexp/Readme.md +7 -1
  300. package/node_modules/path-to-regexp/dist/index.d.ts +12 -7
  301. package/node_modules/path-to-regexp/dist/index.js +99 -99
  302. package/node_modules/path-to-regexp/dist/index.js.map +1 -1
  303. package/node_modules/path-to-regexp/package.json +8 -9
  304. package/node_modules/protobufjs/README.md +562 -259
  305. package/node_modules/protobufjs/dist/light/protobuf.js +1915 -3267
  306. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  307. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  308. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  309. package/node_modules/protobufjs/dist/minimal/protobuf.js +1173 -2018
  310. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  311. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  312. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  313. package/node_modules/protobufjs/dist/protobuf.js +1982 -3483
  314. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  315. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  316. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  317. package/node_modules/protobufjs/ext/descriptor/README.md +70 -3
  318. package/node_modules/protobufjs/ext/descriptor/index.d.ts +193 -0
  319. package/node_modules/protobufjs/ext/descriptor/index.js +1185 -1
  320. package/node_modules/protobufjs/ext/descriptor/test.js +54 -0
  321. package/node_modules/protobufjs/google/api/annotations.json +1 -3
  322. package/node_modules/protobufjs/google/api/http.json +1 -2
  323. package/node_modules/protobufjs/google/protobuf/api.json +6 -12
  324. package/node_modules/protobufjs/google/protobuf/descriptor.json +88 -194
  325. package/node_modules/protobufjs/google/protobuf/descriptor.proto +9 -15
  326. package/node_modules/protobufjs/google/protobuf/source_context.json +1 -2
  327. package/node_modules/protobufjs/google/protobuf/type.json +7 -14
  328. package/node_modules/protobufjs/index.d.ts +685 -1077
  329. package/node_modules/protobufjs/package.json +51 -25
  330. package/node_modules/protobufjs/scripts/postinstall.js +32 -0
  331. package/node_modules/protobufjs/src/common.js +8 -14
  332. package/node_modules/protobufjs/src/converter.js +52 -90
  333. package/node_modules/protobufjs/src/decoder.js +67 -211
  334. package/node_modules/protobufjs/src/encoder.js +7 -27
  335. package/node_modules/protobufjs/src/enum.js +7 -33
  336. package/node_modules/protobufjs/src/field.js +20 -77
  337. package/node_modules/protobufjs/src/index-light.js +29 -29
  338. package/node_modules/protobufjs/src/index-minimal.js +13 -12
  339. package/node_modules/protobufjs/src/index.js +6 -6
  340. package/node_modules/protobufjs/src/mapfield.js +8 -26
  341. package/node_modules/protobufjs/src/message.js +11 -5
  342. package/node_modules/protobufjs/src/method.js +7 -30
  343. package/node_modules/protobufjs/src/namespace.js +10 -26
  344. package/node_modules/protobufjs/src/object.js +31 -44
  345. package/node_modules/protobufjs/src/oneof.js +1 -12
  346. package/node_modules/protobufjs/src/parse.js +67 -194
  347. package/node_modules/protobufjs/src/reader.js +58 -520
  348. package/node_modules/protobufjs/src/reader_buffer.js +5 -31
  349. package/node_modules/protobufjs/src/root.js +4 -16
  350. package/node_modules/protobufjs/src/rpc/service.js +5 -18
  351. package/node_modules/protobufjs/src/service.js +2 -15
  352. package/node_modules/protobufjs/src/tokenize.js +4 -20
  353. package/node_modules/protobufjs/src/type.js +37 -91
  354. package/node_modules/protobufjs/src/typescript.jsdoc +15 -0
  355. package/node_modules/protobufjs/src/util/longbits.js +6 -10
  356. package/node_modules/protobufjs/src/util/minimal.js +51 -71
  357. package/node_modules/protobufjs/src/util.js +17 -51
  358. package/node_modules/protobufjs/src/verifier.js +14 -19
  359. package/node_modules/protobufjs/src/wrappers.js +3 -2
  360. package/node_modules/protobufjs/src/writer.js +189 -428
  361. package/node_modules/protobufjs/src/writer_buffer.js +26 -41
  362. package/node_modules/protobufjs/tsconfig.json +5 -3
  363. package/node_modules/undici-types/LICENSE +21 -0
  364. package/node_modules/undici-types/README.md +6 -0
  365. package/node_modules/undici-types/agent.d.ts +30 -0
  366. package/node_modules/undici-types/api.d.ts +43 -0
  367. package/node_modules/undici-types/balanced-pool.d.ts +30 -0
  368. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  369. package/node_modules/undici-types/cache.d.ts +36 -0
  370. package/node_modules/undici-types/client-stats.d.ts +15 -0
  371. package/node_modules/undici-types/client.d.ts +134 -0
  372. package/node_modules/undici-types/connector.d.ts +37 -0
  373. package/node_modules/undici-types/content-type.d.ts +21 -0
  374. package/node_modules/undici-types/cookies.d.ts +30 -0
  375. package/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  376. package/node_modules/undici-types/dispatcher.d.ts +253 -0
  377. package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
  378. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  379. package/node_modules/undici-types/errors.d.ts +187 -0
  380. package/node_modules/undici-types/eventsource.d.ts +66 -0
  381. package/node_modules/undici-types/fetch.d.ts +235 -0
  382. package/node_modules/undici-types/formdata.d.ts +108 -0
  383. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  384. package/node_modules/undici-types/global-origin.d.ts +7 -0
  385. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  386. package/node_modules/undici-types/handlers.d.ts +16 -0
  387. package/node_modules/undici-types/header.d.ts +165 -0
  388. package/node_modules/undici-types/index.d.ts +93 -0
  389. package/node_modules/undici-types/interceptors.d.ts +80 -0
  390. package/node_modules/undici-types/mock-agent.d.ts +68 -0
  391. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  392. package/node_modules/undici-types/mock-client.d.ts +27 -0
  393. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  394. package/node_modules/undici-types/mock-interceptor.d.ts +98 -0
  395. package/node_modules/undici-types/mock-pool.d.ts +27 -0
  396. package/node_modules/undici-types/package.json +55 -0
  397. package/node_modules/undici-types/patch.d.ts +29 -0
  398. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  399. package/node_modules/undici-types/pool.d.ts +39 -0
  400. package/node_modules/undici-types/proxy-agent.d.ts +36 -0
  401. package/node_modules/undici-types/readable.d.ts +68 -0
  402. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  403. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  404. package/node_modules/undici-types/round-robin-pool.d.ts +39 -0
  405. package/node_modules/undici-types/snapshot-agent.d.ts +113 -0
  406. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  407. package/node_modules/undici-types/util.d.ts +18 -0
  408. package/node_modules/undici-types/utility.d.ts +7 -0
  409. package/node_modules/undici-types/webidl.d.ts +346 -0
  410. package/node_modules/undici-types/websocket.d.ts +188 -0
  411. package/package.json +19 -7
  412. package/dist/chunk-AJBRMUGK.js.map +0 -1
  413. package/dist/chunk-FLIBWADL.js.map +0 -1
  414. package/dist/chunk-IBGLJEW7.js.map +0 -1
  415. package/dist/chunk-KVFNI2UZ.js.map +0 -1
  416. package/node_modules/fast-uri/.github/workflows/ossf-scorecard.yml +0 -45
  417. package/node_modules/fast-uri/SECURITY.md +0 -222
  418. package/node_modules/fast-uri/benchmark/encoder.mjs +0 -54
  419. package/node_modules/fast-uri/test/c0-reference-security.test.js +0 -137
  420. package/node_modules/fast-uri/test/host-encoding.test.js +0 -60
  421. package/node_modules/fast-uri/test/mailto-authority-security.test.js +0 -125
  422. package/node_modules/fast-uri/test/mailto-field-name-security.test.js +0 -151
  423. package/node_modules/fast-uri/test/scheme-normalization.test.js +0 -16
  424. package/node_modules/fast-uri/test/security-utf8-encoding.test.js +0 -0
  425. package/node_modules/fast-uri/types/index.tst.ts +0 -31
  426. package/node_modules/protobufjs/ext/README.md +0 -70
  427. package/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
  428. package/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -424
  429. package/node_modules/protobufjs/ext/descriptor.js +0 -1405
  430. package/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
  431. package/node_modules/protobufjs/ext/protojson.d.ts +0 -20
  432. package/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
  433. package/node_modules/protobufjs/ext/protojson.js +0 -972
  434. package/node_modules/protobufjs/ext/textformat.d.ts +0 -19
  435. package/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
  436. package/node_modules/protobufjs/ext/textformat.js +0 -1280
  437. package/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
  438. package/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
  439. package/node_modules/protobufjs/google/protobuf/json_enumvalue_options.json +0 -56
  440. package/node_modules/protobufjs/google/protobuf/json_enumvalue_options.proto +0 -31
  441. package/node_modules/protobufjs/src/typescript.js +0 -25
  442. package/node_modules/protobufjs/src/util/utf8.js +0 -164
  443. /package/dist/{ast-rule-runner-3PYXOOLH.js.map → ast-rule-runner-2PEUHSHO.js.map} +0 -0
  444. /package/dist/{child-mcp-config-AKQYBMMC.js.map → child-mcp-config-AYVMLJDV.js.map} +0 -0
  445. /package/dist/{chunk-YKCJJP5X.js.map → chunk-236T3AOZ.js.map} +0 -0
  446. /package/dist/{chunk-GCD3OFFM.js.map → chunk-5QNWRC7B.js.map} +0 -0
  447. /package/dist/{chunk-LD6QCSHT.js.map → chunk-B5RDZLU3.js.map} +0 -0
  448. /package/dist/{chunk-UZZHLCYW.js.map → chunk-CZSEUZFE.js.map} +0 -0
  449. /package/dist/{chunk-6FBREJER.js.map → chunk-DCPN7F5J.js.map} +0 -0
  450. /package/dist/{chunk-XRMP4PP4.js.map → chunk-DXDKAVWV.js.map} +0 -0
  451. /package/dist/{chunk-K5MAYIHL.js.map → chunk-FEAWCZ7E.js.map} +0 -0
  452. /package/dist/{chunk-CUPOUBBN.js.map → chunk-GPZQVYKV.js.map} +0 -0
  453. /package/dist/{chunk-MB2UUFF7.js.map → chunk-H6SGSQJM.js.map} +0 -0
  454. /package/dist/{chunk-K6CUB3IV.js.map → chunk-JV3UBRRA.js.map} +0 -0
  455. /package/dist/{chunk-6EUYMTVU.js.map → chunk-KXWLZDQR.js.map} +0 -0
  456. /package/dist/{chunk-CQ6FAAOO.js.map → chunk-LBVPKHHU.js.map} +0 -0
  457. /package/dist/{chunk-EFE6ORME.js.map → chunk-LC34UPDQ.js.map} +0 -0
  458. /package/dist/{chunk-NA55VLER.js.map → chunk-LE6TQVXF.js.map} +0 -0
  459. /package/dist/{chunk-KZ5R5HL7.js.map → chunk-MFUJU7RO.js.map} +0 -0
  460. /package/dist/{chunk-7S6ANELD.js.map → chunk-MQSSTTZU.js.map} +0 -0
  461. /package/dist/{chunk-CP73UYNV.js.map → chunk-OQR2C64M.js.map} +0 -0
  462. /package/dist/{chunk-UBCGX47E.js.map → chunk-P3CFDAW5.js.map} +0 -0
  463. /package/dist/{chunk-G2MC6WXA.js.map → chunk-PG6NTUTS.js.map} +0 -0
  464. /package/dist/{chunk-HQMIDROO.js.map → chunk-PQ3V2SYP.js.map} +0 -0
  465. /package/dist/{chunk-36B7J7CZ.js.map → chunk-Q6R3JTXH.js.map} +0 -0
  466. /package/dist/{chunk-PI54VS4I.js.map → chunk-SNSV6GGV.js.map} +0 -0
  467. /package/dist/{chunk-BSGMAUA4.js.map → chunk-SQPFJLCI.js.map} +0 -0
  468. /package/dist/{chunk-7VMEUGNV.js.map → chunk-TV6RX3ZL.js.map} +0 -0
  469. /package/dist/{chunk-7BKOWPKX.js.map → chunk-TYIIAIXA.js.map} +0 -0
  470. /package/dist/{chunk-2A4P2DX3.js.map → chunk-VH4T4O5L.js.map} +0 -0
  471. /package/dist/{chunk-ABTRD52Y.js.map → chunk-WWBYNWYB.js.map} +0 -0
  472. /package/dist/{chunk-BELY4VU4.js.map → chunk-YE3T4X2U.js.map} +0 -0
  473. /package/dist/{cli-circuit-breaker-37UQWOAA.js.map → cli-circuit-breaker-HWMTEEYI.js.map} +0 -0
  474. /package/dist/{cli-readiness-RSBS6FN3.js.map → cli-readiness-6C6E2T2O.js.map} +0 -0
  475. /package/dist/{cli-server-gateway-C5QPDUWS.js.map → cli-server-gateway-HHRF22EB.js.map} +0 -0
  476. /package/dist/{composite-router-WERJYE7X.js.map → composite-router-CX2W7RVA.js.map} +0 -0
  477. /package/dist/{consensus-vote-G2MKNTMW.js.map → consensus-vote-CQGIWMYY.js.map} +0 -0
  478. /package/dist/{context-retriever-H34LHPWB.js.map → context-retriever-G4LMWEN5.js.map} +0 -0
  479. /package/dist/{doctor-deep-XBUWYYXO.js.map → doctor-deep-VOX7KVGK.js.map} +0 -0
  480. /package/dist/{doctor-gateway-report-JRENPRNM.js.map → doctor-gateway-report-GMYX62JU.js.map} +0 -0
  481. /package/dist/{doctor-live-CFUUN5K4.js.map → doctor-live-AES3PON5.js.map} +0 -0
  482. /package/dist/{expert-bridge-FPFMGB3W.js.map → expert-bridge-WEZXYIGA.js.map} +0 -0
  483. /package/dist/{factory-HYRMAIGW.js.map → factory-L2DIM3PM.js.map} +0 -0
  484. /package/dist/{factory-RQ5Q2TMY.js.map → factory-L6CLXVPW.js.map} +0 -0
  485. /package/dist/{gemini-adapter-EHQUG5QP.js.map → gemini-adapter-CL7YW7UZ.js.map} +0 -0
  486. /package/dist/{improvement-review-SMUO5UVF.js.map → improvement-review-EBC3I55P.js.map} +0 -0
  487. /package/dist/{init-opencode-56GNUSHL.js.map → init-opencode-F6FV63VR.js.map} +0 -0
  488. /package/dist/{issue-triage-LPX3EU4I.js.map → issue-triage-3EJ5DSGG.js.map} +0 -0
  489. /package/dist/{model-config-helpers-XBHRUWIC.js.map → model-config-helpers-27GO3OEU.js.map} +0 -0
  490. /package/dist/{openai-compat-adapter-WEHE5LKH.js.map → openai-compat-adapter-JJD7VWZC.js.map} +0 -0
  491. /package/dist/{pr-reviewer-helpers-XPT57QHF.js.map → pr-reviewer-helpers-KGGKESLT.js.map} +0 -0
  492. /package/dist/{registry-command-D5TA6433.js.map → registry-command-SQQNXDGS.js.map} +0 -0
  493. /package/dist/{repo-security-plan-OH7IPPQU.js.map → repo-security-plan-CIGD7QBY.js.map} +0 -0
  494. /package/dist/{research-helpers-synthesize-UYICMMMM.js.map → research-helpers-synthesize-HAQSK2RL.js.map} +0 -0
  495. /package/dist/{routing-memory-PKD2T674.js.map → routing-memory-AFHV5NDT.js.map} +0 -0
  496. /package/dist/{session-memory-IRR7GLZT.js.map → session-memory-RBY5SHFK.js.map} +0 -0
  497. /package/dist/{setup-config-N4OYZSCY.js.map → setup-config-47NNRD4E.js.map} +0 -0
  498. /package/dist/{setup-custom-api-4VLHKKBF.js.map → setup-custom-api-H74QY7EM.js.map} +0 -0
  499. /package/dist/{tool-memory-MSOEUVUX.js.map → tool-memory-QESESDGS.js.map} +0 -0
  500. /package/dist/{unified-registry-W2DCYXUT.js.map → unified-registry-HWZRXFQ6.js.map} +0 -0
  501. /package/dist/{weather-report-FANVIPXZ.js.map → weather-report-QZLXDT5L.js.map} +0 -0
  502. /package/node_modules/{protobufjs/src/util/float.d.ts → @protobufjs/float/index.d.ts} +0 -0
@@ -7,418 +7,721 @@
7
7
  <a href="https://www.jsdelivr.com/package/npm/protobufjs"><img src="https://img.shields.io/jsdelivr/npm/hm/protobufjs?label=requests&logo=jsdelivr" alt=""></a>
8
8
  </p>
9
9
 
10
- **protobuf.js** is a very fast, conformant, and unusually versatile JavaScript implementation of [Protocol Buffers](https://protobuf.dev) for Node.js and browsers. It is independently maintained with contributions from the upstream Protocol Buffers project, works with `.proto` schemas without requiring `protoc`, and supports runtime reflection as well as specialized code generation with matching TypeScript declarations.
10
+ **Protocol Buffers** are a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more, originally designed at Google ([see](https://protobuf.dev/)).
11
11
 
12
- If protobuf.js is important to your project or organization, or if you depend on it commercially, [consider supporting](https://github.com/sponsors/dcodeIO) its ongoing maintenance. Sponsorship helps make bug fixes, releases, LTS/security handling, and user support more sustainable.
12
+ **protobuf.js** is a pure JavaScript implementation with [TypeScript](https://www.typescriptlang.org) support for [Node.js](https://nodejs.org) and the browser. It's easy to use, does not sacrifice on performance, has good conformance and works out of the box with [.proto](https://protobuf.dev/programming-guides/proto3/) files!
13
13
 
14
- ## Getting started
14
+ Contents
15
+ --------
15
16
 
16
- Getting up and running is simple: Install the package, load a schema, and you are all set to encode and decode Protobuf messages. From there, protobuf.js grows with your requirements: Add code generation with TypeScript declarations, transport-agnostic services, support for text-based formats, and more as needed.
17
+ * [Installation](#installation)<br />
18
+ How to include protobuf.js in your project.
17
19
 
18
- ### Install
20
+ * [Usage](#usage)<br />
21
+ A brief introduction to using the toolset.
22
+
23
+ * [Valid Message](#valid-message)
24
+ * [Toolset](#toolset)<br />
25
+
26
+ * [Examples](#examples)<br />
27
+ A few examples to get you started.
28
+
29
+ * [Using .proto files](#using-proto-files)
30
+ * [Using JSON descriptors](#using-json-descriptors)
31
+ * [Using reflection only](#using-reflection-only)
32
+ * [Using custom classes](#using-custom-classes)
33
+ * [Using services](#using-services)
34
+ * [Usage with TypeScript](#usage-with-typescript)<br />
35
+
36
+ * [Additional documentation](#additional-documentation)<br />
37
+ A list of available documentation resources.
38
+
39
+ * [Performance](#performance)<br />
40
+ A few internals and a benchmark on performance.
41
+
42
+ * [Compatibility](#compatibility)<br />
43
+ Notes on compatibility regarding browsers and optional libraries.
44
+
45
+ * [Building](#building)<br />
46
+ How to build the library and its components yourself.
47
+
48
+ Installation
49
+ ---------------
50
+
51
+ ### Node.js
19
52
 
20
53
  ```sh
21
- npm install protobufjs
54
+ npm install protobufjs --save
22
55
  ```
23
56
 
24
- The [command line utility](./cli/#readme) for generating reflection bundles, static code and TypeScript declarations is published as an add-on package:
57
+ ```js
58
+ // Static code + Reflection + .proto parser
59
+ var protobuf = require("protobufjs");
60
+
61
+ // Static code + Reflection
62
+ var protobuf = require("protobufjs/light");
63
+
64
+ // Static code only
65
+ var protobuf = require("protobufjs/minimal");
66
+ ```
67
+
68
+ The optional [command line utility](./cli/) to generate static code and reflection bundles lives in the `protobufjs-cli` package and can be installed separately:
25
69
 
26
70
  ```sh
27
- npm install --save-dev protobufjs-cli
71
+ npm install protobufjs-cli --save-dev
28
72
  ```
29
73
 
30
- The CLI is a JS-native protobuf.js toolchain that does not require setting up `protoc`. If you prefer a `protoc`-based workflow, it provides `protoc-gen-pbjs` as an option.
74
+ ### Browsers
75
+
76
+ Pick the variant matching your needs and replace the version tag with the exact [release](https://github.com/protobufjs/protobuf.js/tags) your project depends upon. For example, to use the minified full variant:
31
77
 
32
- #### Browser builds
78
+ ```html
79
+ <script src="//cdn.jsdelivr.net/npm/protobufjs@7.X.X/dist/protobuf.min.js"></script>
80
+ ```
33
81
 
34
- Canonical browser builds are [provided via the jsDelivr CDN](https://cdn.jsdelivr.net/npm/protobufjs@8.X.X/dist/), supporting CommonJS, AMD and global `window.protobuf`. Make sure to pin an exact version in production.
82
+ | Distribution | Location
83
+ |--------------|--------------------------------------------------------
84
+ | Full | <https://cdn.jsdelivr.net/npm/protobufjs/dist/>
85
+ | Light | <https://cdn.jsdelivr.net/npm/protobufjs/dist/light/>
86
+ | Minimal | <https://cdn.jsdelivr.net/npm/protobufjs/dist/minimal/>
35
87
 
36
- ## Usage
88
+ All variants support CommonJS and AMD loaders and export globally as `window.protobuf`.
37
89
 
38
- The examples below use this schema:
90
+ Usage
91
+ -----
39
92
 
40
- ```proto
41
- syntax = "proto3";
93
+ Because JavaScript is a dynamically typed language, protobuf.js utilizes the concept of a **valid message** in order to provide the best possible [performance](#performance) (and, as a side product, proper typings):
42
94
 
95
+ ### Valid message
96
+
97
+ > A valid message is an object (1) not missing any required fields and (2) exclusively composed of JS types understood by the wire format writer.
98
+
99
+ There are two possible types of valid messages and the encoder is able to work with both of these for convenience:
100
+
101
+ * **Message instances** (explicit instances of message classes with default values on their prototype) naturally satisfy the requirements of a valid message and
102
+ * **Plain JavaScript objects** that just so happen to be composed in a way satisfying the requirements of a valid message as well.
103
+
104
+ In a nutshell, the wire format writer understands the following types:
105
+
106
+ | Field type | Expected JS type (create, encode) | Conversion (fromObject)
107
+ |------------|-----------------------------------|------------------------
108
+ | s-/u-/int32<br />s-/fixed32 | `number` (32 bit integer) | <code>value &#124; 0</code> if signed<br />`value >>> 0` if unsigned
109
+ | s-/u-/int64<br />s-/fixed64 | `Long`-like (optimal)<br />`number` (53 bit integer) | `Long.fromValue(value)` with long.js<br />`parseInt(value, 10)` otherwise
110
+ | float<br />double | `number` | `Number(value)`
111
+ | bool | `boolean` | `Boolean(value)`
112
+ | string | `string` | `String(value)`
113
+ | bytes | `Uint8Array` (optimal)<br />`Buffer` (optimal under node)<br />`Array.<number>` (8 bit integers) | `base64.decode(value)` if a `string`<br />`Object` with non-zero `.length` is assumed to be buffer-like
114
+ | enum | `number` (32 bit integer) | Looks up the numeric id if a `string`
115
+ | message | Valid message | `Message.fromObject(value)`
116
+ | repeated T | `Array<T>` | Copy
117
+ | map<K, V> | `Object<K,V>` | Copy
118
+
119
+ * Explicit `undefined` and `null` are considered as not set if the field is optional.
120
+ * Maps are objects where the key is the string representation of the respective value or an 8 characters long hash string for `Long`-likes.
121
+
122
+ ### Toolset
123
+
124
+ With that in mind and again for performance reasons, each message class provides a distinct set of methods with each method doing just one thing. This avoids unnecessary assertions / redundant operations where performance is a concern but also forces a user to perform verification (of plain JavaScript objects that *might* just so happen to be a valid message) explicitly where necessary - for example when dealing with user input.
125
+
126
+ **Note** that `Message` below refers to any message class.
127
+
128
+ * **Message.verify**(message: `Object`): `null|string`<br />
129
+ verifies that a **plain JavaScript object** satisfies the requirements of a valid message and thus can be encoded without issues. Instead of throwing, it returns the error message as a string, if any.
130
+
131
+ ```js
132
+ var payload = "invalid (not an object)";
133
+ var err = AwesomeMessage.verify(payload);
134
+ if (err)
135
+ throw Error(err);
136
+ ```
137
+
138
+ * **Message.encode**(message: `Message|Object` [, writer: `Writer`]): `Writer`<br />
139
+ encodes a **message instance** or valid **plain JavaScript object**. This method does not implicitly verify the message and it's up to the user to make sure that the payload is a valid message.
140
+
141
+ ```js
142
+ var buffer = AwesomeMessage.encode(message).finish();
143
+ ```
144
+
145
+ * **Message.encodeDelimited**(message: `Message|Object` [, writer: `Writer`]): `Writer`<br />
146
+ works like `Message.encode` but additionally prepends the length of the message as a varint.
147
+
148
+ * **Message.decode**(reader: `Reader|Uint8Array`): `Message`<br />
149
+ decodes a buffer to a **message instance**. If required fields are missing, it throws a `util.ProtocolError` with an `instance` property set to the so far decoded message. If the wire format is invalid, it throws an `Error`.
150
+
151
+ ```js
152
+ try {
153
+ var decodedMessage = AwesomeMessage.decode(buffer);
154
+ } catch (e) {
155
+ if (e instanceof protobuf.util.ProtocolError) {
156
+ // e.instance holds the so far decoded message with missing required fields
157
+ } else {
158
+ // wire format is invalid
159
+ }
160
+ }
161
+ ```
162
+
163
+ * **Message.decodeDelimited**(reader: `Reader|Uint8Array`): `Message`<br />
164
+ works like `Message.decode` but additionally reads the length of the message prepended as a varint.
165
+
166
+ * **Message.create**(properties: `Object`): `Message`<br />
167
+ creates a new **message instance** from a set of properties that satisfy the requirements of a valid message. Where applicable, it is recommended to prefer `Message.create` over `Message.fromObject` because it doesn't perform possibly redundant conversion.
168
+
169
+ ```js
170
+ var message = AwesomeMessage.create({ awesomeField: "AwesomeString" });
171
+ ```
172
+
173
+ * **Message.fromObject**(object: `Object`): `Message`<br />
174
+ converts any non-valid **plain JavaScript object** to a **message instance** using the conversion steps outlined within the table above.
175
+
176
+ ```js
177
+ var message = AwesomeMessage.fromObject({ awesomeField: 42 });
178
+ // converts awesomeField to a string
179
+ ```
180
+
181
+ * **Message.toObject**(message: `Message` [, options: `ConversionOptions`]): `Object`<br />
182
+ converts a **message instance** to an arbitrary **plain JavaScript object** for interoperability with other libraries or storage. The resulting plain JavaScript object *might* still satisfy the requirements of a valid message depending on the actual conversion options specified, but most of the time it does not.
183
+
184
+ ```js
185
+ var object = AwesomeMessage.toObject(message, {
186
+ enums: String, // enums as string names
187
+ longs: String, // longs as strings (or BigInt for bigint values)
188
+ bytes: String, // bytes as base64 encoded strings
189
+ defaults: true, // includes default values
190
+ arrays: true, // populates empty arrays (repeated fields) even if defaults=false
191
+ objects: true, // populates empty objects (map fields) even if defaults=false
192
+ oneofs: true // includes virtual oneof fields set to the present field's name
193
+ });
194
+ ```
195
+
196
+ For reference, the following diagram aims to display relationships between the different methods and the concept of a valid message:
197
+
198
+ <p align="center"><img alt="Toolset Diagram" src="https://protobufjs.github.io/protobuf.js/toolset.svg" /></p>
199
+
200
+ > In other words: `verify` indicates that calling `create` or `encode` directly on the plain object will [result in a valid message respectively] succeed. `fromObject`, on the other hand, does conversion from a broader range of plain objects to create valid messages. ([ref](https://github.com/protobufjs/protobuf.js/issues/748#issuecomment-291925749))
201
+
202
+ Examples
203
+ --------
204
+
205
+ ### Using .proto files
206
+
207
+ It is possible to load existing .proto files using the full library, which parses and compiles the definitions to ready to use (reflection-based) message classes:
208
+
209
+ ```protobuf
210
+ // awesome.proto
43
211
  package awesomepackage;
212
+ syntax = "proto3";
44
213
 
45
214
  message AwesomeMessage {
46
- string awesome_field = 1;
215
+ string awesome_field = 1; // becomes awesomeField
47
216
  }
48
217
  ```
49
218
 
50
- protobuf.js converts `.proto` field names to camelCase by default, so `awesome_field` is used as `awesomeField` in JavaScript. Use the `keepCase` option when loading or parsing `.proto` files to preserve field names as written.
219
+ ```js
220
+ protobuf.load("awesome.proto", function(err, root) {
221
+ if (err)
222
+ throw err;
51
223
 
52
- ### Load a schema
224
+ // Obtain a message type
225
+ var AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage");
53
226
 
54
- ```ts
55
- const protobuf = require("protobufjs");
227
+ // Exemplary payload
228
+ var payload = { awesomeField: "AwesomeString" };
56
229
 
57
- const root = await protobuf.load("awesome.proto");
58
- const AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage");
59
- ```
230
+ // Verify the payload if necessary (i.e. when possibly incomplete or invalid)
231
+ var errMsg = AwesomeMessage.verify(payload);
232
+ if (errMsg)
233
+ throw Error(errMsg);
60
234
 
61
- Optionally use `load()` with a callback, or `loadSync()` for synchronous loading on Node.js. Imports resolve relative to the importing file by default. To resolve imports against a specific base directory, create a `Root` and override `root.resolvePath` before calling `root.load()`.
235
+ // Create a new message
236
+ var message = AwesomeMessage.create(payload); // or use .fromObject if conversion is necessary
62
237
 
63
- ### Encode and decode
238
+ // Encode a message to an Uint8Array (browser) or Buffer (node)
239
+ var buffer = AwesomeMessage.encode(message).finish();
240
+ // ... do something with buffer
64
241
 
65
- ```ts
66
- const payload = { awesomeField: "hello" };
242
+ // Decode an Uint8Array (browser) or Buffer (node) to a message
243
+ var message = AwesomeMessage.decode(buffer);
244
+ // ... do something with message
67
245
 
68
- // Optionally create a message instance from already valid data
69
- const message = AwesomeMessage.create(payload);
246
+ // If the application uses length-delimited buffers, there is also encodeDelimited and decodeDelimited.
70
247
 
71
- const encoded = AwesomeMessage.encode(message).finish();
72
- const decoded = AwesomeMessage.decode(encoded);
248
+ // Maybe convert the message back to a plain object
249
+ var object = AwesomeMessage.toObject(message, {
250
+ longs: String,
251
+ enums: String,
252
+ bytes: String,
253
+ // see ConversionOptions
254
+ });
255
+ });
73
256
  ```
74
257
 
75
- `encode` expects a message instance or equivalent plain object and does not verify input implicitly. Use `create` to create a message instance from already valid data when useful, `verify` for plain objects whose shape is not guaranteed, and `fromObject` when conversion from broader JavaScript objects is needed.
258
+ Additionally, promise syntax can be used by omitting the callback, if preferred:
76
259
 
77
- Plain objects can be encoded directly when they already use protobuf.js runtime types: numbers for 32-bit numeric fields, booleans for `bool`, strings for `string`, `Uint8Array` or `Buffer` for `bytes`, arrays for repeated fields, and plain objects for maps. Map keys are the string representation of the respective value or an 8-character hash string for 64-bit keys.
260
+ ```js
261
+ protobuf.load("awesome.proto")
262
+ .then(function(root) {
263
+ ...
264
+ });
265
+ ```
78
266
 
79
- Note that, as with any structured binary format, decoded structures incur runtime memory overhead beyond their encoded representation. Applications processing untrusted input should therefore apply appropriate input-size and concurrency limits to bound memory use. For this reason, unknown fields present on the wire are intentionally discarded as the safer default, but can be retained by setting `reader.discardUnknown = false` per reader, or by setting `Reader.discardUnknown = false` to make it the default for subsequently created readers. Preserved unknown field data can also be explicitly dropped with `delete message.$unknowns`.
267
+ ### Using JSON descriptors
268
+
269
+ The library utilizes JSON descriptors that are equivalent to a .proto definition. For example, the following is identical to the .proto definition seen above:
270
+
271
+ ```json
272
+ // awesome.json
273
+ {
274
+ "nested": {
275
+ "awesomepackage": {
276
+ "nested": {
277
+ "AwesomeMessage": {
278
+ "fields": {
279
+ "awesomeField": {
280
+ "type": "string",
281
+ "id": 1
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ ```
80
290
 
81
- ### Convert plain objects
291
+ JSON descriptors closely resemble the internal reflection structure:
82
292
 
83
- Conversion is an explicit interoperability boundary. `fromObject` accepts common JavaScript inputs such as enum values by name, base64 bytes, decimal 64-bit strings, `Long`, and `BigInt`; `toObject` lets callers choose the output expected by their application or transport.
293
+ | Type (T) | Extends | Type-specific properties
294
+ |--------------------|--------------------|-------------------------
295
+ | *ReflectionObject* | | options
296
+ | *Namespace* | *ReflectionObject* | nested
297
+ | Root | *Namespace* | **nested**
298
+ | Type | *Namespace* | **fields**
299
+ | Enum | *ReflectionObject* | **values**
300
+ | Field | *ReflectionObject* | rule, **type**, **id**
301
+ | MapField | Field | **keyType**
302
+ | OneOf | *ReflectionObject* | **oneof** (array of field names)
303
+ | Service | *Namespace* | **methods**
304
+ | Method | *ReflectionObject* | type, **requestType**, **responseType**, requestStream, responseStream
84
305
 
85
- ```ts
86
- const message = AwesomeMessage.fromObject({ awesomeField: 42 });
87
- const object = AwesomeMessage.toObject(message, {
88
- longs: String,
89
- enums: String,
90
- bytes: String
306
+ * **Bold properties** are required. *Italic types* are abstract.
307
+ * `T.fromJSON(name, json)` creates the respective reflection object from a JSON descriptor
308
+ * `T#toJSON()` creates a JSON descriptor from the respective reflection object (its name is used as the key within the parent)
309
+
310
+ Exclusively using JSON descriptors instead of .proto files enables the use of just the light library (the parser isn't required in this case).
311
+
312
+ A JSON descriptor can either be loaded the usual way:
313
+
314
+ ```js
315
+ protobuf.load("awesome.json", function(err, root) {
316
+ if (err) throw err;
317
+
318
+ // Continue at "Obtain a message type" above
91
319
  });
92
320
  ```
93
321
 
94
- Common `ConversionOptions` are:
322
+ Or it can be loaded inline:
95
323
 
96
- | Option | Effect |
97
- |--------|--------|
98
- | `longs: BigInt` | Converts 64-bit values to bigint values |
99
- | `longs: String` | Converts 64-bit values to decimal strings |
100
- | `longs: Number` | Converts 64-bit values to JS numbers (may lose precision) |
101
- | `enums: String` | Converts enum values to names |
102
- | `bytes: String` | Converts bytes to base64 strings |
103
- | `defaults: true` | Includes default values for unset fields |
104
- | `arrays: true` | Includes empty arrays for repeated fields |
105
- | `objects: true` | Includes empty objects for map fields |
106
- | `oneofs: true` | Includes virtual oneof discriminator properties |
324
+ ```js
325
+ var jsonDescriptor = require("./awesome.json"); // exemplary for node
107
326
 
108
- ## Message API
327
+ var root = protobuf.Root.fromJSON(jsonDescriptor);
109
328
 
110
- Message types expose focused methods for validation, conversion, and binary I/O.
329
+ // Continue at "Obtain a message type" above
330
+ ```
111
331
 
112
- * **encode**(message: `Message | object`, writer?: `Writer`): `Writer`
113
- Encodes a message or equivalent plain object. Call `.finish()` on the returned writer to obtain a buffer.
332
+ ### Using reflection only
114
333
 
115
- * **encodeDelimited**(message: `Message | object`, writer?: `Writer`): `Writer`
116
- Encodes a length-delimited message.
334
+ Both the full and the light library include full reflection support. One could, for example, define the .proto definitions seen in the examples above using just reflection:
117
335
 
118
- * **decode**(reader: `Reader | Uint8Array`): `Message`
119
- Decodes a message from protobuf binary data.
336
+ ```js
337
+ ...
338
+ var Root = protobuf.Root,
339
+ Type = protobuf.Type,
340
+ Field = protobuf.Field;
120
341
 
121
- * **decodeDelimited**(reader: `Reader | Uint8Array`): `Message`
122
- Decodes a length-delimited message.
342
+ var AwesomeMessage = new Type("AwesomeMessage").add(new Field("awesomeField", 1, "string"));
123
343
 
124
- * **create**(properties?: `object`): `Message`
125
- Creates a message instance from already valid data.
344
+ var root = new Root().define("awesomepackage").add(AwesomeMessage);
126
345
 
127
- * **verify**(object: `object`): `null | string`
128
- Checks whether a plain object can be encoded as-is. Returns `null` if valid, otherwise an error message.
346
+ // Continue at "Create a new message" above
347
+ ...
348
+ ```
129
349
 
130
- * **fromObject**(object: `object`): `Message`
131
- Converts broader JavaScript input into a message instance.
350
+ Detailed information on the reflection structure is available within the [API documentation](#additional-documentation).
132
351
 
133
- * **toObject**(message: `Message`, options?: `ConversionOptions`): `object`
134
- Converts a message instance to a configurable plain JavaScript object.
352
+ ### Using custom classes
135
353
 
136
- * **message.toJSON**(): `object`
137
- Converts a message instance to JSON-compatible output using default conversion options.
354
+ Message classes can also be extended with custom functionality and it is also possible to register a custom constructor with a reflected message type:
138
355
 
139
- Message instances provide stable runtime identity for testing with `instanceof`.
356
+ ```js
357
+ ...
140
358
 
141
- Length-delimited methods read and write a varint byte length before the message, which is useful for streams and framed protocols.
359
+ // Define a custom constructor
360
+ function AwesomeMessage(properties) {
361
+ // custom initialization code
362
+ ...
363
+ }
142
364
 
143
- If required fields are missing while decoding proto2 data, `decode` throws `protobuf.util.ProtocolError` with the partially decoded message available as `err.instance`.
365
+ // Register the custom constructor with its reflected type (*)
366
+ root.lookupType("awesomepackage.AwesomeMessage").ctor = AwesomeMessage;
144
367
 
145
- ## Code generation
368
+ // Define custom functionality
369
+ AwesomeMessage.customStaticMethod = function() { ... };
370
+ AwesomeMessage.prototype.customInstanceMethod = function() { ... };
146
371
 
147
- Use [`protobufjs-cli`](./cli/#readme) to generate schema-specific code, either directly with `pbjs` or through the optional `protoc-gen-pbjs` plugin for `protoc`.
372
+ // Continue at "Create a new message" above
373
+ ```
148
374
 
149
- protobuf.js offers two code-generation modes, both with matching TypeScript declarations: reflection modules generate optimized code at runtime with reflection metadata retained; static modules generate reflection-free code ahead of time. Both use the same runtime package and automatically import only the runtime capabilities they need.
375
+ (*) Besides referencing its reflected type through `AwesomeMessage.$type` and `AwesomeMesage#$type`, the respective custom class is automatically populated with:
150
376
 
151
- | Target | Output | Runtime entry |
152
- |--------|--------|---------------|
153
- | `json-module` | Reflection module | `protobufjs/light.js` (without parser) |
154
- | `static-module` | Static code module | `protobufjs/minimal.js` (without reflection) |
377
+ * `AwesomeMessage.create`
378
+ * `AwesomeMessage.encode` and `AwesomeMessage.encodeDelimited`
379
+ * `AwesomeMessage.decode` and `AwesomeMessage.decodeDelimited`
380
+ * `AwesomeMessage.verify`
381
+ * `AwesomeMessage.fromObject`, `AwesomeMessage.toObject` and `AwesomeMessage#toJSON`
155
382
 
156
- Module targets support `--wrap default` for CommonJS and AMD, plus `esm`, `commonjs`, `amd`, and `closure`; `--wrap` can also load a custom wrapper module.
383
+ Afterwards, decoded messages of this type are `instanceof AwesomeMessage`.
157
384
 
158
- ### Static modules
385
+ Alternatively, it is also possible to reuse and extend the internal constructor if custom initialization code is not required:
159
386
 
160
- Static modules emit dedicated, reflection-free JavaScript code for your schema.
387
+ ```js
388
+ ...
161
389
 
162
- ```sh
163
- npx pbjs -t static-module -w esm -o awesome.js --dts awesome.proto
164
- ```
390
+ // Reuse the internal constructor
391
+ var AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage").ctor;
165
392
 
166
- ```ts
167
- import { awesomepackage } from "./awesome.js";
393
+ // Define custom functionality
394
+ AwesomeMessage.customStaticMethod = function() { ... };
395
+ AwesomeMessage.prototype.customInstanceMethod = function() { ... };
168
396
 
169
- const message = awesomepackage.AwesomeMessage.create({ awesomeField: "hello" });
397
+ // Continue at "Create a new message" above
170
398
  ```
171
399
 
172
- Static code is repetitive by design, but compresses unusually well with Brotli or gzip and works in [CSP](https://w3c.github.io/webappsec-csp/)-restricted environments.
173
-
174
- ### Reflection modules
400
+ ### Using services
175
401
 
176
- Reflection modules wrap schemas as compact JSON metadata while avoiding `.proto` parsing at runtime.
402
+ The library also supports consuming services but it doesn't make any assumptions about the actual transport channel. Instead, a user must provide a suitable RPC implementation, which is an asynchronous function that takes the reflected service method, the binary request and a node-style callback as its parameters:
177
403
 
178
- ```sh
179
- npx pbjs -t json-module -w esm -o awesome.js --dts awesome.proto
404
+ ```js
405
+ function rpcImpl(method, requestData, callback) {
406
+ // perform the request using an HTTP request or a WebSocket for example
407
+ var responseData = ...;
408
+ // and call the callback with the binary response afterwards:
409
+ callback(null, responseData);
410
+ }
180
411
  ```
181
412
 
413
+ Below is a working example with a typescript implementation using grpc npm package.
182
414
  ```ts
183
- import { awesomepackage } from "./awesome.js";
184
-
185
- const AwesomeMessage = awesomepackage.AwesomeMessage;
415
+ const grpc = require('grpc')
416
+
417
+ const Client = grpc.makeGenericClientConstructor({})
418
+ const client = new Client(
419
+ grpcServerUrl,
420
+ grpc.credentials.createInsecure()
421
+ )
422
+
423
+ const rpcImpl = function(method, requestData, callback) {
424
+ client.makeUnaryRequest(
425
+ method.name,
426
+ arg => arg,
427
+ arg => arg,
428
+ requestData,
429
+ callback
430
+ )
431
+ }
186
432
  ```
187
433
 
188
- Declarations for reflection modules mirror `static-module` typings. Because JSON modules export reflection objects, message instances should be created with `MyMessage.create(...)` rather than constructors. Code using `create(...)` works with static modules as well. Separately, `-t json` can serialize reflection metadata as bare JSON bundles for use with `load()` or `Root.fromJSON()`.
434
+ Example:
189
435
 
190
- ### TypeScript integration
436
+ ```protobuf
437
+ // greeter.proto
438
+ syntax = "proto3";
191
439
 
192
- protobuf.js works with TypeScript out of the box: its runtime API is typed, and generated code can be paired with matching TypeScript declarations in a single CLI invocation. Declarations are strongly typed, including discriminated unions for oneofs and scoped types for plain-object usage:
440
+ service Greeter {
441
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
442
+ }
193
443
 
194
- ```proto
195
- message Profile {
196
- oneof contact {
197
- string email = 1;
198
- string phone = 2;
199
- }
444
+ message HelloRequest {
445
+ string name = 1;
446
+ }
447
+
448
+ message HelloReply {
449
+ string message = 1;
200
450
  }
201
451
  ```
202
452
 
203
- ```ts
204
- const profile = Profile.create({
205
- contact: "email",
206
- email: "hello@example.com"
453
+ ```js
454
+ ...
455
+ var Greeter = root.lookup("Greeter");
456
+ var greeter = Greeter.create(/* see above */ rpcImpl, /* request delimited? */ false, /* response delimited? */ false);
457
+
458
+ greeter.sayHello({ name: 'you' }, function(err, response) {
459
+ console.log('Greeting:', response.message);
207
460
  });
461
+ ```
208
462
 
209
- if (profile.contact === "email") {
210
- profile.email; // string
211
- }
463
+ Services also support promises:
212
464
 
213
- const decoded = Profile.decode(bytes);
214
- if (decoded.contact === "phone") {
215
- decoded.phone; // string
216
- }
465
+ ```js
466
+ greeter.sayHello({ name: 'you' })
467
+ .then(function(response) {
468
+ console.log('Greeting:', response.message);
469
+ });
217
470
  ```
218
471
 
219
- The same narrowed shape is available for plain-object inputs:
472
+ There is also an [example for streaming RPC](https://github.com/protobufjs/protobuf.js/blob/master/examples/streaming-rpc.js).
220
473
 
221
- ```ts
222
- const object: Profile.$Shape = {
223
- contact: "email",
224
- email: "hello@example.com"
225
- };
226
- ```
474
+ Note that the service API is meant for clients. Implementing a server-side endpoint pretty much always requires transport channel (i.e. http, websocket, etc.) specific code with the only common denominator being that it decodes and encodes messages.
475
+
476
+ ### Usage with TypeScript
227
477
 
228
- ## Advanced usage
478
+ The library ships with its own [type definitions](https://github.com/protobufjs/protobuf.js/blob/master/index.d.ts) and modern editors like [Visual Studio Code](https://code.visualstudio.com/) will automatically detect and use them for code completion.
229
479
 
230
- ### Programmatic schemas
480
+ The npm package depends on [@types/node](https://www.npmjs.com/package/@types/node) because of `Buffer` and [@types/long](https://www.npmjs.com/package/@types/long) because of `Long`. If you are not building for node and/or not using long.js, it should be safe to exclude them manually.
231
481
 
232
- Schemas can be constructed directly through reflection:
482
+ #### Using the JS API
483
+
484
+ The API shown above works pretty much the same with TypeScript. However, because everything is typed, accessing fields on instances of dynamically generated message classes requires either using bracket-notation (i.e. `message["awesomeField"]`) or explicit casts. Alternatively, it is possible to use a [typings file generated for its static counterpart](#pbts-for-typescript).
233
485
 
234
486
  ```ts
235
- const AwesomeMessage = new protobuf.Type("AwesomeMessage")
236
- .add(new protobuf.Field("awesomeField", 1, "string"));
487
+ import { load } from "protobufjs"; // respectively "./node_modules/protobufjs"
488
+
489
+ load("awesome.proto", function(err, root) {
490
+ if (err)
491
+ throw err;
492
+
493
+ // example code
494
+ const AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage");
495
+
496
+ let message = AwesomeMessage.create({ awesomeField: "hello" });
497
+ console.log(`message = ${JSON.stringify(message)}`);
237
498
 
238
- const root = new protobuf.Root()
239
- .define("awesomepackage")
240
- .add(AwesomeMessage);
499
+ let buffer = AwesomeMessage.encode(message).finish();
500
+ console.log(`buffer = ${Array.prototype.toString.call(buffer)}`);
501
+
502
+ let decoded = AwesomeMessage.decode(buffer);
503
+ console.log(`decoded = ${JSON.stringify(decoded)}`);
504
+ });
241
505
  ```
242
506
 
243
- ### Custom message classes
507
+ #### Using generated static code
244
508
 
245
- A reflected type can use a custom class as its runtime constructor:
509
+ If you generated static code to `bundle.js` using the CLI and its type definitions to `bundle.d.ts`, then you can just do:
246
510
 
247
511
  ```ts
248
- class AwesomeMessage extends protobuf.Message<AwesomeMessage> {
249
- awesomeField = "";
512
+ import { AwesomeMessage } from "./bundle.js";
250
513
 
251
- constructor(properties?: protobuf.Properties<AwesomeMessage>) {
252
- super(properties);
253
- // ...
254
- }
514
+ // example code
515
+ let message = AwesomeMessage.create({ awesomeField: "hello" });
516
+ let buffer = AwesomeMessage.encode(message).finish();
517
+ let decoded = AwesomeMessage.decode(buffer);
518
+ ```
255
519
 
256
- customInstanceMethod() {
257
- return this.awesomeField.toLowerCase();
258
- }
259
- }
520
+ #### Using decorators
260
521
 
261
- root.lookupType("awesomepackage.AwesomeMessage").ctor = AwesomeMessage;
522
+ The library also includes an early implementation of [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html).
262
523
 
263
- const decoded = AwesomeMessage.decode(bytes);
264
- decoded.customInstanceMethod(); // string
265
- ```
524
+ **Note** that decorators are an experimental feature in TypeScript and that declaration order is important depending on the JS target. For example, `@Field.d(2, AwesomeArrayMessage)` requires that `AwesomeArrayMessage` has been defined earlier when targeting `ES5`.
266
525
 
267
- protobuf.js will populate the constructor with the usual static runtime methods and use it for decoded messages. When assigning constructors manually, add the type to its parent namespace/root first if fields reference other reflected types. In TypeScript, custom members are visible when using the custom class type in consuming code.
526
+ ```ts
527
+ import { Message, Type, Field, OneOf } from "protobufjs/light"; // respectively "./node_modules/protobufjs/light.js"
268
528
 
269
- ### Services
529
+ export class AwesomeSubMessage extends Message<AwesomeSubMessage> {
270
530
 
271
- protobuf.js supports service clients built from service definitions. The service API is transport-agnostic: provide an `rpcImpl` function to connect it to HTTP, WebSocket, gRPC, or another transport.
531
+ @Field.d(1, "string")
532
+ public awesomeString: string;
272
533
 
273
- ```js
274
- function myRpcImpl(method, requestData, callback) {
275
- // method.name
276
- // method.path
277
- // method.requestStream?
278
- // method.responseStream?
279
- performRequest(requestData, function(err, responseData) {
280
- callback(err, responseData);
281
- });
282
534
  }
283
535
 
284
- const myService = MyService.create(myRpcImpl/*, requestDelimited?, responseDelimited? */);
285
- ```
536
+ export enum AwesomeEnum {
537
+ ONE = 1,
538
+ TWO = 2
539
+ }
286
540
 
287
- See [examples/streaming-rpc.js](./examples/streaming-rpc.js) for a streaming example.
541
+ @Type.d("SuperAwesomeMessage")
542
+ export class AwesomeMessage extends Message<AwesomeMessage> {
288
543
 
289
- See [examples/grpc-service.js](./examples/grpc-service.js) for an integration example with [@grpc/grpc-js](https://www.npmjs.com/package/@grpc/grpc-js).
544
+ @Field.d(1, "string", "optional", "awesome default string")
545
+ public awesomeField: string;
290
546
 
291
- ### Extensions
547
+ @Field.d(2, AwesomeSubMessage)
548
+ public awesomeSubMessage: AwesomeSubMessage;
292
549
 
293
- The following extensions provide descriptor conversion and text-based protobuf formats when reflection metadata is available. Most applications only need the binary APIs above.
550
+ @Field.d(3, AwesomeEnum, "optional", AwesomeEnum.ONE)
551
+ public awesomeEnum: AwesomeEnum;
294
552
 
295
- #### Descriptors
553
+ @OneOf.d("awesomeSubMessage", "awesomeEnum")
554
+ public which: string;
296
555
 
297
- protobuf.js uses a compact JSON-based reflection representation internally. See [ext/descriptor](./ext/README.md#descriptor) for use cases that need conversion between reflected roots and `protoc` descriptor messages.
556
+ }
298
557
 
299
- #### ProtoJSON
558
+ // example code
559
+ let message = new AwesomeMessage({ awesomeField: "hello" });
560
+ let buffer = AwesomeMessage.encode(message).finish();
561
+ let decoded = AwesomeMessage.decode(buffer);
562
+ ```
300
563
 
301
- Protocol Buffers support a special [ProtoJSON format](https://protobuf.dev/programming-guides/json/) to share data with systems that do not support the binary wire format, for example when implementing gateways. Spec-compliant ProtoJSON is supported via [ext/protojson](./ext/README.md#protojson).
564
+ Supported decorators are:
302
565
 
303
- #### Text Format
566
+ * **Type.d(typeName?: `string`)** &nbsp; *(optional)*<br />
567
+ annotates a class as a protobuf message type. If `typeName` is not specified, the constructor's runtime function name is used for the reflected type.
304
568
 
305
- Protocol Buffers [Text Format](https://protobuf.dev/reference/protobuf/textformat-spec/) is a special syntax for representing protobuf data in text form, which can be useful for configurations or tests. Spec-compliant Text Format is supported via [ext/textformat](./ext/README.md#textformat).
569
+ * **Field.d&lt;T>(fieldId: `number`, fieldType: `string | Constructor<T>`, fieldRule?: `"optional" | "required" | "repeated"`, defaultValue?: `T`)**<br />
570
+ annotates a property as a protobuf field with the specified id and protobuf type.
306
571
 
307
- ## Conformance
572
+ * **MapField.d&lt;T extends { [key: string]: any }>(fieldId: `number`, fieldKeyType: `string`, fieldValueType. `string | Constructor<{}>`)**<br />
573
+ annotates a property as a protobuf map field with the specified id, protobuf key and value type.
308
574
 
309
- protobuf.js is validated against the official Protocol Buffers conformance suite. It passes all required and recommended tests for the **Proto2**, **Proto3** and **Editions** binary wire formats, with complete **ProtoJSON** and **Text Format** support available as optional extensions when those formats are needed.
575
+ * **OneOf.d&lt;T extends string>(...fieldNames: `string[]`)**<br />
576
+ annotates a property as a protobuf oneof covering the specified fields.
310
577
 
311
- <!-- BEGIN CONFORMANCE DATA -->
578
+ Other notes:
312
579
 
313
- | Category | Total | Required | Recommended |
314
- | ---------- | ------------------: | ------------------: | ------------------: |
315
- | Binary | 100.00% (2835/2835) | 100.00% (1958/1958) | 100.00% (877/877) |
316
- | ↳ Proto2 | 100.00% (707/707) | 100.00% (489/489) | 100.00% (218/218) |
317
- | ↳ Proto3 | 100.00% (707/707) | 100.00% (486/486) | 100.00% (221/221) |
318
- | ↳ Editions | 100.00% (1421/1421) | 100.00% (983/983) | 100.00% (438/438) |
319
- | ProtoJSON | 100.00% (2814/2814) | 100.00% (2362/2362) | 100.00% (452/452) |
320
- | TextFormat | 100.00% (909/909) | 100.00% (845/845) | 100.00% (64/64) |
321
- | Overall | 100.00% (6558/6558) | 100.00% (5165/5165) | 100.00% (1393/1393) |
580
+ * Decorated types reside in `protobuf.roots["decorated"]` using a flat structure, so no duplicate names.
581
+ * Enums are copied to a reflected enum with a generic name on decorator evaluation because referenced enum objects have no runtime name the decorator could use.
582
+ * Default values must be specified as arguments to the decorator instead of using a property initializer for proper prototype behavior.
583
+ * Property names on decorated classes must not be renamed on compile time (i.e. by a minifier) because decorators just receive the original field name as a string.
322
584
 
323
- <!-- END CONFORMANCE DATA -->
585
+ **ProTip!** Not as pretty, but you can [use decorators in plain JavaScript](https://github.com/protobufjs/protobuf.js/blob/master/examples/js-decorators.js) as well.
324
586
 
325
- | Edition | Supported since
326
- |---------|----------------
327
- | 2023 | v7.5.0
328
- | 2024 | v8.0.0
329
- | 2026 | v8.8.0
587
+ Additional documentation
588
+ ------------------------
330
589
 
331
- [Structured results](https://github.com/protobufjs/protobuf.js/actions/workflows/test.yml?query=branch%3Amaster+event%3Apush) of the conformance tests are also available as CI artifacts.
590
+ #### Protocol Buffers
591
+ * [Google's Developer Guide](https://protobuf.dev/overview/)
332
592
 
333
- ## Performance
593
+ #### protobuf.js
594
+ * [API Documentation](https://protobufjs.github.io/protobuf.js)
595
+ * [CHANGELOG](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md)
596
+ * [Frequently asked questions](https://github.com/protobufjs/protobuf.js/wiki) on our wiki
334
597
 
335
- protobuf.js's reflection and static modes share the same code-generation backend and underlying hand-tuned reader and writer primitives. Reflection mode emits specialized encoders and decoders just in time, while static mode emits equivalent code ahead of time.
598
+ #### Community
599
+ * [Questions and answers](http://stackoverflow.com/search?tab=newest&q=protobuf.js) on StackOverflow
336
600
 
337
- To see how this architecture compares in practice, the repository includes a reproducible [benchmark suite](./bench) measuring both modes alongside other general-purpose JavaScript implementations across three cases: our classic common message shape and two unmodified, structurally distinct fixtures sourced from other implementations. Each library is tested through its recommended serialization and deserialization path using identical schemas and message contents.
601
+ Performance
602
+ -----------
603
+ The package includes a benchmark that compares protobuf.js performance to native JSON (as far as this is possible) and [Google's JS implementation](https://github.com/google/protobuf/tree/master/js). On an i7-2600K running node 6.9.1 it yields:
338
604
 
339
- <!-- BEGIN BENCHMARK DATA -->
605
+ ```
606
+ benchmarking encoding performance ...
607
+
608
+ protobuf.js (reflect) x 541,707 ops/sec ±1.13% (87 runs sampled)
609
+ protobuf.js (static) x 548,134 ops/sec ±1.38% (89 runs sampled)
610
+ JSON (string) x 318,076 ops/sec ±0.63% (93 runs sampled)
611
+ JSON (buffer) x 179,165 ops/sec ±2.26% (91 runs sampled)
612
+ google-protobuf x 74,406 ops/sec ±0.85% (86 runs sampled)
613
+
614
+ protobuf.js (static) was fastest
615
+ protobuf.js (reflect) was 0.9% ops/sec slower (factor 1.0)
616
+ JSON (string) was 41.5% ops/sec slower (factor 1.7)
617
+ JSON (buffer) was 67.6% ops/sec slower (factor 3.1)
618
+ google-protobuf was 86.4% ops/sec slower (factor 7.3)
619
+
620
+ benchmarking decoding performance ...
621
+
622
+ protobuf.js (reflect) x 1,383,981 ops/sec ±0.88% (93 runs sampled)
623
+ protobuf.js (static) x 1,378,925 ops/sec ±0.81% (93 runs sampled)
624
+ JSON (string) x 302,444 ops/sec ±0.81% (93 runs sampled)
625
+ JSON (buffer) x 264,882 ops/sec ±0.81% (93 runs sampled)
626
+ google-protobuf x 179,180 ops/sec ±0.64% (94 runs sampled)
627
+
628
+ protobuf.js (reflect) was fastest
629
+ protobuf.js (static) was 0.3% ops/sec slower (factor 1.0)
630
+ JSON (string) was 78.1% ops/sec slower (factor 4.6)
631
+ JSON (buffer) was 80.8% ops/sec slower (factor 5.2)
632
+ google-protobuf was 87.0% ops/sec slower (factor 7.7)
633
+
634
+ benchmarking combined performance ...
635
+
636
+ protobuf.js (reflect) x 275,900 ops/sec ±0.78% (90 runs sampled)
637
+ protobuf.js (static) x 290,096 ops/sec ±0.96% (90 runs sampled)
638
+ JSON (string) x 129,381 ops/sec ±0.77% (90 runs sampled)
639
+ JSON (buffer) x 91,051 ops/sec ±0.94% (90 runs sampled)
640
+ google-protobuf x 42,050 ops/sec ±0.85% (91 runs sampled)
641
+
642
+ protobuf.js (static) was fastest
643
+ protobuf.js (reflect) was 4.7% ops/sec slower (factor 1.0)
644
+ JSON (string) was 55.3% ops/sec slower (factor 2.2)
645
+ JSON (buffer) was 68.6% ops/sec slower (factor 3.2)
646
+ google-protobuf was 85.5% ops/sec slower (factor 6.9)
647
+ ```
340
648
 
341
- <picture>
342
- <source media="(prefers-color-scheme: dark)" srcset="./bench/results/encode-dark.svg">
343
- <source media="(prefers-color-scheme: light)" srcset="./bench/results/encode-light.svg">
344
- <img alt="Encode Throughput" src="./bench/results/encode.svg">
345
- </picture>
649
+ These results are achieved by
346
650
 
347
- <details>
348
- <summary>Show table</summary>
651
+ * generating type-specific encoders, decoders, verifiers and converters at runtime
652
+ * configuring the reader/writer interface according to the environment
653
+ * using node-specific functionality where beneficial and, of course
654
+ * avoiding unnecessary operations through splitting up [the toolset](#toolset).
349
655
 
350
- | Implementation | Common | Vector tile | Buf perf |
351
- | --- | ---: | ---: | ---: |
352
- | protobuf.js static | **5.28M ops/s** &nbsp; <small>1.0x</small> | 3.06K ops/s &nbsp; <small>1.0x</small> | **49.2K ops/s** &nbsp; <small>1.0x</small> |
353
- | protobuf.js reflect | 5.16M ops/s &nbsp; <small>1.0x</small> | **3.08K ops/s** &nbsp; <small>1.0x</small> | 47.5K ops/s &nbsp; <small>1.0x</small> |
354
- | JSON | 3.44M ops/s &nbsp; <small>1.5x</small> | 1.50K ops/s &nbsp; <small>2.1x</small> | 7.13K ops/s &nbsp; <small>6.9x</small> |
355
- | protoc-gen-js | 1.05M ops/s &nbsp; <small>5.0x</small> | 691 ops/s &nbsp; <small>4.5x</small> | 15.0K ops/s &nbsp; <small>3.3x</small> |
356
- | protoc-gen-es | 1.22M ops/s &nbsp; <small>4.3x</small> | 1.14K ops/s &nbsp; <small>2.7x</small> | 35.8K ops/s &nbsp; <small>1.4x</small> |
656
+ You can also run [the benchmark](https://github.com/protobufjs/protobuf.js/blob/master/bench/index.js) ...
357
657
 
358
- </details>
658
+ ```
659
+ $> npm run bench
660
+ ```
359
661
 
360
- <picture>
361
- <source media="(prefers-color-scheme: dark)" srcset="./bench/results/decode-dark.svg">
362
- <source media="(prefers-color-scheme: light)" srcset="./bench/results/decode-light.svg">
363
- <img alt="Decode Throughput" src="./bench/results/decode.svg">
364
- </picture>
662
+ and [the profiler](https://github.com/protobufjs/protobuf.js/blob/master/bench/prof.js) yourself (the latter requires a recent version of node):
365
663
 
366
- <details>
367
- <summary>Show table</summary>
664
+ ```
665
+ $> npm run prof <encode|decode|encode-browser|decode-browser> [iterations=10000000]
666
+ ```
368
667
 
369
- | Implementation | Common | Vector tile | Buf perf |
370
- | --- | ---: | ---: | ---: |
371
- | protobuf.js static | 5.84M ops/s &nbsp; <small>1.1x</small> | 2.45K ops/s &nbsp; <small>1.1x</small> | **78.9K ops/s** &nbsp; <small>1.0x</small> |
372
- | protobuf.js reflect | **6.54M ops/s** &nbsp; <small>1.0x</small> | **2.66K ops/s** &nbsp; <small>1.0x</small> | 77.0K ops/s &nbsp; <small>1.0x</small> |
373
- | JSON | 1.58M ops/s &nbsp; <small>4.1x</small> | 1.21K ops/s &nbsp; <small>2.2x</small> | 21.0K ops/s &nbsp; <small>3.8x</small> |
374
- | protoc-gen-js | 701K ops/s &nbsp; <small>9.3x</small> | 946 ops/s &nbsp; <small>2.8x</small> | 21.5K ops/s &nbsp; <small>3.7x</small> |
375
- | protoc-gen-es | 1.67M ops/s &nbsp; <small>3.9x</small> | 1.19K ops/s &nbsp; <small>2.2x</small> | 31.0K ops/s &nbsp; <small>2.5x</small> |
668
+ Note that as of this writing, the benchmark suite performs significantly slower on node 7.2.0 compared to 6.9.1 because moths.
376
669
 
377
- </details>
670
+ Compatibility
671
+ -------------
378
672
 
379
- <!-- END BENCHMARK DATA -->
673
+ * Works in all modern and not-so-modern browsers except IE8.
674
+ * Because the internals of this package do not rely on `google/protobuf/descriptor.proto`, options are parsed and presented literally.
675
+ * If typed arrays are not supported by the environment, plain arrays will be used instead.
676
+ * Support for pre-ES5 environments (except IE8) can be achieved by [using a polyfill](https://github.com/protobufjs/protobuf.js/blob/master/lib/polyfill.js).
677
+ * Support for [Content Security Policy](https://w3c.github.io/webappsec-csp/)-restricted environments (like Chrome extensions without unsafe-eval) can be achieved by generating and using static code instead.
678
+ * If a proper way to work with 64 bit values (uint64, int64 etc.) is required, just install [long.js](https://github.com/dcodeIO/long.js) alongside this library. All 64 bit numbers will then be returned as a `Long` instance instead of a possibly unsafe JavaScript number ([see](https://github.com/dcodeIO/long.js)).
679
+ * For descriptor.proto interoperability, see [ext/descriptor](https://github.com/protobufjs/protobuf.js/tree/master/ext/descriptor)
380
680
 
381
- [Structured results](./bench/results/latest.json) include environment details for this run and are committed alongside the charts. The suite also runs in CI.
681
+ Building
682
+ --------
382
683
 
383
- To run the benchmark on your own hardware:
684
+ To build the library or its components yourself, clone it from GitHub and install the development dependencies:
384
685
 
385
- ```sh
386
- npm --prefix bench install
387
- npm --prefix bench run generate
388
- npm run bench
686
+ ```
687
+ $> git clone https://github.com/protobufjs/protobuf.js.git
688
+ $> cd protobuf.js
689
+ $> npm install
389
690
  ```
390
691
 
391
- ## Compatibility
692
+ Building the respective development and production versions with their respective source maps to `dist/`:
392
693
 
393
- Supported runtimes are browsers, Node.js v12+, Deno and Bun. When using the CLI with Bun, Node.js must also be installed.
694
+ ```
695
+ $> npm run build
696
+ ```
394
697
 
395
- ## Security
698
+ Building the documentation to `docs/`:
396
699
 
397
- Security-impacting reports are handled through coordinated GitHub Security Advisories where appropriate. See [SECURITY.md](./SECURITY.md) for supported release lines and reporting instructions.
700
+ ```
701
+ $> npm run docs
702
+ ```
398
703
 
399
- ## Development
704
+ Building the TypeScript definition to `index.d.ts`:
400
705
 
401
- ```sh
402
- git clone https://github.com/protobufjs/protobuf.js
403
- cd protobuf.js
404
- npm install
405
- npm --prefix cli install
706
+ ```
707
+ $> npm run build:types
406
708
  ```
407
709
 
408
- Running the tests:
710
+ ### Browserify integration
409
711
 
410
- ```sh
411
- npm test
412
- ```
712
+ By default, protobuf.js integrates into any browserify build-process without requiring any optional modules. Hence:
413
713
 
414
- Building the development and production versions with their respective source maps to `dist/`:
714
+ * If int64 support is required, explicitly require the `long` module somewhere in your project as it will be excluded otherwise. This assumes that a global `require` function is present that protobuf.js can call to obtain the long module.
415
715
 
416
- ```sh
417
- npm run build
418
- ```
716
+ If there is no global `require` function present after bundling, it's also possible to assign the long module programmatically:
419
717
 
420
- ## Additional documentation
718
+ ```js
719
+ var Long = ...;
421
720
 
422
- * [API Documentation](https://protobufjs.github.io/protobuf.js)
423
- * [Changelog](./CHANGELOG.md)
424
- * [Protocol Buffers Documentation](https://protobuf.dev/)
721
+ protobuf.util.Long = Long;
722
+ protobuf.configure();
723
+ ```
724
+
725
+ * If you have any special requirements, there is [the bundler](https://github.com/protobufjs/protobuf.js/blob/master/scripts/bundle.js) for reference.
726
+
727
+ **License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)