@songtonyli/dsh-cli 0.1.32 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@bufbuild/protobuf/README.md +41 -0
  4. package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.js +66 -0
  5. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.js +18 -0
  6. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.js +31 -0
  7. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.js +28 -0
  8. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.js +18 -0
  9. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.js +39 -0
  10. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.js +24 -0
  11. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.js +27 -0
  12. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +43 -0
  13. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.js +15 -0
  14. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.js +105 -0
  15. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +244 -0
  16. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.js +58 -0
  17. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.js +28 -0
  18. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +35 -0
  19. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.js +39 -0
  20. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.js +24 -0
  21. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.js +29 -0
  22. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.js +67 -0
  23. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.js +27 -0
  24. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +74 -0
  25. package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.js +15 -0
  26. package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +296 -0
  27. package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.js +53 -0
  28. package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.js +209 -0
  29. package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.js +168 -0
  30. package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.js +45 -0
  31. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +415 -0
  32. package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +1037 -0
  33. package/node_modules/@bufbuild/protobuf/dist/commonjs/index.js +55 -0
  34. package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.js +33 -0
  35. package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.js +15 -0
  36. package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.js +70 -0
  37. package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +4 -0
  38. package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.js +131 -0
  39. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.js +36 -0
  40. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.js +78 -0
  41. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.js +41 -0
  42. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +157 -0
  43. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.js +115 -0
  44. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.js +110 -0
  45. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.js +376 -0
  46. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +292 -0
  47. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.js +16 -0
  48. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +469 -0
  49. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.js +129 -0
  50. package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +149 -0
  51. package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +954 -0
  52. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.js +437 -0
  53. package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +625 -0
  54. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.js +684 -0
  55. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.js +21 -0
  56. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.js +47 -0
  57. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.js +481 -0
  58. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.js +358 -0
  59. package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.js +220 -0
  60. package/node_modules/@bufbuild/protobuf/dist/commonjs/types.js +15 -0
  61. package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.js +26 -0
  62. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.js +188 -0
  63. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +726 -0
  64. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.js +37 -0
  65. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.js +191 -0
  66. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.js +106 -0
  67. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.js +199 -0
  68. package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.js +334 -0
  69. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +75 -0
  70. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +39 -0
  71. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.js +27 -0
  72. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.js +39 -0
  73. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +68 -0
  74. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
  75. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.js +892 -0
  76. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.js +27 -0
  77. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.js +27 -0
  78. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.js +27 -0
  79. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.js +126 -0
  80. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.js +106 -0
  81. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.js +27 -0
  82. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.js +59 -0
  83. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.js +27 -0
  84. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.js +242 -0
  85. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.js +67 -0
  86. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +48 -0
  87. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/json.js +44 -0
  88. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +57 -0
  89. package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.js +66 -0
  90. package/node_modules/@bufbuild/protobuf/dist/esm/clone.js +63 -0
  91. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.js +14 -0
  92. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.js +26 -0
  93. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.js +25 -0
  94. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.js +14 -0
  95. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.js +23 -0
  96. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.js +21 -0
  97. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.js +24 -0
  98. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +40 -0
  99. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.js +14 -0
  100. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +101 -0
  101. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +239 -0
  102. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.js +53 -0
  103. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js +25 -0
  104. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +32 -0
  105. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +23 -0
  106. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js +21 -0
  107. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.js +26 -0
  108. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.js +63 -0
  109. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.js +24 -0
  110. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +71 -0
  111. package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.js +14 -0
  112. package/node_modules/@bufbuild/protobuf/dist/esm/create.js +293 -0
  113. package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.js +50 -0
  114. package/node_modules/@bufbuild/protobuf/dist/esm/equals.js +206 -0
  115. package/node_modules/@bufbuild/protobuf/dist/esm/extensions.js +159 -0
  116. package/node_modules/@bufbuild/protobuf/dist/esm/fields.js +41 -0
  117. package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +409 -0
  118. package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +1029 -0
  119. package/node_modules/@bufbuild/protobuf/dist/esm/index.js +29 -0
  120. package/node_modules/@bufbuild/protobuf/dist/esm/is-message.js +30 -0
  121. package/node_modules/@bufbuild/protobuf/dist/esm/json-value.js +14 -0
  122. package/node_modules/@bufbuild/protobuf/dist/esm/merge.js +67 -0
  123. package/node_modules/@bufbuild/protobuf/dist/esm/package.json +4 -0
  124. package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js +128 -0
  125. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js +31 -0
  126. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js +71 -0
  127. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.js +21 -0
  128. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +152 -0
  129. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.js +109 -0
  130. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.js +105 -0
  131. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.js +369 -0
  132. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +284 -0
  133. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.js +14 -0
  134. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +464 -0
  135. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js +124 -0
  136. package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +140 -0
  137. package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +948 -0
  138. package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js +433 -0
  139. package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +620 -0
  140. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.js +680 -0
  141. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.js +15 -0
  142. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.js +44 -0
  143. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.js +477 -0
  144. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +355 -0
  145. package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.js +214 -0
  146. package/node_modules/@bufbuild/protobuf/dist/esm/types.js +14 -0
  147. package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.js +23 -0
  148. package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js +184 -0
  149. package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +721 -0
  150. package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.js +18 -0
  151. package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.js +186 -0
  152. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +101 -0
  153. package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.js +195 -0
  154. package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js +325 -0
  155. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +69 -0
  156. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +35 -0
  157. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.js +24 -0
  158. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.js +36 -0
  159. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +65 -0
  160. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
  161. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +888 -0
  162. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js +24 -0
  163. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.js +24 -0
  164. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +24 -0
  165. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +123 -0
  166. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +103 -0
  167. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +24 -0
  168. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js +56 -0
  169. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +24 -0
  170. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.js +239 -0
  171. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +64 -0
  172. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +32 -0
  173. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/json.js +41 -0
  174. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +50 -0
  175. package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +61 -0
  176. package/node_modules/@bufbuild/protobuf/package.json +136 -0
  177. package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
  178. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
  179. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  180. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
  181. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +6 -0
  182. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +143 -0
  183. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +143 -0
  184. package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +3557 -0
  185. package/node_modules/@deepseek-ai/dsh-llm-cursor/package.json +61 -0
  186. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
  187. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +39 -26
  188. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +39 -26
  189. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +1121 -223
  190. package/package.json +5 -1
@@ -0,0 +1,726 @@
1
+ "use strict";
2
+ // Copyright 2021-2026 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.BinaryReader = exports.BinaryWriter = exports.INT32_MIN = exports.INT32_MAX = exports.UINT32_MAX = exports.FLOAT32_MIN = exports.FLOAT32_MAX = exports.WireType = void 0;
17
+ const varint_js_1 = require("./varint.js");
18
+ const proto_int64_js_1 = require("../proto-int64.js");
19
+ const text_encoding_js_1 = require("./text-encoding.js");
20
+ /**
21
+ * Protobuf binary format wire types.
22
+ *
23
+ * A wire type provides just enough information to find the length of the
24
+ * following value.
25
+ *
26
+ * See https://developers.google.com/protocol-buffers/docs/encoding#structure
27
+ */
28
+ var WireType;
29
+ (function (WireType) {
30
+ /**
31
+ * Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum
32
+ */
33
+ WireType[WireType["Varint"] = 0] = "Varint";
34
+ /**
35
+ * Used for fixed64, sfixed64, double.
36
+ * Always 8 bytes with little-endian byte order.
37
+ */
38
+ WireType[WireType["Bit64"] = 1] = "Bit64";
39
+ /**
40
+ * Used for string, bytes, embedded messages, packed repeated fields
41
+ *
42
+ * Only repeated numeric types (types which use the varint, 32-bit,
43
+ * or 64-bit wire types) can be packed. In proto3, such fields are
44
+ * packed by default.
45
+ */
46
+ WireType[WireType["LengthDelimited"] = 2] = "LengthDelimited";
47
+ /**
48
+ * Start of a tag-delimited aggregate, such as a proto2 group, or a message
49
+ * in editions with message_encoding = DELIMITED.
50
+ */
51
+ WireType[WireType["StartGroup"] = 3] = "StartGroup";
52
+ /**
53
+ * End of a tag-delimited aggregate.
54
+ */
55
+ WireType[WireType["EndGroup"] = 4] = "EndGroup";
56
+ /**
57
+ * Used for fixed32, sfixed32, float.
58
+ * Always 4 bytes with little-endian byte order.
59
+ */
60
+ WireType[WireType["Bit32"] = 5] = "Bit32";
61
+ })(WireType || (exports.WireType = WireType = {}));
62
+ /**
63
+ * Maximum value for a 32-bit floating point value (Protobuf FLOAT).
64
+ */
65
+ exports.FLOAT32_MAX = 3.4028234663852886e38;
66
+ /**
67
+ * Minimum value for a 32-bit floating point value (Protobuf FLOAT).
68
+ */
69
+ exports.FLOAT32_MIN = -3.4028234663852886e38;
70
+ /**
71
+ * Maximum value for an unsigned 32-bit integer (Protobuf UINT32, FIXED32).
72
+ */
73
+ exports.UINT32_MAX = 0xffffffff;
74
+ /**
75
+ * Maximum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32).
76
+ */
77
+ exports.INT32_MAX = 0x7fffffff;
78
+ /**
79
+ * Minimum value for a signed 32-bit integer (Protobuf INT32, SFIXED32, SINT32).
80
+ */
81
+ exports.INT32_MIN = -0x80000000;
82
+ class BinaryWriter {
83
+ constructor(encodeUtf8) {
84
+ /**
85
+ * Previous fork positions (the write position at the time
86
+ * `fork()` was called).
87
+ */
88
+ this.stackPos = [];
89
+ this.encodeUtf8Into = encodeUtf8
90
+ ? (0, text_encoding_js_1.emulateEncodeInto)(encodeUtf8)
91
+ : (0, text_encoding_js_1.getTextEncoding)().encodeUtf8Into;
92
+ this.buffer = EMPTY_BUFFER;
93
+ this.viewCache = EMPTY_VIEW;
94
+ this.pos = 0;
95
+ }
96
+ ensureCapacity(size) {
97
+ const required = this.pos + size;
98
+ if (required > this.buffer.length) {
99
+ let newLen = this.buffer.length || INITIAL_SIZE;
100
+ while (newLen < required)
101
+ newLen *= 2;
102
+ const newBuf = new Uint8Array(newLen);
103
+ if (this.pos > 0)
104
+ newBuf.set(this.buffer);
105
+ this.buffer = newBuf;
106
+ }
107
+ }
108
+ /**
109
+ * The DataView over `buffer`, rebuilt only if the buffer has grown since it
110
+ * was last used.
111
+ */
112
+ view() {
113
+ const bytes = this.buffer;
114
+ const view = this.viewCache;
115
+ // Since ensureCapacity() only ever replaces the buffer with a strictly larger one,
116
+ // equal lengths mean the view is still current. This is faster than comparing
117
+ // buffers directly.
118
+ if (view.byteLength === bytes.byteLength)
119
+ return view;
120
+ const newView = new DataView(bytes.buffer);
121
+ this.viewCache = newView;
122
+ return newView;
123
+ }
124
+ /**
125
+ * Return all bytes written and reset this writer.
126
+ */
127
+ finish() {
128
+ const result = this.buffer.slice(0, this.pos);
129
+ this.pos = 0;
130
+ this.stackPos = [];
131
+ return result;
132
+ }
133
+ /**
134
+ * Start a new fork for length-delimited data like a message
135
+ * or a packed repeated field.
136
+ *
137
+ * Must be joined later with `join()`.
138
+ */
139
+ fork() {
140
+ this.stackPos.push(this.pos);
141
+ // Reserve room for the length prefix. Payloads under 128 bytes, fairly
142
+ // common, will need no copy in join().
143
+ this.ensureCapacity(DEFAULT_LEN_PREFIX_SIZE);
144
+ this.buffer[this.pos++] = 0;
145
+ return this;
146
+ }
147
+ /**
148
+ * Join the last fork. Write its length and bytes, then
149
+ * return to the previous state.
150
+ */
151
+ join() {
152
+ const forkPos = this.stackPos.pop();
153
+ if (forkPos === undefined)
154
+ throw new Error("invalid state, fork stack empty");
155
+ // fork() presumed the payload would fit the prefix it reserved. If it
156
+ // doesn't, we need to shift the bytes we just wrote.
157
+ const len = this.pos - forkPos - DEFAULT_LEN_PREFIX_SIZE;
158
+ const lenPrefixSize = varint32Size(len);
159
+ if (lenPrefixSize > DEFAULT_LEN_PREFIX_SIZE) {
160
+ // Widening pushes the payload past the end of the buffer, so grow first:
161
+ // copyWithin clamps to the buffer instead of throwing, so a short buffer
162
+ // would silently drop the tail of the payload.
163
+ this.ensureCapacity(lenPrefixSize - DEFAULT_LEN_PREFIX_SIZE);
164
+ this.buffer.copyWithin(forkPos + lenPrefixSize, forkPos + DEFAULT_LEN_PREFIX_SIZE, this.pos);
165
+ }
166
+ this.pos = forkPos;
167
+ this.uint32(len);
168
+ this.pos += len;
169
+ return this;
170
+ }
171
+ /**
172
+ * Writes a tag (field number and wire type).
173
+ *
174
+ * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.
175
+ *
176
+ * Generated code should compute the tag ahead of time and call `uint32()`.
177
+ */
178
+ tag(fieldNo, type) {
179
+ return this.uint32(((fieldNo << 3) | type) >>> 0);
180
+ }
181
+ /**
182
+ * Write a chunk of raw bytes.
183
+ */
184
+ raw(chunk) {
185
+ this.ensureCapacity(chunk.length);
186
+ this.buffer.set(chunk, this.pos);
187
+ this.pos += chunk.length;
188
+ return this;
189
+ }
190
+ /**
191
+ * Write a `uint32` value, an unsigned 32 bit varint.
192
+ */
193
+ uint32(value) {
194
+ assertUInt32(value);
195
+ // uint32 varints are at most 5 bytes; reserve once and avoid per-byte
196
+ // capacity checks.
197
+ this.ensureCapacity(5);
198
+ if (value < 0x80) {
199
+ this.buffer[this.pos++] = value;
200
+ return this;
201
+ }
202
+ while (value > 0x7f) {
203
+ this.buffer[this.pos++] = (value & 0x7f) | 0x80;
204
+ value >>>= 7;
205
+ }
206
+ this.buffer[this.pos++] = value;
207
+ return this;
208
+ }
209
+ /**
210
+ * Write a `int32` value, a signed 32 bit varint.
211
+ */
212
+ int32(value) {
213
+ assertInt32(value);
214
+ if (value >= 0) {
215
+ return this.uint32(value);
216
+ }
217
+ // Negative: sign-extend to 64 bits, encodes to 10 bytes.
218
+ this.ensureCapacity(10);
219
+ for (let i = 0; i < 9; i++) {
220
+ this.buffer[this.pos++] = (value & 0x7f) | 0x80;
221
+ value >>= 7;
222
+ }
223
+ this.buffer[this.pos++] = 1;
224
+ return this;
225
+ }
226
+ /**
227
+ * Write a `bool` value, a varint.
228
+ */
229
+ bool(value) {
230
+ this.ensureCapacity(1);
231
+ this.buffer[this.pos++] = value ? 1 : 0;
232
+ return this;
233
+ }
234
+ /**
235
+ * Write a `bytes` value, length-delimited arbitrary data.
236
+ */
237
+ bytes(value) {
238
+ this.uint32(value.byteLength);
239
+ return this.raw(value);
240
+ }
241
+ /**
242
+ * Write a `string` value, length-delimited data converted to UTF-8 text.
243
+ */
244
+ string(value) {
245
+ // TextEncoder.encode() coerces its argument to string, but encodeInto()
246
+ // rejects non-strings.
247
+ if (typeof value !== "string") {
248
+ value = String(value);
249
+ }
250
+ const len = value.length;
251
+ // Fast path for ASCII.
252
+ if (len <= ASCII_MAX_LENGTH) {
253
+ this.ensureCapacity(len + 1);
254
+ const ascii = this.buffer;
255
+ let pos = this.pos;
256
+ ascii[pos++] = len;
257
+ let i = 0;
258
+ for (; i < len; i++) {
259
+ const code = value.charCodeAt(i);
260
+ if (code > 0x7f)
261
+ break;
262
+ ascii[pos++] = code;
263
+ }
264
+ if (i == len) {
265
+ this.pos = pos;
266
+ return this;
267
+ }
268
+ }
269
+ // encodeUtf8Into needs the full-length buffer upfront. The length prefix
270
+ // can be upto 5 bytes, and a UTF-16 code unit takes at most 3 UTF-8 bytes.
271
+ this.ensureCapacity(len * 3 + 5);
272
+ // The length prefix goes first, but the byte length is only known after
273
+ // encoding. We guess the final varint size here (assuming most text is
274
+ // ASCII) and then encode.
275
+ const lenPrefixSizeGuess = varint32Size(len);
276
+ const buf = this.buffer;
277
+ const start = this.pos;
278
+ const { written } = this.encodeUtf8Into(value, buf.subarray(start + lenPrefixSizeGuess));
279
+ // If our guess was incorrect, we need to shift the bytes we just wrote.
280
+ const lenPrefixSize = varint32Size(written);
281
+ if (lenPrefixSize != lenPrefixSizeGuess) {
282
+ buf.copyWithin(start + lenPrefixSize, start + lenPrefixSizeGuess, start + lenPrefixSizeGuess + written);
283
+ }
284
+ // Write the lenPrefix and advance the pos.
285
+ this.uint32(written);
286
+ this.pos += written;
287
+ return this;
288
+ }
289
+ /**
290
+ * Write a `float` value, 32-bit floating point number.
291
+ */
292
+ float(value) {
293
+ assertFloat32(value);
294
+ this.ensureCapacity(4);
295
+ this.view().setFloat32(this.pos, value, true);
296
+ this.pos += 4;
297
+ return this;
298
+ }
299
+ /**
300
+ * Write a `double` value, a 64-bit floating point number.
301
+ */
302
+ double(value) {
303
+ this.ensureCapacity(8);
304
+ this.view().setFloat64(this.pos, value, true);
305
+ this.pos += 8;
306
+ return this;
307
+ }
308
+ /**
309
+ * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
310
+ */
311
+ fixed32(value) {
312
+ assertUInt32(value);
313
+ this.ensureCapacity(4);
314
+ this.view().setUint32(this.pos, value, true);
315
+ this.pos += 4;
316
+ return this;
317
+ }
318
+ /**
319
+ * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
320
+ */
321
+ sfixed32(value) {
322
+ assertInt32(value);
323
+ this.ensureCapacity(4);
324
+ this.view().setInt32(this.pos, value, true);
325
+ this.pos += 4;
326
+ return this;
327
+ }
328
+ /**
329
+ * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
330
+ */
331
+ sint32(value) {
332
+ assertInt32(value);
333
+ // zigzag encode then emit as uint32 varint
334
+ return this.uint32(((value << 1) ^ (value >> 31)) >>> 0);
335
+ }
336
+ /**
337
+ * Write a `sfixed64` value, a signed, fixed-length 64-bit integer.
338
+ */
339
+ sfixed64(value) {
340
+ const tc = proto_int64_js_1.protoInt64.enc(value);
341
+ this.ensureCapacity(8);
342
+ const view = this.view();
343
+ view.setInt32(this.pos, tc.lo, true);
344
+ view.setInt32(this.pos + 4, tc.hi, true);
345
+ this.pos += 8;
346
+ return this;
347
+ }
348
+ /**
349
+ * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
350
+ */
351
+ fixed64(value) {
352
+ const tc = proto_int64_js_1.protoInt64.uEnc(value);
353
+ this.ensureCapacity(8);
354
+ const view = this.view();
355
+ view.setInt32(this.pos, tc.lo, true);
356
+ view.setInt32(this.pos + 4, tc.hi, true);
357
+ this.pos += 8;
358
+ return this;
359
+ }
360
+ /**
361
+ * Write a `int64` value, a signed 64-bit varint.
362
+ */
363
+ int64(value) {
364
+ const tc = proto_int64_js_1.protoInt64.enc(value);
365
+ return this.writeVarint64(tc.lo, tc.hi);
366
+ }
367
+ /**
368
+ * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
369
+ */
370
+ sint64(value) {
371
+ const tc = proto_int64_js_1.protoInt64.enc(value),
372
+ // zigzag encode
373
+ sign = tc.hi >> 31, lo = (tc.lo << 1) ^ sign, hi = ((tc.hi << 1) | (tc.lo >>> 31)) ^ sign;
374
+ return this.writeVarint64(lo, hi);
375
+ }
376
+ /**
377
+ * Write a `uint64` value, an unsigned 64-bit varint.
378
+ */
379
+ uint64(value) {
380
+ const tc = proto_int64_js_1.protoInt64.uEnc(value);
381
+ return this.writeVarint64(tc.lo, tc.hi);
382
+ }
383
+ /**
384
+ * Write a 64-bit varint directly into the buffer. Accepts the value as
385
+ * split low/high 32-bit words.
386
+ *
387
+ * Ported from varint64write() to avoid the intermediate number[] buffer.
388
+ * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344
389
+ */
390
+ writeVarint64(lo, hi) {
391
+ // Worst case: 10 bytes.
392
+ this.ensureCapacity(10);
393
+ const buf = this.buffer;
394
+ let pos = this.pos;
395
+ for (let i = 0; i < 28; i = i + 7) {
396
+ const shift = lo >>> i;
397
+ const hasNext = !(shift >>> 7 == 0 && hi == 0);
398
+ buf[pos++] = (hasNext ? shift | 0x80 : shift) & 0xff;
399
+ if (!hasNext) {
400
+ this.pos = pos;
401
+ return this;
402
+ }
403
+ }
404
+ const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4);
405
+ const hasMoreBits = !(hi >> 3 == 0);
406
+ buf[pos++] = (hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff;
407
+ if (!hasMoreBits) {
408
+ this.pos = pos;
409
+ return this;
410
+ }
411
+ for (let i = 3; i < 31; i = i + 7) {
412
+ const shift = hi >>> i;
413
+ const hasNext = !(shift >>> 7 == 0);
414
+ buf[pos++] = (hasNext ? shift | 0x80 : shift) & 0xff;
415
+ if (!hasNext) {
416
+ this.pos = pos;
417
+ return this;
418
+ }
419
+ }
420
+ buf[pos++] = (hi >>> 31) & 0x01;
421
+ this.pos = pos;
422
+ return this;
423
+ }
424
+ }
425
+ exports.BinaryWriter = BinaryWriter;
426
+ /**
427
+ * Capacity of the buffer allocated by the first write..
428
+ */
429
+ const INITIAL_SIZE = 128;
430
+ /**
431
+ * Bytes `fork()` reserves for the length prefix, betting that the payload will
432
+ * be under 128 bytes. `join()` fills them in, and widens them if the bet was
433
+ * wrong.
434
+ */
435
+ const DEFAULT_LEN_PREFIX_SIZE = 1;
436
+ /**
437
+ * Shared empty buffer used as the initial value before the first write.
438
+ * Avoids allocating and zeroing `INITIAL_SIZE` bytes per BinaryWriter when a
439
+ * writer is only used for a tiny message (or not used at all).
440
+ */
441
+ const EMPTY_BUFFER = new Uint8Array(0);
442
+ /**
443
+ * Shared empty view, paired with `EMPTY_BUFFER`. Never written to: any
444
+ * fixed-width write first grows the buffer, which replaces this view.
445
+ */
446
+ const EMPTY_VIEW = new DataView(EMPTY_BUFFER.buffer);
447
+ /**
448
+ * Longest string on the ASCII fast paths. Must stay below 0x80, so
449
+ * that the writer's length prefix always fits a single varint byte.
450
+ */
451
+ const ASCII_MAX_LENGTH = 32;
452
+ /**
453
+ * Number of bytes needed to encode `value` as an unsigned 32-bit varint.
454
+ */
455
+ function varint32Size(value) {
456
+ if (value < 0x80)
457
+ return 1;
458
+ if (value < 0x4000)
459
+ return 2;
460
+ if (value < 0x200000)
461
+ return 3;
462
+ if (value < 0x10000000)
463
+ return 4;
464
+ return 5;
465
+ }
466
+ class BinaryReader {
467
+ constructor(buf, decodeUtf8 = (0, text_encoding_js_1.getTextEncoding)().decodeUtf8) {
468
+ this.decodeUtf8 = decodeUtf8;
469
+ this.varint64Lo = 0;
470
+ this.varint64Hi = 0;
471
+ this.varint64 = varint_js_1.varint64read; // dirty cast for `this`
472
+ /**
473
+ * Read a `uint32` field, an unsigned 32 bit varint.
474
+ */
475
+ this.uint32 = varint_js_1.varint32read;
476
+ this.buf = buf;
477
+ this.len = buf.length;
478
+ this.pos = 0;
479
+ this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
480
+ }
481
+ /**
482
+ * Reads a tag - field number and wire type. Tags are uint32 varints; values
483
+ * that do not fit in uint32 are rejected.
484
+ */
485
+ tag() {
486
+ const start = this.pos;
487
+ const tag = this.uint32();
488
+ const bytesRead = this.pos - start;
489
+ if (bytesRead > 5 || (bytesRead == 5 && this.buf[this.pos - 1] > 0x0f)) {
490
+ throw new Error("illegal tag: varint overflows uint32");
491
+ }
492
+ const fieldNo = tag >>> 3;
493
+ const wireType = tag & 7;
494
+ if (fieldNo <= 0 || wireType > 5) {
495
+ throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
496
+ }
497
+ return [fieldNo, wireType];
498
+ }
499
+ /**
500
+ * Skip one element and return the skipped data.
501
+ *
502
+ * When skipping StartGroup, provide the tags field number to check for
503
+ * matching field number in the EndGroup tag. Recursion into nested groups
504
+ * is guarded by the `recursionLimit` argument: When the limit is reached,
505
+ * this method throws.
506
+ */
507
+ skip(wireType, fieldNo, recursionLimit = 100) {
508
+ let start = this.pos;
509
+ switch (wireType) {
510
+ case WireType.Varint:
511
+ while (this.buf[this.pos++] & 0x80) {
512
+ // ignore
513
+ }
514
+ break;
515
+ // @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
516
+ case WireType.Bit64:
517
+ this.pos += 4;
518
+ case WireType.Bit32:
519
+ this.pos += 4;
520
+ break;
521
+ case WireType.LengthDelimited:
522
+ let len = this.uint32();
523
+ this.pos += len;
524
+ break;
525
+ case WireType.StartGroup:
526
+ if (recursionLimit <= 0) {
527
+ throw new Error("maximum recursion depth reached");
528
+ }
529
+ for (;;) {
530
+ const [fn, wt] = this.tag();
531
+ if (wt === WireType.EndGroup) {
532
+ if (fieldNo !== undefined && fn !== fieldNo) {
533
+ throw new Error("invalid end group tag");
534
+ }
535
+ break;
536
+ }
537
+ this.skip(wt, fn, recursionLimit - 1);
538
+ }
539
+ break;
540
+ default:
541
+ throw new Error("cant skip wire type " + wireType);
542
+ }
543
+ this.assertBounds();
544
+ return this.buf.subarray(start, this.pos);
545
+ }
546
+ /**
547
+ * Throws error if position in byte array is out of range.
548
+ */
549
+ assertBounds() {
550
+ if (this.pos > this.len)
551
+ throw new RangeError("premature EOF");
552
+ }
553
+ /**
554
+ * Read a `int32` field, a signed 32 bit varint.
555
+ */
556
+ int32() {
557
+ return this.uint32() | 0;
558
+ }
559
+ /**
560
+ * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.
561
+ */
562
+ sint32() {
563
+ let zze = this.uint32();
564
+ // decode zigzag
565
+ return (zze >>> 1) ^ -(zze & 1);
566
+ }
567
+ /**
568
+ * Read a `int64` field, a signed 64-bit varint.
569
+ */
570
+ int64() {
571
+ this.varint64();
572
+ return proto_int64_js_1.protoInt64.dec(this.varint64Lo, this.varint64Hi);
573
+ }
574
+ /**
575
+ * Read a `uint64` field, an unsigned 64-bit varint.
576
+ */
577
+ uint64() {
578
+ this.varint64();
579
+ return proto_int64_js_1.protoInt64.uDec(this.varint64Lo, this.varint64Hi);
580
+ }
581
+ /**
582
+ * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
583
+ */
584
+ sint64() {
585
+ this.varint64();
586
+ let lo = this.varint64Lo;
587
+ let hi = this.varint64Hi;
588
+ // decode zig zag
589
+ let s = -(lo & 1);
590
+ lo = ((lo >>> 1) | ((hi & 1) << 31)) ^ s;
591
+ hi = (hi >>> 1) ^ s;
592
+ return proto_int64_js_1.protoInt64.dec(lo, hi);
593
+ }
594
+ /**
595
+ * Read a `bool` field, a variant.
596
+ */
597
+ bool() {
598
+ // Fast path: most bools are 0x0 or 0x1.
599
+ const b = this.buf[this.pos];
600
+ if (b < 0x80) {
601
+ this.pos++;
602
+ return b !== 0;
603
+ }
604
+ this.varint64();
605
+ return this.varint64Lo !== 0 || this.varint64Hi !== 0;
606
+ }
607
+ /**
608
+ * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.
609
+ */
610
+ fixed32() {
611
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
612
+ return this.view.getUint32((this.pos += 4) - 4, true);
613
+ }
614
+ /**
615
+ * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.
616
+ */
617
+ sfixed32() {
618
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
619
+ return this.view.getInt32((this.pos += 4) - 4, true);
620
+ }
621
+ /**
622
+ * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
623
+ */
624
+ fixed64() {
625
+ return proto_int64_js_1.protoInt64.uDec(this.sfixed32(), this.sfixed32());
626
+ }
627
+ /**
628
+ * Read a `fixed64` field, a signed, fixed-length 64-bit integer.
629
+ */
630
+ sfixed64() {
631
+ return proto_int64_js_1.protoInt64.dec(this.sfixed32(), this.sfixed32());
632
+ }
633
+ /**
634
+ * Read a `float` field, 32-bit floating point number.
635
+ */
636
+ float() {
637
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
638
+ return this.view.getFloat32((this.pos += 4) - 4, true);
639
+ }
640
+ /**
641
+ * Read a `double` field, a 64-bit floating point number.
642
+ */
643
+ double() {
644
+ // biome-ignore lint/suspicious/noAssignInExpressions: no
645
+ return this.view.getFloat64((this.pos += 8) - 8, true);
646
+ }
647
+ /**
648
+ * Read a `bytes` field, length-delimited arbitrary data.
649
+ */
650
+ bytes() {
651
+ let len = this.uint32(), start = this.pos;
652
+ this.pos += len;
653
+ this.assertBounds();
654
+ return this.buf.subarray(start, start + len);
655
+ }
656
+ /**
657
+ * Read a `string` field, length-delimited data converted to UTF-8 text. If
658
+ * `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
659
+ */
660
+ string(strict) {
661
+ const bytes = this.bytes();
662
+ const len = bytes.length;
663
+ // Fast path for ASCII.
664
+ if (len <= ASCII_MAX_LENGTH) {
665
+ const codes = new Array(len);
666
+ for (let i = 0; i < len; i++) {
667
+ const byte = bytes[i];
668
+ if (byte > 0x7f) {
669
+ return this.decodeUtf8(bytes, strict);
670
+ }
671
+ codes[i] = byte;
672
+ }
673
+ return String.fromCharCode.apply(String, codes);
674
+ }
675
+ return this.decodeUtf8(bytes, strict);
676
+ }
677
+ }
678
+ exports.BinaryReader = BinaryReader;
679
+ /**
680
+ * Assert a valid signed protobuf 32-bit integer as a number or string.
681
+ */
682
+ function assertInt32(arg) {
683
+ if (typeof arg == "string") {
684
+ arg = Number(arg);
685
+ }
686
+ else if (typeof arg != "number") {
687
+ throw new Error("invalid int32: " + typeof arg);
688
+ }
689
+ if (!Number.isInteger(arg) ||
690
+ arg > exports.INT32_MAX ||
691
+ arg < exports.INT32_MIN)
692
+ throw new Error("invalid int32: " + arg);
693
+ }
694
+ /**
695
+ * Assert a valid unsigned protobuf 32-bit integer as a number or string.
696
+ */
697
+ function assertUInt32(arg) {
698
+ if (typeof arg == "string") {
699
+ arg = Number(arg);
700
+ }
701
+ else if (typeof arg != "number") {
702
+ throw new Error("invalid uint32: " + typeof arg);
703
+ }
704
+ if (!Number.isInteger(arg) ||
705
+ arg > exports.UINT32_MAX ||
706
+ arg < 0)
707
+ throw new Error("invalid uint32: " + arg);
708
+ }
709
+ /**
710
+ * Assert a valid protobuf float value as a number or string.
711
+ */
712
+ function assertFloat32(arg) {
713
+ if (typeof arg == "string") {
714
+ const o = arg;
715
+ arg = Number(arg);
716
+ if (Number.isNaN(arg) && o !== "NaN") {
717
+ throw new Error("invalid float32: " + o);
718
+ }
719
+ }
720
+ else if (typeof arg != "number") {
721
+ throw new Error("invalid float32: " + typeof arg);
722
+ }
723
+ if (Number.isFinite(arg) &&
724
+ (arg > exports.FLOAT32_MAX || arg < exports.FLOAT32_MIN))
725
+ throw new Error("invalid float32: " + arg);
726
+ }