@openclaw/whatsapp 2026.8.1-beta.3 → 2026.8.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 (263) hide show
  1. package/dist/{accounts-BX2fZUyR.js → accounts-CeKQbu_s.js} +9 -26
  2. package/dist/{action-runtime-pM-ExU0l.js → action-runtime-Bw0loEdy.js} +2 -2
  3. package/dist/action-runtime-api.js +1 -1
  4. package/dist/action-runtime.runtime.js +1 -1
  5. package/dist/{call-tool-api.js → agent-tools-api.js} +13 -6
  6. package/dist/{agent-tools-login-BjRpD-JQ.js → agent-tools-login-B-2qZPzc.js} +12 -3
  7. package/dist/api.js +10 -10
  8. package/dist/{approval-handler.runtime-CkMMvUjk.js → approval-handler.runtime-DeyPb57-.js} +3 -3
  9. package/dist/{approval-reactions-Jyr1JaAK.js → approval-reactions-DGDA6hQ7.js} +7 -5
  10. package/dist/{auth-store-CtpBqH5S.js → auth-store-DTj1H9pv.js} +5 -3
  11. package/dist/{channel-DRMYRfZ8.js → channel-DxMmDjqK.js} +26 -24
  12. package/dist/channel-config-api.js +1 -1
  13. package/dist/channel-plugin-api.js +1 -1
  14. package/dist/{channel-react-action-CstrR0CT.js → channel-react-action-BUp7Wbfr.js} +3 -3
  15. package/dist/{channel.runtime-X3JC2gaq.js → channel.runtime-BwSnyXRX.js} +4 -4
  16. package/dist/{channel.setup-DhBBhbQv.js → channel.setup-aOFLSQyw.js} +1 -1
  17. package/dist/{config-schema-BQP5YCeK.js → config-schema-BYA6e_Ii.js} +6 -4
  18. package/dist/{connection-controller-CIYuBJrs.js → connection-controller-BvkxsbWi.js} +2 -2
  19. package/dist/{constants-HU41RHGI.js → constants-C7m81BNe.js} +1 -1
  20. package/dist/{directory-config-P7_3U73Z.js → directory-config-LgxYJLWY.js} +3 -3
  21. package/dist/directory-contract-api.js +1 -1
  22. package/dist/{group-session-key-DmFc_Cqi.js → group-session-key-KUguLmSZ.js} +4 -4
  23. package/dist/index.js +4 -4
  24. package/dist/light-runtime-api.js +2 -2
  25. package/dist/{login-BkpKpndm.js → login-Bk_jiXKD.js} +6 -5
  26. package/dist/{login-qr-1dpv6jjT.js → login-qr-B3m61NqA.js} +43 -20
  27. package/dist/login-qr-runtime.js +1 -1
  28. package/dist/{monitor-IzwQKizW.js → monitor-CTsyo-HE.js} +185 -162
  29. package/dist/{question-reactions-D3eAeB0i.js → question-reactions-B9D6MHXZ.js} +1 -1
  30. package/dist/runtime-api.js +9 -9
  31. package/dist/{send-CwvTU4RI.js → send-DiPjiygK.js} +54 -29
  32. package/dist/{send-api-obOSm2cC.js → send-api-kFcuhSiY.js} +43 -41
  33. package/dist/{setup-finalize-n4K2I2gJ.js → setup-finalize-CqH5wTK5.js} +7 -6
  34. package/dist/setup-plugin-api.js +1 -1
  35. package/dist/{setup-surface-Cwn3zyxK.js → setup-surface-Dm3T6S8t.js} +3 -3
  36. package/dist/{shared-wg42NKFB.js → shared-DDjonGys.js} +7 -6
  37. package/dist/{socket-close-2T0_jZTN.js → socket-close-CpkkJZCU.js} +9 -6
  38. package/dist/{targets-runtime-TMk0lGuy.js → targets-runtime-RBjx3pg_.js} +1 -2
  39. package/dist/{text-runtime-CaKLhowd.js → text-runtime-DyfmcATV.js} +1 -1
  40. package/node_modules/baileys/lib/Defaults/index.js +1 -1
  41. package/node_modules/baileys/lib/Socket/business.d.ts.map +1 -1
  42. package/node_modules/baileys/lib/Socket/chats.d.ts +1 -0
  43. package/node_modules/baileys/lib/Socket/chats.d.ts.map +1 -1
  44. package/node_modules/baileys/lib/Socket/chats.js +10 -5
  45. package/node_modules/baileys/lib/Socket/chats.js.map +1 -1
  46. package/node_modules/baileys/lib/Socket/communities.d.ts.map +1 -1
  47. package/node_modules/baileys/lib/Socket/groups.d.ts.map +1 -1
  48. package/node_modules/baileys/lib/Socket/index.d.ts.map +1 -1
  49. package/node_modules/baileys/lib/Socket/messages-recv.d.ts.map +1 -1
  50. package/node_modules/baileys/lib/Socket/messages-send.d.ts.map +1 -1
  51. package/node_modules/baileys/lib/Socket/newsletter.d.ts.map +1 -1
  52. package/node_modules/baileys/lib/Socket/socket.d.ts.map +1 -1
  53. package/node_modules/baileys/lib/Socket/socket.js +3 -0
  54. package/node_modules/baileys/lib/Socket/socket.js.map +1 -1
  55. package/node_modules/baileys/lib/Types/index.d.ts +1 -0
  56. package/node_modules/baileys/lib/Types/index.d.ts.map +1 -1
  57. package/node_modules/baileys/lib/Types/index.js.map +1 -1
  58. package/node_modules/baileys/lib/Utils/browser-utils.d.ts.map +1 -1
  59. package/node_modules/baileys/lib/Utils/browser-utils.js +1 -0
  60. package/node_modules/baileys/lib/Utils/browser-utils.js.map +1 -1
  61. package/node_modules/baileys/lib/Utils/generics.d.ts +1 -0
  62. package/node_modules/baileys/lib/Utils/generics.d.ts.map +1 -1
  63. package/node_modules/baileys/lib/Utils/generics.js +1 -1
  64. package/node_modules/baileys/lib/Utils/generics.js.map +1 -1
  65. package/node_modules/baileys/lib/Utils/tc-token-utils.d.ts.map +1 -1
  66. package/node_modules/baileys/lib/Utils/tc-token-utils.js +3 -2
  67. package/node_modules/baileys/lib/Utils/tc-token-utils.js.map +1 -1
  68. package/node_modules/baileys/lib/Utils/validate-connection.d.ts.map +1 -1
  69. package/node_modules/baileys/lib/Utils/validate-connection.js +9 -2
  70. package/node_modules/baileys/lib/Utils/validate-connection.js.map +1 -1
  71. package/node_modules/baileys/node_modules/content-type/README.md +2 -0
  72. package/node_modules/baileys/node_modules/content-type/dist/index.d.ts +20 -0
  73. package/node_modules/baileys/node_modules/content-type/dist/index.js +20 -14
  74. package/node_modules/baileys/node_modules/content-type/dist/index.js.map +1 -1
  75. package/node_modules/baileys/node_modules/content-type/package.json +1 -1
  76. package/node_modules/baileys/node_modules/file-type/package.json +1 -1
  77. package/node_modules/baileys/node_modules/file-type/readme.md +3 -0
  78. package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +6 -1
  79. package/node_modules/baileys/node_modules/file-type/source/index.d.ts +3 -0
  80. package/node_modules/baileys/node_modules/file-type/source/index.js +25 -13
  81. package/node_modules/baileys/node_modules/music-metadata/LICENSE.txt +9 -9
  82. package/node_modules/baileys/node_modules/music-metadata/README.md +878 -878
  83. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
  84. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.js +1 -1
  85. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
  86. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
  87. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
  88. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
  89. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
  90. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
  91. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
  92. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
  93. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
  94. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
  95. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
  96. package/node_modules/baileys/node_modules/music-metadata/package.json +156 -156
  97. package/node_modules/baileys/node_modules/process-warning/.github/dependabot.yml +42 -2
  98. package/node_modules/baileys/node_modules/process-warning/.github/workflows/ci.yml +12 -1
  99. package/node_modules/baileys/node_modules/process-warning/.github/workflows/lock-threads.yml +19 -0
  100. package/node_modules/baileys/node_modules/process-warning/LICENSE +1 -1
  101. package/node_modules/baileys/node_modules/process-warning/README.md +41 -2
  102. package/node_modules/baileys/node_modules/process-warning/index.js +85 -17
  103. package/node_modules/baileys/node_modules/process-warning/package.json +6 -7
  104. package/node_modules/baileys/node_modules/process-warning/test/emit-once-only.test.js +3 -3
  105. package/node_modules/baileys/node_modules/process-warning/test/emit-reset.test.js +4 -4
  106. package/node_modules/baileys/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
  107. package/node_modules/baileys/node_modules/process-warning/test/spy-warning.test.js +143 -0
  108. package/node_modules/baileys/node_modules/process-warning/types/index.d.ts +15 -1
  109. package/node_modules/baileys/node_modules/process-warning/types/index.tst.ts +48 -0
  110. package/node_modules/baileys/node_modules/protobufjs/README.md +61 -84
  111. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +66 -45
  112. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  113. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  114. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  115. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +47 -40
  116. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  117. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  118. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  119. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +92 -68
  120. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  121. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  122. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  123. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +26 -10
  124. package/node_modules/baileys/node_modules/protobufjs/index.d.ts +3 -0
  125. package/node_modules/baileys/node_modules/protobufjs/package.json +1 -1
  126. package/node_modules/baileys/node_modules/protobufjs/src/converter.js +5 -1
  127. package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -2
  128. package/node_modules/baileys/node_modules/protobufjs/src/field.js +6 -1
  129. package/node_modules/baileys/node_modules/protobufjs/src/parse.js +26 -23
  130. package/node_modules/baileys/node_modules/protobufjs/src/reader.js +36 -9
  131. package/node_modules/baileys/node_modules/protobufjs/src/util/codegen.js +3 -1
  132. package/node_modules/baileys/node_modules/protobufjs/src/util/utf8.js +2 -28
  133. package/node_modules/baileys/node_modules/protobufjs/src/writer.js +7 -1
  134. package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
  135. package/node_modules/baileys/node_modules/ws/package.json +1 -1
  136. package/node_modules/baileys/package.json +1 -1
  137. package/node_modules/typebox/build/format/date.d.mts +1 -1
  138. package/node_modules/typebox/build/format/date.mjs +1 -1
  139. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  140. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  141. package/node_modules/typebox/build/format/email.d.mts +1 -1
  142. package/node_modules/typebox/build/format/email.mjs +2 -2
  143. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  144. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  145. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  146. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  147. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  148. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  149. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  150. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  151. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  152. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  153. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  154. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  155. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  156. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  157. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  158. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  159. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  160. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  161. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  162. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  163. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  164. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  165. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  166. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  167. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  168. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  169. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  170. package/node_modules/typebox/build/format/iri.mjs +26 -8
  171. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  172. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  173. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  174. package/node_modules/typebox/build/format/regex.mjs +2 -6
  175. package/node_modules/typebox/build/format/time.d.mts +2 -2
  176. package/node_modules/typebox/build/format/time.mjs +19 -14
  177. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  178. package/node_modules/typebox/build/format/uri.mjs +3 -130
  179. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  180. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  181. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  182. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  183. package/node_modules/typebox/build/format/url.d.mts +3 -3
  184. package/node_modules/typebox/build/format/url.mjs +4 -5
  185. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  186. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  187. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  188. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  189. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  190. package/node_modules/typebox/build/guard/string.mjs +7 -7
  191. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  192. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  193. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  194. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  195. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  196. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  197. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  198. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  199. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  200. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  201. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  202. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  203. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  204. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  205. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  206. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  207. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  208. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  209. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  210. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  211. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  212. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  213. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  214. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  215. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  216. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  217. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  218. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  219. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  220. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  221. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  222. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  223. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  224. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  225. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  226. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  227. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  228. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  229. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  230. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  231. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  232. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  233. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  234. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  235. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  236. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  237. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  238. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  239. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  240. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  241. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  242. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  243. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  244. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  245. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  246. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  247. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  248. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  249. package/node_modules/typebox/package.json +27 -27
  250. package/node_modules/typebox/readme.md +79 -82
  251. package/openclaw.plugin.json +2 -1
  252. package/package.json +6 -6
  253. package/node_modules/baileys/node_modules/process-warning/types/index.test-d.ts +0 -36
  254. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  255. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  256. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  257. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  258. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  259. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  260. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  261. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  262. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  263. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "process-warning",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "A small utility for creating warnings and emitting them.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -11,7 +11,7 @@
11
11
  "test": "npm run test:unit && npm run test:jest && npm run test:typescript",
12
12
  "test:jest": "jest jest.test.js",
13
13
  "test:unit": "c8 --100 node --test",
14
- "test:typescript": "tsd"
14
+ "test:typescript": "tstyche"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -62,12 +62,11 @@
62
62
  }
63
63
  ],
64
64
  "devDependencies": {
65
- "@fastify/pre-commit": "^2.1.0",
66
65
  "benchmark": "^2.1.4",
67
- "c8": "^10.1.3",
66
+ "c8": "^12.0.0",
68
67
  "eslint": "^9.17.0",
69
- "jest": "^29.7.0",
70
- "neostandard": "^0.12.0",
71
- "tsd": "^0.31.0"
68
+ "jest": "^30.0.3",
69
+ "neostandard": "^0.13.0",
70
+ "tstyche": "^7.0.0"
72
71
  }
73
72
  }
@@ -5,7 +5,7 @@ const { createWarning } = require('..')
5
5
  const { withResolvers } = require('./promise')
6
6
 
7
7
  test('emit should emit a given code only once', t => {
8
- t.plan(4)
8
+ t.plan(6)
9
9
 
10
10
  const { promise, resolve } = withResolvers()
11
11
 
@@ -22,8 +22,8 @@ test('emit should emit a given code only once', t => {
22
22
  code: 'CODE',
23
23
  message: 'Hello world'
24
24
  })
25
- warn()
26
- warn()
25
+ t.assert.strictEqual(warn(), true)
26
+ t.assert.strictEqual(warn(), false)
27
27
  setImmediate(() => {
28
28
  process.removeListener('warning', onWarning)
29
29
  resolve()
@@ -5,7 +5,7 @@ const { createWarning } = require('../')
5
5
  const { withResolvers } = require('./promise')
6
6
 
7
7
  test('a limited warning can be re-set', t => {
8
- t.plan(4)
8
+ t.plan(7)
9
9
 
10
10
  const { promise, resolve } = withResolvers()
11
11
  let count = 0
@@ -20,14 +20,14 @@ test('a limited warning can be re-set', t => {
20
20
  message: 'Hello world'
21
21
  })
22
22
 
23
- warn()
23
+ t.assert.strictEqual(warn(), true)
24
24
  t.assert.ok(warn.emitted)
25
25
 
26
- warn()
26
+ t.assert.strictEqual(warn(), false)
27
27
  t.assert.ok(warn.emitted)
28
28
 
29
29
  warn.emitted = false
30
- warn()
30
+ t.assert.strictEqual(warn(), true)
31
31
  t.assert.ok(warn.emitted)
32
32
 
33
33
  setImmediate(() => {
@@ -5,7 +5,7 @@ const { createWarning } = require('..')
5
5
  const { withResolvers } = require('./promise')
6
6
 
7
7
  test('emit should emit a given code unlimited times', t => {
8
- t.plan(50)
8
+ t.plan(60)
9
9
 
10
10
  let runs = 0
11
11
  const expectedRun = []
@@ -31,7 +31,7 @@ test('emit should emit a given code unlimited times', t => {
31
31
 
32
32
  for (let i = 0; i < times; i++) {
33
33
  expectedRun.push(i)
34
- warn()
34
+ t.assert.strictEqual(warn(), true)
35
35
  }
36
36
  setImmediate(() => {
37
37
  process.removeListener('warning', onWarning)
@@ -0,0 +1,143 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const { createWarning } = require('..')
5
+ const { spyWarning } = require('..')
6
+
7
+ test('Spy ProcessWarning - unlimited: false', t => {
8
+ const warning = createWarning({
9
+ name: 'Warning',
10
+ code: 'WRN',
11
+ message: 'Hello %s'
12
+ })
13
+ const spyData = spyWarning(warning)
14
+
15
+ t.assert.strictEqual(warning.emitted, false)
16
+ t.assert.deepStrictEqual(spyData.calls, [])
17
+ t.assert.strictEqual(spyData.callCount(), 0)
18
+
19
+ warning('World')
20
+ t.assert.strictEqual(warning.emitted, true)
21
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
22
+ t.assert.strictEqual(spyData.calls[0].result, true)
23
+ t.assert.strictEqual(spyData.callCount(), 1)
24
+
25
+ warning('World')
26
+ t.assert.strictEqual(warning.emitted, true)
27
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
28
+ t.assert.strictEqual(spyData.calls[0].result, true)
29
+ t.assert.deepStrictEqual(spyData.calls[1].arguments, ['World'])
30
+ t.assert.strictEqual(spyData.calls[1].result, false)
31
+ t.assert.strictEqual(spyData.callCount(), 2)
32
+
33
+ spyData.reset()
34
+ t.assert.strictEqual(warning.emitted, false)
35
+ t.assert.deepStrictEqual(spyData.calls, [])
36
+ t.assert.strictEqual(spyData.callCount(), 0)
37
+
38
+ warning('World')
39
+ t.assert.strictEqual(warning.emitted, true)
40
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
41
+ t.assert.strictEqual(spyData.calls[0].result, true)
42
+ t.assert.strictEqual(spyData.callCount(), 1)
43
+
44
+ spyData.restore()
45
+ t.assert.strictEqual(warning.emitted, false)
46
+ t.assert.deepStrictEqual(spyData.calls, [])
47
+ t.assert.strictEqual(spyData.callCount(), 0)
48
+
49
+ warning('World')
50
+ t.assert.strictEqual(warning.emitted, true)
51
+ t.assert.deepStrictEqual(spyData.calls, [])
52
+ t.assert.strictEqual(spyData.callCount(), 0)
53
+ })
54
+
55
+ test('Spy ProcessWarning - unlimited: true', t => {
56
+ const warning = createWarning({
57
+ name: 'Warning',
58
+ code: 'WRN',
59
+ message: 'Hello %s',
60
+ unlimited: true
61
+ })
62
+ const spyData = spyWarning(warning)
63
+
64
+ t.assert.strictEqual(warning.emitted, false)
65
+ t.assert.deepStrictEqual(spyData.calls, [])
66
+ t.assert.strictEqual(spyData.callCount(), 0)
67
+
68
+ warning('World')
69
+ t.assert.strictEqual(warning.emitted, true)
70
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
71
+ t.assert.strictEqual(spyData.calls[0].result, true)
72
+ t.assert.strictEqual(spyData.callCount(), 1)
73
+
74
+ warning('World')
75
+ t.assert.strictEqual(warning.emitted, true)
76
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
77
+ t.assert.strictEqual(spyData.calls[0].result, true)
78
+ t.assert.deepStrictEqual(spyData.calls[1].arguments, ['World'])
79
+ t.assert.strictEqual(spyData.calls[1].result, true)
80
+ t.assert.strictEqual(spyData.callCount(), 2)
81
+
82
+ spyData.reset()
83
+ t.assert.strictEqual(warning.emitted, false)
84
+ t.assert.deepStrictEqual(spyData.calls, [])
85
+ t.assert.strictEqual(spyData.callCount(), 0)
86
+
87
+ warning('World')
88
+ t.assert.strictEqual(warning.emitted, true)
89
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
90
+ t.assert.strictEqual(spyData.calls[0].result, true)
91
+ t.assert.strictEqual(spyData.callCount(), 1)
92
+
93
+ spyData.restore()
94
+ t.assert.strictEqual(warning.emitted, false)
95
+ t.assert.deepStrictEqual(spyData.calls, [])
96
+ t.assert.strictEqual(spyData.callCount(), 0)
97
+
98
+ warning('World')
99
+ t.assert.strictEqual(warning.emitted, true)
100
+ t.assert.deepStrictEqual(spyData.calls, [])
101
+ t.assert.strictEqual(spyData.callCount(), 0)
102
+ })
103
+
104
+ test('Spy ProcessWarning - calls[].arguments', t => {
105
+ const warning = createWarning({
106
+ name: 'Warning',
107
+ code: 'WRN',
108
+ message: 'Hello %s'
109
+ })
110
+ const spyData = spyWarning(warning)
111
+
112
+ warning(undefined)
113
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, [])
114
+ spyData.reset()
115
+
116
+ warning()
117
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, [])
118
+ spyData.reset()
119
+
120
+ warning('World')
121
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
122
+ spyData.reset()
123
+
124
+ warning('World', 'Hello')
125
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', 'Hello'])
126
+ spyData.reset()
127
+
128
+ warning(undefined, 'Hello')
129
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, [undefined, 'Hello'])
130
+ spyData.reset()
131
+
132
+ warning('World', 'Hello', 'World')
133
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', 'Hello', 'World'])
134
+ spyData.reset()
135
+
136
+ warning('World', undefined, 'World')
137
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', undefined, 'World'])
138
+ spyData.reset()
139
+
140
+ warning(undefined, 'Hello', 'World')
141
+ t.assert.deepStrictEqual(spyData.calls[0].arguments, [undefined, 'Hello', 'World'])
142
+ spyData.reset()
143
+ })
@@ -1,6 +1,6 @@
1
1
  declare namespace processWarning {
2
2
  export interface WarningItem {
3
- (a?: any, b?: any, c?: any): void;
3
+ (a?: any, b?: any, c?: any): boolean;
4
4
  name: string;
5
5
  code: string;
6
6
  message: string;
@@ -22,13 +22,27 @@ declare namespace processWarning {
22
22
  unlimited?: boolean;
23
23
  }
24
24
 
25
+ export type WarningSpyData = {
26
+ calls: WarningCallData[],
27
+ callCount(): number
28
+ reset(): void
29
+ restore(): void
30
+ }
31
+
32
+ export type WarningCallData = {
33
+ arguments: unknown[]
34
+ result: boolean
35
+ }
36
+
25
37
  export type ProcessWarning = {
26
38
  createWarning(params: WarningOptions): WarningItem;
27
39
  createDeprecation(params: DeprecationOptions): WarningItem;
40
+ spyWarning(warning: WarningItem): WarningSpyData
28
41
  }
29
42
 
30
43
  export function createWarning (params: WarningOptions): WarningItem
31
44
  export function createDeprecation (params: DeprecationOptions): WarningItem
45
+ export function spyWarning (warning: WarningItem): WarningSpyData
32
46
 
33
47
  const processWarning: ProcessWarning
34
48
  export { processWarning as default }
@@ -0,0 +1,48 @@
1
+ import { expect } from 'tstyche'
2
+ import { createDeprecation, createWarning, spyWarning, WarningCallData, WarningSpyData } from '..'
3
+
4
+ const WarnInstance = createWarning({
5
+ name: 'TypeScriptWarning',
6
+ code: 'CODE',
7
+ message: 'message'
8
+ })
9
+
10
+ expect(WarnInstance.code).type.toBe<string>()
11
+ expect(WarnInstance.message).type.toBe<string>()
12
+ expect(WarnInstance.name).type.toBe<string>()
13
+ expect(WarnInstance.emitted).type.toBe<boolean>()
14
+ expect(WarnInstance.unlimited).type.toBe<boolean>()
15
+
16
+ expect(WarnInstance()).type.toBe<boolean>()
17
+ expect(WarnInstance('foo')).type.toBe<boolean>()
18
+ expect(WarnInstance('foo', 'bar')).type.toBe<boolean>()
19
+
20
+ const buildWarnUnlimited = createWarning({
21
+ name: 'TypeScriptWarning',
22
+ code: 'CODE',
23
+ message: 'message',
24
+ unlimited: true
25
+ })
26
+
27
+ expect(buildWarnUnlimited.unlimited).type.toBe<boolean>()
28
+
29
+ const DeprecationInstance = createDeprecation({
30
+ code: 'CODE',
31
+ message: 'message'
32
+ })
33
+
34
+ expect(DeprecationInstance.code).type.toBe<string>()
35
+
36
+ expect(DeprecationInstance()).type.toBe<boolean>()
37
+ expect(DeprecationInstance('foo')).type.toBe<boolean>()
38
+ expect(DeprecationInstance('foo', 'bar')).type.toBe<boolean>()
39
+
40
+ const spyData = spyWarning(WarnInstance)
41
+ expect(spyData).type.toBe<WarningSpyData>()
42
+ expect(spyData.calls).type.toBe<WarningCallData[]>()
43
+ expect(spyData.callCount).type.toBe<(() => number)>()
44
+ expect(spyData.callCount()).type.toBe<number>()
45
+ expect(spyData.reset).type.toBe<(() => void)>()
46
+ expect(spyData.reset()).type.toBe<void>()
47
+ expect(spyData.restore).type.toBe<(() => void)>()
48
+ expect(spyData.restore()).type.toBe<void>()
@@ -7,15 +7,13 @@
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
- **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
-
12
- **protobuf.js** is a very fast, conformant, and unusually versatile JavaScript implementation of Protocol Buffers for Node.js and browsers. It works with `.proto` files out of the box, does not require protoc, and supports runtime reflection as well as specialized code generation with strong TypeScript declarations.
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.
13
11
 
14
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.
15
13
 
16
14
  ## Getting started
17
15
 
18
- Getting up and running is simple: Install the package, load a `.proto` file, and you are all set to encode and decode Protobuf messages. From there, protobuf.js grows with your requirements: Add any combination of capabilities, such as [code generation](#code-generation), [TypeScript declarations](#typescript-integration), [transport-agnostic services](#services), [programmatic schemas](#programmatic-schemas), [optional extensions](#extensions), and more as needed. All in one flexible toolkit.
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.
19
17
 
20
18
  ### Install
21
19
 
@@ -33,7 +31,7 @@ The CLI is a JS-native protobuf.js toolchain that does not require setting up `p
33
31
 
34
32
  #### Browser builds
35
33
 
36
- Canonical browser builds for each runtime variant 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.
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.
37
35
 
38
36
  ## Usage
39
37
 
@@ -78,7 +76,7 @@ const decoded = AwesomeMessage.decode(encoded);
78
76
 
79
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.
80
78
 
81
- Unknown fields present on the wire are discarded by default. To preserve and forward unknown fields, set `reader.discardUnknown = false` before decoding with that reader, or make this the default for subsequently created readers with `Reader.discardUnknown = false`. Preserved unknown field data can be dropped from a decoded message with `delete message.$unknowns`.
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`.
82
80
 
83
81
  ### Convert plain objects
84
82
 
@@ -138,41 +136,28 @@ Message types expose focused methods for validation, conversion, and binary I/O.
138
136
  * **message.toJSON**(): `object`
139
137
  Converts a message instance to JSON-compatible output using default conversion options.
140
138
 
141
- Message instances provide runtime identity, so they can be tested with `instanceof`. Their `toJSON` method integrates them with `JSON.stringify`.
139
+ Message instances provide stable runtime identity for testing with `instanceof`.
142
140
 
143
141
  Length-delimited methods read and write a varint byte length before the message, which is useful for streams and framed protocols.
144
142
 
145
143
  If required fields are missing while decoding proto2 data, `decode` throws `protobuf.util.ProtocolError` with the partially decoded message available as `err.instance`.
146
144
 
147
- ## Runtimes
148
-
149
- protobuf.js provides three runtime entry points, keeping parser and reflection support optional: Runtime `.proto` loading needs the parser, JSON/reflection bundles need reflection support, and generated static modules only need the minimal runtime.
150
-
151
- | Import | Includes | Use when
152
- | ----------------------- | ------------------ | --------
153
- | `protobufjs` | Reflection, Parser | You load `.proto` files at runtime
154
- | `protobufjs/light.js` | Reflection | You load JSON bundles or build schemas programmatically
155
- | `protobufjs/minimal.js` | Static runtime | You use generated static code
156
-
157
- The full build includes the light build, and the light build includes the minimal runtime.
158
-
159
145
  ## Code generation
160
146
 
161
- Use [`protobufjs-cli`](./cli/#readme) to generate reflection bundles, static JavaScript code, and matching TypeScript declarations, either directly with `pbjs` or through the optional `protoc-gen-pbjs` plugin for `protoc`.
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`.
162
148
 
163
- Reflection keeps schemas as JSON metadata and generates optimized functions at runtime. Static code emits schema-specific, reflection-free functions ahead of time. The main tradeoffs are how schemas are loaded, how bundle size scales with schema size, and whether reflection metadata should remain available at runtime.
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.
164
150
 
165
- | Target | Output | Minimum Runtime |
166
- |--------|--------|-----------------|
167
- | `json` | JSON bundle | `protobufjs/light.js` |
168
- | `json-module` | JSON bundle module | `protobufjs/light.js` |
169
- | `static-module` | Static code module | `protobufjs/minimal.js` |
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) |
170
155
 
171
156
  Module targets support `--wrap default` for CommonJS and AMD, plus `esm`, `commonjs`, `amd`, and `closure`; `--wrap` can also load a custom wrapper module.
172
157
 
173
158
  ### Static modules
174
159
 
175
- Static modules emit dedicated JavaScript for your schema, so they only need `protobufjs/minimal.js` at runtime.
160
+ Static modules emit dedicated, reflection-free JavaScript code for your schema.
176
161
 
177
162
  ```sh
178
163
  npx pbjs -t static-module -w esm -o awesome.js --dts awesome.proto
@@ -184,22 +169,11 @@ import { awesomepackage } from "./awesome.js";
184
169
  const message = awesomepackage.AwesomeMessage.create({ awesomeField: "hello" });
185
170
  ```
186
171
 
187
- While static code is verbose by design, its repeated patterns compress well with Brotli or gzip, and it works in [CSP](https://w3c.github.io/webappsec-csp/)-restricted environments that disallow unsafe-eval without sacrificing performance.
188
-
189
- ### Reflection bundles
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.
190
173
 
191
- Reflection bundles store schemas as compact JSON metadata, avoiding `.proto` parsing at runtime and letting browsers load schema metadata in one request. While they require at least `protobufjs/light.js`, large schemas can produce smaller combined bundles than equivalent static modules because common code is shared through reflection.
174
+ ### Reflection modules
192
175
 
193
- ```sh
194
- npx pbjs -t json -o awesome.json awesome1.proto awesome2.proto ...
195
- ```
196
-
197
- ```ts
198
- const bundle = require("./awesome.json");
199
-
200
- const root = protobuf.Root.fromJSON(bundle);
201
- const AwesomeMessage = root.lookupType("awesomepackage.AwesomeMessage");
202
- ```
176
+ Reflection modules wrap schemas as compact JSON metadata while avoiding `.proto` parsing at runtime.
203
177
 
204
178
  ```sh
205
179
  npx pbjs -t json-module -w esm -o awesome.js --dts awesome.proto
@@ -211,13 +185,11 @@ import { awesomepackage } from "./awesome.js";
211
185
  const AwesomeMessage = awesomepackage.AwesomeMessage;
212
186
  ```
213
187
 
214
- JSON modules export the reflection root and, with `-w esm`, also provide top-level named exports that align with static modules. Their declarations mirror `static-module` typings, but because JSON modules are backed by reflection objects, message instances should be created with `MyMessage.create(...)` instead of constructors. Code using `create(...)` works with static modules as well.
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()`.
215
189
 
216
190
  ### TypeScript integration
217
191
 
218
- protobuf.js works with TypeScript out of the box: the runtime API is typed, and generated JavaScript can be paired with strong TypeScript declarations in the same CLI invocation. Generated output is directly usable from JavaScript without a transpile step, and strongly typed in TypeScript projects, with type-checked oneofs and JavaScript-friendly plain-object input.
219
-
220
- For example, given the oneof:
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:
221
193
 
222
194
  ```proto
223
195
  message Profile {
@@ -228,8 +200,6 @@ message Profile {
228
200
  }
229
201
  ```
230
202
 
231
- Generated declarations narrow both the `contact` oneof and the concrete values:
232
-
233
203
  ```ts
234
204
  const profile = Profile.create({
235
205
  contact: "email",
@@ -246,7 +216,7 @@ if (decoded.contact === "phone") {
246
216
  }
247
217
  ```
248
218
 
249
- Plain objects can use the same narrowed shape through a collision-free scoped type:
219
+ The same narrowed shape is available for plain-object inputs:
250
220
 
251
221
  ```ts
252
222
  const object: Profile.$Shape = {
@@ -259,7 +229,7 @@ const object: Profile.$Shape = {
259
229
 
260
230
  ### Programmatic schemas
261
231
 
262
- The full and light builds can construct schemas directly through reflection:
232
+ Schemas can be constructed directly through reflection:
263
233
 
264
234
  ```ts
265
235
  const AwesomeMessage = new protobuf.Type("AwesomeMessage")
@@ -316,22 +286,7 @@ const myService = MyService.create(myRpcImpl/*, requestDelimited?, responseDelim
316
286
 
317
287
  See [examples/streaming-rpc.js](./examples/streaming-rpc.js) for a streaming example.
318
288
 
319
- Integration example with [@grpc/grpc-js](https://www.npmjs.com/package/@grpc/grpc-js):
320
-
321
- ```js
322
- const grpc = require('@grpc/grpc-js');
323
-
324
- const Client = grpc.makeGenericClientConstructor({});
325
- const client = new Client(serverAddress, grpc.credentials.createInsecure());
326
-
327
- const rpcImpl = (method, requestData, callback) =>
328
- client.makeUnaryRequest(method.path, (data) => data, (data) => data, requestData, callback);
329
-
330
- const greeter = root.lookupService("example.Greeter").create(rpcImpl);
331
- const reply = await greeter.sayHello({ name: "world" });
332
- ```
333
-
334
- See [examples/grpc-service.js](./examples/grpc-service.js) for a complete example.
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).
335
290
 
336
291
  ### Extensions
337
292
 
@@ -339,7 +294,7 @@ The following extensions provide descriptor conversion and text-based protobuf f
339
294
 
340
295
  #### Descriptors
341
296
 
342
- protobuf.js uses a compact JSON-based reflection representation internally that is easy to embed and fast to parse, so schemas can be loaded directly without first decoding binary descriptor blobs or postprocessing their full JSON representation. See [ext/descriptor](./ext/README.md#descriptor) for use cases that need conversion between reflected roots and `protoc` descriptor messages.
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.
343
298
 
344
299
  #### ProtoJSON
345
300
 
@@ -351,7 +306,7 @@ Protocol Buffers [Text Format](https://protobuf.dev/reference/protobuf/textforma
351
306
 
352
307
  ## Conformance
353
308
 
354
- protobuf.js is validated against the official Protocol Buffers conformance suite, achieving complete binary wire-format conformance for **Proto2**, **Proto3** and **Editions**, plus complete **ProtoJSON** and **Text Format** conformance in its default configuration with reflection metadata present.
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.
355
310
 
356
311
  <!-- BEGIN CONFORMANCE DATA -->
357
312
 
@@ -367,37 +322,59 @@ protobuf.js is validated against the official Protocol Buffers conformance suite
367
322
 
368
323
  <!-- END CONFORMANCE DATA -->
369
324
 
370
- [Structured results](https://github.com/protobufjs/protobuf.js/actions/workflows/test.yml?query=branch%3Amaster+event%3Apush) are available as CI artifacts. In case of contradicting claims by your favorite LLM, [see](https://dev.to/dcode/when-the-model-is-the-marketing-device-a-protobuf-short-story-2p7p).
325
+ [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.
371
326
 
372
327
  ## Performance
373
328
 
374
- In both reflection and reflection-free modes, protobuf.js builds specialized encoders and decoders on top of hand-tuned reader and writer primitives, making it a strong fit from battery-powered devices to high-traffic servers, or generally for projects and their downstream users adopting protobuf as a faster, smaller alternative to JSON.
329
+ Both reflection and static modes use specialized encoders and decoders backed by the same hand-tuned reader and writer primitives.
375
330
 
376
- The repository includes a [small benchmark](./bench) over a common message shape, plus Mapbox's vector tile fixture and Buf's perf payload, both unmodified. For each case, it compares protobuf.js encode and decode throughput against JSON encode/decode, Google's protoc-gen-js, and Buf's protoc-gen-es. Results show that protobuf.js is consistently faster than the other Protobuf implementations, up to an order of magnitude on real-world data, and among the libraries tested, it is the only one that is an upgrade over using JSON.
331
+ The repository includes a [benchmark suite](./bench) you can run yourself. It compares protobuf.js with other general-purpose JavaScript implementations across three substantially different cases: our classic common message shape and two unmodified, structurally distinct fixtures sourced externally. The suite measures each library's recommended serialization and deserialization path using identical schemas and inputs, with JSON included as an additional baseline. Across these cases, protobuf.js is a clear upgrade over using JSON and consistently the fastest Protobuf implementation by a considerable margin.
377
332
 
378
333
  <!-- BEGIN BENCHMARK DATA -->
379
334
 
380
- ![Encode benchmark](./bench/results/encode.svg)
335
+ <picture>
336
+ <source media="(prefers-color-scheme: dark)" srcset="./bench/results/encode-dark.svg">
337
+ <source media="(prefers-color-scheme: light)" srcset="./bench/results/encode-light.svg">
338
+ <img alt="Encode benchmark" src="./bench/results/encode.svg">
339
+ </picture>
340
+
341
+ <details>
342
+ <summary>Show table</summary>
343
+
344
+ | Implementation | Common | Vector tile | Buf perf |
345
+ | --- | ---: | ---: | ---: |
346
+ | protobuf.js static | **5.34M ops/s** &nbsp; <small>1.0x</small> | **3.09K ops/s** &nbsp; <small>1.0x</small> | 43.1K ops/s &nbsp; <small>1.0x</small> |
347
+ | protobuf.js reflect | 4.89M ops/s &nbsp; <small>1.1x</small> | 3.03K ops/s &nbsp; <small>1.0x</small> | **43.3K ops/s** &nbsp; <small>1.0x</small> |
348
+ | JSON | 2.09M ops/s &nbsp; <small>2.6x</small> | 897 ops/s &nbsp; <small>3.4x</small> | 6.70K ops/s &nbsp; <small>6.5x</small> |
349
+ | protoc-gen-js | 1.03M ops/s &nbsp; <small>5.2x</small> | 700 ops/s &nbsp; <small>4.4x</small> | 13.9K ops/s &nbsp; <small>3.1x</small> |
350
+ | protoc-gen-es | 402K ops/s &nbsp; <small>13.3x</small> | 235 ops/s &nbsp; <small>13.2x</small> | 8.22K ops/s &nbsp; <small>5.3x</small> |
351
+
352
+ </details>
353
+
354
+ <picture>
355
+ <source media="(prefers-color-scheme: dark)" srcset="./bench/results/decode-dark.svg">
356
+ <source media="(prefers-color-scheme: light)" srcset="./bench/results/decode-light.svg">
357
+ <img alt="Decode benchmark" src="./bench/results/decode.svg">
358
+ </picture>
381
359
 
382
- | Case | protobuf.js static | protobuf.js reflect | JSON | protoc-gen-js | protoc-gen-es |
383
- | --- | ---: | ---: | ---: | ---: | ---: |
384
- | Common | 3.18M ops/s | 3.25M ops/s | 2.07M ops/s | 1.01M ops/s | 395K ops/s |
385
- | Vector tile | 2.82K ops/s | 2.76K ops/s | 859 ops/s | 680 ops/s | 231 ops/s |
386
- | Buf perf | 41.4K ops/s | 39.9K ops/s | 6.59K ops/s | 13.5K ops/s | 8.00K ops/s |
360
+ <details>
361
+ <summary>Show table</summary>
387
362
 
388
- ![Decode benchmark](./bench/results/decode.svg)
363
+ | Implementation | Common | Vector tile | Buf perf |
364
+ | --- | ---: | ---: | ---: |
365
+ | protobuf.js static | 6.45M ops/s &nbsp; <small>1.1x</small> | 2.70K ops/s &nbsp; <small>1.1x</small> | **81.7K ops/s** &nbsp; <small>1.0x</small> |
366
+ | protobuf.js reflect | **6.93M ops/s** &nbsp; <small>1.0x</small> | **2.99K ops/s** &nbsp; <small>1.0x</small> | 80.3K ops/s &nbsp; <small>1.0x</small> |
367
+ | JSON | 1.37M ops/s &nbsp; <small>5.0x</small> | 1.06K ops/s &nbsp; <small>2.8x</small> | 19.5K ops/s &nbsp; <small>4.2x</small> |
368
+ | protoc-gen-js | 811K ops/s &nbsp; <small>8.5x</small> | 851 ops/s &nbsp; <small>3.5x</small> | 21.7K ops/s &nbsp; <small>3.8x</small> |
369
+ | protoc-gen-es | 691K ops/s &nbsp; <small>10.0x</small> | 376 ops/s &nbsp; <small>8.0x</small> | 14.3K ops/s &nbsp; <small>5.7x</small> |
389
370
 
390
- | Case | protobuf.js static | protobuf.js reflect | JSON | protoc-gen-js | protoc-gen-es |
391
- | --- | ---: | ---: | ---: | ---: | ---: |
392
- | Common | 6.11M ops/s | 6.09M ops/s | 1.31M ops/s | 790K ops/s | 710K ops/s |
393
- | Vector tile | 2.45K ops/s | 2.78K ops/s | 1.04K ops/s | 858 ops/s | 392 ops/s |
394
- | Buf perf | 72.5K ops/s | 66.4K ops/s | 19.0K ops/s | 21.1K ops/s | 14.2K ops/s |
371
+ </details>
395
372
 
396
373
  <!-- END BENCHMARK DATA -->
397
374
 
398
- [Structured results](./bench/results/latest.json) of this run are available as committed artifacts.
375
+ [Structured results](./bench/results/latest.json) and environment details for this run are also available as committed artifacts.
399
376
 
400
- To run the benchmark yourself on your own hardware:
377
+ To run the benchmark on your own hardware:
401
378
 
402
379
  ```sh
403
380
  npm --prefix bench install