node-red-contrib-tak-registration 0.11.6 → 0.12.0
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/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/node/assert.d.ts +88 -44
- package/node_modules/@types/node/async_hooks.d.ts +17 -15
- package/node_modules/@types/node/buffer.d.ts +29 -29
- package/node_modules/@types/node/child_process.d.ts +38 -34
- package/node_modules/@types/node/cluster.d.ts +165 -19
- package/node_modules/@types/node/console.d.ts +64 -27
- package/node_modules/@types/node/crypto.d.ts +101 -65
- package/node_modules/@types/node/dgram.d.ts +14 -14
- package/node_modules/@types/node/diagnostics_channel.d.ts +12 -3
- package/node_modules/@types/node/dns/promises.d.ts +79 -28
- package/node_modules/@types/node/dns.d.ts +124 -69
- package/node_modules/@types/node/dom-events.d.ts +2 -0
- package/node_modules/@types/node/domain.d.ts +4 -4
- package/node_modules/@types/node/events.d.ts +115 -63
- package/node_modules/@types/node/fs/promises.d.ts +18 -12
- package/node_modules/@types/node/fs.d.ts +45 -39
- package/node_modules/@types/node/globals.d.ts +1 -0
- package/node_modules/@types/node/http.d.ts +69 -48
- package/node_modules/@types/node/http2.d.ts +83 -47
- package/node_modules/@types/node/https.d.ts +3 -3
- package/node_modules/@types/node/index.d.ts +1 -0
- package/node_modules/@types/node/inspector.d.ts +5 -6
- package/node_modules/@types/node/net.d.ts +58 -13
- package/node_modules/@types/node/os.d.ts +29 -12
- package/node_modules/@types/node/package.json +3 -15
- package/node_modules/@types/node/path.d.ts +1 -1
- package/node_modules/@types/node/perf_hooks.d.ts +308 -48
- package/node_modules/@types/node/process.d.ts +241 -48
- package/node_modules/@types/node/punycode.d.ts +4 -4
- package/node_modules/@types/node/querystring.d.ts +18 -6
- package/node_modules/@types/node/readline/promises.d.ts +9 -9
- package/node_modules/@types/node/readline.d.ts +21 -20
- package/node_modules/@types/node/repl.d.ts +10 -10
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/stream/web.d.ts +3 -2
- package/node_modules/@types/node/stream.d.ts +62 -56
- package/node_modules/@types/node/string_decoder.d.ts +3 -3
- package/node_modules/@types/node/test.d.ts +350 -97
- package/node_modules/@types/node/timers/promises.d.ts +10 -6
- package/node_modules/@types/node/timers.d.ts +5 -5
- package/node_modules/@types/node/tls.d.ts +39 -32
- package/node_modules/@types/node/trace_events.d.ts +40 -25
- package/node_modules/@types/node/tty.d.ts +8 -8
- package/node_modules/@types/node/url.d.ts +15 -7
- package/node_modules/@types/node/util.d.ts +131 -22
- package/node_modules/@types/node/v8.d.ts +50 -6
- package/node_modules/@types/node/vm.d.ts +43 -22
- package/node_modules/@types/node/wasi.d.ts +12 -10
- package/node_modules/@types/node/worker_threads.d.ts +19 -16
- package/node_modules/@types/node/zlib.d.ts +16 -3
- package/node_modules/adm-zip/README.md +2 -1
- package/node_modules/adm-zip/adm-zip.js +46 -45
- package/node_modules/adm-zip/headers/entryHeader.js +14 -12
- package/node_modules/adm-zip/headers/mainHeader.js +1 -1
- package/node_modules/adm-zip/methods/inflater.js +6 -3
- package/node_modules/adm-zip/methods/zipcrypto.js +6 -2
- package/node_modules/adm-zip/package.json +2 -2
- package/node_modules/adm-zip/util/errors.js +1 -0
- package/node_modules/adm-zip/zipEntry.js +64 -43
- package/node_modules/adm-zip/zipFile.js +35 -35
- package/node_modules/axios/CHANGELOG.md +868 -759
- package/node_modules/axios/README.md +65 -17
- package/node_modules/axios/dist/axios.js +1330 -583
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +1 -1
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +696 -316
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +696 -316
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +1 -1
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +607 -257
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +5 -2
- package/node_modules/axios/index.d.ts +5 -2
- package/node_modules/axios/lib/adapters/adapters.js +3 -1
- package/node_modules/axios/lib/adapters/fetch.js +227 -0
- package/node_modules/axios/lib/adapters/http.js +1 -1
- package/node_modules/axios/lib/adapters/xhr.js +31 -101
- package/node_modules/axios/lib/core/Axios.js +17 -11
- package/node_modules/axios/lib/core/AxiosHeaders.js +4 -0
- package/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/axios/lib/defaults/index.js +7 -5
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +9 -8
- package/node_modules/axios/lib/helpers/composeSignals.js +46 -0
- package/node_modules/axios/lib/helpers/progressEventReducer.js +32 -0
- package/node_modules/axios/lib/helpers/resolveConfig.js +57 -0
- package/node_modules/axios/lib/helpers/throttle.js +5 -3
- package/node_modules/axios/lib/helpers/trackStream.js +55 -0
- package/node_modules/axios/lib/platform/common/utils.js +4 -1
- package/node_modules/axios/lib/utils.js +7 -2
- package/node_modules/axios/package.json +27 -26
- package/node_modules/fast-xml-parser/CHANGELOG.md +14 -0
- package/node_modules/fast-xml-parser/README.md +7 -14
- package/node_modules/fast-xml-parser/package.json +1 -1
- package/node_modules/fast-xml-parser/src/fxp.d.ts +4 -4
- package/node_modules/fast-xml-parser/src/v5/CharsSymbol.js +16 -0
- package/node_modules/fast-xml-parser/src/v5/EntitiesParser.js +107 -0
- package/node_modules/fast-xml-parser/src/v5/OptionsBuilder.js +64 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/BaseOutputBuilder.js +71 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsArrBuilder.js +103 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsMinArrBuilder.js +102 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsObjBuilder.js +156 -0
- package/node_modules/fast-xml-parser/src/v5/OutputBuilders/ParserOptionsBuilder.js +96 -0
- package/node_modules/fast-xml-parser/src/v5/Report.js +0 -0
- package/node_modules/fast-xml-parser/src/v5/TagPath.js +81 -0
- package/node_modules/fast-xml-parser/src/v5/TagPathMatcher.js +15 -0
- package/node_modules/fast-xml-parser/src/v5/XMLParser.js +85 -0
- package/node_modules/fast-xml-parser/src/v5/Xml2JsParser.js +237 -0
- package/node_modules/fast-xml-parser/src/v5/XmlPartReader.js +212 -0
- package/node_modules/fast-xml-parser/src/v5/XmlSpecialTagsReader.js +118 -0
- package/node_modules/fast-xml-parser/src/v5/inputSource/BufferSource.js +118 -0
- package/node_modules/fast-xml-parser/src/v5/inputSource/StringSource.js +123 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/EntitiesParser.js +107 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParser.js +23 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParserExt.js +20 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/currency.js +31 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/join.js +14 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/number.js +16 -0
- package/node_modules/fast-xml-parser/src/v5/valueParsers/trim.js +8 -0
- package/node_modules/fast-xml-parser/src/validator.js +2 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +13 -4
- package/node_modules/follow-redirects/index.js +1 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/hasown/CHANGELOG.md +12 -0
- package/node_modules/hasown/index.d.ts +2 -2
- package/node_modules/hasown/package.json +5 -2
- package/node_modules/hasown/tsconfig.json +3 -46
- package/node_modules/object-is/.eslintrc +1 -1
- package/node_modules/object-is/.nycrc +0 -4
- package/node_modules/object-is/CHANGELOG.md +25 -0
- package/node_modules/object-is/README.md +20 -20
- package/node_modules/object-is/package.json +23 -14
- package/node_modules/protobufjs/LICENSE +39 -39
- package/node_modules/protobufjs/README.md +727 -740
- package/node_modules/protobufjs/dist/light/protobuf.js +6264 -6264
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +1928 -1928
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +7978 -7961
- 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/debug/README.md +4 -4
- package/node_modules/protobufjs/ext/debug/index.js +71 -71
- package/node_modules/protobufjs/ext/descriptor/README.md +72 -72
- package/node_modules/protobufjs/ext/descriptor/index.d.ts +191 -191
- package/node_modules/protobufjs/ext/descriptor/index.js +1052 -1052
- package/node_modules/protobufjs/ext/descriptor/test.js +54 -54
- package/node_modules/protobufjs/google/LICENSE +27 -27
- package/node_modules/protobufjs/google/README.md +1 -1
- package/node_modules/protobufjs/google/api/annotations.json +82 -82
- package/node_modules/protobufjs/google/api/annotations.proto +10 -10
- package/node_modules/protobufjs/google/api/http.json +85 -85
- package/node_modules/protobufjs/google/api/http.proto +30 -30
- package/node_modules/protobufjs/google/protobuf/api.json +117 -117
- package/node_modules/protobufjs/google/protobuf/api.proto +33 -33
- package/node_modules/protobufjs/google/protobuf/descriptor.json +738 -738
- package/node_modules/protobufjs/google/protobuf/descriptor.proto +286 -286
- package/node_modules/protobufjs/google/protobuf/source_context.json +19 -19
- package/node_modules/protobufjs/google/protobuf/source_context.proto +7 -7
- package/node_modules/protobufjs/google/protobuf/type.json +201 -201
- package/node_modules/protobufjs/google/protobuf/type.proto +89 -89
- package/node_modules/protobufjs/index.d.ts +2741 -2741
- package/node_modules/protobufjs/index.js +4 -4
- package/node_modules/protobufjs/light.d.ts +2 -2
- package/node_modules/protobufjs/light.js +3 -3
- package/node_modules/protobufjs/minimal.d.ts +2 -2
- package/node_modules/protobufjs/minimal.js +4 -4
- package/node_modules/protobufjs/package.json +111 -111
- package/node_modules/protobufjs/scripts/postinstall.js +32 -32
- package/node_modules/protobufjs/src/common.js +399 -399
- package/node_modules/protobufjs/src/converter.js +301 -301
- package/node_modules/protobufjs/src/decoder.js +129 -129
- package/node_modules/protobufjs/src/encoder.js +100 -100
- package/node_modules/protobufjs/src/enum.js +198 -198
- package/node_modules/protobufjs/src/field.js +377 -377
- package/node_modules/protobufjs/src/index-light.js +104 -104
- package/node_modules/protobufjs/src/index-minimal.js +36 -36
- package/node_modules/protobufjs/src/index.js +12 -12
- package/node_modules/protobufjs/src/mapfield.js +126 -126
- package/node_modules/protobufjs/src/message.js +138 -138
- package/node_modules/protobufjs/src/method.js +160 -160
- package/node_modules/protobufjs/src/namespace.js +433 -433
- package/node_modules/protobufjs/src/object.js +243 -243
- package/node_modules/protobufjs/src/oneof.js +203 -203
- package/node_modules/protobufjs/src/parse.js +889 -872
- package/node_modules/protobufjs/src/reader.js +416 -416
- package/node_modules/protobufjs/src/reader_buffer.js +51 -51
- package/node_modules/protobufjs/src/root.js +368 -368
- package/node_modules/protobufjs/src/roots.js +18 -18
- package/node_modules/protobufjs/src/rpc/service.js +142 -142
- package/node_modules/protobufjs/src/rpc.js +36 -36
- package/node_modules/protobufjs/src/service.js +167 -167
- package/node_modules/protobufjs/src/tokenize.js +416 -416
- package/node_modules/protobufjs/src/type.js +589 -589
- package/node_modules/protobufjs/src/types.js +196 -196
- package/node_modules/protobufjs/src/typescript.jsdoc +15 -15
- package/node_modules/protobufjs/src/util/longbits.js +200 -200
- package/node_modules/protobufjs/src/util/minimal.js +438 -438
- package/node_modules/protobufjs/src/util.js +212 -212
- package/node_modules/protobufjs/src/verifier.js +176 -176
- package/node_modules/protobufjs/src/wrappers.js +102 -102
- package/node_modules/protobufjs/src/writer.js +465 -465
- package/node_modules/protobufjs/src/writer_buffer.js +85 -85
- package/node_modules/protobufjs/tsconfig.json +7 -7
- package/node_modules/set-function-length/CHANGELOG.md +11 -0
- package/node_modules/set-function-length/env.d.ts +9 -6
- package/node_modules/set-function-length/env.js +1 -0
- package/node_modules/set-function-length/index.d.ts +6 -6
- package/node_modules/set-function-length/index.js +1 -3
- package/node_modules/set-function-length/package.json +11 -13
- package/node_modules/set-function-length/tsconfig.json +7 -57
- package/node_modules/uuid/CHANGELOG.md +18 -0
- package/node_modules/uuid/README.md +134 -16
- package/node_modules/uuid/dist/commonjs-browser/index.js +40 -15
- package/node_modules/uuid/dist/commonjs-browser/max.js +7 -0
- package/node_modules/uuid/dist/commonjs-browser/md5.js +30 -53
- package/node_modules/uuid/dist/commonjs-browser/native.js +3 -4
- package/node_modules/uuid/dist/commonjs-browser/nil.js +1 -2
- package/node_modules/uuid/dist/commonjs-browser/parse.js +14 -15
- package/node_modules/uuid/dist/commonjs-browser/regex.js +1 -2
- package/node_modules/uuid/dist/commonjs-browser/rng.js +2 -4
- package/node_modules/uuid/dist/commonjs-browser/sha1.js +27 -49
- package/node_modules/uuid/dist/commonjs-browser/stringify.js +10 -16
- package/node_modules/uuid/dist/commonjs-browser/v1.js +73 -49
- package/node_modules/uuid/dist/commonjs-browser/v1ToV6.js +26 -0
- package/node_modules/uuid/dist/commonjs-browser/v3.js +3 -8
- package/node_modules/uuid/dist/commonjs-browser/v35.js +15 -32
- package/node_modules/uuid/dist/commonjs-browser/v4.js +7 -18
- package/node_modules/uuid/dist/commonjs-browser/v5.js +3 -8
- package/node_modules/uuid/dist/commonjs-browser/v6.js +42 -0
- package/node_modules/uuid/dist/commonjs-browser/v6ToV1.js +26 -0
- package/node_modules/uuid/dist/commonjs-browser/v7.js +152 -0
- package/node_modules/uuid/dist/commonjs-browser/validate.js +2 -7
- package/node_modules/uuid/dist/commonjs-browser/version.js +2 -8
- package/node_modules/uuid/dist/esm-browser/index.js +9 -4
- package/node_modules/uuid/dist/esm-browser/max.js +1 -0
- package/node_modules/uuid/dist/esm-browser/md5.js +29 -50
- package/node_modules/uuid/dist/esm-browser/native.js +1 -1
- package/node_modules/uuid/dist/esm-browser/parse.js +12 -10
- package/node_modules/uuid/dist/esm-browser/regex.js +1 -1
- package/node_modules/uuid/dist/esm-browser/rng.js +3 -4
- package/node_modules/uuid/dist/esm-browser/sha1.js +26 -46
- package/node_modules/uuid/dist/esm-browser/stringify.js +9 -11
- package/node_modules/uuid/dist/esm-browser/v1.js +74 -44
- package/node_modules/uuid/dist/esm-browser/v1ToV6.js +20 -0
- package/node_modules/uuid/dist/esm-browser/v3.js +1 -1
- package/node_modules/uuid/dist/esm-browser/v35.js +14 -25
- package/node_modules/uuid/dist/esm-browser/v4.js +5 -9
- package/node_modules/uuid/dist/esm-browser/v5.js +1 -1
- package/node_modules/uuid/dist/esm-browser/v6.js +36 -0
- package/node_modules/uuid/dist/esm-browser/v6ToV1.js +20 -0
- package/node_modules/uuid/dist/esm-browser/v7.js +146 -0
- package/node_modules/uuid/dist/esm-browser/validate.js +0 -2
- package/node_modules/uuid/dist/esm-browser/version.js +0 -3
- package/node_modules/uuid/dist/esm-node/index.js +9 -4
- package/node_modules/uuid/dist/esm-node/max.js +1 -0
- package/node_modules/uuid/dist/esm-node/md5.js +1 -4
- package/node_modules/uuid/dist/esm-node/native.js +1 -1
- package/node_modules/uuid/dist/esm-node/parse.js +11 -9
- package/node_modules/uuid/dist/esm-node/regex.js +1 -1
- package/node_modules/uuid/dist/esm-node/rng.js +1 -3
- package/node_modules/uuid/dist/esm-node/sha1.js +1 -4
- package/node_modules/uuid/dist/esm-node/stringify.js +7 -9
- package/node_modules/uuid/dist/esm-node/v1.js +66 -36
- package/node_modules/uuid/dist/esm-node/v1ToV6.js +20 -0
- package/node_modules/uuid/dist/esm-node/v35.js +8 -19
- package/node_modules/uuid/dist/esm-node/v4.js +4 -8
- package/node_modules/uuid/dist/esm-node/v6.js +32 -0
- package/node_modules/uuid/dist/esm-node/v6ToV1.js +20 -0
- package/node_modules/uuid/dist/esm-node/v7.js +146 -0
- package/node_modules/uuid/dist/esm-node/validate.js +0 -2
- package/node_modules/uuid/dist/esm-node/version.js +0 -3
- package/node_modules/uuid/dist/index.js +40 -15
- package/node_modules/uuid/dist/max.js +7 -0
- package/node_modules/uuid/dist/md5-browser.js +8 -31
- package/node_modules/uuid/dist/md5.js +4 -10
- package/node_modules/uuid/dist/native-browser.js +2 -3
- package/node_modules/uuid/dist/native.js +5 -9
- package/node_modules/uuid/dist/nil.js +1 -2
- package/node_modules/uuid/dist/parse.js +13 -14
- package/node_modules/uuid/dist/regex.js +1 -2
- package/node_modules/uuid/dist/rng-browser.js +1 -3
- package/node_modules/uuid/dist/rng.js +3 -10
- package/node_modules/uuid/dist/sha1-browser.js +1 -23
- package/node_modules/uuid/dist/sha1.js +4 -10
- package/node_modules/uuid/dist/stringify.js +8 -14
- package/node_modules/uuid/dist/uuid-bin.js +12 -22
- package/node_modules/uuid/dist/v1.js +66 -42
- package/node_modules/uuid/dist/v1ToV6.js +26 -0
- package/node_modules/uuid/dist/v3.js +2 -7
- package/node_modules/uuid/dist/v35.js +11 -28
- package/node_modules/uuid/dist/v4.js +6 -17
- package/node_modules/uuid/dist/v5.js +2 -7
- package/node_modules/uuid/dist/v6.js +38 -0
- package/node_modules/uuid/dist/v6ToV1.js +26 -0
- package/node_modules/uuid/dist/v7.js +152 -0
- package/node_modules/uuid/dist/validate.js +2 -7
- package/node_modules/uuid/dist/version.js +2 -8
- package/node_modules/uuid/package.json +41 -34
- package/node_modules/uuid/wrapper.mjs +5 -0
- package/package.json +6 -6
- package/tak-ingest.js +1 -1
- package/tak-registration.js +8 -1
- package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
- package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
- package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
- package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2363
- package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
- package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
- package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
- package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
- package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4487
- package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -596
- package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -545
- package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
- package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
- package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
- package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
- package/node_modules/@types/node/ts4.8/events.d.ts +0 -879
- package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1239
- package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4311
- package/node_modules/@types/node/ts4.8/globals.d.ts +0 -411
- package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
- package/node_modules/@types/node/ts4.8/http.d.ts +0 -1887
- package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
- package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
- package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
- package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
- package/node_modules/@types/node/ts4.8/module.d.ts +0 -315
- package/node_modules/@types/node/ts4.8/net.d.ts +0 -954
- package/node_modules/@types/node/ts4.8/os.d.ts +0 -478
- package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
- package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -645
- package/node_modules/@types/node/ts4.8/process.d.ts +0 -1561
- package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
- package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
- package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
- package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
- package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
- package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
- package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
- package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -366
- package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
- package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
- package/node_modules/@types/node/ts4.8/test.d.ts +0 -1465
- package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
- package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
- package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
- package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
- package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
- package/node_modules/@types/node/ts4.8/url.d.ts +0 -944
- package/node_modules/@types/node/ts4.8/util.d.ts +0 -2183
- package/node_modules/@types/node/ts4.8/v8.d.ts +0 -764
- package/node_modules/@types/node/ts4.8/vm.d.ts +0 -903
- package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -179
- package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
- package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
- package/node_modules/object-is/.eslintignore +0 -1
- package/node_modules/set-function-length/env.d.ts.map +0 -1
- package/node_modules/set-function-length/index.d.ts.map +0 -1
|
@@ -1,872 +1,889 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = parse;
|
|
3
|
-
|
|
4
|
-
parse.filename = null;
|
|
5
|
-
parse.defaults = { keepCase: false };
|
|
6
|
-
|
|
7
|
-
var tokenize = require("./tokenize"),
|
|
8
|
-
Root = require("./root"),
|
|
9
|
-
Type = require("./type"),
|
|
10
|
-
Field = require("./field"),
|
|
11
|
-
MapField = require("./mapfield"),
|
|
12
|
-
OneOf = require("./oneof"),
|
|
13
|
-
Enum = require("./enum"),
|
|
14
|
-
Service = require("./service"),
|
|
15
|
-
Method = require("./method"),
|
|
16
|
-
types = require("./types"),
|
|
17
|
-
util = require("./util");
|
|
18
|
-
|
|
19
|
-
var base10Re = /^[1-9][0-9]*$/,
|
|
20
|
-
base10NegRe = /^-?[1-9][0-9]*$/,
|
|
21
|
-
base16Re = /^0[x][0-9a-fA-F]+$/,
|
|
22
|
-
base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
|
|
23
|
-
base8Re = /^0[0-7]+$/,
|
|
24
|
-
base8NegRe = /^-?0[0-7]+$/,
|
|
25
|
-
numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
|
|
26
|
-
nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
|
|
27
|
-
typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
|
|
28
|
-
fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Result object returned from {@link parse}.
|
|
32
|
-
* @interface IParserResult
|
|
33
|
-
* @property {string|undefined} package Package name, if declared
|
|
34
|
-
* @property {string[]|undefined} imports Imports, if any
|
|
35
|
-
* @property {string[]|undefined} weakImports Weak imports, if any
|
|
36
|
-
* @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`)
|
|
37
|
-
* @property {Root} root Populated root instance
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Options modifying the behavior of {@link parse}.
|
|
42
|
-
* @interface IParseOptions
|
|
43
|
-
* @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
|
|
44
|
-
* @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
|
|
45
|
-
* @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Options modifying the behavior of JSON serialization.
|
|
50
|
-
* @interface IToJSONOptions
|
|
51
|
-
* @property {boolean} [keepComments=false] Serializes comments.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Parses the given .proto source and returns an object with the parsed contents.
|
|
56
|
-
* @param {string} source Source contents
|
|
57
|
-
* @param {Root} root Root to populate
|
|
58
|
-
* @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
|
|
59
|
-
* @returns {IParserResult} Parser result
|
|
60
|
-
* @property {string} filename=null Currently processing file name for error reporting, if known
|
|
61
|
-
* @property {IParseOptions} defaults Default {@link IParseOptions}
|
|
62
|
-
*/
|
|
63
|
-
function parse(source, root, options) {
|
|
64
|
-
/* eslint-disable callback-return */
|
|
65
|
-
if (!(root instanceof Root)) {
|
|
66
|
-
options = root;
|
|
67
|
-
root = new Root();
|
|
68
|
-
}
|
|
69
|
-
if (!options)
|
|
70
|
-
options = parse.defaults;
|
|
71
|
-
|
|
72
|
-
var preferTrailingComment = options.preferTrailingComment || false;
|
|
73
|
-
var tn = tokenize(source, options.alternateCommentMode || false),
|
|
74
|
-
next = tn.next,
|
|
75
|
-
push = tn.push,
|
|
76
|
-
peek = tn.peek,
|
|
77
|
-
skip = tn.skip,
|
|
78
|
-
cmnt = tn.cmnt;
|
|
79
|
-
|
|
80
|
-
var head = true,
|
|
81
|
-
pkg,
|
|
82
|
-
imports,
|
|
83
|
-
weakImports,
|
|
84
|
-
syntax,
|
|
85
|
-
isProto3 = false;
|
|
86
|
-
|
|
87
|
-
var ptr = root;
|
|
88
|
-
|
|
89
|
-
var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
|
|
90
|
-
|
|
91
|
-
/* istanbul ignore next */
|
|
92
|
-
function illegal(token, name, insideTryCatch) {
|
|
93
|
-
var filename = parse.filename;
|
|
94
|
-
if (!insideTryCatch)
|
|
95
|
-
parse.filename = null;
|
|
96
|
-
return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function readString() {
|
|
100
|
-
var values = [],
|
|
101
|
-
token;
|
|
102
|
-
do {
|
|
103
|
-
/* istanbul ignore if */
|
|
104
|
-
if ((token = next()) !== "\"" && token !== "'")
|
|
105
|
-
throw illegal(token);
|
|
106
|
-
|
|
107
|
-
values.push(next());
|
|
108
|
-
skip(token);
|
|
109
|
-
token = peek();
|
|
110
|
-
} while (token === "\"" || token === "'");
|
|
111
|
-
return values.join("");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function readValue(acceptTypeRef) {
|
|
115
|
-
var token = next();
|
|
116
|
-
switch (token) {
|
|
117
|
-
case "'":
|
|
118
|
-
case "\"":
|
|
119
|
-
push(token);
|
|
120
|
-
return readString();
|
|
121
|
-
case "true": case "TRUE":
|
|
122
|
-
return true;
|
|
123
|
-
case "false": case "FALSE":
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
return parseNumber(token, /* insideTryCatch */ true);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
|
|
130
|
-
/* istanbul ignore else */
|
|
131
|
-
if (acceptTypeRef && typeRefRe.test(token))
|
|
132
|
-
return token;
|
|
133
|
-
|
|
134
|
-
/* istanbul ignore next */
|
|
135
|
-
throw illegal(token, "value");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function readRanges(target, acceptStrings) {
|
|
140
|
-
var token, start;
|
|
141
|
-
do {
|
|
142
|
-
if (acceptStrings && ((token = peek()) === "\"" || token === "'"))
|
|
143
|
-
target.push(readString());
|
|
144
|
-
else
|
|
145
|
-
target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
|
|
146
|
-
} while (skip(",", true));
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
case "
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
case "
|
|
337
|
-
|
|
338
|
-
break;
|
|
339
|
-
|
|
340
|
-
case "
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
break;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
field
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
type.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
case "
|
|
461
|
-
|
|
462
|
-
break;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
if (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if (
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
skip("
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
parseField(parent,
|
|
797
|
-
break;
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = parse;
|
|
3
|
+
|
|
4
|
+
parse.filename = null;
|
|
5
|
+
parse.defaults = { keepCase: false };
|
|
6
|
+
|
|
7
|
+
var tokenize = require("./tokenize"),
|
|
8
|
+
Root = require("./root"),
|
|
9
|
+
Type = require("./type"),
|
|
10
|
+
Field = require("./field"),
|
|
11
|
+
MapField = require("./mapfield"),
|
|
12
|
+
OneOf = require("./oneof"),
|
|
13
|
+
Enum = require("./enum"),
|
|
14
|
+
Service = require("./service"),
|
|
15
|
+
Method = require("./method"),
|
|
16
|
+
types = require("./types"),
|
|
17
|
+
util = require("./util");
|
|
18
|
+
|
|
19
|
+
var base10Re = /^[1-9][0-9]*$/,
|
|
20
|
+
base10NegRe = /^-?[1-9][0-9]*$/,
|
|
21
|
+
base16Re = /^0[x][0-9a-fA-F]+$/,
|
|
22
|
+
base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
|
|
23
|
+
base8Re = /^0[0-7]+$/,
|
|
24
|
+
base8NegRe = /^-?0[0-7]+$/,
|
|
25
|
+
numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
|
|
26
|
+
nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
|
|
27
|
+
typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
|
|
28
|
+
fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Result object returned from {@link parse}.
|
|
32
|
+
* @interface IParserResult
|
|
33
|
+
* @property {string|undefined} package Package name, if declared
|
|
34
|
+
* @property {string[]|undefined} imports Imports, if any
|
|
35
|
+
* @property {string[]|undefined} weakImports Weak imports, if any
|
|
36
|
+
* @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`)
|
|
37
|
+
* @property {Root} root Populated root instance
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options modifying the behavior of {@link parse}.
|
|
42
|
+
* @interface IParseOptions
|
|
43
|
+
* @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
|
|
44
|
+
* @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
|
|
45
|
+
* @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Options modifying the behavior of JSON serialization.
|
|
50
|
+
* @interface IToJSONOptions
|
|
51
|
+
* @property {boolean} [keepComments=false] Serializes comments.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Parses the given .proto source and returns an object with the parsed contents.
|
|
56
|
+
* @param {string} source Source contents
|
|
57
|
+
* @param {Root} root Root to populate
|
|
58
|
+
* @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
|
|
59
|
+
* @returns {IParserResult} Parser result
|
|
60
|
+
* @property {string} filename=null Currently processing file name for error reporting, if known
|
|
61
|
+
* @property {IParseOptions} defaults Default {@link IParseOptions}
|
|
62
|
+
*/
|
|
63
|
+
function parse(source, root, options) {
|
|
64
|
+
/* eslint-disable callback-return */
|
|
65
|
+
if (!(root instanceof Root)) {
|
|
66
|
+
options = root;
|
|
67
|
+
root = new Root();
|
|
68
|
+
}
|
|
69
|
+
if (!options)
|
|
70
|
+
options = parse.defaults;
|
|
71
|
+
|
|
72
|
+
var preferTrailingComment = options.preferTrailingComment || false;
|
|
73
|
+
var tn = tokenize(source, options.alternateCommentMode || false),
|
|
74
|
+
next = tn.next,
|
|
75
|
+
push = tn.push,
|
|
76
|
+
peek = tn.peek,
|
|
77
|
+
skip = tn.skip,
|
|
78
|
+
cmnt = tn.cmnt;
|
|
79
|
+
|
|
80
|
+
var head = true,
|
|
81
|
+
pkg,
|
|
82
|
+
imports,
|
|
83
|
+
weakImports,
|
|
84
|
+
syntax,
|
|
85
|
+
isProto3 = false;
|
|
86
|
+
|
|
87
|
+
var ptr = root;
|
|
88
|
+
|
|
89
|
+
var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
|
|
90
|
+
|
|
91
|
+
/* istanbul ignore next */
|
|
92
|
+
function illegal(token, name, insideTryCatch) {
|
|
93
|
+
var filename = parse.filename;
|
|
94
|
+
if (!insideTryCatch)
|
|
95
|
+
parse.filename = null;
|
|
96
|
+
return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function readString() {
|
|
100
|
+
var values = [],
|
|
101
|
+
token;
|
|
102
|
+
do {
|
|
103
|
+
/* istanbul ignore if */
|
|
104
|
+
if ((token = next()) !== "\"" && token !== "'")
|
|
105
|
+
throw illegal(token);
|
|
106
|
+
|
|
107
|
+
values.push(next());
|
|
108
|
+
skip(token);
|
|
109
|
+
token = peek();
|
|
110
|
+
} while (token === "\"" || token === "'");
|
|
111
|
+
return values.join("");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function readValue(acceptTypeRef) {
|
|
115
|
+
var token = next();
|
|
116
|
+
switch (token) {
|
|
117
|
+
case "'":
|
|
118
|
+
case "\"":
|
|
119
|
+
push(token);
|
|
120
|
+
return readString();
|
|
121
|
+
case "true": case "TRUE":
|
|
122
|
+
return true;
|
|
123
|
+
case "false": case "FALSE":
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
return parseNumber(token, /* insideTryCatch */ true);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
|
|
130
|
+
/* istanbul ignore else */
|
|
131
|
+
if (acceptTypeRef && typeRefRe.test(token))
|
|
132
|
+
return token;
|
|
133
|
+
|
|
134
|
+
/* istanbul ignore next */
|
|
135
|
+
throw illegal(token, "value");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function readRanges(target, acceptStrings) {
|
|
140
|
+
var token, start;
|
|
141
|
+
do {
|
|
142
|
+
if (acceptStrings && ((token = peek()) === "\"" || token === "'"))
|
|
143
|
+
target.push(readString());
|
|
144
|
+
else
|
|
145
|
+
target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
|
|
146
|
+
} while (skip(",", true));
|
|
147
|
+
var dummy = {options: undefined};
|
|
148
|
+
dummy.setOption = function(name, value) {
|
|
149
|
+
if (this.options === undefined) this.options = {};
|
|
150
|
+
this.options[name] = value;
|
|
151
|
+
};
|
|
152
|
+
ifBlock(
|
|
153
|
+
dummy,
|
|
154
|
+
function parseRange_block(token) {
|
|
155
|
+
/* istanbul ignore else */
|
|
156
|
+
if (token === "option") {
|
|
157
|
+
parseOption(dummy, token); // skip
|
|
158
|
+
skip(";");
|
|
159
|
+
} else
|
|
160
|
+
throw illegal(token);
|
|
161
|
+
},
|
|
162
|
+
function parseRange_line() {
|
|
163
|
+
parseInlineOptions(dummy); // skip
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function parseNumber(token, insideTryCatch) {
|
|
168
|
+
var sign = 1;
|
|
169
|
+
if (token.charAt(0) === "-") {
|
|
170
|
+
sign = -1;
|
|
171
|
+
token = token.substring(1);
|
|
172
|
+
}
|
|
173
|
+
switch (token) {
|
|
174
|
+
case "inf": case "INF": case "Inf":
|
|
175
|
+
return sign * Infinity;
|
|
176
|
+
case "nan": case "NAN": case "Nan": case "NaN":
|
|
177
|
+
return NaN;
|
|
178
|
+
case "0":
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
if (base10Re.test(token))
|
|
182
|
+
return sign * parseInt(token, 10);
|
|
183
|
+
if (base16Re.test(token))
|
|
184
|
+
return sign * parseInt(token, 16);
|
|
185
|
+
if (base8Re.test(token))
|
|
186
|
+
return sign * parseInt(token, 8);
|
|
187
|
+
|
|
188
|
+
/* istanbul ignore else */
|
|
189
|
+
if (numberRe.test(token))
|
|
190
|
+
return sign * parseFloat(token);
|
|
191
|
+
|
|
192
|
+
/* istanbul ignore next */
|
|
193
|
+
throw illegal(token, "number", insideTryCatch);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function parseId(token, acceptNegative) {
|
|
197
|
+
switch (token) {
|
|
198
|
+
case "max": case "MAX": case "Max":
|
|
199
|
+
return 536870911;
|
|
200
|
+
case "0":
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* istanbul ignore if */
|
|
205
|
+
if (!acceptNegative && token.charAt(0) === "-")
|
|
206
|
+
throw illegal(token, "id");
|
|
207
|
+
|
|
208
|
+
if (base10NegRe.test(token))
|
|
209
|
+
return parseInt(token, 10);
|
|
210
|
+
if (base16NegRe.test(token))
|
|
211
|
+
return parseInt(token, 16);
|
|
212
|
+
|
|
213
|
+
/* istanbul ignore else */
|
|
214
|
+
if (base8NegRe.test(token))
|
|
215
|
+
return parseInt(token, 8);
|
|
216
|
+
|
|
217
|
+
/* istanbul ignore next */
|
|
218
|
+
throw illegal(token, "id");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function parsePackage() {
|
|
222
|
+
|
|
223
|
+
/* istanbul ignore if */
|
|
224
|
+
if (pkg !== undefined)
|
|
225
|
+
throw illegal("package");
|
|
226
|
+
|
|
227
|
+
pkg = next();
|
|
228
|
+
|
|
229
|
+
/* istanbul ignore if */
|
|
230
|
+
if (!typeRefRe.test(pkg))
|
|
231
|
+
throw illegal(pkg, "name");
|
|
232
|
+
|
|
233
|
+
ptr = ptr.define(pkg);
|
|
234
|
+
skip(";");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function parseImport() {
|
|
238
|
+
var token = peek();
|
|
239
|
+
var whichImports;
|
|
240
|
+
switch (token) {
|
|
241
|
+
case "weak":
|
|
242
|
+
whichImports = weakImports || (weakImports = []);
|
|
243
|
+
next();
|
|
244
|
+
break;
|
|
245
|
+
case "public":
|
|
246
|
+
next();
|
|
247
|
+
// eslint-disable-next-line no-fallthrough
|
|
248
|
+
default:
|
|
249
|
+
whichImports = imports || (imports = []);
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
token = readString();
|
|
253
|
+
skip(";");
|
|
254
|
+
whichImports.push(token);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function parseSyntax() {
|
|
258
|
+
skip("=");
|
|
259
|
+
syntax = readString();
|
|
260
|
+
isProto3 = syntax === "proto3";
|
|
261
|
+
|
|
262
|
+
/* istanbul ignore if */
|
|
263
|
+
if (!isProto3 && syntax !== "proto2")
|
|
264
|
+
throw illegal(syntax, "syntax");
|
|
265
|
+
|
|
266
|
+
skip(";");
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function parseCommon(parent, token) {
|
|
270
|
+
switch (token) {
|
|
271
|
+
|
|
272
|
+
case "option":
|
|
273
|
+
parseOption(parent, token);
|
|
274
|
+
skip(";");
|
|
275
|
+
return true;
|
|
276
|
+
|
|
277
|
+
case "message":
|
|
278
|
+
parseType(parent, token);
|
|
279
|
+
return true;
|
|
280
|
+
|
|
281
|
+
case "enum":
|
|
282
|
+
parseEnum(parent, token);
|
|
283
|
+
return true;
|
|
284
|
+
|
|
285
|
+
case "service":
|
|
286
|
+
parseService(parent, token);
|
|
287
|
+
return true;
|
|
288
|
+
|
|
289
|
+
case "extend":
|
|
290
|
+
parseExtension(parent, token);
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function ifBlock(obj, fnIf, fnElse) {
|
|
297
|
+
var trailingLine = tn.line;
|
|
298
|
+
if (obj) {
|
|
299
|
+
if(typeof obj.comment !== "string") {
|
|
300
|
+
obj.comment = cmnt(); // try block-type comment
|
|
301
|
+
}
|
|
302
|
+
obj.filename = parse.filename;
|
|
303
|
+
}
|
|
304
|
+
if (skip("{", true)) {
|
|
305
|
+
var token;
|
|
306
|
+
while ((token = next()) !== "}")
|
|
307
|
+
fnIf(token);
|
|
308
|
+
skip(";", true);
|
|
309
|
+
} else {
|
|
310
|
+
if (fnElse)
|
|
311
|
+
fnElse();
|
|
312
|
+
skip(";");
|
|
313
|
+
if (obj && (typeof obj.comment !== "string" || preferTrailingComment))
|
|
314
|
+
obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function parseType(parent, token) {
|
|
319
|
+
|
|
320
|
+
/* istanbul ignore if */
|
|
321
|
+
if (!nameRe.test(token = next()))
|
|
322
|
+
throw illegal(token, "type name");
|
|
323
|
+
|
|
324
|
+
var type = new Type(token);
|
|
325
|
+
ifBlock(type, function parseType_block(token) {
|
|
326
|
+
if (parseCommon(type, token))
|
|
327
|
+
return;
|
|
328
|
+
|
|
329
|
+
switch (token) {
|
|
330
|
+
|
|
331
|
+
case "map":
|
|
332
|
+
parseMapField(type, token);
|
|
333
|
+
break;
|
|
334
|
+
|
|
335
|
+
case "required":
|
|
336
|
+
case "repeated":
|
|
337
|
+
parseField(type, token);
|
|
338
|
+
break;
|
|
339
|
+
|
|
340
|
+
case "optional":
|
|
341
|
+
/* istanbul ignore if */
|
|
342
|
+
if (isProto3) {
|
|
343
|
+
parseField(type, "proto3_optional");
|
|
344
|
+
} else {
|
|
345
|
+
parseField(type, "optional");
|
|
346
|
+
}
|
|
347
|
+
break;
|
|
348
|
+
|
|
349
|
+
case "oneof":
|
|
350
|
+
parseOneOf(type, token);
|
|
351
|
+
break;
|
|
352
|
+
|
|
353
|
+
case "extensions":
|
|
354
|
+
readRanges(type.extensions || (type.extensions = []));
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
case "reserved":
|
|
358
|
+
readRanges(type.reserved || (type.reserved = []), true);
|
|
359
|
+
break;
|
|
360
|
+
|
|
361
|
+
default:
|
|
362
|
+
/* istanbul ignore if */
|
|
363
|
+
if (!isProto3 || !typeRefRe.test(token))
|
|
364
|
+
throw illegal(token);
|
|
365
|
+
|
|
366
|
+
push(token);
|
|
367
|
+
parseField(type, "optional");
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
parent.add(type);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function parseField(parent, rule, extend) {
|
|
375
|
+
var type = next();
|
|
376
|
+
if (type === "group") {
|
|
377
|
+
parseGroup(parent, rule);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
// Type names can consume multiple tokens, in multiple variants:
|
|
381
|
+
// package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
|
|
382
|
+
// package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
|
|
383
|
+
// package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
|
|
384
|
+
// package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
|
|
385
|
+
// Keep reading tokens until we get a type name with no period at the end,
|
|
386
|
+
// and the next token does not start with a period.
|
|
387
|
+
while (type.endsWith(".") || peek().startsWith(".")) {
|
|
388
|
+
type += next();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* istanbul ignore if */
|
|
392
|
+
if (!typeRefRe.test(type))
|
|
393
|
+
throw illegal(type, "type");
|
|
394
|
+
|
|
395
|
+
var name = next();
|
|
396
|
+
|
|
397
|
+
/* istanbul ignore if */
|
|
398
|
+
if (!nameRe.test(name))
|
|
399
|
+
throw illegal(name, "name");
|
|
400
|
+
|
|
401
|
+
name = applyCase(name);
|
|
402
|
+
skip("=");
|
|
403
|
+
|
|
404
|
+
var field = new Field(name, parseId(next()), type, rule, extend);
|
|
405
|
+
ifBlock(field, function parseField_block(token) {
|
|
406
|
+
|
|
407
|
+
/* istanbul ignore else */
|
|
408
|
+
if (token === "option") {
|
|
409
|
+
parseOption(field, token);
|
|
410
|
+
skip(";");
|
|
411
|
+
} else
|
|
412
|
+
throw illegal(token);
|
|
413
|
+
|
|
414
|
+
}, function parseField_line() {
|
|
415
|
+
parseInlineOptions(field);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
if (rule === "proto3_optional") {
|
|
419
|
+
// for proto3 optional fields, we create a single-member Oneof to mimic "optional" behavior
|
|
420
|
+
var oneof = new OneOf("_" + name);
|
|
421
|
+
field.setOption("proto3_optional", true);
|
|
422
|
+
oneof.add(field);
|
|
423
|
+
parent.add(oneof);
|
|
424
|
+
} else {
|
|
425
|
+
parent.add(field);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// JSON defaults to packed=true if not set so we have to set packed=false explicity when
|
|
429
|
+
// parsing proto2 descriptors without the option, where applicable. This must be done for
|
|
430
|
+
// all known packable types and anything that could be an enum (= is not a basic type).
|
|
431
|
+
if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))
|
|
432
|
+
field.setOption("packed", false, /* ifNotSet */ true);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function parseGroup(parent, rule) {
|
|
436
|
+
var name = next();
|
|
437
|
+
|
|
438
|
+
/* istanbul ignore if */
|
|
439
|
+
if (!nameRe.test(name))
|
|
440
|
+
throw illegal(name, "name");
|
|
441
|
+
|
|
442
|
+
var fieldName = util.lcFirst(name);
|
|
443
|
+
if (name === fieldName)
|
|
444
|
+
name = util.ucFirst(name);
|
|
445
|
+
skip("=");
|
|
446
|
+
var id = parseId(next());
|
|
447
|
+
var type = new Type(name);
|
|
448
|
+
type.group = true;
|
|
449
|
+
var field = new Field(fieldName, id, name, rule);
|
|
450
|
+
field.filename = parse.filename;
|
|
451
|
+
ifBlock(type, function parseGroup_block(token) {
|
|
452
|
+
switch (token) {
|
|
453
|
+
|
|
454
|
+
case "option":
|
|
455
|
+
parseOption(type, token);
|
|
456
|
+
skip(";");
|
|
457
|
+
break;
|
|
458
|
+
|
|
459
|
+
case "required":
|
|
460
|
+
case "repeated":
|
|
461
|
+
parseField(type, token);
|
|
462
|
+
break;
|
|
463
|
+
|
|
464
|
+
case "optional":
|
|
465
|
+
/* istanbul ignore if */
|
|
466
|
+
if (isProto3) {
|
|
467
|
+
parseField(type, "proto3_optional");
|
|
468
|
+
} else {
|
|
469
|
+
parseField(type, "optional");
|
|
470
|
+
}
|
|
471
|
+
break;
|
|
472
|
+
|
|
473
|
+
case "message":
|
|
474
|
+
parseType(type, token);
|
|
475
|
+
break;
|
|
476
|
+
|
|
477
|
+
case "enum":
|
|
478
|
+
parseEnum(type, token);
|
|
479
|
+
break;
|
|
480
|
+
|
|
481
|
+
/* istanbul ignore next */
|
|
482
|
+
default:
|
|
483
|
+
throw illegal(token); // there are no groups with proto3 semantics
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
parent.add(type)
|
|
487
|
+
.add(field);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function parseMapField(parent) {
|
|
491
|
+
skip("<");
|
|
492
|
+
var keyType = next();
|
|
493
|
+
|
|
494
|
+
/* istanbul ignore if */
|
|
495
|
+
if (types.mapKey[keyType] === undefined)
|
|
496
|
+
throw illegal(keyType, "type");
|
|
497
|
+
|
|
498
|
+
skip(",");
|
|
499
|
+
var valueType = next();
|
|
500
|
+
|
|
501
|
+
/* istanbul ignore if */
|
|
502
|
+
if (!typeRefRe.test(valueType))
|
|
503
|
+
throw illegal(valueType, "type");
|
|
504
|
+
|
|
505
|
+
skip(">");
|
|
506
|
+
var name = next();
|
|
507
|
+
|
|
508
|
+
/* istanbul ignore if */
|
|
509
|
+
if (!nameRe.test(name))
|
|
510
|
+
throw illegal(name, "name");
|
|
511
|
+
|
|
512
|
+
skip("=");
|
|
513
|
+
var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);
|
|
514
|
+
ifBlock(field, function parseMapField_block(token) {
|
|
515
|
+
|
|
516
|
+
/* istanbul ignore else */
|
|
517
|
+
if (token === "option") {
|
|
518
|
+
parseOption(field, token);
|
|
519
|
+
skip(";");
|
|
520
|
+
} else
|
|
521
|
+
throw illegal(token);
|
|
522
|
+
|
|
523
|
+
}, function parseMapField_line() {
|
|
524
|
+
parseInlineOptions(field);
|
|
525
|
+
});
|
|
526
|
+
parent.add(field);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function parseOneOf(parent, token) {
|
|
530
|
+
|
|
531
|
+
/* istanbul ignore if */
|
|
532
|
+
if (!nameRe.test(token = next()))
|
|
533
|
+
throw illegal(token, "name");
|
|
534
|
+
|
|
535
|
+
var oneof = new OneOf(applyCase(token));
|
|
536
|
+
ifBlock(oneof, function parseOneOf_block(token) {
|
|
537
|
+
if (token === "option") {
|
|
538
|
+
parseOption(oneof, token);
|
|
539
|
+
skip(";");
|
|
540
|
+
} else {
|
|
541
|
+
push(token);
|
|
542
|
+
parseField(oneof, "optional");
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
parent.add(oneof);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function parseEnum(parent, token) {
|
|
549
|
+
|
|
550
|
+
/* istanbul ignore if */
|
|
551
|
+
if (!nameRe.test(token = next()))
|
|
552
|
+
throw illegal(token, "name");
|
|
553
|
+
|
|
554
|
+
var enm = new Enum(token);
|
|
555
|
+
ifBlock(enm, function parseEnum_block(token) {
|
|
556
|
+
switch(token) {
|
|
557
|
+
case "option":
|
|
558
|
+
parseOption(enm, token);
|
|
559
|
+
skip(";");
|
|
560
|
+
break;
|
|
561
|
+
|
|
562
|
+
case "reserved":
|
|
563
|
+
readRanges(enm.reserved || (enm.reserved = []), true);
|
|
564
|
+
break;
|
|
565
|
+
|
|
566
|
+
default:
|
|
567
|
+
parseEnumValue(enm, token);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
parent.add(enm);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function parseEnumValue(parent, token) {
|
|
574
|
+
|
|
575
|
+
/* istanbul ignore if */
|
|
576
|
+
if (!nameRe.test(token))
|
|
577
|
+
throw illegal(token, "name");
|
|
578
|
+
|
|
579
|
+
skip("=");
|
|
580
|
+
var value = parseId(next(), true),
|
|
581
|
+
dummy = {
|
|
582
|
+
options: undefined
|
|
583
|
+
};
|
|
584
|
+
dummy.setOption = function(name, value) {
|
|
585
|
+
if (this.options === undefined)
|
|
586
|
+
this.options = {};
|
|
587
|
+
this.options[name] = value;
|
|
588
|
+
};
|
|
589
|
+
ifBlock(dummy, function parseEnumValue_block(token) {
|
|
590
|
+
|
|
591
|
+
/* istanbul ignore else */
|
|
592
|
+
if (token === "option") {
|
|
593
|
+
parseOption(dummy, token); // skip
|
|
594
|
+
skip(";");
|
|
595
|
+
} else
|
|
596
|
+
throw illegal(token);
|
|
597
|
+
|
|
598
|
+
}, function parseEnumValue_line() {
|
|
599
|
+
parseInlineOptions(dummy); // skip
|
|
600
|
+
});
|
|
601
|
+
parent.add(token, value, dummy.comment, dummy.options);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function parseOption(parent, token) {
|
|
605
|
+
var isCustom = skip("(", true);
|
|
606
|
+
|
|
607
|
+
/* istanbul ignore if */
|
|
608
|
+
if (!typeRefRe.test(token = next()))
|
|
609
|
+
throw illegal(token, "name");
|
|
610
|
+
|
|
611
|
+
var name = token;
|
|
612
|
+
var option = name;
|
|
613
|
+
var propName;
|
|
614
|
+
|
|
615
|
+
if (isCustom) {
|
|
616
|
+
skip(")");
|
|
617
|
+
name = "(" + name + ")";
|
|
618
|
+
option = name;
|
|
619
|
+
token = peek();
|
|
620
|
+
if (fqTypeRefRe.test(token)) {
|
|
621
|
+
propName = token.slice(1); //remove '.' before property name
|
|
622
|
+
name += token;
|
|
623
|
+
next();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
skip("=");
|
|
627
|
+
var optionValue = parseOptionValue(parent, name);
|
|
628
|
+
setParsedOption(parent, option, optionValue, propName);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function parseOptionValue(parent, name) {
|
|
632
|
+
// { a: "foo" b { c: "bar" } }
|
|
633
|
+
if (skip("{", true)) {
|
|
634
|
+
var objectResult = {};
|
|
635
|
+
|
|
636
|
+
while (!skip("}", true)) {
|
|
637
|
+
/* istanbul ignore if */
|
|
638
|
+
if (!nameRe.test(token = next())) {
|
|
639
|
+
throw illegal(token, "name");
|
|
640
|
+
}
|
|
641
|
+
if (token === null) {
|
|
642
|
+
throw illegal(token, "end of input");
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
var value;
|
|
646
|
+
var propName = token;
|
|
647
|
+
|
|
648
|
+
skip(":", true);
|
|
649
|
+
|
|
650
|
+
if (peek() === "{")
|
|
651
|
+
value = parseOptionValue(parent, name + "." + token);
|
|
652
|
+
else if (peek() === "[") {
|
|
653
|
+
// option (my_option) = {
|
|
654
|
+
// repeated_value: [ "foo", "bar" ]
|
|
655
|
+
// };
|
|
656
|
+
value = [];
|
|
657
|
+
var lastValue;
|
|
658
|
+
if (skip("[", true)) {
|
|
659
|
+
do {
|
|
660
|
+
lastValue = readValue(true);
|
|
661
|
+
value.push(lastValue);
|
|
662
|
+
} while (skip(",", true));
|
|
663
|
+
skip("]");
|
|
664
|
+
if (typeof lastValue !== "undefined") {
|
|
665
|
+
setOption(parent, name + "." + token, lastValue);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
value = readValue(true);
|
|
670
|
+
setOption(parent, name + "." + token, value);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
var prevValue = objectResult[propName];
|
|
674
|
+
|
|
675
|
+
if (prevValue)
|
|
676
|
+
value = [].concat(prevValue).concat(value);
|
|
677
|
+
|
|
678
|
+
objectResult[propName] = value;
|
|
679
|
+
|
|
680
|
+
// Semicolons and commas can be optional
|
|
681
|
+
skip(",", true);
|
|
682
|
+
skip(";", true);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return objectResult;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
var simpleValue = readValue(true);
|
|
689
|
+
setOption(parent, name, simpleValue);
|
|
690
|
+
return simpleValue;
|
|
691
|
+
// Does not enforce a delimiter to be universal
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function setOption(parent, name, value) {
|
|
695
|
+
if (parent.setOption)
|
|
696
|
+
parent.setOption(name, value);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function setParsedOption(parent, name, value, propName) {
|
|
700
|
+
if (parent.setParsedOption)
|
|
701
|
+
parent.setParsedOption(name, value, propName);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function parseInlineOptions(parent) {
|
|
705
|
+
if (skip("[", true)) {
|
|
706
|
+
do {
|
|
707
|
+
parseOption(parent, "option");
|
|
708
|
+
} while (skip(",", true));
|
|
709
|
+
skip("]");
|
|
710
|
+
}
|
|
711
|
+
return parent;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function parseService(parent, token) {
|
|
715
|
+
|
|
716
|
+
/* istanbul ignore if */
|
|
717
|
+
if (!nameRe.test(token = next()))
|
|
718
|
+
throw illegal(token, "service name");
|
|
719
|
+
|
|
720
|
+
var service = new Service(token);
|
|
721
|
+
ifBlock(service, function parseService_block(token) {
|
|
722
|
+
if (parseCommon(service, token))
|
|
723
|
+
return;
|
|
724
|
+
|
|
725
|
+
/* istanbul ignore else */
|
|
726
|
+
if (token === "rpc")
|
|
727
|
+
parseMethod(service, token);
|
|
728
|
+
else
|
|
729
|
+
throw illegal(token);
|
|
730
|
+
});
|
|
731
|
+
parent.add(service);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function parseMethod(parent, token) {
|
|
735
|
+
// Get the comment of the preceding line now (if one exists) in case the
|
|
736
|
+
// method is defined across multiple lines.
|
|
737
|
+
var commentText = cmnt();
|
|
738
|
+
|
|
739
|
+
var type = token;
|
|
740
|
+
|
|
741
|
+
/* istanbul ignore if */
|
|
742
|
+
if (!nameRe.test(token = next()))
|
|
743
|
+
throw illegal(token, "name");
|
|
744
|
+
|
|
745
|
+
var name = token,
|
|
746
|
+
requestType, requestStream,
|
|
747
|
+
responseType, responseStream;
|
|
748
|
+
|
|
749
|
+
skip("(");
|
|
750
|
+
if (skip("stream", true))
|
|
751
|
+
requestStream = true;
|
|
752
|
+
|
|
753
|
+
/* istanbul ignore if */
|
|
754
|
+
if (!typeRefRe.test(token = next()))
|
|
755
|
+
throw illegal(token);
|
|
756
|
+
|
|
757
|
+
requestType = token;
|
|
758
|
+
skip(")"); skip("returns"); skip("(");
|
|
759
|
+
if (skip("stream", true))
|
|
760
|
+
responseStream = true;
|
|
761
|
+
|
|
762
|
+
/* istanbul ignore if */
|
|
763
|
+
if (!typeRefRe.test(token = next()))
|
|
764
|
+
throw illegal(token);
|
|
765
|
+
|
|
766
|
+
responseType = token;
|
|
767
|
+
skip(")");
|
|
768
|
+
|
|
769
|
+
var method = new Method(name, type, requestType, responseType, requestStream, responseStream);
|
|
770
|
+
method.comment = commentText;
|
|
771
|
+
ifBlock(method, function parseMethod_block(token) {
|
|
772
|
+
|
|
773
|
+
/* istanbul ignore else */
|
|
774
|
+
if (token === "option") {
|
|
775
|
+
parseOption(method, token);
|
|
776
|
+
skip(";");
|
|
777
|
+
} else
|
|
778
|
+
throw illegal(token);
|
|
779
|
+
|
|
780
|
+
});
|
|
781
|
+
parent.add(method);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function parseExtension(parent, token) {
|
|
785
|
+
|
|
786
|
+
/* istanbul ignore if */
|
|
787
|
+
if (!typeRefRe.test(token = next()))
|
|
788
|
+
throw illegal(token, "reference");
|
|
789
|
+
|
|
790
|
+
var reference = token;
|
|
791
|
+
ifBlock(null, function parseExtension_block(token) {
|
|
792
|
+
switch (token) {
|
|
793
|
+
|
|
794
|
+
case "required":
|
|
795
|
+
case "repeated":
|
|
796
|
+
parseField(parent, token, reference);
|
|
797
|
+
break;
|
|
798
|
+
|
|
799
|
+
case "optional":
|
|
800
|
+
/* istanbul ignore if */
|
|
801
|
+
if (isProto3) {
|
|
802
|
+
parseField(parent, "proto3_optional", reference);
|
|
803
|
+
} else {
|
|
804
|
+
parseField(parent, "optional", reference);
|
|
805
|
+
}
|
|
806
|
+
break;
|
|
807
|
+
|
|
808
|
+
default:
|
|
809
|
+
/* istanbul ignore if */
|
|
810
|
+
if (!isProto3 || !typeRefRe.test(token))
|
|
811
|
+
throw illegal(token);
|
|
812
|
+
push(token);
|
|
813
|
+
parseField(parent, "optional", reference);
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
var token;
|
|
820
|
+
while ((token = next()) !== null) {
|
|
821
|
+
switch (token) {
|
|
822
|
+
|
|
823
|
+
case "package":
|
|
824
|
+
|
|
825
|
+
/* istanbul ignore if */
|
|
826
|
+
if (!head)
|
|
827
|
+
throw illegal(token);
|
|
828
|
+
|
|
829
|
+
parsePackage();
|
|
830
|
+
break;
|
|
831
|
+
|
|
832
|
+
case "import":
|
|
833
|
+
|
|
834
|
+
/* istanbul ignore if */
|
|
835
|
+
if (!head)
|
|
836
|
+
throw illegal(token);
|
|
837
|
+
|
|
838
|
+
parseImport();
|
|
839
|
+
break;
|
|
840
|
+
|
|
841
|
+
case "syntax":
|
|
842
|
+
|
|
843
|
+
/* istanbul ignore if */
|
|
844
|
+
if (!head)
|
|
845
|
+
throw illegal(token);
|
|
846
|
+
|
|
847
|
+
parseSyntax();
|
|
848
|
+
break;
|
|
849
|
+
|
|
850
|
+
case "option":
|
|
851
|
+
|
|
852
|
+
parseOption(ptr, token);
|
|
853
|
+
skip(";");
|
|
854
|
+
break;
|
|
855
|
+
|
|
856
|
+
default:
|
|
857
|
+
|
|
858
|
+
/* istanbul ignore else */
|
|
859
|
+
if (parseCommon(ptr, token)) {
|
|
860
|
+
head = false;
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/* istanbul ignore next */
|
|
865
|
+
throw illegal(token);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
parse.filename = null;
|
|
870
|
+
return {
|
|
871
|
+
"package" : pkg,
|
|
872
|
+
"imports" : imports,
|
|
873
|
+
weakImports : weakImports,
|
|
874
|
+
syntax : syntax,
|
|
875
|
+
root : root
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Parses the given .proto source and returns an object with the parsed contents.
|
|
881
|
+
* @name parse
|
|
882
|
+
* @function
|
|
883
|
+
* @param {string} source Source contents
|
|
884
|
+
* @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
|
|
885
|
+
* @returns {IParserResult} Parser result
|
|
886
|
+
* @property {string} filename=null Currently processing file name for error reporting, if known
|
|
887
|
+
* @property {IParseOptions} defaults Default {@link IParseOptions}
|
|
888
|
+
* @variation 2
|
|
889
|
+
*/
|