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