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
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v8.8.1 (c) 2016, daniel wirtz
3
- * compiled sun, 11 oct 2026 17:08:01 utc
2
+ * protobuf.js v7.6.6 (c) 2016, daniel wirtz
3
+ * compiled thu, 27 aug 2026 10:13:18 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -38,7 +38,784 @@
38
38
  module.exports = protobuf;
39
39
 
40
40
  })/* end of prelude */({1:[function(require,module,exports){
41
+ "use strict";
42
+ module.exports = asPromise;
43
+
44
+ /**
45
+ * Callback as used by {@link util.asPromise}.
46
+ * @typedef asPromiseCallback
47
+ * @type {function}
48
+ * @param {Error|null} error Error, if any
49
+ * @param {...*} params Additional arguments
50
+ * @returns {undefined}
51
+ */
52
+
53
+ /**
54
+ * Returns a promise from a node-style callback function.
55
+ * @memberof util
56
+ * @param {asPromiseCallback} fn Function to call
57
+ * @param {*} ctx Function context
58
+ * @param {...*} params Function arguments
59
+ * @returns {Promise<*>} Promisified function
60
+ */
61
+ function asPromise(fn, ctx/*, varargs */) {
62
+ var params = new Array(arguments.length - 1),
63
+ offset = 0,
64
+ index = 2,
65
+ pending = true;
66
+ while (index < arguments.length)
67
+ params[offset++] = arguments[index++];
68
+ return new Promise(function executor(resolve, reject) {
69
+ params[offset] = function callback(err/*, varargs */) {
70
+ if (pending) {
71
+ pending = false;
72
+ if (err)
73
+ reject(err);
74
+ else {
75
+ var params = new Array(arguments.length - 1),
76
+ offset = 0;
77
+ while (offset < params.length)
78
+ params[offset++] = arguments[offset];
79
+ resolve.apply(null, params);
80
+ }
81
+ }
82
+ };
83
+ try {
84
+ fn.apply(ctx || null, params);
85
+ } catch (err) {
86
+ if (pending) {
87
+ pending = false;
88
+ reject(err);
89
+ }
90
+ }
91
+ });
92
+ }
93
+
94
+ },{}],2:[function(require,module,exports){
95
+ "use strict";
96
+
97
+ /**
98
+ * A minimal base64 implementation for number arrays.
99
+ * @memberof util
100
+ * @namespace
101
+ */
102
+ var base64 = exports;
103
+
104
+ /**
105
+ * Calculates the byte length of a base64 encoded string.
106
+ * @param {string} string Base64 encoded string
107
+ * @returns {number} Byte length
108
+ */
109
+ base64.length = function length(string) {
110
+ var p = string.length;
111
+ if (!p)
112
+ return 0;
113
+ var n = 0;
114
+ while (--p % 4 > 1 && string.charAt(p) === "=")
115
+ ++n;
116
+ return Math.ceil(string.length * 3) / 4 - n;
117
+ };
118
+
119
+ // Base64 encoding table
120
+ var b64 = new Array(64);
121
+
122
+ // Base64 decoding table
123
+ var s64 = new Array(123);
124
+
125
+ // 65..90, 97..122, 48..57, 43, 47
126
+ for (var i = 0; i < 64;)
127
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
128
+
129
+ /**
130
+ * Encodes a buffer to a base64 encoded string.
131
+ * @param {Uint8Array} buffer Source buffer
132
+ * @param {number} start Source start
133
+ * @param {number} end Source end
134
+ * @returns {string} Base64 encoded string
135
+ */
136
+ base64.encode = function encode(buffer, start, end) {
137
+ var parts = null,
138
+ chunk = [];
139
+ var i = 0, // output index
140
+ j = 0, // goto index
141
+ t; // temporary
142
+ while (start < end) {
143
+ var b = buffer[start++];
144
+ switch (j) {
145
+ case 0:
146
+ chunk[i++] = b64[b >> 2];
147
+ t = (b & 3) << 4;
148
+ j = 1;
149
+ break;
150
+ case 1:
151
+ chunk[i++] = b64[t | b >> 4];
152
+ t = (b & 15) << 2;
153
+ j = 2;
154
+ break;
155
+ case 2:
156
+ chunk[i++] = b64[t | b >> 6];
157
+ chunk[i++] = b64[b & 63];
158
+ j = 0;
159
+ break;
160
+ }
161
+ if (i > 8191) {
162
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
163
+ i = 0;
164
+ }
165
+ }
166
+ if (j) {
167
+ chunk[i++] = b64[t];
168
+ chunk[i++] = 61;
169
+ if (j === 1)
170
+ chunk[i++] = 61;
171
+ }
172
+ if (parts) {
173
+ if (i)
174
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
175
+ return parts.join("");
176
+ }
177
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
178
+ };
179
+
180
+ var invalidEncoding = "invalid encoding";
181
+
182
+ /**
183
+ * Decodes a base64 encoded string to a buffer.
184
+ * @param {string} string Source string
185
+ * @param {Uint8Array} buffer Destination buffer
186
+ * @param {number} offset Destination offset
187
+ * @returns {number} Number of bytes written
188
+ * @throws {Error} If encoding is invalid
189
+ */
190
+ base64.decode = function decode(string, buffer, offset) {
191
+ var start = offset;
192
+ var j = 0, // goto index
193
+ t; // temporary
194
+ for (var i = 0; i < string.length;) {
195
+ var c = string.charCodeAt(i++);
196
+ if (c === 61 && j > 1)
197
+ break;
198
+ if ((c = s64[c]) === undefined)
199
+ throw Error(invalidEncoding);
200
+ switch (j) {
201
+ case 0:
202
+ t = c;
203
+ j = 1;
204
+ break;
205
+ case 1:
206
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
207
+ t = c;
208
+ j = 2;
209
+ break;
210
+ case 2:
211
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
212
+ t = c;
213
+ j = 3;
214
+ break;
215
+ case 3:
216
+ buffer[offset++] = (t & 3) << 6 | c;
217
+ j = 0;
218
+ break;
219
+ }
220
+ }
221
+ if (j === 1)
222
+ throw Error(invalidEncoding);
223
+ return offset - start;
224
+ };
225
+
226
+ /**
227
+ * Tests if the specified string appears to be base64 encoded.
228
+ * @param {string} string String to test
229
+ * @returns {boolean} `true` if probably base64 encoded, otherwise false
230
+ */
231
+ base64.test = function test(string) {
232
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
233
+ };
234
+
235
+ },{}],3:[function(require,module,exports){
236
+ "use strict";
237
+ module.exports = EventEmitter;
238
+
239
+ /**
240
+ * Constructs a new event emitter instance.
241
+ * @classdesc A minimal event emitter.
242
+ * @memberof util
243
+ * @constructor
244
+ */
245
+ function EventEmitter() {
246
+
247
+ /**
248
+ * Registered listeners.
249
+ * @type {Object.<string,*>}
250
+ * @private
251
+ */
252
+ this._listeners = Object.create(null);
253
+ }
254
+
255
+ /**
256
+ * Event listener as used by {@link util.EventEmitter}.
257
+ * @typedef EventEmitterListener
258
+ * @type {function}
259
+ * @param {...*} args Arguments
260
+ * @returns {undefined}
261
+ */
262
+
263
+ /**
264
+ * Registers an event listener.
265
+ * @param {string} evt Event name
266
+ * @param {EventEmitterListener} fn Listener
267
+ * @param {*} [ctx] Listener context
268
+ * @returns {this} `this`
269
+ */
270
+ EventEmitter.prototype.on = function on(evt, fn, ctx) {
271
+ (this._listeners[evt] || (this._listeners[evt] = [])).push({
272
+ fn : fn,
273
+ ctx : ctx || this
274
+ });
275
+ return this;
276
+ };
277
+
278
+ /**
279
+ * Removes an event listener or any matching listeners if arguments are omitted.
280
+ * @param {string} [evt] Event name. Removes all listeners if omitted.
281
+ * @param {EventEmitterListener} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
282
+ * @returns {this} `this`
283
+ */
284
+ EventEmitter.prototype.off = function off(evt, fn) {
285
+ if (evt === undefined)
286
+ this._listeners = Object.create(null);
287
+ else {
288
+ if (fn === undefined)
289
+ this._listeners[evt] = [];
290
+ else {
291
+ var listeners = this._listeners[evt];
292
+ if (!listeners)
293
+ return this;
294
+ for (var i = 0; i < listeners.length;)
295
+ if (listeners[i].fn === fn)
296
+ listeners.splice(i, 1);
297
+ else
298
+ ++i;
299
+ }
300
+ }
301
+ return this;
302
+ };
303
+
304
+ /**
305
+ * Emits an event by calling its listeners with the specified arguments.
306
+ * @param {string} evt Event name
307
+ * @param {...*} args Arguments
308
+ * @returns {this} `this`
309
+ */
310
+ EventEmitter.prototype.emit = function emit(evt) {
311
+ var listeners = this._listeners[evt];
312
+ if (listeners) {
313
+ var args = [],
314
+ i = 1;
315
+ for (; i < arguments.length;)
316
+ args.push(arguments[i++]);
317
+ for (i = 0; i < listeners.length;)
318
+ listeners[i].fn.apply(listeners[i++].ctx, args);
319
+ }
320
+ return this;
321
+ };
322
+
323
+ },{}],4:[function(require,module,exports){
324
+ "use strict";
325
+
326
+ module.exports = factory(factory);
327
+
328
+ /**
329
+ * Reads / writes floats / doubles from / to buffers.
330
+ * @name util.float
331
+ * @namespace
332
+ */
333
+
334
+ /**
335
+ * Writes a 32 bit float to a buffer using little endian byte order.
336
+ * @name util.float.writeFloatLE
337
+ * @function
338
+ * @param {number} val Value to write
339
+ * @param {Uint8Array} buf Target buffer
340
+ * @param {number} pos Target buffer offset
341
+ * @returns {undefined}
342
+ */
343
+
344
+ /**
345
+ * Writes a 32 bit float to a buffer using big endian byte order.
346
+ * @name util.float.writeFloatBE
347
+ * @function
348
+ * @param {number} val Value to write
349
+ * @param {Uint8Array} buf Target buffer
350
+ * @param {number} pos Target buffer offset
351
+ * @returns {undefined}
352
+ */
353
+
354
+ /**
355
+ * Reads a 32 bit float from a buffer using little endian byte order.
356
+ * @name util.float.readFloatLE
357
+ * @function
358
+ * @param {Uint8Array} buf Source buffer
359
+ * @param {number} pos Source buffer offset
360
+ * @returns {number} Value read
361
+ */
362
+
363
+ /**
364
+ * Reads a 32 bit float from a buffer using big endian byte order.
365
+ * @name util.float.readFloatBE
366
+ * @function
367
+ * @param {Uint8Array} buf Source buffer
368
+ * @param {number} pos Source buffer offset
369
+ * @returns {number} Value read
370
+ */
371
+
372
+ /**
373
+ * Writes a 64 bit double to a buffer using little endian byte order.
374
+ * @name util.float.writeDoubleLE
375
+ * @function
376
+ * @param {number} val Value to write
377
+ * @param {Uint8Array} buf Target buffer
378
+ * @param {number} pos Target buffer offset
379
+ * @returns {undefined}
380
+ */
381
+
382
+ /**
383
+ * Writes a 64 bit double to a buffer using big endian byte order.
384
+ * @name util.float.writeDoubleBE
385
+ * @function
386
+ * @param {number} val Value to write
387
+ * @param {Uint8Array} buf Target buffer
388
+ * @param {number} pos Target buffer offset
389
+ * @returns {undefined}
390
+ */
391
+
392
+ /**
393
+ * Reads a 64 bit double from a buffer using little endian byte order.
394
+ * @name util.float.readDoubleLE
395
+ * @function
396
+ * @param {Uint8Array} buf Source buffer
397
+ * @param {number} pos Source buffer offset
398
+ * @returns {number} Value read
399
+ */
400
+
401
+ /**
402
+ * Reads a 64 bit double from a buffer using big endian byte order.
403
+ * @name util.float.readDoubleBE
404
+ * @function
405
+ * @param {Uint8Array} buf Source buffer
406
+ * @param {number} pos Source buffer offset
407
+ * @returns {number} Value read
408
+ */
409
+
410
+ // Factory function for the purpose of node-based testing in modified global environments
411
+ function factory(exports) {
412
+
413
+ // float: typed array
414
+ if (typeof Float32Array !== "undefined") (function() {
415
+
416
+ var f32 = new Float32Array([ -0 ]),
417
+ f8b = new Uint8Array(f32.buffer),
418
+ le = f8b[3] === 128;
419
+
420
+ function writeFloat_f32_cpy(val, buf, pos) {
421
+ f32[0] = val;
422
+ buf[pos ] = f8b[0];
423
+ buf[pos + 1] = f8b[1];
424
+ buf[pos + 2] = f8b[2];
425
+ buf[pos + 3] = f8b[3];
426
+ }
427
+
428
+ function writeFloat_f32_rev(val, buf, pos) {
429
+ f32[0] = val;
430
+ buf[pos ] = f8b[3];
431
+ buf[pos + 1] = f8b[2];
432
+ buf[pos + 2] = f8b[1];
433
+ buf[pos + 3] = f8b[0];
434
+ }
435
+
436
+ /* istanbul ignore next */
437
+ exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
438
+ /* istanbul ignore next */
439
+ exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
440
+
441
+ function readFloat_f32_cpy(buf, pos) {
442
+ f8b[0] = buf[pos ];
443
+ f8b[1] = buf[pos + 1];
444
+ f8b[2] = buf[pos + 2];
445
+ f8b[3] = buf[pos + 3];
446
+ return f32[0];
447
+ }
448
+
449
+ function readFloat_f32_rev(buf, pos) {
450
+ f8b[3] = buf[pos ];
451
+ f8b[2] = buf[pos + 1];
452
+ f8b[1] = buf[pos + 2];
453
+ f8b[0] = buf[pos + 3];
454
+ return f32[0];
455
+ }
456
+
457
+ /* istanbul ignore next */
458
+ exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
459
+ /* istanbul ignore next */
460
+ exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
461
+
462
+ // float: ieee754
463
+ })(); else (function() {
464
+
465
+ function writeFloat_ieee754(writeUint, val, buf, pos) {
466
+ var sign = val < 0 ? 1 : 0;
467
+ if (sign)
468
+ val = -val;
469
+ if (val === 0)
470
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
471
+ else if (isNaN(val))
472
+ writeUint(2143289344, buf, pos);
473
+ else if (val > 3.4028234663852886e+38) // +-Infinity
474
+ writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
475
+ else if (val < 1.1754943508222875e-38) // denormal
476
+ writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
477
+ else {
478
+ var exponent = Math.floor(Math.log(val) / Math.LN2),
479
+ mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
480
+ writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
481
+ }
482
+ }
483
+
484
+ exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
485
+ exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
486
+
487
+ function readFloat_ieee754(readUint, buf, pos) {
488
+ var uint = readUint(buf, pos),
489
+ sign = (uint >> 31) * 2 + 1,
490
+ exponent = uint >>> 23 & 255,
491
+ mantissa = uint & 8388607;
492
+ return exponent === 255
493
+ ? mantissa
494
+ ? NaN
495
+ : sign * Infinity
496
+ : exponent === 0 // denormal
497
+ ? sign * 1.401298464324817e-45 * mantissa
498
+ : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
499
+ }
500
+
501
+ exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
502
+ exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
503
+
504
+ })();
505
+
506
+ // double: typed array
507
+ if (typeof Float64Array !== "undefined") (function() {
508
+
509
+ var f64 = new Float64Array([-0]),
510
+ f8b = new Uint8Array(f64.buffer),
511
+ le = f8b[7] === 128;
512
+
513
+ function writeDouble_f64_cpy(val, buf, pos) {
514
+ f64[0] = val;
515
+ buf[pos ] = f8b[0];
516
+ buf[pos + 1] = f8b[1];
517
+ buf[pos + 2] = f8b[2];
518
+ buf[pos + 3] = f8b[3];
519
+ buf[pos + 4] = f8b[4];
520
+ buf[pos + 5] = f8b[5];
521
+ buf[pos + 6] = f8b[6];
522
+ buf[pos + 7] = f8b[7];
523
+ }
524
+
525
+ function writeDouble_f64_rev(val, buf, pos) {
526
+ f64[0] = val;
527
+ buf[pos ] = f8b[7];
528
+ buf[pos + 1] = f8b[6];
529
+ buf[pos + 2] = f8b[5];
530
+ buf[pos + 3] = f8b[4];
531
+ buf[pos + 4] = f8b[3];
532
+ buf[pos + 5] = f8b[2];
533
+ buf[pos + 6] = f8b[1];
534
+ buf[pos + 7] = f8b[0];
535
+ }
536
+
537
+ /* istanbul ignore next */
538
+ exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
539
+ /* istanbul ignore next */
540
+ exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
541
+
542
+ function readDouble_f64_cpy(buf, pos) {
543
+ f8b[0] = buf[pos ];
544
+ f8b[1] = buf[pos + 1];
545
+ f8b[2] = buf[pos + 2];
546
+ f8b[3] = buf[pos + 3];
547
+ f8b[4] = buf[pos + 4];
548
+ f8b[5] = buf[pos + 5];
549
+ f8b[6] = buf[pos + 6];
550
+ f8b[7] = buf[pos + 7];
551
+ return f64[0];
552
+ }
553
+
554
+ function readDouble_f64_rev(buf, pos) {
555
+ f8b[7] = buf[pos ];
556
+ f8b[6] = buf[pos + 1];
557
+ f8b[5] = buf[pos + 2];
558
+ f8b[4] = buf[pos + 3];
559
+ f8b[3] = buf[pos + 4];
560
+ f8b[2] = buf[pos + 5];
561
+ f8b[1] = buf[pos + 6];
562
+ f8b[0] = buf[pos + 7];
563
+ return f64[0];
564
+ }
565
+
566
+ /* istanbul ignore next */
567
+ exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
568
+ /* istanbul ignore next */
569
+ exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
570
+
571
+ // double: ieee754
572
+ })(); else (function() {
573
+
574
+ function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
575
+ var sign = val < 0 ? 1 : 0;
576
+ if (sign)
577
+ val = -val;
578
+ if (val === 0) {
579
+ writeUint(0, buf, pos + off0);
580
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
581
+ } else if (isNaN(val)) {
582
+ writeUint(0, buf, pos + off0);
583
+ writeUint(2146959360, buf, pos + off1);
584
+ } else if (val > 1.7976931348623157e+308) { // +-Infinity
585
+ writeUint(0, buf, pos + off0);
586
+ writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
587
+ } else {
588
+ var mantissa;
589
+ if (val < 2.2250738585072014e-308) { // denormal
590
+ mantissa = val / 5e-324;
591
+ writeUint(mantissa >>> 0, buf, pos + off0);
592
+ writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
593
+ } else {
594
+ var exponent = Math.floor(Math.log(val) / Math.LN2);
595
+ if (exponent === 1024)
596
+ exponent = 1023;
597
+ mantissa = val * Math.pow(2, -exponent);
598
+ writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
599
+ writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
600
+ }
601
+ }
602
+ }
603
+
604
+ exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
605
+ exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
606
+
607
+ function readDouble_ieee754(readUint, off0, off1, buf, pos) {
608
+ var lo = readUint(buf, pos + off0),
609
+ hi = readUint(buf, pos + off1);
610
+ var sign = (hi >> 31) * 2 + 1,
611
+ exponent = hi >>> 20 & 2047,
612
+ mantissa = 4294967296 * (hi & 1048575) + lo;
613
+ return exponent === 2047
614
+ ? mantissa
615
+ ? NaN
616
+ : sign * Infinity
617
+ : exponent === 0 // denormal
618
+ ? sign * 5e-324 * mantissa
619
+ : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
620
+ }
621
+
622
+ exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
623
+ exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
624
+
625
+ })();
626
+
627
+ return exports;
628
+ }
629
+
630
+ // uint helpers
631
+
632
+ function writeUintLE(val, buf, pos) {
633
+ buf[pos ] = val & 255;
634
+ buf[pos + 1] = val >>> 8 & 255;
635
+ buf[pos + 2] = val >>> 16 & 255;
636
+ buf[pos + 3] = val >>> 24;
637
+ }
638
+
639
+ function writeUintBE(val, buf, pos) {
640
+ buf[pos ] = val >>> 24;
641
+ buf[pos + 1] = val >>> 16 & 255;
642
+ buf[pos + 2] = val >>> 8 & 255;
643
+ buf[pos + 3] = val & 255;
644
+ }
645
+
646
+ function readUintLE(buf, pos) {
647
+ return (buf[pos ]
648
+ | buf[pos + 1] << 8
649
+ | buf[pos + 2] << 16
650
+ | buf[pos + 3] << 24) >>> 0;
651
+ }
652
+
653
+ function readUintBE(buf, pos) {
654
+ return (buf[pos ] << 24
655
+ | buf[pos + 1] << 16
656
+ | buf[pos + 2] << 8
657
+ | buf[pos + 3]) >>> 0;
658
+ }
659
+
660
+ },{}],5:[function(require,module,exports){
661
+ "use strict";
662
+ module.exports = pool;
663
+
664
+ /**
665
+ * An allocator as used by {@link util.pool}.
666
+ * @typedef PoolAllocator
667
+ * @type {function}
668
+ * @param {number} size Buffer size
669
+ * @returns {Uint8Array} Buffer
670
+ */
671
+
672
+ /**
673
+ * A slicer as used by {@link util.pool}.
674
+ * @typedef PoolSlicer
675
+ * @type {function}
676
+ * @param {number} start Start offset
677
+ * @param {number} end End offset
678
+ * @returns {Uint8Array} Buffer slice
679
+ * @this {Uint8Array}
680
+ */
681
+
682
+ /**
683
+ * A general purpose buffer pool.
684
+ * @memberof util
685
+ * @function
686
+ * @param {PoolAllocator} alloc Allocator
687
+ * @param {PoolSlicer} slice Slicer
688
+ * @param {number} [size=8192] Slab size
689
+ * @returns {PoolAllocator} Pooled allocator
690
+ */
691
+ function pool(alloc, slice, size) {
692
+ var SIZE = size || 8192;
693
+ var MAX = SIZE >>> 1;
694
+ var slab = null;
695
+ var offset = SIZE;
696
+ return function pool_alloc(size) {
697
+ if (size < 1 || size > MAX)
698
+ return alloc(size);
699
+ if (offset + size > SIZE) {
700
+ slab = alloc(SIZE);
701
+ offset = 0;
702
+ }
703
+ var buf = slice.call(slab, offset, offset += size);
704
+ if (offset & 7) // align to 32 bit
705
+ offset = (offset | 7) + 1;
706
+ return buf;
707
+ };
708
+ }
709
+
710
+ },{}],6:[function(require,module,exports){
711
+ "use strict";
712
+
713
+ /**
714
+ * A minimal UTF8 implementation for number arrays.
715
+ * @memberof util
716
+ * @namespace
717
+ */
718
+ var utf8 = exports,
719
+ replacementChar = "\ufffd";
720
+
721
+ /**
722
+ * Calculates the UTF8 byte length of a string.
723
+ * @param {string} string String
724
+ * @returns {number} Byte length
725
+ */
726
+ utf8.length = function utf8_length(string) {
727
+ var len = 0,
728
+ c = 0;
729
+ for (var i = 0; i < string.length; ++i) {
730
+ c = string.charCodeAt(i);
731
+ if (c < 128)
732
+ len += 1;
733
+ else if (c < 2048)
734
+ len += 2;
735
+ else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
736
+ ++i;
737
+ len += 4;
738
+ } else
739
+ len += 3;
740
+ }
741
+ return len;
742
+ };
743
+
744
+ /**
745
+ * Reads UTF8 bytes as a string.
746
+ * @param {Uint8Array} buffer Source buffer
747
+ * @param {number} start Source start
748
+ * @param {number} end Source end
749
+ * @returns {string} String read
750
+ */
751
+ utf8.read = function utf8_read(buffer, start, end) {
752
+ if (end - start < 1) {
753
+ return "";
754
+ }
755
+
756
+ var str = "";
757
+ for (var i = start; i < end;) {
758
+ var t = buffer[i++];
759
+ if (t <= 0x7F) {
760
+ str += String.fromCharCode(t);
761
+ } else if (t >= 0xC0 && t < 0xE0) {
762
+ var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
763
+ str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
764
+ } else if (t >= 0xE0 && t < 0xF0) {
765
+ var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
766
+ str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
767
+ } else if (t >= 0xF0) {
768
+ var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
769
+ if (t2 < 0x10000 || t2 > 0x10FFFF)
770
+ str += replacementChar;
771
+ else {
772
+ t2 -= 0x10000;
773
+ str += String.fromCharCode(0xD800 + (t2 >> 10));
774
+ str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
775
+ }
776
+ }
777
+ }
778
+
779
+ return str;
780
+ };
781
+
782
+ /**
783
+ * Writes a string as UTF8 bytes.
784
+ * @param {string} string Source string
785
+ * @param {Uint8Array} buffer Destination buffer
786
+ * @param {number} offset Destination offset
787
+ * @returns {number} Bytes written
788
+ */
789
+ utf8.write = function utf8_write(string, buffer, offset) {
790
+ var start = offset,
791
+ c1, // character 1
792
+ c2; // character 2
793
+ for (var i = 0; i < string.length; ++i) {
794
+ c1 = string.charCodeAt(i);
795
+ if (c1 < 128) {
796
+ buffer[offset++] = c1;
797
+ } else if (c1 < 2048) {
798
+ buffer[offset++] = c1 >> 6 | 192;
799
+ buffer[offset++] = c1 & 63 | 128;
800
+ } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
801
+ c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
802
+ ++i;
803
+ buffer[offset++] = c1 >> 18 | 240;
804
+ buffer[offset++] = c1 >> 12 & 63 | 128;
805
+ buffer[offset++] = c1 >> 6 & 63 | 128;
806
+ buffer[offset++] = c1 & 63 | 128;
807
+ } else {
808
+ buffer[offset++] = c1 >> 12 | 224;
809
+ buffer[offset++] = c1 >> 6 & 63 | 128;
810
+ buffer[offset++] = c1 & 63 | 128;
811
+ }
812
+ }
813
+ return offset - start;
814
+ };
815
+
816
+ },{}],7:[function(require,module,exports){
41
817
  "use strict";
818
+ var protobuf = exports;
42
819
 
43
820
  /**
44
821
  * Build type, one of `"full"`, `"light"` or `"minimal"`.
@@ -46,19 +823,19 @@
46
823
  * @type {string}
47
824
  * @const
48
825
  */
49
- exports.build = "minimal";
826
+ protobuf.build = "minimal";
50
827
 
51
828
  // Serialization
52
- exports.Writer = require(15);
53
- exports.BufferWriter = require(16);
54
- exports.Reader = require(2);
55
- exports.BufferReader = require(3);
829
+ protobuf.Writer = require(15);
830
+ protobuf.BufferWriter = require(16);
831
+ protobuf.Reader = require(8);
832
+ protobuf.BufferReader = require(9);
56
833
 
57
834
  // Utility
58
- exports.util = require(12);
59
- exports.rpc = require(5);
60
- exports.roots = require(4);
61
- exports.configure = configure;
835
+ protobuf.util = require(14);
836
+ protobuf.rpc = require(11);
837
+ protobuf.roots = require(10);
838
+ protobuf.configure = configure;
62
839
 
63
840
  /* istanbul ignore next */
64
841
  /**
@@ -66,19 +843,19 @@ exports.configure = configure;
66
843
  * @returns {undefined}
67
844
  */
68
845
  function configure() {
69
- exports.util.LongBits._configure(exports.util.Long);
70
- exports.Writer._configure(exports.BufferWriter);
71
- exports.Reader._configure(exports.BufferReader);
846
+ protobuf.util._configure();
847
+ protobuf.Writer._configure(protobuf.BufferWriter);
848
+ protobuf.Reader._configure(protobuf.BufferReader);
72
849
  }
73
850
 
74
851
  // Set up buffer utility according to the environment
75
852
  configure();
76
853
 
77
- },{"12":12,"15":15,"16":16,"2":2,"3":3,"4":4,"5":5}],2:[function(require,module,exports){
854
+ },{"10":10,"11":11,"14":14,"15":15,"16":16,"8":8,"9":9}],8:[function(require,module,exports){
78
855
  "use strict";
79
856
  module.exports = Reader;
80
857
 
81
- var util = require(12);
858
+ var util = require(14);
82
859
 
83
860
  var BufferReader; // cyclic
84
861
 
@@ -92,7 +869,7 @@ function indexOutOfRange(reader, writeLength) {
92
869
 
93
870
  /**
94
871
  * Constructs a new reader instance using the specified buffer.
95
- * @classdesc Wire format reader using `Uint8Array`.
872
+ * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.
96
873
  * @constructor
97
874
  * @param {Uint8Array} buffer Buffer to read from
98
875
  */
@@ -115,28 +892,20 @@ function Reader(buffer) {
115
892
  * @type {number}
116
893
  */
117
894
  this.len = buffer.length;
118
-
119
- /**
120
- * Cached DataView for packed reads.
121
- * @type {DataView|null}
122
- */
123
- this.view = null;
124
-
125
- /**
126
- * Whether to discard unknown fields while decoding.
127
- * @type {boolean}
128
- */
129
- this.discardUnknown = Reader.discardUnknown;
130
895
  }
131
896
 
132
- function create_array(buffer) {
133
- // TODO: Remove plain array reader support in the next major release.
134
- if (Array.isArray(buffer))
135
- buffer = new Uint8Array(buffer);
136
- if (buffer instanceof Uint8Array)
137
- return new Reader(buffer);
138
- throw Error("illegal buffer");
139
- }
897
+ var create_array = typeof Uint8Array !== "undefined"
898
+ ? function create_typed_array(buffer) {
899
+ if (buffer instanceof Uint8Array || Array.isArray(buffer))
900
+ return new Reader(buffer);
901
+ throw Error("illegal buffer");
902
+ }
903
+ /* istanbul ignore next */
904
+ : function create_array(buffer) {
905
+ if (Array.isArray(buffer))
906
+ return new Reader(buffer);
907
+ throw Error("illegal buffer");
908
+ };
140
909
 
141
910
  var create = function create() {
142
911
  return util.Buffer
@@ -161,15 +930,7 @@ var create = function create() {
161
930
  */
162
931
  Reader.create = create();
163
932
 
164
- /**
165
- * Returns raw bytes from the backing buffer without advancing the reader.
166
- * @param {number} start Start offset
167
- * @param {number} end End offset
168
- * @returns {Uint8Array} Raw bytes
169
- */
170
- Reader.prototype.raw = function read_raw(start, end) {
171
- return this.buf.subarray(start, end);
172
- };
933
+ Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice;
173
934
 
174
935
  function readVarint32NearEnd(reader) {
175
936
  // Safely read up to four bytes of a varint32 near the reader limit
@@ -190,139 +951,29 @@ function readVarint32NearEnd(reader) {
190
951
  * @function
191
952
  * @returns {number} Value read
192
953
  */
193
- Reader.prototype.uint32 = function read_uint32() {
194
- if (this.len - this.pos < 5) {
195
- if (this.pos >= this.len)
196
- throw indexOutOfRange(this);
197
- if (this.buf[this.pos] >= 128)
198
- return readVarint32NearEnd(this);
199
- }
200
- var buf = this.buf,
201
- pos = this.pos,
202
- value = (buf[pos] & 127) >>> 0;
203
- if (buf[pos++] < 128) {
204
- this.pos = pos;
205
- return value;
206
- }
207
- value = (value | (buf[pos] & 127) << 7) >>> 0;
208
- if (buf[pos++] < 128) {
209
- this.pos = pos;
210
- return value;
211
- }
212
- value = (value | (buf[pos] & 127) << 14) >>> 0;
213
- if (buf[pos++] < 128) {
214
- this.pos = pos;
215
- return value;
216
- }
217
- value = (value | (buf[pos] & 127) << 21) >>> 0;
218
- if (buf[pos++] < 128) {
219
- this.pos = pos;
220
- return value;
221
- }
222
- value = (value | (buf[pos] & 15) << 28) >>> 0;
223
- if (buf[pos++] < 128) {
224
- this.pos = pos;
225
- return value;
226
- }
954
+ Reader.prototype.uint32 = (function read_uint32_setup() {
955
+ var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
956
+ return function read_uint32() {
957
+ if (this.len - this.pos < 5) {
958
+ if (this.pos >= this.len)
959
+ throw indexOutOfRange(this);
960
+ if (this.buf[this.pos] >= 128)
961
+ return readVarint32NearEnd(this);
962
+ }
963
+ value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
964
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
965
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
966
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;
967
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;
227
968
 
228
- for (var i = 0; i < 5; ++i) {
229
969
  /* istanbul ignore if */
230
- if (pos >= this.len) {
231
- this.pos = pos;
232
- throw indexOutOfRange(this);
233
- }
234
- if (buf[pos++] < 128) {
235
- this.pos = pos;
236
- return value;
970
+ if ((this.pos += 5) > this.len) {
971
+ this.pos = this.len;
972
+ throw indexOutOfRange(this, 10);
237
973
  }
238
- }
239
- /* istanbul ignore next */
240
- this.pos = pos;
241
- throw Error("invalid varint encoding");
242
- };
243
-
244
- /**
245
- * Reads a field tag.
246
- * @function
247
- * @returns {number} Tag read
248
- */
249
- Reader.prototype.tag = function read_tag() {
250
- if (this.len - this.pos < 5) {
251
- if (this.pos >= this.len)
252
- throw indexOutOfRange(this);
253
- if (this.buf[this.pos] >= 128)
254
- return readVarint32NearEnd(this);
255
- }
256
- var buf = this.buf,
257
- pos = this.pos,
258
- value = (buf[pos] & 127) >>> 0;
259
- if (buf[pos++] < 128) {
260
- this.pos = pos;
261
- return value;
262
- }
263
- value = (value | (buf[pos] & 127) << 7) >>> 0;
264
- if (buf[pos++] < 128) {
265
- this.pos = pos;
266
- return value;
267
- }
268
- value = (value | (buf[pos] & 127) << 14) >>> 0;
269
- if (buf[pos++] < 128) {
270
- this.pos = pos;
271
- return value;
272
- }
273
- value = (value | (buf[pos] & 127) << 21) >>> 0;
274
- if (buf[pos++] < 128) {
275
- this.pos = pos;
276
- return value;
277
- }
278
- value = (value | (buf[pos] & 15) << 28) >>> 0;
279
- if (buf[pos] < 128 && (buf[pos] & 112) === 0) {
280
- this.pos = pos + 1;
281
974
  return value;
282
- }
283
-
284
- this.pos = pos + 1;
285
- throw Error("invalid tag encoding");
286
- };
287
-
288
- /**
289
- * Reads a varint length prefix within signed 32 bit range.
290
- * @returns {number} Length read
291
- */
292
- Reader.prototype.size = function read_size() {
293
- if (this.len - this.pos < 5) {
294
- if (this.pos >= this.len)
295
- throw indexOutOfRange(this);
296
- if (this.buf[this.pos] >= 128)
297
- return readVarint32NearEnd(this);
298
- }
299
- var buf = this.buf,
300
- pos = this.pos,
301
- value = (buf[pos] & 127) >>> 0;
302
- if (buf[pos++] < 128) {
303
- this.pos = pos;
304
- return value;
305
- }
306
- value = (value | (buf[pos] & 127) << 7) >>> 0;
307
- if (buf[pos++] < 128) {
308
- this.pos = pos;
309
- return value;
310
- }
311
- value = (value | (buf[pos] & 127) << 14) >>> 0;
312
- if (buf[pos++] < 128) {
313
- this.pos = pos;
314
- return value;
315
- }
316
- value = (value | (buf[pos] & 127) << 21) >>> 0;
317
- if (buf[pos++] < 128) {
318
- this.pos = pos;
319
- return value;
320
- }
321
- this.pos = pos + 1;
322
- if (buf[pos] > 7)
323
- throw Error("invalid length encoding");
324
- return (value | buf[pos] << 28) >>> 0;
325
- };
975
+ };
976
+ })();
326
977
 
327
978
  /**
328
979
  * Reads a varint as a signed 32 bit value.
@@ -361,16 +1012,18 @@ function readLongVarint() {
361
1012
  return bits;
362
1013
  i = 0;
363
1014
  } else {
364
- for (; i < 4; ++i) {
1015
+ for (; i < 3; ++i) {
365
1016
  /* istanbul ignore if */
366
1017
  if (this.pos >= this.len)
367
1018
  throw indexOutOfRange(this);
368
- // 1st..4th
1019
+ // 1st..3th
369
1020
  bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
370
1021
  if (this.buf[this.pos++] < 128)
371
1022
  return bits;
372
1023
  }
373
- throw indexOutOfRange(this);
1024
+ // 4th
1025
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
1026
+ return bits;
374
1027
  }
375
1028
  if (this.len - this.pos > 4) { // fast route (hi)
376
1029
  for (; i < 5; ++i) {
@@ -422,20 +1075,7 @@ function readLongVarint() {
422
1075
  * @returns {boolean} Value read
423
1076
  */
424
1077
  Reader.prototype.bool = function read_bool() {
425
- var value = false,
426
- b;
427
- for (var i = 0; i < 10; ++i) {
428
- /* istanbul ignore if */
429
- if (this.pos >= this.len)
430
- throw indexOutOfRange(this);
431
- b = this.buf[this.pos++];
432
- if (b & 127)
433
- value = true;
434
- if (b < 128)
435
- return value;
436
- }
437
- /* istanbul ignore next */
438
- throw Error("invalid varint encoding");
1078
+ return this.uint32() !== 0;
439
1079
  };
440
1080
 
441
1081
  function readFixed32_end(buf, end) { // note that this uses `end`, not `pos`
@@ -530,302 +1170,12 @@ Reader.prototype.double = function read_double() {
530
1170
  return value;
531
1171
  };
532
1172
 
533
- /**
534
- * Reads a packed repeated field of unsigned 32 bit varints.
535
- * @param {number[]} [array] Array to read into; a new one is created if omitted
536
- * @returns {number[]} Array read into
537
- */
538
- Reader.prototype.uint32s = function read_uint32s(array) {
539
- if (array === undefined) array = [];
540
- var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
541
- if (end > len) throw indexOutOfRange(this, end - this.pos);
542
- this.len = end;
543
- while (pos < end) {
544
- value = buf[pos++];
545
- if (value < 128)
546
- array.push(value);
547
- else {
548
- this.pos = pos - 1;
549
- array.push(this.uint32());
550
- pos = this.pos;
551
- }
552
- }
553
- this.pos = pos;
554
- if (pos !== end) throw RangeError("index out of range");
555
- this.len = len;
556
- return array;
557
- };
558
-
559
- /**
560
- * Reads a packed repeated field of signed 32 bit varints.
561
- * @param {number[]} [array] Array to read into; a new one is created if omitted
562
- * @returns {number[]} Array read into
563
- */
564
- Reader.prototype.int32s = function read_int32s(array) {
565
- if (array === undefined) array = [];
566
- var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
567
- if (end > len) throw indexOutOfRange(this, end - this.pos);
568
- this.len = end;
569
- while (pos < end) {
570
- value = buf[pos++];
571
- if (value < 128)
572
- array.push(value);
573
- else {
574
- this.pos = pos - 1;
575
- array.push(this.int32());
576
- pos = this.pos;
577
- }
578
- }
579
- this.pos = pos;
580
- if (pos !== end) throw RangeError("index out of range");
581
- this.len = len;
582
- return array;
583
- };
584
-
585
- /**
586
- * Reads a packed repeated field of zig-zag encoded signed 32 bit varints.
587
- * @param {number[]} [array] Array to read into; a new one is created if omitted
588
- * @returns {number[]} Array read into
589
- */
590
- Reader.prototype.sint32s = function read_sint32s(array) {
591
- if (array === undefined) array = [];
592
- var end = this.size() + this.pos, len = this.len;
593
- if (end > len) throw indexOutOfRange(this, end - this.pos);
594
- this.len = end;
595
- while (this.pos < end)
596
- array.push(this.sint32());
597
- if (this.pos !== end) throw RangeError("index out of range");
598
- this.len = len;
599
- return array;
600
- };
601
-
602
- /**
603
- * Reads a packed repeated field of booleans.
604
- * @param {boolean[]} [array] Array to read into; a new one is created if omitted
605
- * @returns {boolean[]} Array read into
606
- */
607
- Reader.prototype.bools = function read_bools(array) {
608
- if (array === undefined) array = [];
609
- var end = this.size() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
610
- if (end > len) throw indexOutOfRange(this, end - this.pos);
611
- this.len = end;
612
- while (pos < end) {
613
- value = buf[pos++];
614
- if (value < 128)
615
- array.push(value !== 0);
616
- else {
617
- this.pos = pos - 1;
618
- array.push(this.bool());
619
- pos = this.pos;
620
- }
621
- }
622
- this.pos = pos;
623
- if (pos !== end) throw RangeError("index out of range");
624
- this.len = len;
625
- return array;
626
- };
627
-
628
- // The view allocation only pays off when amortized over enough reads
629
- var VIEW_THRESHOLD_FLOAT = 8,
630
- VIEW_THRESHOLD_INT = 128;
631
-
632
- function getLazyView(reader, count, threshold) {
633
- var view = reader.view;
634
- if (view || count < threshold)
635
- return view;
636
- var buf = reader.buf;
637
- return reader.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
638
- }
639
-
640
- /**
641
- * Reads a packed repeated field of unsigned 32 bit fixed values.
642
- * @param {number[]} [array] Array to read into; a new one is created if omitted
643
- * @returns {number[]} Array read into
644
- */
645
- Reader.prototype.fixed32s = function read_fixed32s(array) {
646
- if (array === undefined) array = [];
647
- var len = this.size(), end = this.pos + len;
648
- /* istanbul ignore if */
649
- if (end > this.len) throw indexOutOfRange(this, len);
650
- var count = len >>> 2, i = array.length, pos = this.pos;
651
- array.length = i + count;
652
- var dv = getLazyView(this, count, VIEW_THRESHOLD_INT);
653
- if (dv)
654
- for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getUint32(pos, true);
655
- else {
656
- var buf = this.buf;
657
- for (var j = 0; j < count; ++j, pos += 4) array[i++] = readFixed32_end(buf, pos + 4);
658
- }
659
- this.pos = pos;
660
- if (pos !== end) throw indexOutOfRange(this, 4);
661
- return array;
662
- };
663
-
664
- /**
665
- * Reads a packed repeated field of signed 32 bit fixed values.
666
- * @param {number[]} [array] Array to read into; a new one is created if omitted
667
- * @returns {number[]} Array read into
668
- */
669
- Reader.prototype.sfixed32s = function read_sfixed32s(array) {
670
- if (array === undefined) array = [];
671
- var len = this.size(), end = this.pos + len;
672
- /* istanbul ignore if */
673
- if (end > this.len) throw indexOutOfRange(this, len);
674
- var count = len >>> 2, i = array.length, pos = this.pos;
675
- array.length = i + count;
676
- var dv = getLazyView(this, count, VIEW_THRESHOLD_INT);
677
- if (dv)
678
- for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getInt32(pos, true);
679
- else {
680
- var buf = this.buf;
681
- for (var j = 0; j < count; ++j, pos += 4) array[i++] = readFixed32_end(buf, pos + 4) | 0;
682
- }
683
- this.pos = pos;
684
- if (pos !== end) throw indexOutOfRange(this, 4);
685
- return array;
686
- };
687
-
688
- /**
689
- * Reads a packed repeated field of floats (32 bit).
690
- * @param {number[]} [array] Array to read into; a new one is created if omitted
691
- * @returns {number[]} Array read into
692
- */
693
- Reader.prototype.floats = function read_floats(array) {
694
- if (array === undefined) array = [];
695
- var len = this.size(), end = this.pos + len;
696
- /* istanbul ignore if */
697
- if (end > this.len) throw indexOutOfRange(this, len);
698
- var count = len >>> 2, i = array.length, pos = this.pos;
699
- array.length = i + count;
700
- var dv = getLazyView(this, count, VIEW_THRESHOLD_FLOAT);
701
- if (dv)
702
- for (var k = 0; k < count; ++k, pos += 4) array[i++] = dv.getFloat32(pos, true);
703
- else {
704
- var buf = this.buf;
705
- for (var j = 0; j < count; ++j, pos += 4) array[i++] = util.float.readFloatLE(buf, pos);
706
- }
707
- this.pos = pos;
708
- if (pos !== end) throw indexOutOfRange(this, 4);
709
- return array;
710
- };
711
-
712
- /**
713
- * Reads a packed repeated field of doubles (64 bit float).
714
- * @param {number[]} [array] Array to read into; a new one is created if omitted
715
- * @returns {number[]} Array read into
716
- */
717
- Reader.prototype.doubles = function read_doubles(array) {
718
- if (array === undefined) array = [];
719
- var len = this.size(), end = this.pos + len;
720
- /* istanbul ignore if */
721
- if (end > this.len) throw indexOutOfRange(this, len);
722
- var count = len >>> 3, i = array.length, pos = this.pos;
723
- array.length = i + count;
724
- var dv = getLazyView(this, count, VIEW_THRESHOLD_FLOAT);
725
- if (dv)
726
- for (var k = 0; k < count; ++k, pos += 8) array[i++] = dv.getFloat64(pos, true);
727
- else {
728
- var buf = this.buf;
729
- for (var j = 0; j < count; ++j, pos += 8) array[i++] = util.float.readDoubleLE(buf, pos);
730
- }
731
- this.pos = pos;
732
- if (pos !== end) throw indexOutOfRange(this, 8);
733
- return array;
734
- };
735
-
736
- /**
737
- * Reads a packed repeated field of unsigned 64 bit varints.
738
- * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted
739
- * @returns {Array.<Long|number>} Array read into
740
- */
741
- Reader.prototype.uint64s = function read_uint64s(array) {
742
- if (array === undefined) array = [];
743
- var end = this.size() + this.pos, len = this.len;
744
- if (end > len) throw indexOutOfRange(this, end - this.pos);
745
- this.len = end;
746
- while (this.pos < end)
747
- array.push(this.uint64());
748
- if (this.pos !== end) throw RangeError("index out of range");
749
- this.len = len;
750
- return array;
751
- };
752
-
753
- /**
754
- * Reads a packed repeated field of signed 64 bit varints.
755
- * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted
756
- * @returns {Array.<Long|number>} Array read into
757
- */
758
- Reader.prototype.int64s = function read_int64s(array) {
759
- if (array === undefined) array = [];
760
- var end = this.size() + this.pos, len = this.len;
761
- if (end > len) throw indexOutOfRange(this, end - this.pos);
762
- this.len = end;
763
- while (this.pos < end)
764
- array.push(this.int64());
765
- if (this.pos !== end) throw RangeError("index out of range");
766
- this.len = len;
767
- return array;
768
- };
769
-
770
- /**
771
- * Reads a packed repeated field of zig-zag encoded signed 64 bit varints.
772
- * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted
773
- * @returns {Array.<Long|number>} Array read into
774
- */
775
- Reader.prototype.sint64s = function read_sint64s(array) {
776
- if (array === undefined) array = [];
777
- var end = this.size() + this.pos, len = this.len;
778
- if (end > len) throw indexOutOfRange(this, end - this.pos);
779
- this.len = end;
780
- while (this.pos < end)
781
- array.push(this.sint64());
782
- if (this.pos !== end) throw RangeError("index out of range");
783
- this.len = len;
784
- return array;
785
- };
786
-
787
- /**
788
- * Reads a packed repeated field of unsigned 64 bit fixed values.
789
- * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted
790
- * @returns {Array.<Long|number>} Array read into
791
- */
792
- Reader.prototype.fixed64s = function read_fixed64s(array) {
793
- if (array === undefined) array = [];
794
- var len = this.size(), end = this.pos + len, i = array.length;
795
- /* istanbul ignore if */
796
- if (end > this.len) throw indexOutOfRange(this, len);
797
- var count = len >>> 3;
798
- array.length = i + count; // 8 bytes per value, count is known
799
- for (var j = 0; j < count; ++j)
800
- array[i++] = this.fixed64();
801
- if (this.pos !== end) throw indexOutOfRange(this, 8);
802
- return array;
803
- };
804
-
805
- /**
806
- * Reads a packed repeated field of signed 64 bit fixed values.
807
- * @param {Array.<Long|number>} [array] Array to read into; a new one is created if omitted
808
- * @returns {Array.<Long|number>} Array read into
809
- */
810
- Reader.prototype.sfixed64s = function read_sfixed64s(array) {
811
- if (array === undefined) array = [];
812
- var len = this.size(), end = this.pos + len, i = array.length;
813
- /* istanbul ignore if */
814
- if (end > this.len) throw indexOutOfRange(this, len);
815
- var count = len >>> 3;
816
- array.length = i + count; // 8 bytes per value, count is known
817
- for (var j = 0; j < count; ++j)
818
- array[i++] = this.sfixed64();
819
- if (this.pos !== end) throw indexOutOfRange(this, 8);
820
- return array;
821
- };
822
-
823
1173
  /**
824
1174
  * Reads a sequence of bytes preceeded by its length as a varint.
825
1175
  * @returns {Uint8Array} Value read
826
1176
  */
827
1177
  Reader.prototype.bytes = function read_bytes() {
828
- var length = this.size(),
1178
+ var length = this.uint32(),
829
1179
  start = this.pos,
830
1180
  end = this.pos + length;
831
1181
 
@@ -833,8 +1183,17 @@ Reader.prototype.bytes = function read_bytes() {
833
1183
  if (end > this.len)
834
1184
  throw indexOutOfRange(this, length);
835
1185
 
836
- this.pos = end;
837
- return this.raw(start, end);
1186
+ this.pos += length;
1187
+ if (Array.isArray(this.buf)) // plain array
1188
+ return this.buf.slice(start, end);
1189
+
1190
+ if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
1191
+ var nativeBuffer = util.Buffer;
1192
+ return nativeBuffer
1193
+ ? nativeBuffer.alloc(0)
1194
+ : new this.buf.constructor(0);
1195
+ }
1196
+ return this._slice.call(this.buf, start, end);
838
1197
  };
839
1198
 
840
1199
  /**
@@ -842,33 +1201,8 @@ Reader.prototype.bytes = function read_bytes() {
842
1201
  * @returns {string} Value read
843
1202
  */
844
1203
  Reader.prototype.string = function read_string() {
845
- var length = this.size(),
846
- start = this.pos,
847
- end = this.pos + length;
848
-
849
- /* istanbul ignore if */
850
- if (end > this.len)
851
- throw indexOutOfRange(this, length);
852
-
853
- this.pos = end;
854
- return utf8.read(this.buf, start, end);
855
- };
856
-
857
- /**
858
- * Reads a string preceeded by its byte length as a varint, rejecting invalid UTF8.
859
- * @returns {string} Value read
860
- */
861
- Reader.prototype.stringVerify = function read_string_verify() {
862
- var length = this.size(),
863
- start = this.pos,
864
- end = this.pos + length;
865
-
866
- /* istanbul ignore if */
867
- if (end > this.len)
868
- throw indexOutOfRange(this, length);
869
-
870
- this.pos = end;
871
- return utf8.readStrict(this.buf, start, end);
1204
+ var bytes = this.bytes();
1205
+ return utf8.read(bytes, 0, bytes.length);
872
1206
  };
873
1207
 
874
1208
  /**
@@ -898,25 +1232,16 @@ Reader.prototype.skip = function skip(length) {
898
1232
  */
899
1233
  Reader.recursionLimit = util.recursionLimit;
900
1234
 
901
- /**
902
- * Whether readers discard unknown fields while decoding.
903
- * @type {boolean}
904
- */
905
- Reader.discardUnknown = true;
906
-
907
1235
  /**
908
1236
  * Skips the next element of the specified wire type.
909
1237
  * @param {number} wireType Wire type received
910
1238
  * @param {number} [depth] Depth of recursion to control nested calls; 0 if omitted
911
- * @param {number} [fieldNumber] Field number for validating group end tags
912
1239
  * @returns {Reader} `this`
913
1240
  */
914
- Reader.prototype.skipType = function(wireType, depth, fieldNumber) {
1241
+ Reader.prototype.skipType = function(wireType, depth) {
915
1242
  if (depth === undefined) depth = 0;
916
1243
  if (depth > Reader.recursionLimit)
917
- throw Error("max depth exceeded");
918
- if (fieldNumber === 0)
919
- throw Error("illegal tag: field number 0");
1244
+ throw Error("maximum nesting depth exceeded");
920
1245
  switch (wireType) {
921
1246
  case 0:
922
1247
  this.skip();
@@ -925,21 +1250,11 @@ Reader.prototype.skipType = function(wireType, depth, fieldNumber) {
925
1250
  this.skip(8);
926
1251
  break;
927
1252
  case 2:
928
- this.skip(this.size());
1253
+ this.skip(this.uint32());
929
1254
  break;
930
1255
  case 3:
931
- while (true) {
932
- var tag = this.tag();
933
- var nestedField = tag >>> 3;
934
- wireType = tag & 7;
935
- if (!nestedField)
936
- throw Error("illegal tag: field number 0");
937
- if (wireType === 4) {
938
- if (fieldNumber !== undefined && nestedField !== fieldNumber)
939
- throw Error("invalid end group tag");
940
- break;
941
- }
942
- this.skipType(wireType, depth + 1, nestedField);
1256
+ while ((wireType = this.uint32() & 7) !== 4) {
1257
+ this.skipType(wireType, depth + 1);
943
1258
  }
944
1259
  break;
945
1260
  case 5:
@@ -984,22 +1299,15 @@ Reader._configure = function(BufferReader_) {
984
1299
  });
985
1300
  };
986
1301
 
987
- },{"12":12}],3:[function(require,module,exports){
1302
+ },{"14":14}],9:[function(require,module,exports){
988
1303
  "use strict";
989
1304
  module.exports = BufferReader;
990
1305
 
991
1306
  // extends Reader
992
- var Reader = require(2);
993
- BufferReader.prototype = Object.create(Reader.prototype, {
994
- constructor: {
995
- value: BufferReader,
996
- writable: true,
997
- enumerable: false,
998
- configurable: true
999
- }
1000
- });
1307
+ var Reader = require(8);
1308
+ (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
1001
1309
 
1002
- var util = require(12);
1310
+ var util = require(14);
1003
1311
 
1004
1312
  /**
1005
1313
  * Constructs a new buffer reader instance.
@@ -1015,7 +1323,7 @@ function BufferReader(buffer) {
1015
1323
  * Read buffer.
1016
1324
  * @name BufferReader#buf
1017
1325
  * @type {Buffer}
1018
- */
1326
+ */
1019
1327
  }
1020
1328
 
1021
1329
  BufferReader._configure = function () {
@@ -1024,34 +1332,15 @@ BufferReader._configure = function () {
1024
1332
  BufferReader.prototype._slice = util.Buffer.prototype.slice;
1025
1333
  };
1026
1334
 
1027
- /**
1028
- * Returns raw bytes from the backing buffer without advancing the reader.
1029
- * @name BufferReader#raw
1030
- * @function
1031
- * @param {number} start Start offset
1032
- * @param {number} end End offset
1033
- * @returns {Buffer} Raw bytes
1034
- */
1035
- BufferReader.prototype.raw = function read_raw_buffer(start, end) {
1036
- return this._slice.call(this.buf, start, end);
1037
- };
1038
1335
 
1039
1336
  /**
1040
1337
  * @override
1041
1338
  */
1042
1339
  BufferReader.prototype.string = function read_string_buffer() {
1043
- var len = this.size(), // modifies pos
1044
- start = this.pos,
1045
- end = this.pos + len;
1046
-
1047
- /* istanbul ignore if */
1048
- if (end > this.len)
1049
- throw RangeError("index out of range: " + this.pos + " + " + len + " > " + this.len);
1050
-
1051
- this.pos = end;
1340
+ var len = this.uint32(); // modifies pos
1052
1341
  return this.buf.utf8Slice
1053
- ? this.buf.utf8Slice(start, end)
1054
- : this.buf.toString("utf-8", start, end);
1342
+ ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len))
1343
+ : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
1055
1344
  };
1056
1345
 
1057
1346
  /**
@@ -1063,7 +1352,7 @@ BufferReader.prototype.string = function read_string_buffer() {
1063
1352
 
1064
1353
  BufferReader._configure();
1065
1354
 
1066
- },{"12":12,"2":2}],4:[function(require,module,exports){
1355
+ },{"14":14,"8":8}],10:[function(require,module,exports){
1067
1356
  "use strict";
1068
1357
  module.exports = Object.create(null);
1069
1358
 
@@ -1083,7 +1372,7 @@ module.exports = Object.create(null);
1083
1372
  * var root = protobuf.roots["myroot"];
1084
1373
  */
1085
1374
 
1086
- },{}],5:[function(require,module,exports){
1375
+ },{}],11:[function(require,module,exports){
1087
1376
  "use strict";
1088
1377
 
1089
1378
  /**
@@ -1119,23 +1408,16 @@ var rpc = exports;
1119
1408
  * @returns {undefined}
1120
1409
  */
1121
1410
 
1122
- rpc.Service = require(6);
1411
+ rpc.Service = require(12);
1123
1412
 
1124
- },{"6":6}],6:[function(require,module,exports){
1413
+ },{"12":12}],12:[function(require,module,exports){
1125
1414
  "use strict";
1126
1415
  module.exports = Service;
1127
1416
 
1128
- var util = require(12);
1417
+ var util = require(14);
1129
1418
 
1130
1419
  // Extends EventEmitter
1131
- Service.prototype = Object.create(util.EventEmitter.prototype, {
1132
- constructor: {
1133
- value: Service,
1134
- writable: true,
1135
- enumerable: false,
1136
- configurable: true
1137
- }
1138
- });
1420
+ (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
1139
1421
 
1140
1422
  /**
1141
1423
  * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}.
@@ -1154,16 +1436,10 @@ Service.prototype = Object.create(util.EventEmitter.prototype, {
1154
1436
  * @typedef rpc.ServiceMethod
1155
1437
  * @template TReq extends Message<TReq>
1156
1438
  * @template TRes extends Message<TRes>
1157
- * @type {{
1158
- * (request: TReq|Properties<TReq>, callback: rpc.ServiceMethodCallback<TRes>): void;
1159
- * (request: TReq|Properties<TReq>): Promise<TRes>;
1160
- * readonly name: string;
1161
- * readonly path: string;
1162
- * readonly requestType: string;
1163
- * readonly responseType: string;
1164
- * readonly requestStream: true|undefined;
1165
- * readonly responseStream: true|undefined;
1166
- * }}
1439
+ * @type {function}
1440
+ * @param {TReq|Properties<TReq>} request Request message or plain object
1441
+ * @param {rpc.ServiceMethodCallback<TRes>} [callback] Node-style callback called with the error, if any, and the response message
1442
+ * @returns {Promise<Message<TRes>>} Promise if `callback` has been omitted, otherwise `undefined`
1167
1443
  */
1168
1444
 
1169
1445
  /**
@@ -1278,682 +1554,55 @@ Service.prototype.end = function end(endedByRPC) {
1278
1554
  return this;
1279
1555
  };
1280
1556
 
1281
- },{"12":12}],7:[function(require,module,exports){
1557
+ },{"14":14}],13:[function(require,module,exports){
1282
1558
  "use strict";
1283
- module.exports = asPromise;
1284
-
1285
- /**
1286
- * Callback as used by {@link util.asPromise}.
1287
- * @typedef asPromiseCallback
1288
- * @type {function}
1289
- * @param {Error|null} error Error, if any
1290
- * @param {...*} params Additional arguments
1291
- * @returns {undefined}
1292
- */
1293
-
1294
- /**
1295
- * Returns a promise from a node-style callback function.
1296
- * @memberof util
1297
- * @param {asPromiseCallback} fn Function to call
1298
- * @param {*} ctx Function context
1299
- * @param {...*} params Function arguments
1300
- * @returns {Promise<*>} Promisified function
1301
- */
1302
- function asPromise(fn, ctx/*, varargs */) {
1303
- var params = new Array(arguments.length - 1),
1304
- offset = 0,
1305
- index = 2,
1306
- pending = true;
1307
- while (index < arguments.length)
1308
- params[offset++] = arguments[index++];
1309
- return new Promise(function executor(resolve, reject) {
1310
- params[offset] = function callback(err/*, varargs */) {
1311
- if (pending) {
1312
- pending = false;
1313
- if (err)
1314
- reject(err);
1315
- else {
1316
- var params = new Array(arguments.length - 1),
1317
- offset = 0;
1318
- while (offset < params.length)
1319
- params[offset++] = arguments[offset];
1320
- resolve.apply(null, params);
1321
- }
1322
- }
1323
- };
1324
- try {
1325
- fn.apply(ctx || null, params);
1326
- } catch (err) {
1327
- if (pending) {
1328
- pending = false;
1329
- reject(err);
1330
- }
1331
- }
1332
- });
1333
- }
1559
+ module.exports = LongBits;
1334
1560
 
1335
- },{}],8:[function(require,module,exports){
1336
- "use strict";
1561
+ var util = require(14);
1337
1562
 
1338
1563
  /**
1339
- * A minimal base64 implementation for number arrays.
1564
+ * Constructs new long bits.
1565
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
1340
1566
  * @memberof util
1341
- * @namespace
1567
+ * @constructor
1568
+ * @param {number} lo Low 32 bits, unsigned
1569
+ * @param {number} hi High 32 bits, unsigned
1342
1570
  */
1343
- var base64 = exports;
1571
+ function LongBits(lo, hi) {
1344
1572
 
1345
- /**
1346
- * Calculates the byte length of a base64 encoded string.
1347
- * @param {string} string Base64 encoded string
1348
- * @returns {number} Byte length
1349
- */
1350
- base64.length = function length(string) {
1351
- var p = string.length;
1352
- if (!p)
1353
- return 0;
1354
- while (p > 0 && string.charAt(p - 1) === "=")
1355
- --p;
1356
- return Math.floor(p * 3 / 4);
1357
- };
1573
+ // note that the casts below are theoretically unnecessary as of today, but older statically
1574
+ // generated converter code might still call the ctor with signed 32bits. kept for compat.
1358
1575
 
1359
- // Base64 encoding table
1360
- var b64 = new Array(64);
1361
-
1362
- // Base64 decoding table
1363
- var s64 = new Array(123);
1364
-
1365
- // 65..90, 97..122, 48..57, 43, 47
1366
- for (var i = 0; i < 64;)
1367
- s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
1368
-
1369
- s64[45] = 62; // - -> +
1370
- s64[95] = 63; // _ -> /
1371
-
1372
- /**
1373
- * Encodes a buffer to a base64 encoded string.
1374
- * @param {Uint8Array} buffer Source buffer
1375
- * @param {number} start Source start
1376
- * @param {number} end Source end
1377
- * @returns {string} Base64 encoded string
1378
- */
1379
- base64.encode = function encode(buffer, start, end) {
1380
- var parts = null,
1381
- chunk = [];
1382
- var i = 0, // output index
1383
- j = 0, // goto index
1384
- t; // temporary
1385
- while (start < end) {
1386
- var b = buffer[start++];
1387
- switch (j) {
1388
- case 0:
1389
- chunk[i++] = b64[b >> 2];
1390
- t = (b & 3) << 4;
1391
- j = 1;
1392
- break;
1393
- case 1:
1394
- chunk[i++] = b64[t | b >> 4];
1395
- t = (b & 15) << 2;
1396
- j = 2;
1397
- break;
1398
- case 2:
1399
- chunk[i++] = b64[t | b >> 6];
1400
- chunk[i++] = b64[b & 63];
1401
- j = 0;
1402
- break;
1403
- }
1404
- if (i > 8191) {
1405
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
1406
- i = 0;
1407
- }
1408
- }
1409
- if (j) {
1410
- chunk[i++] = b64[t];
1411
- chunk[i++] = 61;
1412
- if (j === 1)
1413
- chunk[i++] = 61;
1414
- }
1415
- if (parts) {
1416
- if (i)
1417
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
1418
- return parts.join("");
1419
- }
1420
- return String.fromCharCode.apply(String, chunk.slice(0, i));
1421
- };
1576
+ /**
1577
+ * Low bits.
1578
+ * @type {number}
1579
+ */
1580
+ this.lo = lo >>> 0;
1422
1581
 
1423
- var invalidEncoding = "invalid encoding";
1582
+ /**
1583
+ * High bits.
1584
+ * @type {number}
1585
+ */
1586
+ this.hi = hi >>> 0;
1587
+ }
1424
1588
 
1425
1589
  /**
1426
- * Decodes a base64 encoded string to a buffer.
1427
- * @param {string} string Source string
1428
- * @param {Uint8Array} buffer Destination buffer
1429
- * @param {number} offset Destination offset
1430
- * @returns {number} Number of bytes written
1431
- * @throws {Error} If encoding is invalid
1590
+ * Zero bits.
1591
+ * @memberof util.LongBits
1592
+ * @type {util.LongBits}
1432
1593
  */
1433
- base64.decode = function decode(string, buffer, offset) {
1434
- var start = offset;
1435
- var j = 0, // goto index
1436
- t; // temporary
1437
- for (var i = 0; i < string.length;) {
1438
- var c = string.charCodeAt(i++);
1439
- if (c === 61 && j > 1)
1440
- break;
1441
- if ((c = s64[c]) === undefined)
1442
- throw Error(invalidEncoding);
1443
- switch (j) {
1444
- case 0:
1445
- t = c;
1446
- j = 1;
1447
- break;
1448
- case 1:
1449
- buffer[offset++] = t << 2 | (c & 48) >> 4;
1450
- t = c;
1451
- j = 2;
1452
- break;
1453
- case 2:
1454
- buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
1455
- t = c;
1456
- j = 3;
1457
- break;
1458
- case 3:
1459
- buffer[offset++] = (t & 3) << 6 | c;
1460
- j = 0;
1461
- break;
1462
- }
1463
- }
1464
- if (j === 1)
1465
- throw Error(invalidEncoding);
1466
- return offset - start;
1467
- };
1594
+ var zero = LongBits.zero = new LongBits(0, 0);
1468
1595
 
1469
- var base64Re = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,
1470
- base64UrlRe = /[-_]/,
1471
- base64UrlNoPaddingRe = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==)?|[A-Za-z0-9_-]{3}=?)?$/;
1596
+ zero.toNumber = function() { return 0; };
1597
+ zero.zzEncode = zero.zzDecode = function() { return this; };
1598
+ zero.length = function() { return 1; };
1472
1599
 
1473
1600
  /**
1474
- * Tests if the specified string appears to be base64 encoded.
1475
- * @param {string} string String to test
1476
- * @returns {boolean} `true` if probably base64 encoded, otherwise false
1601
+ * Zero hash.
1602
+ * @memberof util.LongBits
1603
+ * @type {string}
1477
1604
  */
1478
- base64.test = function test(string) {
1479
- return base64Re.test(string)
1480
- || base64UrlRe.test(string) && base64UrlNoPaddingRe.test(string);
1481
- };
1482
-
1483
- },{}],9:[function(require,module,exports){
1484
- "use strict";
1485
- module.exports = EventEmitter;
1486
-
1487
- /**
1488
- * Constructs a new event emitter instance.
1489
- * @classdesc A minimal event emitter.
1490
- * @memberof util
1491
- * @constructor
1492
- */
1493
- function EventEmitter() {
1494
-
1495
- /**
1496
- * Registered listeners.
1497
- * @type {Object.<string,*>}
1498
- * @private
1499
- */
1500
- this._listeners = Object.create(null);
1501
- }
1502
-
1503
- /**
1504
- * Event listener as used by {@link util.EventEmitter}.
1505
- * @typedef EventEmitterListener
1506
- * @type {function}
1507
- * @param {...*} args Arguments
1508
- * @returns {undefined}
1509
- */
1510
-
1511
- /**
1512
- * Registers an event listener.
1513
- * @param {string} evt Event name
1514
- * @param {EventEmitterListener} fn Listener
1515
- * @param {*} [ctx] Listener context
1516
- * @returns {this} `this`
1517
- */
1518
- EventEmitter.prototype.on = function on(evt, fn, ctx) {
1519
- (this._listeners[evt] || (this._listeners[evt] = [])).push({
1520
- fn : fn,
1521
- ctx : ctx || this
1522
- });
1523
- return this;
1524
- };
1525
-
1526
- /**
1527
- * Removes an event listener or any matching listeners if arguments are omitted.
1528
- * @param {string} [evt] Event name. Removes all listeners if omitted.
1529
- * @param {EventEmitterListener} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
1530
- * @returns {this} `this`
1531
- */
1532
- EventEmitter.prototype.off = function off(evt, fn) {
1533
- if (evt === undefined)
1534
- this._listeners = Object.create(null);
1535
- else {
1536
- if (fn === undefined)
1537
- this._listeners[evt] = [];
1538
- else {
1539
- var listeners = this._listeners[evt];
1540
- if (!listeners)
1541
- return this;
1542
- for (var i = 0; i < listeners.length;)
1543
- if (listeners[i].fn === fn)
1544
- listeners.splice(i, 1);
1545
- else
1546
- ++i;
1547
- }
1548
- }
1549
- return this;
1550
- };
1551
-
1552
- /**
1553
- * Emits an event by calling its listeners with the specified arguments.
1554
- * @param {string} evt Event name
1555
- * @param {...*} args Arguments
1556
- * @returns {this} `this`
1557
- */
1558
- EventEmitter.prototype.emit = function emit(evt) {
1559
- var listeners = this._listeners[evt];
1560
- if (listeners) {
1561
- var args = [],
1562
- i = 1;
1563
- for (; i < arguments.length;)
1564
- args.push(arguments[i++]);
1565
- for (i = 0; i < listeners.length;)
1566
- listeners[i].fn.apply(listeners[i++].ctx, args);
1567
- }
1568
- return this;
1569
- };
1570
-
1571
- },{}],10:[function(require,module,exports){
1572
- "use strict";
1573
-
1574
- module.exports = factory(factory);
1575
-
1576
- /**
1577
- * Reads / writes floats / doubles from / to buffers.
1578
- * @name util.float
1579
- * @namespace
1580
- */
1581
-
1582
- /**
1583
- * Writes a 32 bit float to a buffer using little endian byte order.
1584
- * @name util.float.writeFloatLE
1585
- * @function
1586
- * @param {number} val Value to write
1587
- * @param {Uint8Array} buf Target buffer
1588
- * @param {number} pos Target buffer offset
1589
- * @returns {undefined}
1590
- */
1591
-
1592
- /**
1593
- * Writes a 32 bit float to a buffer using big endian byte order.
1594
- * @name util.float.writeFloatBE
1595
- * @function
1596
- * @param {number} val Value to write
1597
- * @param {Uint8Array} buf Target buffer
1598
- * @param {number} pos Target buffer offset
1599
- * @returns {undefined}
1600
- */
1601
-
1602
- /**
1603
- * Reads a 32 bit float from a buffer using little endian byte order.
1604
- * @name util.float.readFloatLE
1605
- * @function
1606
- * @param {Uint8Array} buf Source buffer
1607
- * @param {number} pos Source buffer offset
1608
- * @returns {number} Value read
1609
- */
1610
-
1611
- /**
1612
- * Reads a 32 bit float from a buffer using big endian byte order.
1613
- * @name util.float.readFloatBE
1614
- * @function
1615
- * @param {Uint8Array} buf Source buffer
1616
- * @param {number} pos Source buffer offset
1617
- * @returns {number} Value read
1618
- */
1619
-
1620
- /**
1621
- * Writes a 64 bit double to a buffer using little endian byte order.
1622
- * @name util.float.writeDoubleLE
1623
- * @function
1624
- * @param {number} val Value to write
1625
- * @param {Uint8Array} buf Target buffer
1626
- * @param {number} pos Target buffer offset
1627
- * @returns {undefined}
1628
- */
1629
-
1630
- /**
1631
- * Writes a 64 bit double to a buffer using big endian byte order.
1632
- * @name util.float.writeDoubleBE
1633
- * @function
1634
- * @param {number} val Value to write
1635
- * @param {Uint8Array} buf Target buffer
1636
- * @param {number} pos Target buffer offset
1637
- * @returns {undefined}
1638
- */
1639
-
1640
- /**
1641
- * Reads a 64 bit double from a buffer using little endian byte order.
1642
- * @name util.float.readDoubleLE
1643
- * @function
1644
- * @param {Uint8Array} buf Source buffer
1645
- * @param {number} pos Source buffer offset
1646
- * @returns {number} Value read
1647
- */
1648
-
1649
- /**
1650
- * Reads a 64 bit double from a buffer using big endian byte order.
1651
- * @name util.float.readDoubleBE
1652
- * @function
1653
- * @param {Uint8Array} buf Source buffer
1654
- * @param {number} pos Source buffer offset
1655
- * @returns {number} Value read
1656
- */
1657
-
1658
- // Factory function for the purpose of node-based testing in modified global environments
1659
- function factory(exports) {
1660
-
1661
- // float: typed array
1662
- if (typeof Float32Array !== "undefined") (function() {
1663
-
1664
- var f32 = new Float32Array([ -0 ]),
1665
- f8b = new Uint8Array(f32.buffer),
1666
- le = f8b[3] === 128;
1667
-
1668
- function writeFloat_f32_cpy(val, buf, pos) {
1669
- f32[0] = val;
1670
- buf[pos ] = f8b[0];
1671
- buf[pos + 1] = f8b[1];
1672
- buf[pos + 2] = f8b[2];
1673
- buf[pos + 3] = f8b[3];
1674
- }
1675
-
1676
- function writeFloat_f32_rev(val, buf, pos) {
1677
- f32[0] = val;
1678
- buf[pos ] = f8b[3];
1679
- buf[pos + 1] = f8b[2];
1680
- buf[pos + 2] = f8b[1];
1681
- buf[pos + 3] = f8b[0];
1682
- }
1683
-
1684
- /* istanbul ignore next */
1685
- exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
1686
- /* istanbul ignore next */
1687
- exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
1688
-
1689
- function readFloat_f32_cpy(buf, pos) {
1690
- f8b[0] = buf[pos ];
1691
- f8b[1] = buf[pos + 1];
1692
- f8b[2] = buf[pos + 2];
1693
- f8b[3] = buf[pos + 3];
1694
- return f32[0];
1695
- }
1696
-
1697
- function readFloat_f32_rev(buf, pos) {
1698
- f8b[3] = buf[pos ];
1699
- f8b[2] = buf[pos + 1];
1700
- f8b[1] = buf[pos + 2];
1701
- f8b[0] = buf[pos + 3];
1702
- return f32[0];
1703
- }
1704
-
1705
- /* istanbul ignore next */
1706
- exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
1707
- /* istanbul ignore next */
1708
- exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
1709
-
1710
- // float: ieee754
1711
- })(); else (function() {
1712
-
1713
- function writeFloat_ieee754(writeUint, val, buf, pos) {
1714
- var sign = val < 0 ? 1 : 0;
1715
- if (sign)
1716
- val = -val;
1717
- if (val === 0)
1718
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
1719
- else if (isNaN(val))
1720
- writeUint(2143289344, buf, pos);
1721
- else if (val > 3.4028234663852886e+38) // +-Infinity
1722
- writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
1723
- else if (val < 1.1754943508222875e-38) // denormal
1724
- writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
1725
- else {
1726
- var exponent = Math.floor(Math.log(val) / Math.LN2),
1727
- mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
1728
- writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
1729
- }
1730
- }
1731
-
1732
- exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
1733
- exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
1734
-
1735
- function readFloat_ieee754(readUint, buf, pos) {
1736
- var uint = readUint(buf, pos),
1737
- sign = (uint >> 31) * 2 + 1,
1738
- exponent = uint >>> 23 & 255,
1739
- mantissa = uint & 8388607;
1740
- return exponent === 255
1741
- ? mantissa
1742
- ? NaN
1743
- : sign * Infinity
1744
- : exponent === 0 // denormal
1745
- ? sign * 1.401298464324817e-45 * mantissa
1746
- : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
1747
- }
1748
-
1749
- exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
1750
- exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
1751
-
1752
- })();
1753
-
1754
- // double: typed array
1755
- if (typeof Float64Array !== "undefined") (function() {
1756
-
1757
- var f64 = new Float64Array([-0]),
1758
- f8b = new Uint8Array(f64.buffer),
1759
- le = f8b[7] === 128;
1760
-
1761
- function writeDouble_f64_cpy(val, buf, pos) {
1762
- f64[0] = val;
1763
- buf[pos ] = f8b[0];
1764
- buf[pos + 1] = f8b[1];
1765
- buf[pos + 2] = f8b[2];
1766
- buf[pos + 3] = f8b[3];
1767
- buf[pos + 4] = f8b[4];
1768
- buf[pos + 5] = f8b[5];
1769
- buf[pos + 6] = f8b[6];
1770
- buf[pos + 7] = f8b[7];
1771
- }
1772
-
1773
- function writeDouble_f64_rev(val, buf, pos) {
1774
- f64[0] = val;
1775
- buf[pos ] = f8b[7];
1776
- buf[pos + 1] = f8b[6];
1777
- buf[pos + 2] = f8b[5];
1778
- buf[pos + 3] = f8b[4];
1779
- buf[pos + 4] = f8b[3];
1780
- buf[pos + 5] = f8b[2];
1781
- buf[pos + 6] = f8b[1];
1782
- buf[pos + 7] = f8b[0];
1783
- }
1784
-
1785
- /* istanbul ignore next */
1786
- exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
1787
- /* istanbul ignore next */
1788
- exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
1789
-
1790
- function readDouble_f64_cpy(buf, pos) {
1791
- f8b[0] = buf[pos ];
1792
- f8b[1] = buf[pos + 1];
1793
- f8b[2] = buf[pos + 2];
1794
- f8b[3] = buf[pos + 3];
1795
- f8b[4] = buf[pos + 4];
1796
- f8b[5] = buf[pos + 5];
1797
- f8b[6] = buf[pos + 6];
1798
- f8b[7] = buf[pos + 7];
1799
- return f64[0];
1800
- }
1801
-
1802
- function readDouble_f64_rev(buf, pos) {
1803
- f8b[7] = buf[pos ];
1804
- f8b[6] = buf[pos + 1];
1805
- f8b[5] = buf[pos + 2];
1806
- f8b[4] = buf[pos + 3];
1807
- f8b[3] = buf[pos + 4];
1808
- f8b[2] = buf[pos + 5];
1809
- f8b[1] = buf[pos + 6];
1810
- f8b[0] = buf[pos + 7];
1811
- return f64[0];
1812
- }
1813
-
1814
- /* istanbul ignore next */
1815
- exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
1816
- /* istanbul ignore next */
1817
- exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
1818
-
1819
- // double: ieee754
1820
- })(); else (function() {
1821
-
1822
- function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
1823
- var sign = val < 0 ? 1 : 0;
1824
- if (sign)
1825
- val = -val;
1826
- if (val === 0) {
1827
- writeUint(0, buf, pos + off0);
1828
- writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
1829
- } else if (isNaN(val)) {
1830
- writeUint(0, buf, pos + off0);
1831
- writeUint(2146959360, buf, pos + off1);
1832
- } else if (val > 1.7976931348623157e+308) { // +-Infinity
1833
- writeUint(0, buf, pos + off0);
1834
- writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
1835
- } else {
1836
- var mantissa;
1837
- if (val < 2.2250738585072014e-308) { // denormal
1838
- mantissa = val / 5e-324;
1839
- writeUint(mantissa >>> 0, buf, pos + off0);
1840
- writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
1841
- } else {
1842
- var exponent = Math.floor(Math.log(val) / Math.LN2);
1843
- if (exponent === 1024)
1844
- exponent = 1023;
1845
- mantissa = val * Math.pow(2, -exponent);
1846
- writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
1847
- writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
1848
- }
1849
- }
1850
- }
1851
-
1852
- exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
1853
- exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
1854
-
1855
- function readDouble_ieee754(readUint, off0, off1, buf, pos) {
1856
- var lo = readUint(buf, pos + off0),
1857
- hi = readUint(buf, pos + off1);
1858
- var sign = (hi >> 31) * 2 + 1,
1859
- exponent = hi >>> 20 & 2047,
1860
- mantissa = 4294967296 * (hi & 1048575) + lo;
1861
- return exponent === 2047
1862
- ? mantissa
1863
- ? NaN
1864
- : sign * Infinity
1865
- : exponent === 0 // denormal
1866
- ? sign * 5e-324 * mantissa
1867
- : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
1868
- }
1869
-
1870
- exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
1871
- exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
1872
-
1873
- })();
1874
-
1875
- return exports;
1876
- }
1877
-
1878
- // uint helpers
1879
-
1880
- function writeUintLE(val, buf, pos) {
1881
- buf[pos ] = val & 255;
1882
- buf[pos + 1] = val >>> 8 & 255;
1883
- buf[pos + 2] = val >>> 16 & 255;
1884
- buf[pos + 3] = val >>> 24;
1885
- }
1886
-
1887
- function writeUintBE(val, buf, pos) {
1888
- buf[pos ] = val >>> 24;
1889
- buf[pos + 1] = val >>> 16 & 255;
1890
- buf[pos + 2] = val >>> 8 & 255;
1891
- buf[pos + 3] = val & 255;
1892
- }
1893
-
1894
- function readUintLE(buf, pos) {
1895
- return (buf[pos ]
1896
- | buf[pos + 1] << 8
1897
- | buf[pos + 2] << 16
1898
- | buf[pos + 3] << 24) >>> 0;
1899
- }
1900
-
1901
- function readUintBE(buf, pos) {
1902
- return (buf[pos ] << 24
1903
- | buf[pos + 1] << 16
1904
- | buf[pos + 2] << 8
1905
- | buf[pos + 3]) >>> 0;
1906
- }
1907
-
1908
- },{}],11:[function(require,module,exports){
1909
- "use strict";
1910
- module.exports = LongBits;
1911
-
1912
- var Long;
1913
-
1914
- /**
1915
- * Constructs new long bits.
1916
- * @classdesc Helper class for working with the low and high bits of a 64 bit value.
1917
- * @memberof util
1918
- * @constructor
1919
- * @param {number} lo Low 32 bits, unsigned
1920
- * @param {number} hi High 32 bits, unsigned
1921
- */
1922
- function LongBits(lo, hi) {
1923
-
1924
- // note that the casts below are theoretically unnecessary as of today, but older statically
1925
- // generated converter code might still call the ctor with signed 32bits. kept for compat.
1926
-
1927
- /**
1928
- * Low bits.
1929
- * @type {number}
1930
- */
1931
- this.lo = lo >>> 0;
1932
-
1933
- /**
1934
- * High bits.
1935
- * @type {number}
1936
- */
1937
- this.hi = hi >>> 0;
1938
- }
1939
-
1940
- /**
1941
- * Zero bits.
1942
- * @memberof util.LongBits
1943
- * @type {util.LongBits}
1944
- */
1945
- var zero = LongBits.zero = new LongBits(0, 0);
1946
-
1947
- zero.toNumber = function() { return 0; };
1948
- zero.zzEncode = zero.zzDecode = function() { return this; };
1949
- zero.length = function() { return 1; };
1950
-
1951
- /**
1952
- * Zero hash.
1953
- * @memberof util.LongBits
1954
- * @type {string}
1955
- */
1956
- var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
1605
+ var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
1957
1606
 
1958
1607
  /**
1959
1608
  * Constructs new long bits from the specified number.
@@ -1988,10 +1637,10 @@ LongBits.fromNumber = function fromNumber(value) {
1988
1637
  LongBits.from = function from(value) {
1989
1638
  if (typeof value === "number")
1990
1639
  return LongBits.fromNumber(value);
1991
- if (typeof value === "string" || value instanceof String) {
1640
+ if (util.isString(value)) {
1992
1641
  /* istanbul ignore else */
1993
- if (Long)
1994
- value = Long.fromString(value);
1642
+ if (util.Long)
1643
+ value = util.Long.fromString(value);
1995
1644
  else
1996
1645
  return LongBits.fromNumber(parseInt(value, 10));
1997
1646
  }
@@ -2020,8 +1669,8 @@ LongBits.prototype.toNumber = function toNumber(unsigned) {
2020
1669
  * @returns {Long} Long
2021
1670
  */
2022
1671
  LongBits.prototype.toLong = function toLong(unsigned) {
2023
- return Long
2024
- ? new Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
1672
+ return util.Long
1673
+ ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
2025
1674
  /* istanbul ignore next */
2026
1675
  : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
2027
1676
  };
@@ -2107,35 +1756,30 @@ LongBits.prototype.length = function length() {
2107
1756
  : part2 < 128 ? 9 : 10;
2108
1757
  };
2109
1758
 
2110
- LongBits._configure = function(Long_) {
2111
- Long = Long_;
2112
- };
2113
-
2114
- },{}],12:[function(require,module,exports){
1759
+ },{"14":14}],14:[function(require,module,exports){
2115
1760
  "use strict";
2116
- /* global globalThis */
2117
1761
  var util = exports;
2118
1762
 
2119
1763
  // used to return a Promise where callback is omitted
2120
- util.asPromise = require(7);
1764
+ util.asPromise = require(1);
2121
1765
 
2122
1766
  // converts to / from base64 encoded strings
2123
- util.base64 = require(8);
1767
+ util.base64 = require(2);
2124
1768
 
2125
1769
  // base class of rpc.Service
2126
- util.EventEmitter = require(9);
1770
+ util.EventEmitter = require(3);
2127
1771
 
2128
1772
  // float handling accross browsers
2129
- util.float = require(10);
1773
+ util.float = require(4);
2130
1774
 
2131
1775
  // converts to / from utf8 encoded strings
2132
- util.utf8 = require(14);
1776
+ util.utf8 = require(6);
2133
1777
 
2134
1778
  // provides a node-like buffer pool in the browser
2135
- util.pool = require(13);
1779
+ util.pool = require(5);
2136
1780
 
2137
1781
  // utility to work with the low and high bits of a 64 bit value
2138
- util.LongBits = require(11);
1782
+ util.LongBits = require(13);
2139
1783
 
2140
1784
  /**
2141
1785
  * Tests if the specified key can affect object prototypes.
@@ -2168,7 +1812,6 @@ util.isNode = Boolean(typeof global !== "undefined"
2168
1812
  util.global = util.isNode && global
2169
1813
  || typeof window !== "undefined" && window
2170
1814
  || typeof self !== "undefined" && self
2171
- || typeof globalThis !== "undefined" && globalThis
2172
1815
  || this; // eslint-disable-line no-invalid-this
2173
1816
 
2174
1817
  /**
@@ -2251,59 +1894,43 @@ util.isSet = function isSet(obj, prop) {
2251
1894
  util.Buffer = (function() {
2252
1895
  try {
2253
1896
  var Buffer = util.global.Buffer;
2254
- // refuse to use non-node buffers if not explicitly assigned (perf reasons)
2255
- return Buffer.prototype.utf8Write || util.isNode ? Buffer : /* istanbul ignore next */ null;
1897
+ // refuse to use non-node buffers if not explicitly assigned (perf reasons):
1898
+ return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
2256
1899
  } catch (e) {
2257
1900
  /* istanbul ignore next */
2258
1901
  return null;
2259
1902
  }
2260
1903
  })();
2261
1904
 
1905
+ // Internal alias of or polyfull for Buffer.from.
1906
+ util._Buffer_from = null;
1907
+
1908
+ // Internal alias of or polyfill for Buffer.allocUnsafe.
1909
+ util._Buffer_allocUnsafe = null;
1910
+
2262
1911
  /**
2263
1912
  * Creates a new buffer of whatever type supported by the environment.
2264
1913
  * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
2265
1914
  * @returns {Uint8Array|Buffer} Buffer
2266
1915
  */
2267
1916
  util.newBuffer = function newBuffer(sizeOrArray) {
2268
- var Buffer = util.Buffer;
2269
1917
  /* istanbul ignore next */
2270
1918
  return typeof sizeOrArray === "number"
2271
- ? Buffer
2272
- ? Buffer.allocUnsafe(sizeOrArray)
2273
- : new Uint8Array(sizeOrArray)
2274
- : Buffer
2275
- ? Buffer.from(sizeOrArray)
2276
- : new Uint8Array(sizeOrArray);
2277
- };
2278
-
2279
- /**
2280
- * Prepends a raw field tag to raw field data.
2281
- * @param {number} id Field id
2282
- * @param {number} wireType Wire type
2283
- * @param {Uint8Array} data Raw field data
2284
- * @returns {Uint8Array|Buffer} Raw field bytes
2285
- * @ignore
2286
- */
2287
- util.rawField = function rawField(id, wireType, data) {
2288
- var out = [],
2289
- tag = id << 3 | wireType;
2290
- tag >>>= 0;
2291
- while (tag > 127) {
2292
- out.push(tag & 127 | 128);
2293
- tag >>>= 7;
2294
- }
2295
- out.push(tag);
2296
- for (var i = 0; i < data.length; ++i)
2297
- out.push(data[i]);
2298
- return util.newBuffer(out);
1919
+ ? util.Buffer
1920
+ ? util._Buffer_allocUnsafe(sizeOrArray)
1921
+ : new util.Array(sizeOrArray)
1922
+ : util.Buffer
1923
+ ? util._Buffer_from(sizeOrArray)
1924
+ : typeof Uint8Array === "undefined"
1925
+ ? sizeOrArray
1926
+ : new Uint8Array(sizeOrArray);
2299
1927
  };
2300
1928
 
2301
1929
  /**
2302
- * Array implementation used in the browser.
1930
+ * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
2303
1931
  * @type {Constructor<Uint8Array>}
2304
- * @deprecated Use `Uint8Array` instead.
2305
1932
  */
2306
- util.Array = Uint8Array;
1933
+ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
2307
1934
 
2308
1935
  /**
2309
1936
  * Any compatible Long instance.
@@ -2335,7 +1962,7 @@ util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore
2335
1962
  * @type {RegExp}
2336
1963
  * @const
2337
1964
  */
2338
- util.key2Re = /^(?:true|false|0|1)$/;
1965
+ util.key2Re = /^true|false|0|1$/;
2339
1966
 
2340
1967
  /**
2341
1968
  * Regular expression used to verify 32 bit (`int32` etc.) map keys.
@@ -2349,7 +1976,7 @@ util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
2349
1976
  * @type {RegExp}
2350
1977
  * @const
2351
1978
  */
2352
- util.key64Re = /^(?:[\x00-\xff]{8}|-?(?:0|[1-9][0-9]*))$/; // eslint-disable-line no-control-regex
1979
+ util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
2353
1980
 
2354
1981
  /**
2355
1982
  * Converts a number or long to an 8 characters long hash string.
@@ -2375,27 +2002,6 @@ util.longFromHash = function longFromHash(hash, unsigned) {
2375
2002
  return bits.toNumber(Boolean(unsigned));
2376
2003
  };
2377
2004
 
2378
- /**
2379
- * Converts a 64 bit key to a long or number if it is an 8 characters long hash string.
2380
- * @param {string} key Map key
2381
- * @param {boolean} [unsigned=false] Whether unsigned or not
2382
- * @returns {Long|number|string} Original value
2383
- */
2384
- util.longFromKey = function longFromKey(key, unsigned) {
2385
- return util.key64Re.test(key) && !util.key32Re.test(key)
2386
- ? util.longFromHash(key, unsigned)
2387
- : key;
2388
- };
2389
-
2390
- /**
2391
- * Converts a boolean key to a boolean value.
2392
- * @param {string} key Map key
2393
- * @returns {boolean} Boolean value
2394
- */
2395
- util.boolFromKey = function boolFromKey(key) {
2396
- return key === "true" || key === "1";
2397
- };
2398
-
2399
2005
  /**
2400
2006
  * Merges the properties of the source object into the destination object.
2401
2007
  * @memberof util
@@ -2412,7 +2018,7 @@ function merge(dst) { // used by converters
2412
2018
  if (!src)
2413
2019
  continue;
2414
2020
  for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
2415
- if (!isUnsafeProperty(keys[i]) && (!ifNotSet || !Object.prototype.hasOwnProperty.call(dst, keys[i]) || dst[keys[i]] === undefined))
2021
+ if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
2416
2022
  dst[keys[i]] = src[keys[i]];
2417
2023
  }
2418
2024
  return dst;
@@ -2439,14 +2045,11 @@ util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_
2439
2045
  * @memberof util
2440
2046
  * @param {Object.<string,*>} obj Object
2441
2047
  * @param {string} key Property key
2442
- * @param {boolean} [enumerable=true] Whether the property should be enumerable
2443
2048
  * @returns {undefined}
2444
2049
  */
2445
- util.makeProp = function makeProp(obj, key, enumerable) {
2446
- if (Object.prototype.hasOwnProperty.call(obj, key))
2447
- return;
2050
+ util.makeProp = function makeProp(obj, key) {
2448
2051
  Object.defineProperty(obj, key, {
2449
- enumerable: enumerable === undefined ? true : enumerable,
2052
+ enumerable: true,
2450
2053
  configurable: true,
2451
2054
  writable: true
2452
2055
  });
@@ -2624,285 +2227,151 @@ util.toJSONOptions = {
2624
2227
  json: true
2625
2228
  };
2626
2229
 
2627
- },{"10":10,"11":11,"13":13,"14":14,"7":7,"8":8,"9":9,"long":"long"}],13:[function(require,module,exports){
2628
- "use strict";
2629
- module.exports = pool;
2630
-
2631
- /**
2632
- * An allocator as used by {@link util.pool}.
2633
- * @typedef PoolAllocator
2634
- * @type {function}
2635
- * @param {number} size Buffer size
2636
- * @returns {Uint8Array} Buffer
2637
- */
2638
-
2639
- /**
2640
- * A slicer as used by {@link util.pool}.
2641
- * @typedef PoolSlicer
2642
- * @type {function}
2643
- * @param {number} start Start offset
2644
- * @param {number} end End offset
2645
- * @returns {Uint8Array} Buffer slice
2646
- * @this Uint8Array
2647
- */
2648
-
2649
- /**
2650
- * A general purpose buffer pool.
2651
- * @memberof util
2652
- * @function
2653
- * @param {PoolAllocator} alloc Allocator
2654
- * @param {PoolSlicer} slice Slicer
2655
- * @param {number} [size=8192] Slab size
2656
- * @returns {PoolAllocator} Pooled allocator
2657
- */
2658
- function pool(alloc, slice, size) {
2659
- var SIZE = size || 8192;
2660
- var MAX = SIZE >>> 1;
2661
- var slab = null;
2662
- var offset = SIZE;
2663
- return function pool_alloc(size) {
2664
- if (size < 1 || size > MAX)
2665
- return alloc(size);
2666
- if (offset + size > SIZE) {
2667
- slab = alloc(SIZE);
2668
- offset = 0;
2669
- }
2670
- var buf = slice.call(slab, offset, offset += size);
2671
- if (offset & 7) // align to 32 bit
2672
- offset = (offset | 7) + 1;
2673
- return buf;
2674
- };
2675
- }
2230
+ // Sets up buffer utility according to the environment (called in index-minimal)
2231
+ util._configure = function() {
2232
+ var Buffer = util.Buffer;
2233
+ /* istanbul ignore if */
2234
+ if (!Buffer) {
2235
+ util._Buffer_from = util._Buffer_allocUnsafe = null;
2236
+ return;
2237
+ }
2238
+ // because node 4.x buffers are incompatible & immutable
2239
+ // see: https://github.com/dcodeIO/protobuf.js/pull/665
2240
+ util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
2241
+ /* istanbul ignore next */
2242
+ function Buffer_from(value, encoding) {
2243
+ return new Buffer(value, encoding);
2244
+ };
2245
+ util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
2246
+ /* istanbul ignore next */
2247
+ function Buffer_allocUnsafe(size) {
2248
+ return new Buffer(size);
2249
+ };
2250
+ };
2676
2251
 
2677
- },{}],14:[function(require,module,exports){
2252
+ },{"1":1,"13":13,"2":2,"3":3,"4":4,"5":5,"6":6,"long":"long"}],15:[function(require,module,exports){
2678
2253
  "use strict";
2254
+ module.exports = Writer;
2679
2255
 
2680
- /**
2681
- * A minimal UTF8 implementation.
2682
- * @memberof util
2683
- * @namespace
2684
- */
2685
- var utf8 = exports,
2686
- looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }),
2687
- strictDecoder;
2688
- var TEXT_DECODER_MIN_LENGTH = 64;
2689
-
2690
- try {
2691
- strictDecoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
2692
- } catch (err) {
2693
- // "fatal" option is not supported on Node.js compiled without ICU
2694
- strictDecoder = looseDecoder;
2695
- }
2256
+ var util = require(14);
2696
2257
 
2697
- /**
2698
- * Calculates the UTF8 byte length of a string.
2699
- * @param {string} string String
2700
- * @returns {number} Byte length
2701
- */
2702
- utf8.length = function utf8_length(string) {
2703
- var len = 0,
2704
- c = 0;
2705
- for (var i = 0; i < string.length; ++i) {
2706
- c = string.charCodeAt(i);
2707
- if (c < 128)
2708
- len += 1;
2709
- else if (c < 2048)
2710
- len += 2;
2711
- else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
2712
- ++i;
2713
- len += 4;
2714
- } else
2715
- len += 3;
2716
- }
2717
- return len;
2718
- };
2258
+ var BufferWriter; // cyclic
2719
2259
 
2720
- function utf8_read_decoder(decoder, buffer, start, end) {
2721
- var source = start === 0 && end === buffer.length
2722
- ? buffer
2723
- : buffer.subarray(start, end);
2724
- return decoder.decode(source);
2725
- }
2260
+ var LongBits = util.LongBits,
2261
+ base64 = util.base64,
2262
+ utf8 = util.utf8;
2726
2263
 
2727
2264
  /**
2728
- * Reads UTF8 bytes as a string.
2729
- * @param {Uint8Array} buffer Source buffer
2730
- * @param {number} start Source start
2731
- * @param {number} end Source end
2732
- * @returns {string} String read
2733
- */
2734
- utf8.read = function utf8_read_loose(buffer, start, end) {
2735
- if (end - start < 1)
2736
- return "";
2737
- if (end - start >= TEXT_DECODER_MIN_LENGTH)
2738
- return utf8_read_decoder(looseDecoder, buffer, start, end);
2739
-
2740
- var str = "",
2741
- i = start,
2742
- c1, c2, c3, c4, c5, c6, c7, c8;
2743
-
2744
- for (; i + 7 < end; i += 8) {
2745
- c1 = buffer[i];
2746
- c2 = buffer[i + 1];
2747
- c3 = buffer[i + 2];
2748
- c4 = buffer[i + 3];
2749
- c5 = buffer[i + 4];
2750
- c6 = buffer[i + 5];
2751
- c7 = buffer[i + 6];
2752
- c8 = buffer[i + 7];
2753
- if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
2754
- return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2755
- str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
2756
- }
2265
+ * Constructs a new writer operation instance.
2266
+ * @classdesc Scheduled writer operation.
2267
+ * @constructor
2268
+ * @param {function(*, Uint8Array, number)} fn Function to call
2269
+ * @param {number} len Value byte length
2270
+ * @param {*} val Value to write
2271
+ * @ignore
2272
+ */
2273
+ function Op(fn, len, val) {
2757
2274
 
2758
- for (; i < end; ++i) {
2759
- c1 = buffer[i];
2760
- if (c1 & 0x80)
2761
- return str + utf8_read_decoder(looseDecoder, buffer, i, end);
2762
- str += String.fromCharCode(c1);
2763
- }
2275
+ /**
2276
+ * Function to call.
2277
+ * @type {function(Uint8Array, number, *)}
2278
+ */
2279
+ this.fn = fn;
2764
2280
 
2765
- return str;
2766
- };
2281
+ /**
2282
+ * Value byte length.
2283
+ * @type {number}
2284
+ */
2285
+ this.len = len;
2767
2286
 
2768
- /**
2769
- * Reads UTF8 bytes as a string, rejecting invalid UTF8.
2770
- * @param {Uint8Array} buffer Source buffer
2771
- * @param {number} start Source start
2772
- * @param {number} end Source end
2773
- * @returns {string} String read
2774
- */
2775
- utf8.readStrict = function utf8_read_strict(buffer, start, end) {
2776
- if (end - start < 1)
2777
- return "";
2778
- if (end - start >= TEXT_DECODER_MIN_LENGTH)
2779
- return utf8_read_decoder(strictDecoder, buffer, start, end);
2780
-
2781
- var str = "",
2782
- i = start,
2783
- c1, c2, c3, c4, c5, c6, c7, c8;
2784
-
2785
- for (; i + 7 < end; i += 8) {
2786
- c1 = buffer[i];
2787
- c2 = buffer[i + 1];
2788
- c3 = buffer[i + 2];
2789
- c4 = buffer[i + 3];
2790
- c5 = buffer[i + 4];
2791
- c6 = buffer[i + 5];
2792
- c7 = buffer[i + 6];
2793
- c8 = buffer[i + 7];
2794
- if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
2795
- return str + utf8_read_decoder(strictDecoder, buffer, i, end);
2796
- str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
2797
- }
2287
+ /**
2288
+ * Next operation.
2289
+ * @type {Writer.Op|undefined}
2290
+ */
2291
+ this.next = undefined;
2798
2292
 
2799
- for (; i < end; ++i) {
2800
- c1 = buffer[i];
2801
- if (c1 & 0x80)
2802
- return str + utf8_read_decoder(strictDecoder, buffer, i, end);
2803
- str += String.fromCharCode(c1);
2804
- }
2293
+ /**
2294
+ * Value to write.
2295
+ * @type {*}
2296
+ */
2297
+ this.val = val; // type varies
2298
+ }
2805
2299
 
2806
- return str;
2807
- };
2300
+ /* istanbul ignore next */
2301
+ function noop() {} // eslint-disable-line no-empty-function
2808
2302
 
2809
2303
  /**
2810
- * Writes a string as UTF8 bytes.
2811
- * @param {string} string Source string
2812
- * @param {Uint8Array} buffer Destination buffer
2813
- * @param {number} offset Destination offset
2814
- * @returns {number} Bytes written
2815
- */
2816
- utf8.write = function utf8_write(string, buffer, offset) {
2817
- var start = offset,
2818
- c1, // character 1
2819
- c2; // character 2
2820
- for (var i = 0; i < string.length; ++i) {
2821
- c1 = string.charCodeAt(i);
2822
- if (c1 < 128) {
2823
- buffer[offset++] = c1;
2824
- } else if (c1 < 2048) {
2825
- buffer[offset++] = c1 >> 6 | 192;
2826
- buffer[offset++] = c1 & 63 | 128;
2827
- } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
2828
- c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
2829
- ++i;
2830
- buffer[offset++] = c1 >> 18 | 240;
2831
- buffer[offset++] = c1 >> 12 & 63 | 128;
2832
- buffer[offset++] = c1 >> 6 & 63 | 128;
2833
- buffer[offset++] = c1 & 63 | 128;
2834
- } else {
2835
- buffer[offset++] = c1 >> 12 | 224;
2836
- buffer[offset++] = c1 >> 6 & 63 | 128;
2837
- buffer[offset++] = c1 & 63 | 128;
2838
- }
2839
- }
2840
- return offset - start;
2841
- };
2304
+ * Constructs a new writer state instance.
2305
+ * @classdesc Copied writer state.
2306
+ * @memberof Writer
2307
+ * @constructor
2308
+ * @param {Writer} writer Writer to copy state from
2309
+ * @ignore
2310
+ */
2311
+ function State(writer) {
2842
2312
 
2843
- },{}],15:[function(require,module,exports){
2844
- "use strict";
2845
- module.exports = Writer;
2313
+ /**
2314
+ * Current head.
2315
+ * @type {Writer.Op}
2316
+ */
2317
+ this.head = writer.head;
2846
2318
 
2847
- var util = require(12);
2319
+ /**
2320
+ * Current tail.
2321
+ * @type {Writer.Op}
2322
+ */
2323
+ this.tail = writer.tail;
2848
2324
 
2849
- var BufferWriter; // cyclic
2325
+ /**
2326
+ * Current buffer length.
2327
+ * @type {number}
2328
+ */
2329
+ this.len = writer.len;
2850
2330
 
2851
- var LongBits = util.LongBits,
2852
- base64 = util.base64,
2853
- utf8 = util.utf8;
2331
+ /**
2332
+ * Next state.
2333
+ * @type {State|null}
2334
+ */
2335
+ this.next = writer.states;
2336
+ }
2854
2337
 
2855
2338
  /**
2856
2339
  * Constructs a new writer instance.
2857
- * @classdesc Wire format writer using `Uint8Array`.
2340
+ * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.
2858
2341
  * @constructor
2859
2342
  */
2860
2343
  function Writer() {
2861
2344
 
2862
2345
  /**
2863
- * Write cursor into {@link Writer#buf}.
2346
+ * Current length.
2864
2347
  * @type {number}
2865
2348
  */
2866
- this.pos = 0;
2349
+ this.len = 0;
2867
2350
 
2868
2351
  /**
2869
- * Backing buffer.
2870
- * @type {Uint8Array}
2352
+ * Operations head.
2353
+ * @type {Object}
2871
2354
  */
2872
- this.buf = this.constructor.alloc(Writer.initialBufferSize);
2355
+ this.head = new Op(noop, 0, 0);
2873
2356
 
2874
2357
  /**
2875
- * Cached DataView over {@link Writer#buf}.
2876
- * @type {DataView|null}
2358
+ * Operations tail
2359
+ * @type {Object}
2877
2360
  */
2878
- this.view = null;
2361
+ this.tail = this.head;
2879
2362
 
2880
2363
  /**
2881
- * Stack of forked length-prefix positions.
2882
- * @type {Array<number>|null}
2364
+ * Linked forked states.
2365
+ * @type {Object|null}
2883
2366
  */
2884
2367
  this.states = null;
2885
- }
2886
2368
 
2887
- /**
2888
- * Initial backing buffer size in bytes. Defaults to 128.
2889
- * @type {number}
2890
- */
2891
- Writer.initialBufferSize = 128;
2892
-
2893
- /**
2894
- * Current write position.
2895
- * @name Writer#len
2896
- * @type {number}
2897
- * @deprecated Use {@link Writer#pos} instead.
2898
- */
2899
- Object.defineProperty(Writer.prototype, "len", {
2900
- configurable: true,
2901
- enumerable: true,
2902
- get: function get_len() {
2903
- return this.pos;
2904
- }
2905
- });
2369
+ // When a value is written, the writer calculates its byte length and puts it into a linked
2370
+ // list of operations to perform when finish() is called. This both allows us to allocate
2371
+ // buffers of the exact required size and reduces the amount of work we have to do compared
2372
+ // to first calculating over objects and then encoding over objects. In our case, the encoding
2373
+ // part is just a linked list walk calling operations with already prepared values.
2374
+ }
2906
2375
 
2907
2376
  var create = function create() {
2908
2377
  return util.Buffer
@@ -2930,48 +2399,30 @@ Writer.create = create();
2930
2399
  * @returns {Uint8Array} Buffer
2931
2400
  */
2932
2401
  Writer.alloc = function alloc(size) {
2933
- return new Uint8Array(size);
2402
+ return new util.Array(size);
2934
2403
  };
2935
2404
 
2936
2405
  // Use Uint8Array buffer pool in the browser, just like node does with buffers
2937
- Writer.alloc = util.pool(Writer.alloc, Uint8Array.prototype.subarray);
2406
+ /* istanbul ignore else */
2407
+ if (util.Array !== Array)
2408
+ Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray);
2938
2409
 
2939
2410
  /**
2940
- * Calculates the number of bytes a value occupies as a varint.
2941
- * @param {number} value Value to size (unsigned)
2942
- * @returns {number} Byte length (1..5)
2943
- * @ignore
2944
- */
2945
- function sizeVarint32(value) {
2946
- return value < 128 ? 1
2947
- : value < 16384 ? 2
2948
- : value < 2097152 ? 3
2949
- : value < 268435456 ? 4
2950
- : 5;
2951
- }
2952
-
2953
- /**
2954
- * Ensures that at least `n` more bytes fit into the backing buffer, doubling it if not.
2955
- * @param {number} n Number of additional bytes required
2956
- * @returns {undefined}
2411
+ * Pushes a new operation to the queue.
2412
+ * @param {function(Uint8Array, number, *)} fn Function to call
2413
+ * @param {number} len Value byte length
2414
+ * @param {number} val Value to write
2415
+ * @returns {Writer} `this`
2957
2416
  * @private
2958
2417
  */
2959
- Writer.prototype._reserve = function _reserve(n) {
2960
- var need = this.pos + n;
2961
- if (need > this.buf.length) {
2962
- var size = this.buf.length << 1;
2963
- if (size < need)
2964
- size = need;
2965
- var buf = this.constructor.alloc(size);
2966
- buf.set(this.buf.subarray(0, this.pos), 0);
2967
- this.buf = buf;
2968
- this.view = null; // invalidate
2969
- }
2418
+ Writer.prototype._push = function push(fn, len, val) {
2419
+ this.tail = this.tail.next = new Op(fn, len, val);
2420
+ this.len += len;
2421
+ return this;
2970
2422
  };
2971
2423
 
2972
- function writeStringAscii(val, buf, pos) {
2973
- for (var i = 0; i < val.length;)
2974
- buf[pos++] = val.charCodeAt(i++);
2424
+ function writeByte(val, buf, pos) {
2425
+ buf[pos] = val & 255;
2975
2426
  }
2976
2427
 
2977
2428
  function writeVarint32(val, buf, pos) {
@@ -2980,19 +2431,42 @@ function writeVarint32(val, buf, pos) {
2980
2431
  val >>>= 7;
2981
2432
  }
2982
2433
  buf[pos] = val;
2983
- return pos + 1;
2984
2434
  }
2985
2435
 
2436
+ /**
2437
+ * Constructs a new varint writer operation instance.
2438
+ * @classdesc Scheduled varint writer operation.
2439
+ * @extends Op
2440
+ * @constructor
2441
+ * @param {number} len Value byte length
2442
+ * @param {number} val Value to write
2443
+ * @ignore
2444
+ */
2445
+ function VarintOp(len, val) {
2446
+ this.len = len;
2447
+ this.next = undefined;
2448
+ this.val = val;
2449
+ }
2450
+
2451
+ VarintOp.prototype = Object.create(Op.prototype);
2452
+ VarintOp.prototype.fn = writeVarint32;
2453
+
2986
2454
  /**
2987
2455
  * Writes an unsigned 32 bit value as a varint.
2988
2456
  * @param {number} value Value to write
2989
2457
  * @returns {Writer} `this`
2990
2458
  */
2991
2459
  Writer.prototype.uint32 = function write_uint32(value) {
2992
- value = value >>> 0;
2993
- this._reserve(5);
2994
- var pos = this.pos;
2995
- this.pos = writeVarint32(value, this.buf, pos);
2460
+ // here, the call to this.push has been inlined and a varint specific Op subclass is used.
2461
+ // uint32 is by far the most frequently used operation and benefits significantly from this.
2462
+ this.len += (this.tail = this.tail.next = new VarintOp(
2463
+ (value = value >>> 0)
2464
+ < 128 ? 1
2465
+ : value < 16384 ? 2
2466
+ : value < 2097152 ? 3
2467
+ : value < 268435456 ? 4
2468
+ : 5,
2469
+ value)).len;
2996
2470
  return this;
2997
2471
  };
2998
2472
 
@@ -3003,13 +2477,9 @@ Writer.prototype.uint32 = function write_uint32(value) {
3003
2477
  * @returns {Writer} `this`
3004
2478
  */
3005
2479
  Writer.prototype.int32 = function write_int32(value) {
3006
- if ((value |= 0) < 0) { // 10 bytes per spec
3007
- this._reserve(10);
3008
- writeVarint64(LongBits.fromNumber(value), this.buf, this.pos);
3009
- this.pos += 10;
3010
- return this;
3011
- }
3012
- return this.uint32(value);
2480
+ return (value |= 0) < 0
2481
+ ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
2482
+ : this.uint32(value);
3013
2483
  };
3014
2484
 
3015
2485
  /**
@@ -3033,8 +2503,7 @@ function writeVarint64(val, buf, pos) {
3033
2503
  buf[pos++] = lo & 127 | 128;
3034
2504
  lo = lo >>> 7;
3035
2505
  }
3036
- buf[pos] = lo;
3037
- return pos + 1;
2506
+ buf[pos++] = lo;
3038
2507
  }
3039
2508
 
3040
2509
  /**
@@ -3045,10 +2514,7 @@ function writeVarint64(val, buf, pos) {
3045
2514
  */
3046
2515
  Writer.prototype.uint64 = function write_uint64(value) {
3047
2516
  var bits = LongBits.from(value);
3048
- this._reserve(10);
3049
- var pos = this.pos;
3050
- this.pos = writeVarint64(bits, this.buf, pos);
3051
- return this;
2517
+ return this._push(writeVarint64, bits.length(), bits);
3052
2518
  };
3053
2519
 
3054
2520
  /**
@@ -3068,10 +2534,7 @@ Writer.prototype.int64 = Writer.prototype.uint64;
3068
2534
  */
3069
2535
  Writer.prototype.sint64 = function write_sint64(value) {
3070
2536
  var bits = LongBits.from(value).zzEncode();
3071
- this._reserve(10);
3072
- var pos = this.pos;
3073
- this.pos = writeVarint64(bits, this.buf, pos);
3074
- return this;
2537
+ return this._push(writeVarint64, bits.length(), bits);
3075
2538
  };
3076
2539
 
3077
2540
  /**
@@ -3080,9 +2543,7 @@ Writer.prototype.sint64 = function write_sint64(value) {
3080
2543
  * @returns {Writer} `this`
3081
2544
  */
3082
2545
  Writer.prototype.bool = function write_bool(value) {
3083
- this._reserve(1);
3084
- this.buf[this.pos++] = value ? 1 : 0;
3085
- return this;
2546
+ return this._push(writeByte, 1, value ? 1 : 0);
3086
2547
  };
3087
2548
 
3088
2549
  function writeFixed32(val, buf, pos) {
@@ -3098,10 +2559,7 @@ function writeFixed32(val, buf, pos) {
3098
2559
  * @returns {Writer} `this`
3099
2560
  */
3100
2561
  Writer.prototype.fixed32 = function write_fixed32(value) {
3101
- this._reserve(4);
3102
- writeFixed32(value >>> 0, this.buf, this.pos);
3103
- this.pos += 4;
3104
- return this;
2562
+ return this._push(writeFixed32, 4, value >>> 0);
3105
2563
  };
3106
2564
 
3107
2565
  /**
@@ -3120,11 +2578,7 @@ Writer.prototype.sfixed32 = Writer.prototype.fixed32;
3120
2578
  */
3121
2579
  Writer.prototype.fixed64 = function write_fixed64(value) {
3122
2580
  var bits = LongBits.from(value);
3123
- this._reserve(8);
3124
- writeFixed32(bits.lo, this.buf, this.pos);
3125
- writeFixed32(bits.hi, this.buf, this.pos + 4);
3126
- this.pos += 8;
3127
- return this;
2581
+ return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
3128
2582
  };
3129
2583
 
3130
2584
  /**
@@ -3143,10 +2597,7 @@ Writer.prototype.sfixed64 = Writer.prototype.fixed64;
3143
2597
  * @returns {Writer} `this`
3144
2598
  */
3145
2599
  Writer.prototype.float = function write_float(value) {
3146
- this._reserve(4);
3147
- util.float.writeFloatLE(value, this.buf, this.pos);
3148
- this.pos += 4;
3149
- return this;
2600
+ return this._push(util.float.writeFloatLE, 4, value);
3150
2601
  };
3151
2602
 
3152
2603
  /**
@@ -3156,12 +2607,19 @@ Writer.prototype.float = function write_float(value) {
3156
2607
  * @returns {Writer} `this`
3157
2608
  */
3158
2609
  Writer.prototype.double = function write_double(value) {
3159
- this._reserve(8);
3160
- util.float.writeDoubleLE(value, this.buf, this.pos);
3161
- this.pos += 8;
3162
- return this;
2610
+ return this._push(util.float.writeDoubleLE, 8, value);
3163
2611
  };
3164
2612
 
2613
+ var writeBytes = util.Array.prototype.set
2614
+ ? function writeBytes_set(val, buf, pos) {
2615
+ buf.set(val, pos); // also works for plain array values
2616
+ }
2617
+ /* istanbul ignore next */
2618
+ : function writeBytes_for(val, buf, pos) {
2619
+ for (var i = 0; i < val.length; ++i)
2620
+ buf[pos + i] = val[i];
2621
+ };
2622
+
3165
2623
  /**
3166
2624
  * Writes a sequence of bytes.
3167
2625
  * @param {Uint8Array|string} value Buffer or base64 encoded string to write
@@ -3169,52 +2627,14 @@ Writer.prototype.double = function write_double(value) {
3169
2627
  */
3170
2628
  Writer.prototype.bytes = function write_bytes(value) {
3171
2629
  var len = value.length >>> 0;
3172
- if (!len) {
3173
- this._reserve(1);
3174
- this.buf[this.pos++] = 0;
3175
- return this;
3176
- }
2630
+ if (!len)
2631
+ return this._push(writeByte, 1, 0);
3177
2632
  if (util.isString(value)) {
3178
2633
  var buf = Writer.alloc(len = base64.length(value));
3179
2634
  base64.decode(value, buf, 0);
3180
2635
  value = buf;
3181
2636
  }
3182
- this.uint32(len);
3183
- this._reserve(len);
3184
- this.buf.set(value, this.pos);
3185
- this.pos += len;
3186
- return this;
3187
- };
3188
-
3189
- /**
3190
- * Writes raw bytes without a tag or length prefix.
3191
- * @param {Uint8Array} value Raw bytes
3192
- * @returns {Writer} `this`
3193
- */
3194
- Writer.prototype.raw = function write_raw(value) {
3195
- var len = value.length >>> 0;
3196
- if (!len)
3197
- return this;
3198
- this._reserve(len);
3199
- this.buf.set(value, this.pos);
3200
- this.pos += len;
3201
- return this;
3202
- };
3203
-
3204
- /**
3205
- * Backfills the length varint.
3206
- * @param {number} pos Position of reserved length byte
3207
- * @param {number} len Length of content after length varint
3208
- * @returns {Writer} `this`
3209
- * @private
3210
- */
3211
- Writer.prototype._delim = function _delim(pos, len) {
3212
- var n = sizeVarint32(len);
3213
- if (n > 1)
3214
- this.buf.copyWithin(pos + n, pos + 1, pos + 1 + len);
3215
- writeVarint32(len, this.buf, pos);
3216
- this.pos = pos + n + len;
3217
- return this;
2637
+ return this.uint32(len)._push(writeBytes, len, value);
3218
2638
  };
3219
2639
 
3220
2640
  /**
@@ -3223,245 +2643,21 @@ Writer.prototype._delim = function _delim(pos, len) {
3223
2643
  * @returns {Writer} `this`
3224
2644
  */
3225
2645
  Writer.prototype.string = function write_string(value) {
3226
- var n = value.length;
3227
- if (!n) {
3228
- this._reserve(1);
3229
- this.buf[this.pos++] = 0;
3230
- return this;
3231
- }
3232
- if (n < 0x80) {
3233
- this._reserve(n * 3 + 5); // worst case
3234
- var lenPos = this.pos;
3235
- return this._delim(lenPos, utf8.write(value, this.buf, lenPos + 1));
3236
- }
3237
2646
  var len = utf8.length(value);
3238
- this.uint32(len);
3239
- this._reserve(len);
3240
- if (len === value.length)
3241
- writeStringAscii(value, this.buf, this.pos);
3242
- else
3243
- utf8.write(value, this.buf, this.pos);
3244
- this.pos += len;
3245
- return this;
3246
- };
3247
-
3248
- /**
3249
- * Writes an array of unsigned 32 bit values as a packed repeated field.
3250
- * @param {number[]} value Values to write
3251
- * @returns {Writer} `this`
3252
- */
3253
- Writer.prototype.uint32s = function write_uint32s(value) {
3254
- var n = value.length;
3255
- this._reserve(n * 5 + 5); // worst case: 5 bytes per value + length varint
3256
- var buf = this.buf, lenPos = this.pos, p = lenPos + 1;
3257
- for (var i = 0; i < n; ++i)
3258
- p = writeVarint32(value[i] >>> 0, buf, p);
3259
- return this._delim(lenPos, p - lenPos - 1);
3260
- };
3261
-
3262
- /**
3263
- * Writes an array of signed 32 bit values as a packed repeated field.
3264
- * @param {number[]} value Values to write
3265
- * @returns {Writer} `this`
3266
- */
3267
- Writer.prototype.int32s = function write_int32s(value) {
3268
- var n = value.length;
3269
- this._reserve(n * 10 + 5); // worst case: 10 bytes per negative value + length varint
3270
- var buf = this.buf, lenPos = this.pos, pos = lenPos + 1, val;
3271
- for (var i = 0; i < n; ++i) {
3272
- if ((val = value[i] | 0) < 0) { // negatives are 10 bytes per spec
3273
- pos = writeVarint64(LongBits.fromNumber(val), buf, pos);
3274
- } else {
3275
- pos = writeVarint32(val, buf, pos);
3276
- }
3277
- }
3278
- return this._delim(lenPos, pos - lenPos - 1);
3279
- };
3280
-
3281
- /**
3282
- * Writes an array of 32 bit values as packed, zig-zag encoded varints.
3283
- * @param {number[]} value Values to write
3284
- * @returns {Writer} `this`
3285
- */
3286
- Writer.prototype.sint32s = function write_sint32s(value) {
3287
- var n = value.length;
3288
- this._reserve(n * 5 + 5);
3289
- var buf = this.buf, lenPos = this.pos, pos = lenPos + 1;
3290
- for (var i = 0; i < n; ++i)
3291
- pos = writeVarint32((value[i] << 1 ^ value[i] >> 31) >>> 0, buf, pos);
3292
- return this._delim(lenPos, pos - lenPos - 1);
3293
- };
3294
-
3295
- /**
3296
- * Writes an array of unsigned 64 bit values as a packed repeated field.
3297
- * @param {Array.<Long|number|string>} value Values to write
3298
- * @returns {Writer} `this`
3299
- */
3300
- Writer.prototype.uint64s = function write_uint64s(value) {
3301
- var n = value.length;
3302
- this._reserve(n * 10 + 5);
3303
- var buf = this.buf, lenPos = this.pos, pos = lenPos + 1;
3304
- for (var i = 0; i < n; ++i) {
3305
- pos = writeVarint64(LongBits.from(value[i]), buf, pos);
3306
- }
3307
- return this._delim(lenPos, pos - lenPos - 1);
3308
- };
3309
-
3310
- /**
3311
- * Writes an array of signed 64 bit values as a packed repeated field.
3312
- * @function
3313
- * @param {Array.<Long|number|string>} value Values to write
3314
- * @returns {Writer} `this`
3315
- */
3316
- Writer.prototype.int64s = Writer.prototype.uint64s;
3317
-
3318
- /**
3319
- * Writes an array of 64 bit values as packed, zig-zag encoded varints.
3320
- * @param {Array.<Long|number|string>} value Values to write
3321
- * @returns {Writer} `this`
3322
- */
3323
- Writer.prototype.sint64s = function write_sint64s(value) {
3324
- var n = value.length;
3325
- this._reserve(n * 10 + 5);
3326
- var buf = this.buf, lenPos = this.pos, pos = lenPos + 1;
3327
- for (var i = 0; i < n; ++i) {
3328
- pos = writeVarint64(LongBits.from(value[i]).zzEncode(), buf, pos);
3329
- }
3330
- return this._delim(lenPos, pos - lenPos - 1);
3331
- };
3332
-
3333
- /**
3334
- * Writes an array of boolish values as a packed repeated field.
3335
- * @param {boolean[]} value Values to write
3336
- * @returns {Writer} `this`
3337
- */
3338
- Writer.prototype.bools = function write_bools(value) {
3339
- var n = value.length;
3340
- this.uint32(n); // one byte per value
3341
- this._reserve(n);
3342
- var buf = this.buf, p = this.pos;
3343
- for (var i = 0; i < n; ++i)
3344
- buf[p++] = value[i] ? 1 : 0;
3345
- this.pos += n;
3346
- return this;
3347
- };
3348
-
3349
- // The view allocation only pays off when amortized over enough writes
3350
- var VIEW_THRESHOLD_FLOAT = 16,
3351
- VIEW_THRESHOLD_INT = 128;
3352
-
3353
- function getLazyView(writer, count, threshold) {
3354
- var view = writer.view;
3355
- if (view || count < threshold)
3356
- return view;
3357
- var buf = writer.buf;
3358
- return writer.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
3359
- }
3360
-
3361
- /**
3362
- * Writes an array of unsigned 32 bit values as packed, fixed 32 bits.
3363
- * @param {number[]} value Values to write
3364
- * @returns {Writer} `this`
3365
- */
3366
- Writer.prototype.fixed32s = function write_fixed32s(value) {
3367
- var n = value.length, bytes = n * 4;
3368
- this.uint32(bytes); // length is known exactly
3369
- this._reserve(bytes);
3370
- var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_INT);
3371
- if (dv)
3372
- for (i = 0; i < n; ++i) { dv.setUint32(p, value[i] >>> 0, true); p += 4; }
3373
- else {
3374
- var buf = this.buf;
3375
- for (i = 0; i < n; ++i) { writeFixed32(value[i] >>> 0, buf, p); p += 4; }
3376
- }
3377
- this.pos += bytes;
3378
- return this;
3379
- };
3380
-
3381
- /**
3382
- * Writes an array of signed 32 bit values as packed, fixed 32 bits.
3383
- * @function
3384
- * @param {number[]} value Values to write
3385
- * @returns {Writer} `this`
3386
- */
3387
- Writer.prototype.sfixed32s = Writer.prototype.fixed32s;
3388
-
3389
- /**
3390
- * Writes an array of unsigned 64 bit values as packed, fixed 64 bits.
3391
- * @param {Array.<Long|number|string>} value Values to write
3392
- * @returns {Writer} `this`
3393
- */
3394
- Writer.prototype.fixed64s = function write_fixed64s(value) {
3395
- var n = value.length, bytes = n * 8;
3396
- this.uint32(bytes);
3397
- this._reserve(bytes);
3398
- var p = this.pos, i, bits, dv = getLazyView(this, n, VIEW_THRESHOLD_INT);
3399
- if (dv)
3400
- for (i = 0; i < n; ++i) { bits = LongBits.from(value[i]); dv.setUint32(p, bits.lo, true); dv.setUint32(p + 4, bits.hi, true); p += 8; }
3401
- else {
3402
- var buf = this.buf;
3403
- for (i = 0; i < n; ++i) { bits = LongBits.from(value[i]); writeFixed32(bits.lo, buf, p); writeFixed32(bits.hi, buf, p + 4); p += 8; }
3404
- }
3405
- this.pos += bytes;
3406
- return this;
3407
- };
3408
-
3409
- /**
3410
- * Writes an array of signed 64 bit values as packed, fixed 64 bits.
3411
- * @function
3412
- * @param {Array.<Long|number|string>} value Values to write
3413
- * @returns {Writer} `this`
3414
- */
3415
- Writer.prototype.sfixed64s = Writer.prototype.fixed64s;
3416
-
3417
- /**
3418
- * Writes an array of floats (32 bit) as a packed repeated field.
3419
- * @param {number[]} value Values to write
3420
- * @returns {Writer} `this`
3421
- */
3422
- Writer.prototype.floats = function write_floats(value) {
3423
- var n = value.length, bytes = n * 4;
3424
- this.uint32(bytes);
3425
- this._reserve(bytes);
3426
- var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_FLOAT);
3427
- if (dv)
3428
- for (i = 0; i < n; ++i) { dv.setFloat32(p, value[i], true); p += 4; }
3429
- else {
3430
- var buf = this.buf;
3431
- for (i = 0; i < n; ++i) { util.float.writeFloatLE(value[i], buf, p); p += 4; }
3432
- }
3433
- this.pos += bytes;
3434
- return this;
3435
- };
3436
-
3437
- /**
3438
- * Writes an array of doubles (64 bit float) as a packed repeated field.
3439
- * @param {number[]} value Values to write
3440
- * @returns {Writer} `this`
3441
- */
3442
- Writer.prototype.doubles = function write_doubles(value) {
3443
- var n = value.length, bytes = n * 8;
3444
- this.uint32(bytes);
3445
- this._reserve(bytes);
3446
- var p = this.pos, i, dv = getLazyView(this, n, VIEW_THRESHOLD_FLOAT);
3447
- if (dv)
3448
- for (i = 0; i < n; ++i) { dv.setFloat64(p, value[i], true); p += 8; }
3449
- else {
3450
- var buf = this.buf;
3451
- for (i = 0; i < n; ++i) { util.float.writeDoubleLE(value[i], buf, p); p += 8; }
3452
- }
3453
- this.pos += bytes;
3454
- return this;
2647
+ return len
2648
+ ? this.uint32(len)._push(utf8.write, len, value)
2649
+ : this._push(writeByte, 1, 0);
3455
2650
  };
3456
2651
 
3457
2652
  /**
3458
2653
  * Forks this writer's state by pushing it to a stack.
2654
+ * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
3459
2655
  * @returns {Writer} `this`
3460
2656
  */
3461
2657
  Writer.prototype.fork = function fork() {
3462
- this._reserve(1);
3463
- (this.states || (this.states = [])).push(this.pos);
3464
- this.pos += 1;
2658
+ this.states = new State(this);
2659
+ this.head = this.tail = new Op(noop, 0, 0);
2660
+ this.len = 0;
3465
2661
  return this;
3466
2662
  };
3467
2663
 
@@ -3470,75 +2666,49 @@ Writer.prototype.fork = function fork() {
3470
2666
  * @returns {Writer} `this`
3471
2667
  */
3472
2668
  Writer.prototype.reset = function reset() {
3473
- var states = this.states;
3474
- if (states && states.length) {
3475
- this.pos = states.pop();
2669
+ if (this.states) {
2670
+ this.head = this.states.head;
2671
+ this.tail = this.states.tail;
2672
+ this.len = this.states.len;
2673
+ this.states = this.states.next;
3476
2674
  } else {
3477
- this.pos = 0;
2675
+ this.head = this.tail = new Op(noop, 0, 0);
2676
+ this.len = 0;
3478
2677
  }
3479
2678
  return this;
3480
2679
  };
3481
2680
 
3482
2681
  /**
3483
- * Resets to the last state and prepends the fork state's current write length as a varint.
2682
+ * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
3484
2683
  * @returns {Writer} `this`
3485
2684
  */
3486
2685
  Writer.prototype.ldelim = function ldelim() {
3487
- var states = this.states,
3488
- len,
3489
- vlen;
3490
- if (states && states.length) {
3491
- var lenPos = states.pop();
3492
- len = this.pos - lenPos - 1;
3493
- vlen = sizeVarint32(len);
3494
- if (vlen > 1) { // grow the reserved single byte and shift content forward
3495
- this._reserve(vlen - 1);
3496
- this.buf.copyWithin(lenPos + vlen, lenPos + 1, lenPos + 1 + len);
3497
- this.pos += vlen - 1;
3498
- writeVarint32(len, this.buf, lenPos);
3499
- } else {
3500
- this.buf[lenPos] = len;
3501
- }
3502
- } else { // not forked: prefix the entire buffer with its length
3503
- // TODO: Compatibility with older generated code.
3504
- // Remove this branch in the next major release.
3505
- len = this.pos;
3506
- vlen = sizeVarint32(len);
3507
- this._reserve(vlen);
3508
- this.buf.copyWithin(vlen, 0, len);
3509
- writeVarint32(len, this.buf, 0);
3510
- this.pos += vlen;
2686
+ var head = this.head,
2687
+ tail = this.tail,
2688
+ len = this.len;
2689
+ this.reset().uint32(len);
2690
+ if (len) {
2691
+ this.tail.next = head.next; // skip noop
2692
+ this.tail = tail;
2693
+ this.len += len;
3511
2694
  }
3512
2695
  return this;
3513
2696
  };
3514
2697
 
3515
2698
  /**
3516
2699
  * Finishes the write operation.
3517
- * Returns a buffer sized to the written data by default.
3518
- * @param {boolean} [shared=false] Whether to return a shared view instead of a unique copy
3519
2700
  * @returns {Uint8Array} Finished buffer
3520
2701
  */
3521
- Writer.prototype.finish = function finish(shared) {
3522
- if (shared)
3523
- return this.buf.subarray(0, this.pos);
3524
- var buf = this.constructor.alloc(this.pos);
3525
- buf.set(this.buf.subarray(0, this.pos), 0);
3526
- return buf;
3527
- };
3528
-
3529
- /**
3530
- * Finishes the write operation, writing into the provided buffer.
3531
- * The caller must ensure that `buf` has enough space starting at `offset`
3532
- * to hold {@link Writer#pos} bytes.
3533
- * @param {T} buf Target buffer
3534
- * @param {number} [offset=0] Offset to start writing at
3535
- * @returns {T} The provided buffer
3536
- * @template T extends Uint8Array
3537
- */
3538
- Writer.prototype.finishInto = function finishInto(buf, offset) {
3539
- if (offset === undefined)
3540
- offset = 0;
3541
- buf.set(this.buf.subarray(0, this.pos), offset);
2702
+ Writer.prototype.finish = function finish() {
2703
+ var head = this.head.next, // skip noop
2704
+ buf = this.constructor.alloc(this.len),
2705
+ pos = 0;
2706
+ while (head) {
2707
+ head.fn(head.val, buf, pos);
2708
+ pos += head.len;
2709
+ head = head.next;
2710
+ }
2711
+ // this.head = this.tail = null;
3542
2712
  return buf;
3543
2713
  };
3544
2714
 
@@ -3548,22 +2718,15 @@ Writer._configure = function(BufferWriter_) {
3548
2718
  BufferWriter._configure();
3549
2719
  };
3550
2720
 
3551
- },{"12":12}],16:[function(require,module,exports){
2721
+ },{"14":14}],16:[function(require,module,exports){
3552
2722
  "use strict";
3553
2723
  module.exports = BufferWriter;
3554
2724
 
3555
2725
  // extends Writer
3556
2726
  var Writer = require(15);
3557
- BufferWriter.prototype = Object.create(Writer.prototype, {
3558
- constructor: {
3559
- value: BufferWriter,
3560
- writable: true,
3561
- enumerable: false,
3562
- configurable: true
3563
- }
3564
- });
2727
+ (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
3565
2728
 
3566
- var util = require(12);
2729
+ var util = require(14);
3567
2730
 
3568
2731
  /**
3569
2732
  * Constructs a new buffer writer instance.
@@ -3575,8 +2738,6 @@ function BufferWriter() {
3575
2738
  Writer.call(this);
3576
2739
  }
3577
2740
 
3578
- var writeStringBuffer;
3579
-
3580
2741
  BufferWriter._configure = function () {
3581
2742
  /**
3582
2743
  * Allocates a buffer of the specified size.
@@ -3584,14 +2745,19 @@ BufferWriter._configure = function () {
3584
2745
  * @param {number} size Buffer size
3585
2746
  * @returns {Buffer} Buffer
3586
2747
  */
3587
- BufferWriter.alloc = util.Buffer && util.Buffer.allocUnsafe;
2748
+ BufferWriter.alloc = util._Buffer_allocUnsafe;
3588
2749
 
3589
- writeStringBuffer = util.Buffer && util.Buffer.prototype.utf8Write
3590
- ? function writeStringBuffer_utf8Write(val, buf, pos) {
3591
- return buf.utf8Write(val, pos);
2750
+ BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set"
2751
+ ? function writeBytesBuffer_set(val, buf, pos) {
2752
+ buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
2753
+ // also works for plain array values
3592
2754
  }
3593
- : function writeStringBuffer_write(val, buf, pos) {
3594
- return buf.write(val, pos);
2755
+ /* istanbul ignore next */
2756
+ : function writeBytesBuffer_copy(val, buf, pos) {
2757
+ if (val.copy) // Buffer values
2758
+ val.copy(buf, pos, 0, val.length);
2759
+ else for (var i = 0; i < val.length;) // plain array values
2760
+ buf[pos++] = val[i++];
3595
2761
  };
3596
2762
  };
3597
2763
 
@@ -3601,42 +2767,31 @@ BufferWriter._configure = function () {
3601
2767
  */
3602
2768
  BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
3603
2769
  if (util.isString(value))
3604
- value = util.Buffer.from(value, "base64");
2770
+ value = util._Buffer_from(value, "base64");
3605
2771
  var len = value.length >>> 0;
3606
2772
  this.uint32(len);
3607
- if (len) {
3608
- this._reserve(len);
3609
- this.buf.set(value, this.pos);
3610
- this.pos += len;
3611
- }
2773
+ if (len)
2774
+ this._push(BufferWriter.writeBytesBuffer, len, value);
3612
2775
  return this;
3613
2776
  };
3614
2777
 
2778
+ function writeStringBuffer(val, buf, pos) {
2779
+ if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
2780
+ util.utf8.write(val, buf, pos);
2781
+ else if (buf.utf8Write)
2782
+ buf.utf8Write(val, pos);
2783
+ else
2784
+ buf.write(val, pos);
2785
+ }
2786
+
3615
2787
  /**
3616
2788
  * @override
3617
2789
  */
3618
2790
  BufferWriter.prototype.string = function write_string_buffer(value) {
3619
- var n = value.length;
3620
- if (!n) {
3621
- this._reserve(1);
3622
- this.buf[this.pos++] = 0;
3623
- return this;
3624
- }
3625
- if (n < 0x80) {
3626
- this._reserve(n * 3 + 5); // worst case
3627
- var pos = this.pos,
3628
- buf = this.buf;
3629
- return this._delim(pos,
3630
- n < 40
3631
- ? util.utf8.write(value, buf, pos + 1)
3632
- : writeStringBuffer(value, buf, pos + 1)
3633
- );
3634
- }
3635
2791
  var len = util.Buffer.byteLength(value);
3636
2792
  this.uint32(len);
3637
- this._reserve(len);
3638
- writeStringBuffer(value, this.buf, this.pos);
3639
- this.pos += len;
2793
+ if (len)
2794
+ this._push(writeStringBuffer, len, value);
3640
2795
  return this;
3641
2796
  };
3642
2797
 
@@ -3650,7 +2805,7 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
3650
2805
 
3651
2806
  BufferWriter._configure();
3652
2807
 
3653
- },{"12":12,"15":15}]},{},[1])
2808
+ },{"14":14,"15":15}]},{},[7])
3654
2809
 
3655
2810
  })();
3656
2811
  //# sourceMappingURL=protobuf.js.map