slidge-whatsapp 0.2.6__cp313-cp313-manylinux_2_36_aarch64.whl → 0.3.0b0__cp313-cp313-manylinux_2_36_aarch64.whl

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.

Potentially problematic release.


This version of slidge-whatsapp might be problematic. Click here for more details.

Files changed (258) hide show
  1. slidge_whatsapp/contact.py +13 -3
  2. slidge_whatsapp/event.go +115 -39
  3. slidge_whatsapp/gateway.go +7 -63
  4. slidge_whatsapp/gateway.py +2 -3
  5. slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.h +156 -139
  6. slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.so +0 -0
  7. slidge_whatsapp/generated/build.py +135 -121
  8. slidge_whatsapp/generated/whatsapp.c +1441 -1169
  9. slidge_whatsapp/generated/whatsapp.go +1090 -979
  10. slidge_whatsapp/generated/whatsapp.py +854 -729
  11. slidge_whatsapp/generated/whatsapp_go.h +156 -139
  12. slidge_whatsapp/go.mod +18 -15
  13. slidge_whatsapp/go.sum +38 -32
  14. slidge_whatsapp/group.py +34 -30
  15. slidge_whatsapp/media/media.go +6 -2
  16. slidge_whatsapp/session.go +33 -16
  17. slidge_whatsapp/session.py +46 -14
  18. slidge_whatsapp/vendor/github.com/beeper/argo-go/LICENSE +9 -0
  19. slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockreader.go +329 -0
  20. slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockwriter.go +417 -0
  21. slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/decoder.go +652 -0
  22. slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/encoder.go +985 -0
  23. slidge_whatsapp/vendor/github.com/beeper/argo-go/header/header.go +135 -0
  24. slidge_whatsapp/vendor/github.com/beeper/argo-go/internal/util/util.go +133 -0
  25. slidge_whatsapp/vendor/github.com/beeper/argo-go/label/label.go +384 -0
  26. slidge_whatsapp/vendor/github.com/beeper/argo-go/label/wiremarkers.go +37 -0
  27. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/bitset/bitset.go +197 -0
  28. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/buf/buf.go +420 -0
  29. slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/varint/varint.go +246 -0
  30. slidge_whatsapp/vendor/github.com/beeper/argo-go/wire/wire.go +614 -0
  31. slidge_whatsapp/vendor/github.com/beeper/argo-go/wirecodec/decode.go +341 -0
  32. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/LICENSE +21 -0
  33. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/list.go +95 -0
  34. slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/orderedmap.go +187 -0
  35. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz.go +1 -0
  36. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_cgo.go +3 -0
  37. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_nocgo.go +4 -5
  38. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_darwin.go +11 -1
  39. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_linux.go +10 -0
  40. slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_windows.go +12 -0
  41. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/.gitignore +0 -2
  42. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/CHANGELOG.md +30 -0
  43. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/COPYRIGHT.txt +6 -1
  44. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/README.md +14 -17
  45. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi.go +1 -1
  46. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi2.go +7 -0
  47. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/LICENSE +21 -0
  48. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_amd64/libffi.8.dylib +0 -0
  49. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_arm64/libffi.8.dylib +0 -0
  50. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/windows_amd64/libffi-8.dll +0 -0
  51. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif.go +15 -0
  52. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif_arm64.go +16 -0
  53. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed.go +49 -0
  54. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_amd64.go +10 -0
  55. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_arm64.go +10 -0
  56. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_windows_amd64.go +10 -0
  57. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/ffi.go +51 -13
  58. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/init.go +22 -9
  59. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/README.md +2 -0
  60. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c +3096 -1651
  61. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h +188 -128
  62. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_userauth.go +13 -140
  63. slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h +4 -0
  64. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.23.go +2 -2
  65. slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.25.go +37 -0
  66. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/LICENSE +19 -0
  67. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/argmap.go +37 -0
  68. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/collections.go +148 -0
  69. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/comment.go +31 -0
  70. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/decode.go +216 -0
  71. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/definition.go +110 -0
  72. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +43 -0
  73. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/document.go +89 -0
  74. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/dumper.go +159 -0
  75. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/fragment.go +41 -0
  76. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/operation.go +32 -0
  77. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/path.go +72 -0
  78. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +41 -0
  79. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/source.go +19 -0
  80. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/type.go +68 -0
  81. slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +122 -0
  82. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/handleerrors.go +60 -26
  83. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/json.go +1 -6
  84. slidge_whatsapp/vendor/go.mau.fi/util/exhttp/networkerror.go +2 -1
  85. slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +104 -0
  86. slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +19 -3
  87. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/.pre-commit-config.yaml +3 -3
  88. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +1 -1
  89. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/hash.go +1 -1
  90. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +5 -1
  91. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo-wire-type-store.argo +63 -0
  92. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo.go +62 -0
  93. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/name-to-queryids.json +306 -0
  94. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +40 -7
  95. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/binary/encoder.go +1 -1
  96. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +2 -1
  97. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +79 -45
  98. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +13 -6
  99. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download-to-file.go +19 -12
  100. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +26 -6
  101. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +3 -0
  102. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +99 -27
  103. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +54 -26
  104. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +1 -0
  105. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +208 -57
  106. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +2 -14
  107. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +83 -7
  108. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +17 -8
  109. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -2
  110. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +15 -6
  111. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/extra.go +7 -0
  112. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +983 -0
  113. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.proto +85 -0
  114. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/extra.go +3 -0
  115. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +197 -0
  116. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.proto +13 -0
  117. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +279 -0
  118. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.proto +21 -0
  119. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +137 -0
  120. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.proto +10 -0
  121. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +313 -0
  122. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.proto +27 -0
  123. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1299 -0
  124. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.proto +112 -0
  125. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +514 -0
  126. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.proto +47 -0
  127. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +123 -0
  128. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.proto +7 -0
  129. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/extra.go +3 -0
  130. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +720 -0
  131. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.proto +59 -0
  132. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/extra.go +3 -0
  133. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +365 -0
  134. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.proto +33 -0
  135. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1238 -0
  136. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.proto +105 -0
  137. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +16 -4
  138. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.proto +3 -0
  139. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.pb.go +5156 -0
  140. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.proto +516 -0
  141. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +46 -10
  142. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +4 -0
  143. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +8975 -11209
  144. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +193 -421
  145. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +52 -23
  146. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +3 -0
  147. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +198 -0
  148. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.proto +14 -0
  149. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/extra.go +7 -6
  150. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +952 -0
  151. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +88 -0
  152. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +1143 -463
  153. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +60 -0
  154. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +60 -38
  155. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +3 -0
  156. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +11 -3
  157. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +2 -0
  158. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +20 -7
  159. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingfields.json +1 -0
  160. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingtoken.go +176 -0
  161. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +10 -2
  162. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +38 -21
  163. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +1 -0
  164. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
  165. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +3 -2
  166. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go +9 -6
  167. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +25 -5
  168. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +4 -2
  169. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/10-chat-db-lid-migration-ts.sql +2 -0
  170. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +5 -1
  171. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +1 -0
  172. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +13 -2
  173. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +2 -1
  174. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +1 -0
  175. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +2 -0
  176. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +14 -8
  177. slidge_whatsapp/vendor/golang.org/x/crypto/curve25519/curve25519.go +1 -1
  178. slidge_whatsapp/vendor/golang.org/x/net/http2/config.go +44 -2
  179. slidge_whatsapp/vendor/golang.org/x/net/http2/frame.go +8 -8
  180. slidge_whatsapp/vendor/golang.org/x/net/http2/gotrack.go +14 -3
  181. slidge_whatsapp/vendor/golang.org/x/net/http2/http2.go +7 -29
  182. slidge_whatsapp/vendor/golang.org/x/net/http2/server.go +53 -71
  183. slidge_whatsapp/vendor/golang.org/x/net/http2/transport.go +20 -74
  184. slidge_whatsapp/vendor/golang.org/x/sys/unix/affinity_linux.go +1 -3
  185. slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +3 -0
  186. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_darwin.go +1 -55
  187. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_solaris.go +1 -1
  188. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +47 -16
  189. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +3 -0
  190. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +3 -0
  191. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +3 -0
  192. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +3 -0
  193. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +3 -0
  194. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +3 -0
  195. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +3 -0
  196. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +3 -0
  197. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +3 -0
  198. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +3 -0
  199. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +3 -0
  200. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +3 -0
  201. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +3 -0
  202. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +3 -0
  203. slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +3 -0
  204. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +4 -4
  205. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +1 -0
  206. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +1 -0
  207. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +1 -0
  208. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +1 -0
  209. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +1 -0
  210. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +1 -0
  211. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +1 -0
  212. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +1 -0
  213. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +1 -0
  214. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +1 -0
  215. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +1 -0
  216. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +1 -0
  217. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +1 -0
  218. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +1 -0
  219. slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +1 -0
  220. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +168 -12
  221. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +17 -1
  222. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +16 -0
  223. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +18 -2
  224. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +16 -0
  225. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +16 -0
  226. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +17 -1
  227. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +16 -0
  228. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +16 -0
  229. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +17 -1
  230. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +18 -2
  231. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +16 -0
  232. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +16 -0
  233. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +16 -0
  234. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +16 -0
  235. slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +16 -0
  236. slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +6 -0
  237. slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +483 -483
  238. slidge_whatsapp/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +25 -1
  239. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb +0 -0
  240. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +10 -5
  241. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/presence.go +33 -0
  242. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +6 -0
  243. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +68 -22
  244. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go +2 -1
  245. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go +8 -37
  246. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/presence.go +0 -3
  247. slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
  248. slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +8 -0
  249. slidge_whatsapp/vendor/modules.txt +57 -23
  250. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/METADATA +2 -2
  251. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/RECORD +254 -174
  252. slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi_amd64.go +0 -7
  253. slidge_whatsapp/vendor/golang.org/x/net/http2/config_go124.go +0 -61
  254. slidge_whatsapp/vendor/golang.org/x/net/http2/config_pre_go124.go +0 -16
  255. slidge_whatsapp/vendor/golang.org/x/net/http2/timer.go +0 -20
  256. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/LICENSE +0 -0
  257. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/WHEEL +0 -0
  258. {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0b0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,135 @@
1
+ package header
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/beeper/argo-go/pkg/bitset"
7
+ "github.com/beeper/argo-go/pkg/buf"
8
+ )
9
+
10
+ // Public constants for header flags
11
+ const (
12
+ HeaderInlineEverythingFlag = 0
13
+ HeaderSelfDescribingFlag = 1
14
+ HeaderOutOfBandFieldErrorsFlag = 2
15
+ HeaderSelfDescribingErrorsFlag = 3
16
+ HeaderNullTerminatedStringsFlag = 4
17
+ HeaderNoDeduplicationFlag = 5
18
+ HeaderHasUserFlagsFlag = 6
19
+ )
20
+
21
+ // Header represents the Argo message header.
22
+ type Header struct {
23
+ flags *bitset.BitSet
24
+ userFlags *bitset.BitSet
25
+ }
26
+
27
+ // NewHeader creates a new Header.
28
+ func NewHeader() *Header {
29
+ return &Header{
30
+ flags: bitset.NewBitSet(),
31
+ }
32
+ }
33
+
34
+ // GetFlag returns the boolean value of a given header flag.
35
+ func (h *Header) GetFlag(flag int) bool {
36
+ if h.flags == nil {
37
+ return false
38
+ }
39
+ return h.flags.GetBit(flag)
40
+ }
41
+
42
+ // SetFlag sets the boolean value of a given header flag.
43
+ func (h *Header) SetFlag(flag int, value bool) {
44
+ if h.flags == nil {
45
+ h.flags = bitset.NewBitSet()
46
+ }
47
+ if value {
48
+ h.flags.SetBit(flag)
49
+ } else {
50
+ h.flags.UnsetBit(flag)
51
+ }
52
+ }
53
+
54
+ // Read reads the header from the provided Read buffer.
55
+ // It updates the Header's internal state (flags, userFlags).
56
+ // It also advances the position of the buffer.
57
+ func (h *Header) Read(reader buf.Read) error {
58
+ if reader == nil {
59
+ return fmt.Errorf("reader is nil, cannot read header")
60
+ }
61
+
62
+ var vbs bitset.VarBitSet
63
+ _, flags, err := vbs.Read(reader) // Read standard flags using VarBitSet.Read
64
+ if err != nil {
65
+ return fmt.Errorf("failed to read standard header flags: %w", err)
66
+ }
67
+ h.flags = flags
68
+
69
+ // Check based on the just-read standard flags
70
+ if h.GetFlag(HeaderHasUserFlagsFlag) { // Use new GetFlag method
71
+ _, userFlags, err := vbs.Read(reader) // Read user flags using VarBitSet.Read
72
+ if err != nil {
73
+ return fmt.Errorf("failed to read user header flags: %w", err)
74
+ }
75
+ h.userFlags = userFlags
76
+ } else {
77
+ h.userFlags = nil // Ensure userFlags is nil if HasUserFlags is false
78
+ }
79
+ return nil
80
+ }
81
+
82
+ // Write writes the header to the provided Write buffer.
83
+ func (h *Header) Write(writer buf.Write) error {
84
+ if writer == nil {
85
+ return fmt.Errorf("writer is nil, cannot write header")
86
+ }
87
+ flagBytes, err := (&bitset.VarBitSet{}).Write(h.flags, 0)
88
+ if err != nil {
89
+ return fmt.Errorf("failed to write flags: %w", err)
90
+ }
91
+
92
+ var userFlagBytes []byte
93
+ if h.GetFlag(HeaderHasUserFlagsFlag) { // Use new GetFlag method
94
+ userFlagBytes, err = (&bitset.VarBitSet{}).Write(h.userFlags, 0)
95
+ if err != nil {
96
+ return fmt.Errorf("failed to write userFlags: %w", err)
97
+ }
98
+ }
99
+
100
+ if _, err := writer.Write(flagBytes); err != nil {
101
+ return fmt.Errorf("buffer write error for flags: %w", err)
102
+ }
103
+ if userFlagBytes != nil {
104
+ if _, err := writer.Write(userFlagBytes); err != nil {
105
+ return fmt.Errorf("buffer write error for userFlags: %w", err)
106
+ }
107
+ }
108
+ return nil
109
+ }
110
+
111
+ // AsBytes serializes the header to a byte slice.
112
+ func (h *Header) AsBytes() ([]byte, error) {
113
+ tempBuf := buf.NewBuf(0) // Use argo.Buf which implements Write
114
+ err := h.Write(tempBuf)
115
+ if err != nil {
116
+ return nil, err // Propagate error from Write
117
+ }
118
+ return tempBuf.Bytes(), nil
119
+ }
120
+
121
+ // UserFlags returns the user flags BitSet.
122
+ func (h *Header) UserFlags() *bitset.BitSet {
123
+ return h.userFlags
124
+ }
125
+
126
+ // SetUserFlags sets the user flags BitSet.
127
+ // This also sets or unsets the HeaderHasUserFlagsFlag bit accordingly.
128
+ func (h *Header) SetUserFlags(bs *bitset.BitSet) {
129
+ h.userFlags = bs
130
+ if h.flags == nil { // Ensure flags is initialized
131
+ h.flags = bitset.NewBitSet()
132
+ }
133
+ hasUserFlagsSet := bs != nil && len(bs.Bytes()) > 0
134
+ h.SetFlag(HeaderHasUserFlagsFlag, hasUserFlagsSet) // Use new SetFlag method
135
+ }
@@ -0,0 +1,133 @@
1
+ // Package util provides miscellaneous utility functions used across the argo-go library.
2
+ package util
3
+
4
+ import (
5
+ "bytes"
6
+ "encoding/json"
7
+ "fmt"
8
+ "strconv"
9
+ "strings"
10
+
11
+ "github.com/elliotchance/orderedmap/v3"
12
+ "github.com/vektah/gqlparser/v2/ast"
13
+ )
14
+
15
+ // GroupBy groups elements of a slice into a map based on a key extracted from each element.
16
+ func GroupBy[T any, K comparable](array []T, extract func(T) K) map[K][]T {
17
+ grouped := make(map[K][]T)
18
+ for _, element := range array {
19
+ key := extract(element)
20
+ grouped[key] = append(grouped[key], element)
21
+ }
22
+ return grouped
23
+ }
24
+
25
+ // AddPathIndex appends an integer index to an ast.Path.
26
+ func AddPathIndex(p ast.Path, i int) ast.Path {
27
+ path := make(ast.Path, len(p), len(p)+1)
28
+ copy(path, p)
29
+ path = append(path, ast.PathIndex(i))
30
+ return path
31
+ }
32
+
33
+ // AddPathName appends a string name to an ast.Path.
34
+ func AddPathName(p ast.Path, s string) ast.Path {
35
+ path := make(ast.Path, len(p), len(p)+1)
36
+ copy(path, p)
37
+ path = append(path, ast.PathName(s))
38
+ return path
39
+ }
40
+
41
+ func FormatPath(p ast.Path) string {
42
+ if p == nil {
43
+ return "<nil>"
44
+ }
45
+ var parts []string
46
+ for _, el := range p {
47
+ switch v := el.(type) {
48
+ case ast.PathName:
49
+ parts = append(parts, string(v))
50
+ case ast.PathIndex:
51
+ parts = append(parts, strconv.Itoa(int(v)))
52
+ default:
53
+ parts = append(parts, fmt.Sprintf("%v", v))
54
+ }
55
+ }
56
+ return strings.Join(parts, ".")
57
+ }
58
+
59
+ // NewOrderedMapJSON creates a new OrderedMapJSON wrapper.
60
+ func NewOrderedMapJSON[K comparable, V any](om *orderedmap.OrderedMap[K, V]) *OrderedMapJSON[K, V] {
61
+ return &OrderedMapJSON[K, V]{om}
62
+ }
63
+
64
+ // OrderedMapJSON is a wrapper around orderedmap.OrderedMap to allow custom JSON marshalling.
65
+ // It needs to be generic to match the orderedmap.OrderedMap it wraps.
66
+ type OrderedMapJSON[K comparable, V any] struct {
67
+ *orderedmap.OrderedMap[K, V]
68
+ }
69
+
70
+ // MarshalJSON implements the json.Marshaler interface.
71
+ // This method will be called by json.Marshal and json.MarshalIndent.
72
+ func (omj OrderedMapJSON[K, V]) MarshalJSON() ([]byte, error) {
73
+ if omj.OrderedMap == nil {
74
+ return []byte("null"), nil
75
+ }
76
+
77
+ var buf bytes.Buffer
78
+ buf.WriteString("{")
79
+
80
+ first := true
81
+ for key := range omj.Keys() { // Keys() returns keys in order
82
+ value, _ := omj.Get(key)
83
+
84
+ if !first {
85
+ buf.WriteString(",")
86
+ }
87
+ first = false
88
+
89
+ // Marshal key
90
+ keyBytes, keyErr := json.Marshal(key)
91
+ if keyErr != nil {
92
+ return nil, fmt.Errorf("failed to marshal ordered map key (%v): %w", key, keyErr)
93
+ }
94
+ buf.Write(keyBytes)
95
+
96
+ buf.WriteString(":")
97
+
98
+ // Marshal value
99
+ var valBytes []byte
100
+ var valErr error
101
+
102
+ // Convert value (type V) to interface{} to perform dynamic type assertion
103
+ valAsInterface := interface{}(value)
104
+
105
+ // Check if the value is specifically an *orderedmap.OrderedMap[string, any]
106
+ if subMap, ok := valAsInterface.(*orderedmap.OrderedMap[string, any]); ok {
107
+ // For this specific project structure where maps are *orderedmap.OrderedMap[string, any],
108
+ // we can create a new wrapper for the sub-map.
109
+ wrappedSubMap := NewOrderedMapJSON[string, any](subMap)
110
+ valBytes, valErr = wrappedSubMap.MarshalJSON() // Recursive call to our MarshalJSON
111
+ } else {
112
+ // Standard marshalling for other types
113
+ valBytes, valErr = json.Marshal(valAsInterface)
114
+ }
115
+
116
+ if valErr != nil {
117
+ return nil, fmt.Errorf("failed to marshal ordered map value for key (%v): %w", key, valErr)
118
+ }
119
+ buf.Write(valBytes)
120
+ }
121
+
122
+ buf.WriteString("}")
123
+ return buf.Bytes(), nil
124
+ }
125
+
126
+ // MustMarshalJSON calls MarshalJSON and panics if an error occurs.
127
+ func (omj OrderedMapJSON[K, V]) MustMarshalJSON() []byte {
128
+ data, err := omj.MarshalJSON()
129
+ if err != nil {
130
+ panic(fmt.Errorf("failed to marshal OrderedMapJSON to JSON: %w", err))
131
+ }
132
+ return data
133
+ }
@@ -0,0 +1,384 @@
1
+ // Package label defines the Label type and its associated operations for Argo.
2
+ // Labels are signed variable-length integers (encoded using ZigZag ULEB128)
3
+ // that serve multiple purposes in the Argo binary format:
4
+ // - Encoding lengths of data segments (e.g., string length, array size).
5
+ // - Representing special marker values like Null, Absent, or Error.
6
+ // - Encoding backreferences to previously seen values for data deduplication.
7
+ //
8
+ // The package provides constants for common marker labels (Null, Absent, True, False, etc.),
9
+ // functions to create labels from integer values, methods to determine a label's kind
10
+ // (Length, Null, Backreference, etc.), and functions for encoding labels to and
11
+ // decoding labels from byte streams.
12
+ package label
13
+
14
+ import (
15
+ "errors"
16
+ "fmt"
17
+ "math/big"
18
+
19
+ "github.com/beeper/argo-go/pkg/buf"
20
+ "github.com/beeper/argo-go/pkg/varint"
21
+ )
22
+
23
+ // LabelKind categorizes a Label based on its numerical value and Argo semantics.
24
+ // Different kinds determine how the label (and potentially associated data) is interpreted.
25
+ type LabelKind int
26
+
27
+ const (
28
+ // LabelKindNull (-1) indicates a null or missing value where the field itself is present.
29
+ LabelKindNull LabelKind = iota
30
+ // LabelKindAbsent (-2) indicates a field or array entry that is entirely absent or omitted.
31
+ LabelKindAbsent
32
+ // LabelKindError (-3) indicates that an error occurred at this position in the data structure.
33
+ // The error details may follow or be found in a separate error list.
34
+ LabelKindError
35
+ // LabelKindBackreference (negative, < -3) indicates a reference to a previously encountered value.
36
+ // The specific negative value is used to calculate an offset to the original value.
37
+ LabelKindBackreference
38
+ // LabelKindLength (non-negative, >= 0) indicates the length of a subsequent data value (e.g., string bytes, array elements).
39
+ // It can also represent boolean true (1) or false/non-null marker (0) in specific contexts.
40
+ LabelKindLength
41
+ )
42
+
43
+ // String returns a human-readable name for the LabelKind.
44
+ func (lk LabelKind) String() string {
45
+ switch lk {
46
+ case LabelKindNull:
47
+ return "Null"
48
+ case LabelKindAbsent:
49
+ return "Absent"
50
+ case LabelKindError:
51
+ return "Error"
52
+ case LabelKindBackreference:
53
+ return "Backreference"
54
+ case LabelKindLength:
55
+ // This covers lengths, true (1), false (0), and non-null (0).
56
+ return "Length/Boolean/Marker"
57
+ default:
58
+ return fmt.Sprintf("UnknownLabelKind(%d)", int(lk))
59
+ }
60
+ }
61
+
62
+ // Label wraps a *big.Int to represent an Argo label.
63
+ // Its value determines its kind (length, null, backreference, etc.) and specific meaning.
64
+ // Labels are immutable once created; their underlying *big.Int should not be modified
65
+ // after creation, especially for the global Label constants.
66
+ type Label struct {
67
+ value *big.Int
68
+ }
69
+
70
+ // New creates a new Label from the provided *big.Int.
71
+ // The caller should not modify `val` after passing it to New, especially if it's
72
+ // not a fresh *big.Int, to avoid unintended side effects on the Label.
73
+ // If `val` is nil, a Label with a *big.Int value of 0 is created.
74
+ func New(val *big.Int) Label {
75
+ if val == nil {
76
+ // Ensure value is never nil internally to prevent panics on method calls.
77
+ // Default to 0 if nil is passed; callers should ideally avoid passing nil.
78
+ return Label{value: big.NewInt(0)}
79
+ }
80
+ return Label{value: val}
81
+ }
82
+
83
+ // NewFromInt64 creates a new Label from an int64 value.
84
+ // This is a convenience constructor for creating labels from standard integer types.
85
+ func NewFromInt64(val int64) Label {
86
+ return Label{value: big.NewInt(val)}
87
+ }
88
+
89
+ // Value returns the underlying *big.Int of the Label.
90
+ // Callers must not modify the returned *big.Int, as it may be shared by
91
+ // predefined Label constants (e.g., NullMarker, TrueMarker) or other Label instances.
92
+ // To perform arithmetic, create a new *big.Int (e.g., `new(big.Int).Set(l.Value())`).
93
+ func (l Label) Value() *big.Int {
94
+ return l.value
95
+ }
96
+
97
+ // String returns the decimal string representation of the Label's underlying *big.Int value.
98
+ func (l Label) String() string {
99
+ if l.value == nil {
100
+ // This case should ideally not be reached if constructors always ensure a non-nil l.value.
101
+ return "<uninitialized_label>"
102
+ }
103
+ return l.value.String()
104
+ }
105
+
106
+ // --- Internal *big.Int constants for special label values ---
107
+ // These are unexported and used to initialize the exported Label constants and for comparisons.
108
+ var (
109
+ trueMarkerBigInt *big.Int // Represents boolean True (value 1)
110
+ falseMarkerBigInt *big.Int // Represents boolean False (value 0), also used as NonNull marker
111
+ nonNullMarkerBigInt *big.Int // Represents a NonNull marker (value 0), indicating presence for non-labeled types
112
+ nullMarkerBigInt *big.Int // Represents a Null value (value -1)
113
+ absentMarkerBigInt *big.Int // Represents an Absent field/item (value -2)
114
+ errorMarkerBigInt *big.Int // Represents an Error marker (value -3)
115
+
116
+ // lowestReservedBigInt is the numerically largest (i.e., closest to zero) negative *big.Int
117
+ // that has a special, non-backreference meaning. Values numerically smaller than this
118
+ // (e.g., -4, -5, ...) are considered backreferences.
119
+ lowestReservedBigInt *big.Int
120
+ )
121
+
122
+ // --- Exported Label constants ---
123
+ // These provide convenient access to common, predefined label values.
124
+ var (
125
+ TrueMarker Label // Label for boolean True (value 1).
126
+ FalseMarker Label // Label for boolean False (value 0).
127
+ NonNullMarker Label // Label for NonNull marker (value 0); alias for FalseMarker.
128
+ NullMarker Label // Label for Null (value -1).
129
+ AbsentMarker Label // Label for Absent (value -2).
130
+ ErrorMarker Label // Label for Error (value -3).
131
+ LowestReservedValue Label // Label instance for the lowest reserved non-backreference value (-3).
132
+ )
133
+
134
+ // --- Exported pre-encoded byte slices for common Label values ---
135
+ // These are the ZigZag ULEB128 encoded forms of the marker labels.
136
+ var (
137
+ Null []byte // Encoded form of NullMarker (-1).
138
+ Absent []byte // Encoded form of AbsentMarker (-2).
139
+ Error []byte // Encoded form of ErrorMarker (-3).
140
+ Zero []byte // Encoded form of 0 (used for FalseMarker, NonNullMarker, and length 0).
141
+ NonNull []byte // Encoded form of NonNullMarker (0); alias for Zero.
142
+ False []byte // Encoded form of FalseMarker (0); alias for Zero.
143
+ True []byte // Encoded form of TrueMarker (1).
144
+ )
145
+
146
+ // labelToOffsetFactor is used in the calculation of backreference offsets.
147
+ // It is derived from `lowestReservedBigInt` and ensures that backreference IDs
148
+ // map correctly to array/slice offsets.
149
+ // Specifically, offset = -NumericValue(backreference_label) + labelToOffsetFactor.
150
+ // If lowestReservedBigInt is -3, factor is -3 - 1 = -4.
151
+ var labelToOffsetFactor int64
152
+
153
+ func init() {
154
+ // Initialize *big.Int marker values.
155
+ trueMarkerBigInt = big.NewInt(1)
156
+ falseMarkerBigInt = big.NewInt(0)
157
+ nonNullMarkerBigInt = big.NewInt(0) // By spec, NonNull is 0, same as False.
158
+ nullMarkerBigInt = big.NewInt(-1)
159
+ absentMarkerBigInt = big.NewInt(-2)
160
+ errorMarkerBigInt = big.NewInt(-3)
161
+ // lowestReservedBigInt is set to errorMarkerBigInt (-3). Values less than this are backrefs.
162
+ lowestReservedBigInt = new(big.Int).Set(errorMarkerBigInt) // Use a copy for safety, though *big.Ints from NewInt are new.
163
+
164
+ // Initialize exported Label struct constants using the *big.Int markers.
165
+ TrueMarker = New(trueMarkerBigInt)
166
+ FalseMarker = New(falseMarkerBigInt)
167
+ NonNullMarker = New(nonNullMarkerBigInt) // Effectively New(big.NewInt(0))
168
+ NullMarker = New(nullMarkerBigInt)
169
+ AbsentMarker = New(absentMarkerBigInt)
170
+ ErrorMarker = New(errorMarkerBigInt)
171
+ LowestReservedValue = New(lowestReservedBigInt) // Label for -3
172
+
173
+ // Initialize pre-encoded byte slices for common labels.
174
+ Null = varint.ZigZagEncode(nullMarkerBigInt) // ZigZag(-1)
175
+ Absent = varint.ZigZagEncode(absentMarkerBigInt) // ZigZag(-2)
176
+ Error = varint.ZigZagEncode(errorMarkerBigInt) // ZigZag(-3)
177
+ Zero = varint.ZigZagEncode(big.NewInt(0)) // ZigZag(0)
178
+ NonNull = Zero // NonNull is 0.
179
+ False = Zero // False is 0.
180
+ True = varint.ZigZagEncode(big.NewInt(1)) // ZigZag(1)
181
+
182
+ // Calculate labelToOffsetFactor for backreference processing.
183
+ // This factor adjusts the negated backreference label value to yield a 0-indexed offset.
184
+ // Argo JS: labelToOffsetFactor = Number(LowestReservedValue) - 1
185
+ // Since LowestReservedValue is -3, labelToOffsetFactor becomes -3 - 1 = -4.
186
+ if !lowestReservedBigInt.IsInt64() {
187
+ // This should not happen as -3 is well within int64 range.
188
+ panic("label: internal error - lowestReservedBigInt cannot be represented as int64 during init")
189
+ }
190
+ labelToOffsetFactor = lowestReservedBigInt.Int64() - 1
191
+ }
192
+
193
+ // Kind determines and returns the semantic LabelKind of the Label (e.g., Null, Length, Backreference).
194
+ // The kind is derived from the label's numerical value according to Argo rules.
195
+ func (l Label) Kind() LabelKind {
196
+ if l.value == nil { // Should ideally not occur due to constructors ensuring non-nil.
197
+ // Consider this an internal error or undefined state.
198
+ // Returning LabelKindError or panicking might be alternatives.
199
+ // For now, assuming it implies an error state if reached.
200
+ return LabelKindError
201
+ }
202
+ if l.value.Sign() >= 0 { // Non-negative values (0, 1, lengths) are LabelKindLength.
203
+ return LabelKindLength
204
+ }
205
+
206
+ // Negative values: compare with specific marker *big.Int values.
207
+ if l.value.Cmp(nullMarkerBigInt) == 0 { // -1
208
+ return LabelKindNull
209
+ }
210
+ if l.value.Cmp(absentMarkerBigInt) == 0 { // -2
211
+ return LabelKindAbsent
212
+ }
213
+ if l.value.Cmp(errorMarkerBigInt) == 0 { // -3
214
+ return LabelKindError
215
+ }
216
+ // Any other negative value (i.e., value < -3) is a backreference.
217
+ return LabelKindBackreference
218
+ }
219
+
220
+ // IsNull checks if the label represents a Null value (i.e., its value is -1).
221
+ func (l Label) IsNull() bool {
222
+ if l.value == nil {
223
+ return false // An uninitialized label is not NullMarker.
224
+ }
225
+ return l.value.Cmp(nullMarkerBigInt) == 0
226
+ }
227
+
228
+ // IsAbsent checks if the label represents an Absent value (i.e., its value is -2).
229
+ func (l Label) IsAbsent() bool {
230
+ if l.value == nil {
231
+ return false // An uninitialized label is not AbsentMarker.
232
+ }
233
+ return l.value.Cmp(absentMarkerBigInt) == 0
234
+ }
235
+
236
+ // IsError checks if the label represents an Error marker (i.e., its value is -3).
237
+ func (l Label) IsError() bool {
238
+ if l.value == nil {
239
+ return false // An uninitialized label is not ErrorMarker.
240
+ }
241
+ return l.value.Cmp(errorMarkerBigInt) == 0
242
+ }
243
+
244
+ // IsLength checks if the label represents a length or a non-negative marker (i.e., its value >= 0).
245
+ // This includes actual lengths, TrueMarker (1), FalseMarker (0), and NonNullMarker (0).
246
+ func (l Label) IsLength() bool {
247
+ if l.value == nil {
248
+ return false // An uninitialized label is not a length.
249
+ }
250
+ return l.value.Sign() >= 0
251
+ }
252
+
253
+ // IsBackref checks if the label represents a backreference.
254
+ // A backreference label has a value numerically less than `lowestReservedBigInt` (i.e., < -3).
255
+ func (l Label) IsBackref() bool {
256
+ if l.value == nil {
257
+ return false // An uninitialized label is not a backreference.
258
+ }
259
+ // A label is a backreference if its value is negative and not one of the special
260
+ // negative markers (Null, Absent, Error). This is equivalent to being < lowestReservedBigInt.
261
+ return l.value.Cmp(lowestReservedBigInt) < 0
262
+ }
263
+
264
+ // Encode converts the Label into its ZigZag ULEB128 encoded byte representation.
265
+ // For common marker labels (Null, Absent, Error), it returns their pre-encoded global byte slices.
266
+ // Otherwise, it performs ZigZag encoding on the label's *big.Int value.
267
+ func (l Label) Encode() []byte {
268
+ if l.value == nil {
269
+ // This handles the case of an uninitialized Label struct (e.g. var lbl Label).
270
+ // Defaulting to encoding Null seems a reasonable, albeit potentially masking, behavior.
271
+ // A stricter approach might panic or return an error.
272
+ return Null
273
+ }
274
+
275
+ // Use the label's Kind to efficiently select pre-encoded values for markers.
276
+ switch l.Kind() {
277
+ case LabelKindNull:
278
+ return Null // Use pre-encoded global constant.
279
+ case LabelKindAbsent:
280
+ return Absent // Use pre-encoded global constant.
281
+ case LabelKindError:
282
+ return Error // Use pre-encoded global constant.
283
+ case LabelKindLength, LabelKindBackreference:
284
+ // This path handles positive numbers (lengths), zero (False/NonNull/Length 0),
285
+ // and true backreferences (negative values numerically smaller than errorMarkerBigInt).
286
+ // If l.value was, for example, exactly nullMarkerBigInt, l.Kind() would be LabelKindNull,
287
+ // correctly taking that path to use the pre-encoded `Null` slice.
288
+ return varint.ZigZagEncode(l.value)
289
+ default:
290
+ // This case should ideally not be reached if Kind() is comprehensive and l.value is valid.
291
+ // If an unknown or unexpected Kind were somehow produced, panicking might be appropriate
292
+ // as it indicates an internal logic inconsistency.
293
+ // For robustness in unexpected scenarios, falling back to direct encoding could be done,
294
+ // but it implies an issue that should be investigated.
295
+ // Assuming Kind() correctly categorizes all valid label values, this default is defensive.
296
+ // Consider logging an internal error if this path is ever taken in a production system.
297
+ // As a fallback, encode the raw value. This might occur if l.value was somehow
298
+ // set to nil *after* construction and Kind() returned an unexpected default.
299
+ fmt.Printf("label.Encode: warning - unexpected LabelKind, falling back to direct ZigZagEncode for value: %s\n", l.String())
300
+ return varint.ZigZagEncode(l.value)
301
+ }
302
+ }
303
+
304
+ // Read decodes a label from a buffer `b` that implements the `buf.Read` interface.
305
+ // It reads a ZigZag ULEB128 encoded number from the buffer at its current position,
306
+ // advances the buffer's position by the number of bytes read, and returns the decoded Label.
307
+ // Any errors encountered during varint decoding are propagated.
308
+ func Read(b buf.Read) (Label, error) {
309
+ bufferBytes := b.Bytes()
310
+ currentPosition := b.Position()
311
+
312
+ if currentPosition < 0 {
313
+ return Label{value: big.NewInt(0)}, errors.New("label: buffer position is negative, cannot read")
314
+ }
315
+
316
+ // Ensure currentPosition is int for slice indexing, though ZigZagDecode expects int offset.
317
+ // This cast is safe if b.Position() is within typical buffer size ranges.
318
+ // varint.ZigZagDecode will handle bounds checking against len(bufferBytes).
319
+ decodedBigInt, numBytesRead, err := varint.ZigZagDecode(bufferBytes, int(currentPosition))
320
+ if err != nil {
321
+ // Return a zero-value Label on error, along with the error itself.
322
+ return Label{value: big.NewInt(0)}, fmt.Errorf("label.Read: failed to decode varint: %w", err)
323
+ }
324
+
325
+ b.IncrementPosition(int64(numBytesRead))
326
+ return New(decodedBigInt), nil
327
+ }
328
+
329
+ // ToOffset converts a backreference Label into a 0-indexed array/slice offset.
330
+ // The Label must represent a valid backreference (i.e., its Kind must be LabelKindBackreference).
331
+ // An error is returned if the Label is not a valid backreference (e.g., it's non-negative
332
+ // or one of the special markers like Null, Absent, Error), or if its value is too large
333
+ // to be represented as an int64 after transformation (highly unlikely for practical offsets).
334
+ // The formula used is: offset = -NumericValue(label) + labelToOffsetFactor.
335
+ // For example, if labelToOffsetFactor is -4:
336
+ // - A label of -4 (smallest valid backref value) gives offset: -(-4) + (-4) = 4 - 4 = 0.
337
+ // - A label of -5 gives offset: -(-5) + (-4) = 5 - 4 = 1.
338
+ func (l Label) ToOffset() (int64, error) {
339
+ if l.value == nil {
340
+ return 0, errors.New("label: ToOffset called on uninitialized Label")
341
+ }
342
+ // A label must be a true backreference to be converted to an offset.
343
+ // This means its value must be < lowestReservedBigInt (-3).
344
+ if l.Kind() != LabelKindBackreference {
345
+ return 0, fmt.Errorf("label: cannot convert label of kind '%s' (value %s) to offset; must be a backreference", l.Kind(), l.String())
346
+ }
347
+
348
+ // Perform the calculation: offset = -labelValue + labelToOffsetFactor
349
+ negatedLabelVal := new(big.Int).Neg(l.value)
350
+
351
+ if !negatedLabelVal.IsInt64() {
352
+ // This is extremely unlikely for a backreference offset but check for safety.
353
+ return 0, fmt.Errorf("label: negated backreference value %s too large for int64 conversion in ToOffset", negatedLabelVal.String())
354
+ }
355
+
356
+ offset := negatedLabelVal.Int64() + labelToOffsetFactor
357
+ if offset < 0 {
358
+ // This would indicate an issue with labelToOffsetFactor or the input label value,
359
+ // as valid backreferences should produce non-negative offsets.
360
+ return 0, fmt.Errorf("label: calculated offset %d is negative for label %s; internal logic error or invalid backreference", offset, l.String())
361
+ }
362
+ return offset, nil
363
+ }
364
+
365
+ // Is checks if this label (l) has the same numerical value as another label (other).
366
+ // It compares their underlying *big.Int values.
367
+ // Handles cases where one or both labels might be uninitialized (value is nil),
368
+ // although constructors aim to prevent l.value from being nil.
369
+ func (l Label) Is(other Label) bool {
370
+ val1 := l.Value() // Use Value() to respect potential nil internal value.
371
+ val2 := other.Value()
372
+
373
+ if val1 == nil && val2 == nil {
374
+ // Both are uninitialized (e.g. zero value Label struct not passed through New*).
375
+ // Or if New(nil) resulted in Label{value:nil} (though current New(nil) makes it 0).
376
+ return true
377
+ }
378
+ if val1 == nil || val2 == nil {
379
+ // One is initialized, the other is not (or became nil post-construction).
380
+ return false
381
+ }
382
+ // Both have non-nil *big.Int values, compare them.
383
+ return val1.Cmp(val2) == 0
384
+ }
@@ -0,0 +1,37 @@
1
+ package label
2
+
3
+ var (
4
+ WireTypeMarkerString Label
5
+ WireTypeMarkerBoolean Label
6
+ WireTypeMarkerVarint Label
7
+ WireTypeMarkerFloat64 Label
8
+ WireTypeMarkerBytes Label
9
+ WireTypeMarkerFixed Label
10
+ WireTypeMarkerBlock Label
11
+ WireTypeMarkerNullable Label
12
+ WireTypeMarkerArray Label
13
+ WireTypeMarkerRecord Label
14
+ WireTypeMarkerDesc Label
15
+ WireTypeMarkerError Label
16
+ WireTypeMarkerPath Label
17
+ WireTypeMarkerUnion Label
18
+ WireTypeMarkerExtensions Label
19
+ )
20
+
21
+ func init() {
22
+ WireTypeMarkerString = NewFromInt64(-1)
23
+ WireTypeMarkerBoolean = NewFromInt64(-2)
24
+ WireTypeMarkerVarint = NewFromInt64(-3)
25
+ WireTypeMarkerFloat64 = NewFromInt64(-4)
26
+ WireTypeMarkerBytes = NewFromInt64(-5)
27
+ WireTypeMarkerFixed = NewFromInt64(-6)
28
+ WireTypeMarkerBlock = NewFromInt64(-7)
29
+ WireTypeMarkerNullable = NewFromInt64(-8)
30
+ WireTypeMarkerArray = NewFromInt64(-9)
31
+ WireTypeMarkerRecord = NewFromInt64(-10)
32
+ WireTypeMarkerDesc = NewFromInt64(-11)
33
+ WireTypeMarkerError = NewFromInt64(-12)
34
+ WireTypeMarkerPath = NewFromInt64(-13)
35
+ WireTypeMarkerUnion = NewFromInt64(-14)
36
+ WireTypeMarkerExtensions = NewFromInt64(-15)
37
+ }