@bufbuild/protobuf 1.9.0 → 2.0.0-alpha.1

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 (426) hide show
  1. package/dist/cjs/clone.d.ts +6 -0
  2. package/dist/cjs/clone.js +77 -0
  3. package/dist/cjs/codegenv1/boot.d.ts +63 -0
  4. package/dist/cjs/codegenv1/boot.js +102 -0
  5. package/dist/cjs/codegenv1/embed.d.ts +43 -0
  6. package/dist/cjs/codegenv1/embed.js +238 -0
  7. package/dist/cjs/codegenv1/enum.d.ts +17 -0
  8. package/dist/cjs/codegenv1/enum.js +43 -0
  9. package/dist/cjs/codegenv1/extension.d.ts +9 -0
  10. package/dist/cjs/codegenv1/extension.js +29 -0
  11. package/dist/cjs/codegenv1/file.d.ts +7 -0
  12. package/dist/cjs/codegenv1/file.js +38 -0
  13. package/dist/cjs/codegenv1/index.d.ts +9 -0
  14. package/dist/cjs/codegenv1/index.js +38 -0
  15. package/dist/cjs/codegenv1/message.d.ts +9 -0
  16. package/dist/cjs/codegenv1/message.js +25 -0
  17. package/dist/cjs/codegenv1/restore-json-names.d.ts +2 -0
  18. package/dist/cjs/codegenv1/restore-json-names.js +27 -0
  19. package/dist/cjs/codegenv1/service.d.ts +8 -0
  20. package/dist/cjs/codegenv1/service.js +28 -0
  21. package/dist/cjs/codegenv1/symbols.d.ts +116 -0
  22. package/dist/cjs/codegenv1/symbols.js +58 -0
  23. package/dist/cjs/codegenv1/types.d.ts +19 -0
  24. package/dist/cjs/codegenv1/types.js +21 -0
  25. package/dist/cjs/create.d.ts +9 -0
  26. package/dist/cjs/create.js +242 -0
  27. package/dist/{esm/descriptor-set.d.ts → cjs/desc-types.d.ts} +144 -242
  28. package/dist/cjs/equals.d.ts +9 -0
  29. package/dist/cjs/equals.js +133 -0
  30. package/dist/cjs/{extension-accessor.d.ts → extensions.d.ts} +11 -7
  31. package/dist/cjs/extensions.js +138 -0
  32. package/dist/cjs/fields.d.ts +22 -0
  33. package/dist/cjs/fields.js +39 -0
  34. package/dist/cjs/from-binary.d.ts +34 -0
  35. package/dist/cjs/from-binary.js +221 -0
  36. package/dist/cjs/from-json.d.ts +48 -0
  37. package/dist/cjs/from-json.js +614 -0
  38. package/dist/cjs/index.d.ts +16 -42
  39. package/dist/cjs/index.js +21 -55
  40. package/dist/cjs/is-message.d.ts +5 -20
  41. package/dist/cjs/is-message.js +11 -29
  42. package/dist/cjs/json-value.d.ts +16 -0
  43. package/dist/cjs/proto-int64.js +2 -2
  44. package/dist/cjs/reflect/error.d.ts +9 -0
  45. package/dist/cjs/reflect/error.js +36 -0
  46. package/dist/cjs/reflect/guard.d.ts +20 -0
  47. package/dist/cjs/reflect/guard.js +78 -0
  48. package/dist/cjs/reflect/index.d.ts +8 -0
  49. package/dist/cjs/reflect/index.js +41 -0
  50. package/dist/cjs/reflect/names.d.ts +23 -0
  51. package/dist/cjs/reflect/names.js +112 -0
  52. package/dist/cjs/reflect/nested-types.d.ts +2 -0
  53. package/dist/cjs/reflect/nested-types.js +38 -0
  54. package/dist/cjs/reflect/reflect-check.d.ts +10 -0
  55. package/dist/cjs/reflect/reflect-check.js +150 -0
  56. package/dist/cjs/reflect/reflect-types.d.ts +136 -0
  57. package/dist/cjs/{extension.js → reflect/reflect-types.js} +1 -0
  58. package/dist/cjs/reflect/reflect.d.ts +23 -0
  59. package/dist/cjs/reflect/reflect.js +409 -0
  60. package/dist/cjs/reflect/registry.d.ts +82 -0
  61. package/dist/cjs/reflect/registry.js +870 -0
  62. package/dist/{esm → cjs/reflect}/scalar.d.ts +21 -1
  63. package/dist/cjs/reflect/scalar.js +298 -0
  64. package/dist/cjs/reflect/unsafe.d.ts +58 -0
  65. package/dist/cjs/reflect/unsafe.js +171 -0
  66. package/dist/cjs/to-binary.d.ts +24 -0
  67. package/dist/cjs/to-binary.js +194 -0
  68. package/dist/cjs/to-json.d.ts +50 -0
  69. package/dist/cjs/to-json.js +384 -0
  70. package/dist/cjs/types.d.ts +68 -0
  71. package/dist/cjs/wire/base64-encoding.d.ts +23 -0
  72. package/dist/cjs/wire/base64-encoding.js +156 -0
  73. package/dist/cjs/wire/binary-encoding.d.ts +242 -0
  74. package/dist/cjs/{binary-encoding.js → wire/binary-encoding.js} +11 -10
  75. package/dist/cjs/wire/index.d.ts +5 -0
  76. package/dist/cjs/wire/index.js +34 -0
  77. package/dist/cjs/wire/size-delimited.d.ts +51 -0
  78. package/dist/cjs/wire/size-delimited.js +154 -0
  79. package/dist/cjs/wire/text-encoding.d.ts +26 -0
  80. package/dist/cjs/wire/text-encoding.js +55 -0
  81. package/dist/cjs/wire/text-format.d.ts +14 -0
  82. package/dist/cjs/{private → wire}/text-format.js +12 -2
  83. package/dist/{esm/google → cjs/wire}/varint.d.ts +2 -2
  84. package/dist/cjs/{google → wire}/varint.js +11 -10
  85. package/dist/cjs/wkt/any.d.ts +38 -0
  86. package/dist/cjs/wkt/any.js +76 -0
  87. package/dist/cjs/{google → wkt/gen/google}/protobuf/any_pb.d.ts +6 -27
  88. package/dist/cjs/wkt/gen/google/protobuf/any_pb.js +22 -0
  89. package/dist/cjs/{google → wkt/gen/google}/protobuf/api_pb.d.ts +14 -38
  90. package/dist/cjs/wkt/gen/google/protobuf/api_pb.js +30 -0
  91. package/dist/cjs/{google → wkt/gen/google}/protobuf/compiler/plugin_pb.d.ts +47 -77
  92. package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +55 -0
  93. package/dist/cjs/{google → wkt/gen/google}/protobuf/descriptor_pb.d.ts +384 -533
  94. package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.js +691 -0
  95. package/dist/{esm → cjs/wkt/gen}/google/protobuf/duration_pb.d.ts +6 -18
  96. package/dist/cjs/wkt/gen/google/protobuf/duration_pb.js +22 -0
  97. package/dist/cjs/wkt/gen/google/protobuf/empty_pb.d.ts +17 -0
  98. package/dist/cjs/wkt/gen/google/protobuf/empty_pb.js +22 -0
  99. package/dist/{esm → cjs/wkt/gen}/google/protobuf/field_mask_pb.d.ts +6 -18
  100. package/dist/cjs/{proto-double.js → wkt/gen/google/protobuf/field_mask_pb.js} +7 -14
  101. package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.d.ts +19 -0
  102. package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.js +22 -0
  103. package/dist/{esm → cjs/wkt/gen}/google/protobuf/struct_pb.d.ts +28 -57
  104. package/dist/cjs/wkt/gen/google/protobuf/struct_pb.js +48 -0
  105. package/dist/{esm → cjs/wkt/gen}/google/protobuf/timestamp_pb.d.ts +6 -21
  106. package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.js +22 -0
  107. package/dist/{esm → cjs/wkt/gen}/google/protobuf/type_pb.d.ts +47 -82
  108. package/dist/cjs/wkt/gen/google/protobuf/type_pb.js +223 -0
  109. package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.d.ts +147 -0
  110. package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.js +46 -0
  111. package/dist/cjs/wkt/index.d.ts +15 -0
  112. package/dist/cjs/wkt/index.js +44 -0
  113. package/dist/cjs/wkt/timestamp.d.ts +21 -0
  114. package/dist/cjs/wkt/timestamp.js +58 -0
  115. package/dist/cjs/wkt/wrappers.d.ts +15 -0
  116. package/dist/cjs/wkt/wrappers.js +43 -0
  117. package/dist/esm/clone.d.ts +6 -0
  118. package/dist/esm/clone.js +73 -0
  119. package/dist/esm/codegenv1/boot.d.ts +63 -0
  120. package/dist/esm/codegenv1/boot.js +97 -0
  121. package/dist/esm/codegenv1/embed.d.ts +43 -0
  122. package/dist/esm/codegenv1/embed.js +232 -0
  123. package/dist/esm/codegenv1/enum.d.ts +17 -0
  124. package/dist/esm/codegenv1/enum.js +38 -0
  125. package/dist/esm/codegenv1/extension.d.ts +9 -0
  126. package/dist/esm/codegenv1/extension.js +25 -0
  127. package/dist/esm/codegenv1/file.d.ts +7 -0
  128. package/dist/esm/codegenv1/file.js +34 -0
  129. package/dist/esm/codegenv1/index.d.ts +9 -0
  130. package/dist/esm/codegenv1/index.js +22 -0
  131. package/dist/esm/codegenv1/message.d.ts +9 -0
  132. package/dist/esm/codegenv1/message.js +21 -0
  133. package/dist/esm/codegenv1/restore-json-names.d.ts +2 -0
  134. package/dist/esm/codegenv1/restore-json-names.js +23 -0
  135. package/dist/esm/codegenv1/service.d.ts +8 -0
  136. package/dist/esm/codegenv1/service.js +24 -0
  137. package/dist/esm/codegenv1/symbols.d.ts +116 -0
  138. package/dist/esm/codegenv1/symbols.js +55 -0
  139. package/dist/esm/codegenv1/types.d.ts +19 -0
  140. package/dist/esm/{field-list.js → codegenv1/types.js} +6 -0
  141. package/dist/esm/create.d.ts +9 -0
  142. package/dist/esm/create.js +239 -0
  143. package/dist/{cjs/descriptor-set.d.ts → esm/desc-types.d.ts} +144 -242
  144. package/dist/esm/equals.d.ts +9 -0
  145. package/dist/esm/equals.js +129 -0
  146. package/dist/esm/{extension-accessor.d.ts → extensions.d.ts} +11 -7
  147. package/dist/esm/extensions.js +130 -0
  148. package/dist/esm/fields.d.ts +22 -0
  149. package/dist/esm/fields.js +34 -0
  150. package/dist/esm/from-binary.d.ts +34 -0
  151. package/dist/esm/from-binary.js +215 -0
  152. package/dist/esm/from-json.d.ts +48 -0
  153. package/dist/esm/from-json.js +607 -0
  154. package/dist/esm/index.d.ts +16 -42
  155. package/dist/esm/index.js +13 -30
  156. package/dist/esm/is-message.d.ts +5 -20
  157. package/dist/esm/is-message.js +11 -29
  158. package/dist/esm/json-value.d.ts +16 -0
  159. package/dist/esm/proto-int64.js +2 -2
  160. package/dist/esm/reflect/error.d.ts +9 -0
  161. package/dist/esm/reflect/error.js +31 -0
  162. package/dist/esm/reflect/guard.d.ts +20 -0
  163. package/dist/esm/reflect/guard.js +70 -0
  164. package/dist/esm/reflect/index.d.ts +8 -0
  165. package/dist/esm/reflect/index.js +21 -0
  166. package/dist/esm/reflect/names.d.ts +23 -0
  167. package/dist/esm/reflect/names.js +106 -0
  168. package/dist/esm/reflect/nested-types.d.ts +2 -0
  169. package/dist/esm/reflect/nested-types.js +34 -0
  170. package/dist/esm/reflect/reflect-check.d.ts +10 -0
  171. package/dist/esm/reflect/reflect-check.js +143 -0
  172. package/dist/esm/reflect/reflect-types.d.ts +136 -0
  173. package/dist/esm/reflect/reflect-types.js +15 -0
  174. package/dist/esm/reflect/reflect.d.ts +23 -0
  175. package/dist/esm/reflect/reflect.js +403 -0
  176. package/dist/esm/reflect/registry.d.ts +82 -0
  177. package/dist/esm/reflect/registry.js +865 -0
  178. package/dist/{cjs → esm/reflect}/scalar.d.ts +21 -1
  179. package/dist/esm/reflect/scalar.js +289 -0
  180. package/dist/esm/reflect/unsafe.d.ts +58 -0
  181. package/dist/esm/reflect/unsafe.js +160 -0
  182. package/dist/esm/to-binary.d.ts +24 -0
  183. package/dist/esm/to-binary.js +189 -0
  184. package/dist/esm/to-json.d.ts +50 -0
  185. package/dist/esm/to-json.js +379 -0
  186. package/dist/esm/types.d.ts +68 -0
  187. package/dist/esm/wire/base64-encoding.d.ts +23 -0
  188. package/dist/esm/wire/base64-encoding.js +151 -0
  189. package/dist/esm/wire/binary-encoding.d.ts +242 -0
  190. package/dist/esm/{binary-encoding.js → wire/binary-encoding.js} +11 -10
  191. package/dist/esm/wire/index.d.ts +5 -0
  192. package/dist/esm/wire/index.js +18 -0
  193. package/dist/esm/wire/size-delimited.d.ts +51 -0
  194. package/dist/esm/wire/size-delimited.js +148 -0
  195. package/dist/esm/wire/text-encoding.d.ts +26 -0
  196. package/dist/esm/wire/text-encoding.js +50 -0
  197. package/dist/esm/wire/text-format.d.ts +14 -0
  198. package/dist/esm/{private → wire}/text-format.js +12 -2
  199. package/dist/{cjs/google → esm/wire}/varint.d.ts +2 -2
  200. package/dist/esm/{google → wire}/varint.js +11 -10
  201. package/dist/esm/wkt/any.d.ts +38 -0
  202. package/dist/esm/wkt/any.js +69 -0
  203. package/dist/esm/{google → wkt/gen/google}/protobuf/any_pb.d.ts +6 -27
  204. package/dist/esm/wkt/gen/google/protobuf/any_pb.js +19 -0
  205. package/dist/esm/{google → wkt/gen/google}/protobuf/api_pb.d.ts +14 -38
  206. package/dist/esm/wkt/gen/google/protobuf/api_pb.js +27 -0
  207. package/dist/esm/{google → wkt/gen/google}/protobuf/compiler/plugin_pb.d.ts +47 -77
  208. package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +52 -0
  209. package/dist/esm/{google → wkt/gen/google}/protobuf/descriptor_pb.d.ts +384 -533
  210. package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +687 -0
  211. package/dist/{cjs → esm/wkt/gen}/google/protobuf/duration_pb.d.ts +6 -18
  212. package/dist/esm/wkt/gen/google/protobuf/duration_pb.js +19 -0
  213. package/dist/esm/wkt/gen/google/protobuf/empty_pb.d.ts +17 -0
  214. package/dist/esm/wkt/gen/google/protobuf/empty_pb.js +19 -0
  215. package/dist/{cjs → esm/wkt/gen}/google/protobuf/field_mask_pb.d.ts +6 -18
  216. package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +19 -0
  217. package/dist/esm/wkt/gen/google/protobuf/source_context_pb.d.ts +19 -0
  218. package/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +19 -0
  219. package/dist/{cjs → esm/wkt/gen}/google/protobuf/struct_pb.d.ts +28 -57
  220. package/dist/esm/wkt/gen/google/protobuf/struct_pb.js +45 -0
  221. package/dist/{cjs → esm/wkt/gen}/google/protobuf/timestamp_pb.d.ts +6 -21
  222. package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +19 -0
  223. package/dist/{cjs → esm/wkt/gen}/google/protobuf/type_pb.d.ts +47 -82
  224. package/dist/esm/wkt/gen/google/protobuf/type_pb.js +220 -0
  225. package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.d.ts +147 -0
  226. package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +43 -0
  227. package/dist/esm/wkt/index.d.ts +15 -0
  228. package/dist/esm/wkt/index.js +28 -0
  229. package/dist/esm/wkt/timestamp.d.ts +21 -0
  230. package/dist/esm/wkt/timestamp.js +50 -0
  231. package/dist/esm/wkt/wrappers.d.ts +15 -0
  232. package/dist/esm/wkt/wrappers.js +38 -0
  233. package/package.json +37 -5
  234. package/dist/cjs/binary-encoding.d.ts +0 -420
  235. package/dist/cjs/binary-format.d.ts +0 -113
  236. package/dist/cjs/codegen-info.d.ts +0 -33
  237. package/dist/cjs/codegen-info.js +0 -69
  238. package/dist/cjs/create-descriptor-set.d.ts +0 -36
  239. package/dist/cjs/create-descriptor-set.js +0 -910
  240. package/dist/cjs/create-registry-from-desc.d.ts +0 -15
  241. package/dist/cjs/create-registry-from-desc.js +0 -264
  242. package/dist/cjs/create-registry.d.ts +0 -9
  243. package/dist/cjs/create-registry.js +0 -94
  244. package/dist/cjs/enum.d.ts +0 -35
  245. package/dist/cjs/extension-accessor.js +0 -114
  246. package/dist/cjs/extension.d.ts +0 -24
  247. package/dist/cjs/field-list.d.ts +0 -27
  248. package/dist/cjs/field-list.js +0 -15
  249. package/dist/cjs/field.d.ts +0 -314
  250. package/dist/cjs/field.js +0 -15
  251. package/dist/cjs/google/protobuf/any_pb.js +0 -273
  252. package/dist/cjs/google/protobuf/api_pb.js +0 -316
  253. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +0 -219
  254. package/dist/cjs/google/protobuf/descriptor_pb.js +0 -2034
  255. package/dist/cjs/google/protobuf/duration_pb.js +0 -169
  256. package/dist/cjs/google/protobuf/empty_pb.d.ts +0 -28
  257. package/dist/cjs/google/protobuf/empty_pb.js +0 -52
  258. package/dist/cjs/google/protobuf/field_mask_pb.js +0 -311
  259. package/dist/cjs/google/protobuf/source_context_pb.d.ts +0 -29
  260. package/dist/cjs/google/protobuf/source_context_pb.js +0 -55
  261. package/dist/cjs/google/protobuf/struct_pb.js +0 -240
  262. package/dist/cjs/google/protobuf/timestamp_pb.js +0 -213
  263. package/dist/cjs/google/protobuf/type_pb.js +0 -562
  264. package/dist/cjs/google/protobuf/wrappers_pb.d.ts +0 -267
  265. package/dist/cjs/google/protobuf/wrappers_pb.js +0 -569
  266. package/dist/cjs/json-format.d.ts +0 -111
  267. package/dist/cjs/json-format.js +0 -15
  268. package/dist/cjs/message-type.d.ts +0 -51
  269. package/dist/cjs/message-type.js +0 -15
  270. package/dist/cjs/message.d.ts +0 -131
  271. package/dist/cjs/message.js +0 -129
  272. package/dist/cjs/private/binary-format.d.ts +0 -7
  273. package/dist/cjs/private/binary-format.js +0 -430
  274. package/dist/cjs/private/enum.d.ts +0 -27
  275. package/dist/cjs/private/enum.js +0 -94
  276. package/dist/cjs/private/extensions.d.ts +0 -34
  277. package/dist/cjs/private/extensions.js +0 -86
  278. package/dist/cjs/private/feature-set.d.ts +0 -19
  279. package/dist/cjs/private/feature-set.js +0 -106
  280. package/dist/cjs/private/field-list.d.ts +0 -18
  281. package/dist/cjs/private/field-list.js +0 -76
  282. package/dist/cjs/private/field-normalize.d.ts +0 -9
  283. package/dist/cjs/private/field-normalize.js +0 -69
  284. package/dist/cjs/private/field-wrapper.d.ts +0 -25
  285. package/dist/cjs/private/field-wrapper.js +0 -57
  286. package/dist/cjs/private/field.d.ts +0 -16
  287. package/dist/cjs/private/field.js +0 -45
  288. package/dist/cjs/private/json-format.d.ts +0 -2
  289. package/dist/cjs/private/json-format.js +0 -626
  290. package/dist/cjs/private/message-type.d.ts +0 -18
  291. package/dist/cjs/private/message-type.js +0 -50
  292. package/dist/cjs/private/names.d.ts +0 -43
  293. package/dist/cjs/private/names.js +0 -278
  294. package/dist/cjs/private/options-map.d.ts +0 -7
  295. package/dist/cjs/private/options-map.js +0 -15
  296. package/dist/cjs/private/proto-runtime.d.ts +0 -53
  297. package/dist/cjs/private/proto-runtime.js +0 -41
  298. package/dist/cjs/private/reflect.d.ts +0 -9
  299. package/dist/cjs/private/reflect.js +0 -79
  300. package/dist/cjs/private/reify-wkt.d.ts +0 -102
  301. package/dist/cjs/private/reify-wkt.js +0 -172
  302. package/dist/cjs/private/scalars.d.ts +0 -18
  303. package/dist/cjs/private/scalars.js +0 -105
  304. package/dist/cjs/private/text-format.d.ts +0 -4
  305. package/dist/cjs/private/util-common.d.ts +0 -2
  306. package/dist/cjs/private/util-common.js +0 -237
  307. package/dist/cjs/private/util.d.ts +0 -38
  308. package/dist/cjs/private/util.js +0 -15
  309. package/dist/cjs/proto-base64.d.ts +0 -18
  310. package/dist/cjs/proto-base64.js +0 -128
  311. package/dist/cjs/proto-delimited.d.ts +0 -54
  312. package/dist/cjs/proto-delimited.js +0 -155
  313. package/dist/cjs/proto-double.d.ts +0 -5
  314. package/dist/cjs/proto2.d.ts +0 -4
  315. package/dist/cjs/proto2.js +0 -53
  316. package/dist/cjs/proto3.d.ts +0 -4
  317. package/dist/cjs/proto3.js +0 -56
  318. package/dist/cjs/scalar.js +0 -81
  319. package/dist/cjs/service-type.d.ts +0 -96
  320. package/dist/cjs/service-type.js +0 -53
  321. package/dist/cjs/to-plain-message.d.ts +0 -12
  322. package/dist/cjs/to-plain-message.js +0 -72
  323. package/dist/cjs/type-registry.d.ts +0 -57
  324. package/dist/cjs/type-registry.js +0 -15
  325. package/dist/esm/binary-encoding.d.ts +0 -420
  326. package/dist/esm/binary-format.d.ts +0 -113
  327. package/dist/esm/codegen-info.d.ts +0 -33
  328. package/dist/esm/codegen-info.js +0 -67
  329. package/dist/esm/create-descriptor-set.d.ts +0 -36
  330. package/dist/esm/create-descriptor-set.js +0 -906
  331. package/dist/esm/create-registry-from-desc.d.ts +0 -15
  332. package/dist/esm/create-registry-from-desc.js +0 -261
  333. package/dist/esm/create-registry.d.ts +0 -9
  334. package/dist/esm/create-registry.js +0 -90
  335. package/dist/esm/descriptor-set.js +0 -14
  336. package/dist/esm/enum.d.ts +0 -35
  337. package/dist/esm/extension-accessor.js +0 -107
  338. package/dist/esm/extension.d.ts +0 -24
  339. package/dist/esm/field-list.d.ts +0 -27
  340. package/dist/esm/field.d.ts +0 -314
  341. package/dist/esm/field.js +0 -14
  342. package/dist/esm/google/protobuf/any_pb.js +0 -269
  343. package/dist/esm/google/protobuf/api_pb.js +0 -310
  344. package/dist/esm/google/protobuf/compiler/plugin_pb.js +0 -212
  345. package/dist/esm/google/protobuf/descriptor_pb.js +0 -1999
  346. package/dist/esm/google/protobuf/duration_pb.js +0 -165
  347. package/dist/esm/google/protobuf/empty_pb.d.ts +0 -28
  348. package/dist/esm/google/protobuf/empty_pb.js +0 -48
  349. package/dist/esm/google/protobuf/field_mask_pb.js +0 -307
  350. package/dist/esm/google/protobuf/source_context_pb.d.ts +0 -29
  351. package/dist/esm/google/protobuf/source_context_pb.js +0 -51
  352. package/dist/esm/google/protobuf/struct_pb.js +0 -234
  353. package/dist/esm/google/protobuf/timestamp_pb.js +0 -209
  354. package/dist/esm/google/protobuf/type_pb.js +0 -554
  355. package/dist/esm/google/protobuf/wrappers_pb.d.ts +0 -267
  356. package/dist/esm/google/protobuf/wrappers_pb.js +0 -557
  357. package/dist/esm/json-format.d.ts +0 -111
  358. package/dist/esm/json-format.js +0 -14
  359. package/dist/esm/message-type.d.ts +0 -51
  360. package/dist/esm/message-type.js +0 -14
  361. package/dist/esm/message.d.ts +0 -131
  362. package/dist/esm/message.js +0 -125
  363. package/dist/esm/private/binary-format.d.ts +0 -7
  364. package/dist/esm/private/binary-format.js +0 -426
  365. package/dist/esm/private/enum.d.ts +0 -27
  366. package/dist/esm/private/enum.js +0 -87
  367. package/dist/esm/private/extensions.d.ts +0 -34
  368. package/dist/esm/private/extensions.js +0 -81
  369. package/dist/esm/private/feature-set.d.ts +0 -19
  370. package/dist/esm/private/feature-set.js +0 -102
  371. package/dist/esm/private/field-list.d.ts +0 -18
  372. package/dist/esm/private/field-list.js +0 -72
  373. package/dist/esm/private/field-normalize.d.ts +0 -9
  374. package/dist/esm/private/field-normalize.js +0 -65
  375. package/dist/esm/private/field-wrapper.d.ts +0 -25
  376. package/dist/esm/private/field-wrapper.js +0 -53
  377. package/dist/esm/private/field.d.ts +0 -16
  378. package/dist/esm/private/field.js +0 -41
  379. package/dist/esm/private/json-format.d.ts +0 -2
  380. package/dist/esm/private/json-format.js +0 -623
  381. package/dist/esm/private/message-type.d.ts +0 -18
  382. package/dist/esm/private/message-type.js +0 -46
  383. package/dist/esm/private/names.d.ts +0 -43
  384. package/dist/esm/private/names.js +0 -269
  385. package/dist/esm/private/options-map.d.ts +0 -7
  386. package/dist/esm/private/options-map.js +0 -14
  387. package/dist/esm/private/proto-runtime.d.ts +0 -53
  388. package/dist/esm/private/proto-runtime.js +0 -37
  389. package/dist/esm/private/reflect.d.ts +0 -9
  390. package/dist/esm/private/reflect.js +0 -74
  391. package/dist/esm/private/reify-wkt.d.ts +0 -102
  392. package/dist/esm/private/reify-wkt.js +0 -168
  393. package/dist/esm/private/scalars.d.ts +0 -18
  394. package/dist/esm/private/scalars.js +0 -99
  395. package/dist/esm/private/text-format.d.ts +0 -4
  396. package/dist/esm/private/util-common.d.ts +0 -2
  397. package/dist/esm/private/util-common.js +0 -234
  398. package/dist/esm/private/util.d.ts +0 -38
  399. package/dist/esm/private/util.js +0 -14
  400. package/dist/esm/proto-base64.d.ts +0 -18
  401. package/dist/esm/proto-base64.js +0 -125
  402. package/dist/esm/proto-delimited.d.ts +0 -54
  403. package/dist/esm/proto-delimited.js +0 -152
  404. package/dist/esm/proto-double.d.ts +0 -5
  405. package/dist/esm/proto-double.js +0 -26
  406. package/dist/esm/proto2.d.ts +0 -4
  407. package/dist/esm/proto2.js +0 -50
  408. package/dist/esm/proto3.d.ts +0 -4
  409. package/dist/esm/proto3.js +0 -53
  410. package/dist/esm/scalar.js +0 -78
  411. package/dist/esm/service-type.d.ts +0 -96
  412. package/dist/esm/service-type.js +0 -50
  413. package/dist/esm/to-plain-message.d.ts +0 -12
  414. package/dist/esm/to-plain-message.js +0 -70
  415. package/dist/esm/type-registry.d.ts +0 -57
  416. package/dist/esm/type-registry.js +0 -14
  417. /package/dist/cjs/{binary-format.js → desc-types.js} +0 -0
  418. /package/dist/cjs/{descriptor-set.js → json-value.js} +0 -0
  419. /package/dist/cjs/{private → reflect}/assert.d.ts +0 -0
  420. /package/dist/cjs/{private → reflect}/assert.js +0 -0
  421. /package/dist/cjs/{enum.js → types.js} +0 -0
  422. /package/dist/esm/{binary-format.js → desc-types.js} +0 -0
  423. /package/dist/esm/{enum.js → json-value.js} +0 -0
  424. /package/dist/esm/{private → reflect}/assert.d.ts +0 -0
  425. /package/dist/esm/{private → reflect}/assert.js +0 -0
  426. /package/dist/esm/{extension.js → types.js} +0 -0
@@ -0,0 +1,148 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
15
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
16
+ var m = o[Symbol.asyncIterator], i;
17
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
18
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
19
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
20
+ };
21
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
22
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
23
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
25
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
26
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
27
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
28
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
29
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
30
+ function fulfill(value) { resume("next", value); }
31
+ function reject(value) { resume("throw", value); }
32
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
33
+ };
34
+ import { toBinary } from "../to-binary.js";
35
+ import { BinaryReader, BinaryWriter } from "./binary-encoding.js";
36
+ import { fromBinary } from "../from-binary.js";
37
+ /**
38
+ * Serialize a message, prefixing it with its size.
39
+ *
40
+ * A size-delimited message is a varint size in bytes, followed by exactly
41
+ * that many bytes of a message serialized with the binary format.
42
+ *
43
+ * This size-delimited format is compatible with other implementations.
44
+ * For details, see https://github.com/protocolbuffers/protobuf/issues/10229
45
+ */
46
+ export function sizeDelimitedEncode(messageDesc, message, options) {
47
+ const writer = new BinaryWriter();
48
+ writer.bytes(toBinary(messageDesc, message, options));
49
+ return writer.finish();
50
+ }
51
+ /**
52
+ * Parse a stream of size-delimited messages.
53
+ *
54
+ * A size-delimited message is a varint size in bytes, followed by exactly
55
+ * that many bytes of a message serialized with the binary format.
56
+ *
57
+ * This size-delimited format is compatible with other implementations.
58
+ * For details, see https://github.com/protocolbuffers/protobuf/issues/10229
59
+ */
60
+ export function sizeDelimitedDecodeStream(messageDesc, iterable, options) {
61
+ return __asyncGenerator(this, arguments, function* sizeDelimitedDecodeStream_1() {
62
+ var _a, e_1, _b, _c;
63
+ // append chunk to buffer, returning updated buffer
64
+ function append(buffer, chunk) {
65
+ const n = new Uint8Array(buffer.byteLength + chunk.byteLength);
66
+ n.set(buffer);
67
+ n.set(chunk, buffer.length);
68
+ return n;
69
+ }
70
+ let buffer = new Uint8Array(0);
71
+ try {
72
+ for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = yield __await(iterable_1.next()), _a = iterable_1_1.done, !_a; _d = true) {
73
+ _c = iterable_1_1.value;
74
+ _d = false;
75
+ const chunk = _c;
76
+ buffer = append(buffer, chunk);
77
+ for (;;) {
78
+ const size = sizeDelimitedPeek(buffer);
79
+ if (size.eof) {
80
+ // size is incomplete, buffer more data
81
+ break;
82
+ }
83
+ if (size.offset + size.size > buffer.byteLength) {
84
+ // message is incomplete, buffer more data
85
+ break;
86
+ }
87
+ yield yield __await(fromBinary(messageDesc, buffer.subarray(size.offset, size.offset + size.size), options));
88
+ buffer = buffer.subarray(size.offset + size.size);
89
+ }
90
+ }
91
+ }
92
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
93
+ finally {
94
+ try {
95
+ if (!_d && !_a && (_b = iterable_1.return)) yield __await(_b.call(iterable_1));
96
+ }
97
+ finally { if (e_1) throw e_1.error; }
98
+ }
99
+ if (buffer.byteLength > 0) {
100
+ throw new Error("incomplete data");
101
+ }
102
+ });
103
+ }
104
+ /**
105
+ * Decodes the size from the given size-delimited message, which may be
106
+ * incomplete.
107
+ *
108
+ * Returns an object with the following properties:
109
+ * - size: The size of the delimited message in bytes
110
+ * - offset: The offset in the given byte array where the message starts
111
+ * - eof: true
112
+ *
113
+ * If the size-delimited data does not include all bytes of the varint size,
114
+ * the following object is returned:
115
+ * - size: null
116
+ * - offset: null
117
+ * - eof: false
118
+ *
119
+ * This function can be used to implement parsing of size-delimited messages
120
+ * from a stream.
121
+ */
122
+ export function sizeDelimitedPeek(data) {
123
+ const sizeEof = { eof: true, size: null, offset: null };
124
+ for (let i = 0; i < 10; i++) {
125
+ if (i > data.byteLength) {
126
+ return sizeEof;
127
+ }
128
+ if ((data[i] & 0x80) == 0) {
129
+ const reader = new BinaryReader(data);
130
+ let size;
131
+ try {
132
+ size = reader.uint32();
133
+ }
134
+ catch (e) {
135
+ if (e instanceof RangeError) {
136
+ return sizeEof;
137
+ }
138
+ throw e;
139
+ }
140
+ return {
141
+ eof: false,
142
+ size,
143
+ offset: reader.pos,
144
+ };
145
+ }
146
+ }
147
+ throw new Error("invalid varint");
148
+ }
@@ -0,0 +1,26 @@
1
+ interface TextEncoding {
2
+ /**
3
+ * Verify that the given text is valid UTF-8.
4
+ */
5
+ checkUtf8: (text: string) => boolean;
6
+ /**
7
+ * Encode UTF-8 text to binary.
8
+ */
9
+ encodeUtf8: (text: string) => Uint8Array;
10
+ /**
11
+ * Decode UTF-8 text from binary.
12
+ */
13
+ decodeUtf8: (bytes: Uint8Array) => string;
14
+ }
15
+ /**
16
+ * Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to
17
+ * binary. This WHATWG API is widely available, but it is not part of the
18
+ * ECMAScript standard. On runtimes where it is not available, use this
19
+ * function to provide your own implementation.
20
+ *
21
+ * Note that the Text Encoding API does not provide a way to validate UTF-8.
22
+ * Our implementation falls back to use encodeURIComponent().
23
+ */
24
+ export declare function configureTextEncoding(textEncoding: TextEncoding): void;
25
+ export declare function getTextEncoding(): TextEncoding;
26
+ export {};
@@ -0,0 +1,50 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ const symbol = Symbol.for("@bufbuild/protobuf/text-encoding");
15
+ /**
16
+ * Protobuf-ES requires the Text Encoding API to convert UTF-8 from and to
17
+ * binary. This WHATWG API is widely available, but it is not part of the
18
+ * ECMAScript standard. On runtimes where it is not available, use this
19
+ * function to provide your own implementation.
20
+ *
21
+ * Note that the Text Encoding API does not provide a way to validate UTF-8.
22
+ * Our implementation falls back to use encodeURIComponent().
23
+ */
24
+ export function configureTextEncoding(textEncoding) {
25
+ globalThis[symbol] = textEncoding;
26
+ }
27
+ export function getTextEncoding() {
28
+ if (globalThis[symbol] == undefined) {
29
+ const te = new globalThis.TextEncoder();
30
+ const td = new globalThis.TextDecoder();
31
+ globalThis[symbol] = {
32
+ encodeUtf8(text) {
33
+ return te.encode(text);
34
+ },
35
+ decodeUtf8(bytes) {
36
+ return td.decode(bytes);
37
+ },
38
+ checkUtf8(text) {
39
+ try {
40
+ encodeURIComponent(text);
41
+ return true;
42
+ }
43
+ catch (e) {
44
+ return false;
45
+ }
46
+ },
47
+ };
48
+ }
49
+ return globalThis[symbol];
50
+ }
@@ -0,0 +1,14 @@
1
+ import type { DescEnum } from "../desc-types.js";
2
+ import { ScalarType } from "../reflect/scalar.js";
3
+ /**
4
+ * Parse an enum value from the Protobuf text format.
5
+ *
6
+ * @private
7
+ */
8
+ export declare function parseTextFormatEnumValue(descEnum: DescEnum, value: string): number;
9
+ /**
10
+ * Parse a scalar value from the Protobuf text format.
11
+ *
12
+ * @private
13
+ */
14
+ export declare function parseTextFormatScalarValue(type: ScalarType, value: string): number | boolean | string | bigint | Uint8Array;
@@ -11,14 +11,24 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { assert } from "./assert.js";
14
+ import { assert } from "../reflect/assert.js";
15
15
  import { protoInt64 } from "../proto-int64.js";
16
- import { ScalarType } from "../scalar.js";
16
+ import { ScalarType } from "../reflect/scalar.js";
17
+ /**
18
+ * Parse an enum value from the Protobuf text format.
19
+ *
20
+ * @private
21
+ */
17
22
  export function parseTextFormatEnumValue(descEnum, value) {
18
23
  const enumValue = descEnum.values.find((v) => v.name === value);
19
24
  assert(enumValue, `cannot parse ${descEnum.name} default value: ${value}`);
20
25
  return enumValue.number;
21
26
  }
27
+ /**
28
+ * Parse a scalar value from the Protobuf text format.
29
+ *
30
+ * @private
31
+ */
22
32
  export function parseTextFormatScalarValue(type, value) {
23
33
  switch (type) {
24
34
  case ScalarType.STRING:
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175
11
11
  */
12
- export declare function varint64read(this: ReaderLike): [number, number];
12
+ export declare function varint64read<T extends ReaderLike>(this: T): [number, number];
13
13
  /**
14
14
  * Write a 64 bit varint, given as two JS numbers, to the given bytes array.
15
15
  *
@@ -60,7 +60,7 @@ export declare function varint32write(value: number, bytes: number[]): void;
60
60
  *
61
61
  * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220
62
62
  */
63
- export declare function varint32read(this: ReaderLike): number;
63
+ export declare function varint32read<T extends ReaderLike>(this: T): number;
64
64
  type ReaderLike = {
65
65
  buf: Uint8Array;
66
66
  pos: number;
@@ -156,7 +156,7 @@ export function int64ToString(lo, hi) {
156
156
  let bits = newBits(lo, hi);
157
157
  // If we're treating the input as a signed value and the high bit is set, do
158
158
  // a manual two's complement conversion before the decimal conversion.
159
- const negative = (bits.hi & 0x80000000);
159
+ const negative = bits.hi & 0x80000000;
160
160
  if (negative) {
161
161
  bits = negate(bits.lo, bits.hi);
162
162
  }
@@ -179,7 +179,7 @@ export function uInt64ToString(lo, hi) {
179
179
  // highBits <= 0x1FFFFF can be safely expressed with a double and retain
180
180
  // integer precision.
181
181
  // Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true.
182
- if (hi <= 0x1FFFFF) {
182
+ if (hi <= 0x1fffff) {
183
183
  return String(TWO_PWR_32_DBL * hi + lo);
184
184
  }
185
185
  // What this code is doing is essentially converting the input number from
@@ -191,15 +191,15 @@ export function uInt64ToString(lo, hi) {
191
191
  // 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.
192
192
  // Split 32:32 representation into 16:24:24 representation so our
193
193
  // intermediate digits don't overflow.
194
- const low = lo & 0xFFFFFF;
195
- const mid = ((lo >>> 24) | (hi << 8)) & 0xFFFFFF;
196
- const high = (hi >> 16) & 0xFFFF;
194
+ const low = lo & 0xffffff;
195
+ const mid = ((lo >>> 24) | (hi << 8)) & 0xffffff;
196
+ const high = (hi >> 16) & 0xffff;
197
197
  // Assemble our three base-1e7 digits, ignoring carries. The maximum
198
198
  // value in a digit at this step is representable as a 48-bit integer, which
199
199
  // can be stored in a 64-bit floating point number.
200
- let digitA = low + (mid * 6777216) + (high * 6710656);
201
- let digitB = mid + (high * 8147497);
202
- let digitC = (high * 2);
200
+ let digitA = low + mid * 6777216 + high * 6710656;
201
+ let digitB = mid + high * 8147497;
202
+ let digitC = high * 2;
203
203
  // Apply carries from A to B and from B to C.
204
204
  const base = 10000000;
205
205
  if (digitA >= base) {
@@ -213,8 +213,9 @@ export function uInt64ToString(lo, hi) {
213
213
  // If digitC is 0, then we should have returned in the trivial code path
214
214
  // at the top for non-safe integers. Given this, we can assume both digitB
215
215
  // and digitA need leading zeros.
216
- return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) +
217
- decimalFrom1e7WithLeadingZeros(digitA);
216
+ return (digitC.toString() +
217
+ decimalFrom1e7WithLeadingZeros(digitB) +
218
+ decimalFrom1e7WithLeadingZeros(digitA));
218
219
  }
219
220
  function toUnsigned(lo, hi) {
220
221
  return { lo: lo >>> 0, hi: hi >>> 0 };
@@ -0,0 +1,38 @@
1
+ import type { Message, MessageShape } from "../types.js";
2
+ import type { Any } from "./gen/google/protobuf/any_pb.js";
3
+ import type { DescMessage } from "../desc-types.js";
4
+ import type { Registry } from "../reflect/index.js";
5
+ /**
6
+ * Creates a `google.protobuf.Any` from a message.
7
+ */
8
+ export declare function anyPack<Desc extends DescMessage>(messageDesc: Desc, message: MessageShape<Desc>): Any;
9
+ /**
10
+ * Packs the message into the given any.
11
+ */
12
+ export declare function anyPack<Desc extends DescMessage>(messageDesc: Desc, message: MessageShape<Desc>, into: Any): void;
13
+ /**
14
+ * Returns true if the Any contains the type given by messageDesc.
15
+ */
16
+ export declare function anyIs(any: Any, messageDesc: DescMessage): boolean;
17
+ /**
18
+ * Returns true if the Any contains a message with the given typeName.
19
+ */
20
+ export declare function anyIs(any: Any, typeName: string): boolean;
21
+ /**
22
+ * Unpacks the message the Any represents.
23
+ *
24
+ * Returns undefined if the Any is empty, or if packed type is not included
25
+ * in the given registry.
26
+ */
27
+ export declare function anyUnpack(any: Any, registry: Registry): Message | undefined;
28
+ /**
29
+ * Unpacks the message the Any represents.
30
+ *
31
+ * Returns undefined if the Any is empty, or if it does not contain the type
32
+ * given by messageDesc.
33
+ */
34
+ export declare function anyUnpack<Desc extends DescMessage>(any: Any, messageDesc: Desc): MessageShape<Desc> | undefined;
35
+ /**
36
+ * Same as anyUnpack but unpacks into the target message.
37
+ */
38
+ export declare function anyUnpackTo<Desc extends DescMessage>(any: Any, messageDesc: Desc, message: MessageShape<Desc>): MessageShape<Desc> | undefined;
@@ -0,0 +1,69 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { AnyDesc } from "./gen/google/protobuf/any_pb.js";
15
+ import { create } from "../create.js";
16
+ import { toBinary } from "../to-binary.js";
17
+ import { fromBinary, mergeFromBinary } from "../from-binary.js";
18
+ export function anyPack(messageDesc, message, into) {
19
+ let ret = false;
20
+ if (!into) {
21
+ into = create(AnyDesc);
22
+ ret = true;
23
+ }
24
+ into.value = toBinary(messageDesc, message);
25
+ into.typeUrl = typeNameToUrl(message.$typeName);
26
+ return ret ? into : undefined;
27
+ }
28
+ export function anyIs(any, descOrTypeName) {
29
+ if (any.typeUrl === "") {
30
+ return false;
31
+ }
32
+ const want = typeof descOrTypeName == "string"
33
+ ? descOrTypeName
34
+ : descOrTypeName.typeName;
35
+ const got = typeUrlToName(any.typeUrl);
36
+ return want === got;
37
+ }
38
+ export function anyUnpack(any, registryOrMessageDesc) {
39
+ if (any.typeUrl === "") {
40
+ return undefined;
41
+ }
42
+ const desc = registryOrMessageDesc.kind == "message"
43
+ ? registryOrMessageDesc
44
+ : registryOrMessageDesc.getMessage(typeUrlToName(any.typeUrl));
45
+ if (!desc) {
46
+ return undefined;
47
+ }
48
+ return fromBinary(desc, any.value);
49
+ }
50
+ /**
51
+ * Same as anyUnpack but unpacks into the target message.
52
+ */
53
+ export function anyUnpackTo(any, messageDesc, message) {
54
+ if (any.typeUrl === "") {
55
+ return undefined;
56
+ }
57
+ return mergeFromBinary(messageDesc, message, any.value);
58
+ }
59
+ function typeNameToUrl(name) {
60
+ return `type.googleapis.com/${name}`;
61
+ }
62
+ function typeUrlToName(url) {
63
+ const slash = url.lastIndexOf("/");
64
+ const name = slash >= 0 ? url.substring(slash + 1) : url;
65
+ if (!name.length) {
66
+ throw new Error(`invalid type url: ${url}`);
67
+ }
68
+ return name;
69
+ }
@@ -1,11 +1,6 @@
1
- import type { PartialMessage, PlainMessage } from "../../message.js";
2
- import { Message } from "../../message.js";
3
- import { proto3 } from "../../proto3.js";
4
- import type { JsonReadOptions, JsonValue, JsonWriteOptions } from "../../json-format.js";
5
- import type { IMessageTypeRegistry } from "../../type-registry.js";
6
- import type { MessageType } from "../../message-type.js";
7
- import type { FieldList } from "../../field-list.js";
8
- import type { BinaryReadOptions } from "../../binary-format.js";
1
+ import type { GenDescFile, GenDescMessage } from "../../../../codegenv1/types.js";
2
+ import type { Message } from "../../../../types.js";
3
+ export declare const fileDesc_google_protobuf_any: GenDescFile;
9
4
  /**
10
5
  * `Any` contains an arbitrary serialized protocol buffer message along with a
11
6
  * URL that describes the type of the serialized message.
@@ -96,7 +91,7 @@ import type { BinaryReadOptions } from "../../binary-format.js";
96
91
  *
97
92
  * @generated from message google.protobuf.Any
98
93
  */
99
- export declare class Any extends Message<Any> {
94
+ export type Any = Message<"google.protobuf.Any"> & {
100
95
  /**
101
96
  * A URL/resource name that uniquely identifies the type of the serialized
102
97
  * protocol buffer message. This string must contain at least
@@ -137,21 +132,5 @@ export declare class Any extends Message<Any> {
137
132
  * @generated from field: bytes value = 2;
138
133
  */
139
134
  value: Uint8Array;
140
- constructor(data?: PartialMessage<Any>);
141
- toJson(options?: Partial<JsonWriteOptions>): JsonValue;
142
- fromJson(json: JsonValue, options?: Partial<JsonReadOptions>): this;
143
- packFrom(message: Message): void;
144
- unpackTo(target: Message): boolean;
145
- unpack(registry: IMessageTypeRegistry): Message | undefined;
146
- is(type: MessageType | string): boolean;
147
- private typeNameToUrl;
148
- private typeUrlToName;
149
- static readonly runtime: typeof proto3;
150
- static readonly typeName = "google.protobuf.Any";
151
- static readonly fields: FieldList;
152
- static pack(message: Message): Any;
153
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Any;
154
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Any;
155
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Any;
156
- static equals(a: Any | PlainMessage<Any> | undefined, b: Any | PlainMessage<Any> | undefined): boolean;
157
- }
135
+ };
136
+ export declare const AnyDesc: GenDescMessage<Any>;
@@ -0,0 +1,19 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { fileDesc } from "../../../../codegenv1/file.js";
15
+ import { messageDesc } from "../../../../codegenv1/message.js";
16
+ export const fileDesc_google_protobuf_any = /*@__PURE__*/ fileDesc("Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYiJgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2NvbS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM");
17
+ // Describes the message google.protobuf.Any.
18
+ // Use `create(AnyDesc)` to create a new Any.
19
+ export const AnyDesc = /*@__PURE__*/ messageDesc(fileDesc_google_protobuf_any, 0);
@@ -1,11 +1,8 @@
1
- import type { PartialMessage, PlainMessage } from "../../message.js";
2
- import { Message } from "../../message.js";
3
- import { Option, Syntax } from "./type_pb.js";
4
- import { SourceContext } from "./source_context_pb.js";
5
- import { proto3 } from "../../proto3.js";
6
- import type { FieldList } from "../../field-list.js";
7
- import type { BinaryReadOptions } from "../../binary-format.js";
8
- import type { JsonReadOptions, JsonValue } from "../../json-format.js";
1
+ import type { GenDescFile, GenDescMessage } from "../../../../codegenv1/types.js";
2
+ import type { SourceContext } from "./source_context_pb.js";
3
+ import type { Option, Syntax } from "./type_pb.js";
4
+ import type { Message } from "../../../../types.js";
5
+ export declare const fileDesc_google_protobuf_api: GenDescFile;
9
6
  /**
10
7
  * Api is a light-weight descriptor for an API Interface.
11
8
  *
@@ -19,7 +16,7 @@ import type { JsonReadOptions, JsonValue } from "../../json-format.js";
19
16
  *
20
17
  * @generated from message google.protobuf.Api
21
18
  */
22
- export declare class Api extends Message<Api> {
19
+ export type Api = Message<"google.protobuf.Api"> & {
23
20
  /**
24
21
  * The fully qualified name of this interface, including package name
25
22
  * followed by the interface's simple name.
@@ -83,21 +80,14 @@ export declare class Api extends Message<Api> {
83
80
  * @generated from field: google.protobuf.Syntax syntax = 7;
84
81
  */
85
82
  syntax: Syntax;
86
- constructor(data?: PartialMessage<Api>);
87
- static readonly runtime: typeof proto3;
88
- static readonly typeName = "google.protobuf.Api";
89
- static readonly fields: FieldList;
90
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Api;
91
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Api;
92
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Api;
93
- static equals(a: Api | PlainMessage<Api> | undefined, b: Api | PlainMessage<Api> | undefined): boolean;
94
- }
83
+ };
84
+ export declare const ApiDesc: GenDescMessage<Api>;
95
85
  /**
96
86
  * Method represents a method of an API interface.
97
87
  *
98
88
  * @generated from message google.protobuf.Method
99
89
  */
100
- export declare class Method extends Message<Method> {
90
+ export type Method = Message<"google.protobuf.Method"> & {
101
91
  /**
102
92
  * The simple name of this method.
103
93
  *
@@ -140,15 +130,8 @@ export declare class Method extends Message<Method> {
140
130
  * @generated from field: google.protobuf.Syntax syntax = 7;
141
131
  */
142
132
  syntax: Syntax;
143
- constructor(data?: PartialMessage<Method>);
144
- static readonly runtime: typeof proto3;
145
- static readonly typeName = "google.protobuf.Method";
146
- static readonly fields: FieldList;
147
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Method;
148
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Method;
149
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Method;
150
- static equals(a: Method | PlainMessage<Method> | undefined, b: Method | PlainMessage<Method> | undefined): boolean;
151
- }
133
+ };
134
+ export declare const MethodDesc: GenDescMessage<Method>;
152
135
  /**
153
136
  * Declares an API Interface to be included in this interface. The including
154
137
  * interface must redeclare all the methods from the included interface, but
@@ -231,7 +214,7 @@ export declare class Method extends Message<Method> {
231
214
  *
232
215
  * @generated from message google.protobuf.Mixin
233
216
  */
234
- export declare class Mixin extends Message<Mixin> {
217
+ export type Mixin = Message<"google.protobuf.Mixin"> & {
235
218
  /**
236
219
  * The fully qualified name of the interface which is included.
237
220
  *
@@ -245,12 +228,5 @@ export declare class Mixin extends Message<Mixin> {
245
228
  * @generated from field: string root = 2;
246
229
  */
247
230
  root: string;
248
- constructor(data?: PartialMessage<Mixin>);
249
- static readonly runtime: typeof proto3;
250
- static readonly typeName = "google.protobuf.Mixin";
251
- static readonly fields: FieldList;
252
- static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Mixin;
253
- static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Mixin;
254
- static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Mixin;
255
- static equals(a: Mixin | PlainMessage<Mixin> | undefined, b: Mixin | PlainMessage<Mixin> | undefined): boolean;
256
- }
231
+ };
232
+ export declare const MixinDesc: GenDescMessage<Mixin>;
@@ -0,0 +1,27 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { fileDesc } from "../../../../codegenv1/file.js";
15
+ import { fileDesc_google_protobuf_source_context } from "./source_context_pb.js";
16
+ import { fileDesc_google_protobuf_type } from "./type_pb.js";
17
+ import { messageDesc } from "../../../../codegenv1/message.js";
18
+ export const fileDesc_google_protobuf_api = /*@__PURE__*/ fileDesc("Chlnb29nbGUvcHJvdG9idWYvYXBpLnByb3RvEg9nb29nbGUucHJvdG9idWYigQIKA0FwaRIMCgRuYW1lGAEgASgJEigKB21ldGhvZHMYAiADKAsyFy5nb29nbGUucHJvdG9idWYuTWV0aG9kEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9uEg8KB3ZlcnNpb24YBCABKAkSNgoOc291cmNlX2NvbnRleHQYBSABKAsyHi5nb29nbGUucHJvdG9idWYuU291cmNlQ29udGV4dBImCgZtaXhpbnMYBiADKAsyFi5nb29nbGUucHJvdG9idWYuTWl4aW4SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRheCLVAQoGTWV0aG9kEgwKBG5hbWUYASABKAkSGAoQcmVxdWVzdF90eXBlX3VybBgCIAEoCRIZChFyZXF1ZXN0X3N0cmVhbWluZxgDIAEoCBIZChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1pbmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5PcHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRheCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdgoTY29tLmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVosZ29vZ2xlLmdvbGFuZy5vcmcvcHJvdG9idWYvdHlwZXMva25vd24vYXBpcGKiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw", [fileDesc_google_protobuf_source_context, fileDesc_google_protobuf_type]);
19
+ // Describes the message google.protobuf.Api.
20
+ // Use `create(ApiDesc)` to create a new Api.
21
+ export const ApiDesc = /*@__PURE__*/ messageDesc(fileDesc_google_protobuf_api, 0);
22
+ // Describes the message google.protobuf.Method.
23
+ // Use `create(MethodDesc)` to create a new Method.
24
+ export const MethodDesc = /*@__PURE__*/ messageDesc(fileDesc_google_protobuf_api, 1);
25
+ // Describes the message google.protobuf.Mixin.
26
+ // Use `create(MixinDesc)` to create a new Mixin.
27
+ export const MixinDesc = /*@__PURE__*/ messageDesc(fileDesc_google_protobuf_api, 2);