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,341 @@
1
+ package wirecodec
2
+
3
+ import (
4
+ "encoding/binary"
5
+ "fmt"
6
+ "math"
7
+
8
+ "github.com/beeper/argo-go/block"
9
+ "github.com/beeper/argo-go/codec"
10
+ "github.com/beeper/argo-go/header"
11
+ "github.com/beeper/argo-go/label"
12
+ "github.com/beeper/argo-go/pkg/buf"
13
+ "github.com/beeper/argo-go/wire"
14
+ )
15
+
16
+ type anyBlockReader interface {
17
+ Read(parent buf.Read) (interface{}, error)
18
+ }
19
+
20
+ type genericBlockReaderWrapper struct {
21
+ coreRead func(parentBuf buf.Read) (interface{}, error)
22
+ blockDataBuffer buf.Read
23
+ }
24
+
25
+ func (g *genericBlockReaderWrapper) Read(parentBuf buf.Read) (interface{}, error) {
26
+ return g.coreRead(parentBuf)
27
+ }
28
+
29
+ type Decoder struct {
30
+ r buf.Read
31
+ slicer *codec.MessageSlicer
32
+ readers map[wire.BlockKey]anyBlockReader
33
+ }
34
+
35
+ func NewFromSlicer(s *codec.MessageSlicer) *Decoder {
36
+ return &Decoder{
37
+ r: s.Core(),
38
+ slicer: s,
39
+ readers: make(map[wire.BlockKey]anyBlockReader),
40
+ }
41
+ }
42
+
43
+ func (d *Decoder) DecodeWireType() (wire.Type, error) {
44
+ lbl, err := label.Read(d.r)
45
+ if err != nil {
46
+ return nil, err
47
+ }
48
+
49
+ switch {
50
+ // ---------- scalars ----------
51
+ case label.WireTypeMarkerString.Is(lbl):
52
+ return wire.String, nil
53
+ case label.WireTypeMarkerBoolean.Is(lbl):
54
+ return wire.Boolean, nil
55
+ case label.WireTypeMarkerVarint.Is(lbl):
56
+ return wire.Varint, nil
57
+ case label.WireTypeMarkerFloat64.Is(lbl):
58
+ return wire.Float64, nil
59
+ case label.WireTypeMarkerBytes.Is(lbl):
60
+ return wire.Bytes, nil
61
+ case label.WireTypeMarkerFixed.Is(lbl):
62
+ lengthLbl, err := label.Read(d.r)
63
+ if err != nil {
64
+ return nil, err
65
+ }
66
+ n := int(lengthLbl.Value().Int64())
67
+ if n < 0 {
68
+ return nil, fmt.Errorf("wirecodec: negative FIXED length %d", n)
69
+ }
70
+ return wire.FixedType{Length: n}, nil
71
+
72
+ // ---------- block ----------
73
+ case label.WireTypeMarkerBlock.Is(lbl):
74
+ // Only scalar/desc allowed for block element
75
+ elem, err := d.decodeScalarWireType()
76
+ if err != nil {
77
+ return nil, err
78
+ }
79
+ key, err := d.readBlockString()
80
+ if err != nil {
81
+ return nil, err
82
+ }
83
+ dedupe, err := d.readBlockBool()
84
+ if err != nil {
85
+ return nil, err
86
+ }
87
+ return wire.NewBlockType(elem, wire.BlockKey(key), dedupe), nil
88
+
89
+ // ---------- wrappers ----------
90
+ case label.WireTypeMarkerNullable.Is(lbl):
91
+ of, err := d.DecodeWireType()
92
+ if err != nil {
93
+ return nil, err
94
+ }
95
+ return wire.NewNullableType(of), nil
96
+
97
+ case label.WireTypeMarkerArray.Is(lbl):
98
+ of, err := d.DecodeWireType()
99
+ if err != nil {
100
+ return nil, err
101
+ }
102
+ return wire.ArrayType{Of: of}, nil
103
+
104
+ // ---------- record ----------
105
+ case label.WireTypeMarkerRecord.Is(lbl):
106
+ lenLbl, err := label.Read(d.r)
107
+ if err != nil {
108
+ return nil, err
109
+ }
110
+ n := int(lenLbl.Value().Int64())
111
+ if n < 0 {
112
+ return nil, fmt.Errorf("wirecodec: negative record-field count %d", n)
113
+ }
114
+ return d.decodeRecord(n)
115
+
116
+ // ---------- simple markers ----------
117
+ case label.WireTypeMarkerDesc.Is(lbl):
118
+ return wire.Desc, nil
119
+ case label.WireTypeMarkerError.Is(lbl):
120
+ return wire.Error, nil
121
+ case label.WireTypeMarkerPath.Is(lbl):
122
+ return wire.Path, nil
123
+ case label.WireTypeMarkerExtensions.Is(lbl):
124
+ return wire.Extensions, nil
125
+ }
126
+
127
+ return nil, fmt.Errorf("wirecodec: unknown wire-type label %s", lbl.Value().String())
128
+ }
129
+
130
+ func (d *Decoder) DecodeWireTypeStore() (map[string]wire.Type, error) {
131
+ objLbl, err := label.Read(d.r)
132
+ if err != nil {
133
+ return nil, err
134
+ }
135
+ if !wire.SelfDescribingTypeMarkerObject.Is(objLbl) {
136
+ return nil, fmt.Errorf("wirecodec: expected object marker, found %v", objLbl.Value())
137
+ }
138
+
139
+ cntLbl, err := label.Read(d.r)
140
+ if err != nil {
141
+ return nil, err
142
+ }
143
+ n := int(cntLbl.Value().Int64())
144
+ if n < 0 {
145
+ return nil, fmt.Errorf("wirecodec: negative type-store length %d", n)
146
+ }
147
+
148
+ out := make(map[string]wire.Type, n)
149
+ for i := 0; i < n; i++ {
150
+ name, err := d.readBlockString()
151
+ if err != nil {
152
+ return nil, fmt.Errorf("wirecodec: read store name: %w", err)
153
+ }
154
+ wt, err := d.DecodeWireType()
155
+ if err != nil {
156
+ return nil, fmt.Errorf("wirecodec: decode type %q: %w", name, err)
157
+ }
158
+ out[name] = wt
159
+ }
160
+ return out, nil
161
+ }
162
+
163
+ func (d *Decoder) decodeScalarWireType() (wire.Type, error) {
164
+ lbl, err := label.Read(d.r)
165
+ if err != nil {
166
+ return nil, err
167
+ }
168
+
169
+ switch {
170
+ case label.WireTypeMarkerString.Is(lbl):
171
+ return wire.String, nil
172
+ case label.WireTypeMarkerBoolean.Is(lbl):
173
+ return wire.Boolean, nil
174
+ case label.WireTypeMarkerVarint.Is(lbl):
175
+ return wire.Varint, nil
176
+ case label.WireTypeMarkerFloat64.Is(lbl):
177
+ return wire.Float64, nil
178
+ case label.WireTypeMarkerBytes.Is(lbl):
179
+ return wire.Bytes, nil
180
+ case label.WireTypeMarkerFixed.Is(lbl):
181
+ lenLbl, err := label.Read(d.r)
182
+ if err != nil {
183
+ return nil, err
184
+ }
185
+ n := int(lenLbl.Value().Int64())
186
+ if n < 0 {
187
+ return nil, fmt.Errorf("wirecodec: negative FIXED length %d", n)
188
+ }
189
+ return wire.FixedType{Length: n}, nil
190
+ case label.WireTypeMarkerDesc.Is(lbl):
191
+ return wire.Desc, nil
192
+ }
193
+ return nil, fmt.Errorf("wirecodec: invalid scalar wire-type label %s", lbl.Value().String())
194
+ }
195
+
196
+ func (d *Decoder) decodeRecord(length int) (wire.Type, error) {
197
+ if length < 0 {
198
+ return nil, fmt.Errorf("wirecodec: negative record-field count %d", length)
199
+ }
200
+ fields := make([]wire.Field, 0, length)
201
+ for i := 0; i < length; i++ {
202
+ name, err := d.readBlockString()
203
+ if err != nil {
204
+ return nil, fmt.Errorf("record field %d name: %w", i, err)
205
+ }
206
+ ft, err := d.DecodeWireType()
207
+ if err != nil {
208
+ return nil, fmt.Errorf("record field %q type: %w", name, err)
209
+ }
210
+ omit, err := d.readBlockBool()
211
+ if err != nil {
212
+ return nil, fmt.Errorf("record field %q omittable: %w", name, err)
213
+ }
214
+ fields = append(fields, wire.Field{Name: name, Of: ft, Omittable: omit})
215
+ }
216
+ return wire.RecordType{Fields: fields}, nil
217
+ }
218
+
219
+ func (d *Decoder) readBlockString() (string, error) {
220
+ key := wire.BlockKey("String")
221
+ elem, ok := wire.SelfDescribingBlocks[key]
222
+ if !ok {
223
+ return "", fmt.Errorf("wirecodec: self-describing String block not found")
224
+ }
225
+ blk := wire.NewBlockType(elem, key, wire.MustDeduplicateByDefault(elem))
226
+
227
+ r, err := d.getBlockReader(blk, wire.String)
228
+ if err != nil {
229
+ return "", fmt.Errorf("wirecodec: get String block reader: %w", err)
230
+ }
231
+ v, err := r.Read(d.r)
232
+ if err != nil {
233
+ return "", fmt.Errorf("wirecodec: read String from block: %w", err)
234
+ }
235
+ s, ok := v.(string)
236
+ if !ok {
237
+ return "", fmt.Errorf("wirecodec: String block reader returned %T", v)
238
+ }
239
+ return s, nil
240
+ }
241
+
242
+ func (d *Decoder) readBlockBool() (bool, error) {
243
+ lbl, err := label.Read(d.r)
244
+ if err != nil {
245
+ return false, err
246
+ }
247
+ switch {
248
+ case label.FalseMarker.Is(lbl):
249
+ return false, nil
250
+ case label.TrueMarker.Is(lbl):
251
+ return true, nil
252
+ default:
253
+ return false, fmt.Errorf("wirecodec: expected boolean marker got %v", lbl.Value())
254
+ }
255
+ }
256
+
257
+ func DecodeWireTypeStoreFile(msg []byte) (map[string]wire.Type, error) {
258
+ slicer, err := codec.NewMessageSlicer(buf.NewBufReadonly(msg))
259
+ if err != nil {
260
+ return nil, err
261
+ }
262
+ return NewFromSlicer(slicer).DecodeWireTypeStore()
263
+ }
264
+
265
+ func (d *Decoder) getBlockReader(blockDef wire.BlockType, valueWireType wire.Type) (anyBlockReader, error) {
266
+ if r, ok := d.readers[blockDef.Key]; ok {
267
+ return r, nil
268
+ }
269
+ r, err := d.makeBlockReader(valueWireType, blockDef.Dedupe, blockDef.Key)
270
+ if err != nil {
271
+ return nil, err
272
+ }
273
+ d.readers[blockDef.Key] = r
274
+ return r, nil
275
+ }
276
+
277
+ func (d *Decoder) makeBlockReader(valueWireType wire.Type, dedupe bool, key wire.BlockKey) (anyBlockReader, error) {
278
+ blockData := d.slicer.NextBlock()
279
+ if blockData == nil {
280
+ if !d.slicer.Header().GetFlag(header.HeaderInlineEverythingFlag) {
281
+ return nil, fmt.Errorf("wirecodec: no more block segments for key %s", key)
282
+ }
283
+ blockData = d.slicer.Core()
284
+ if blockData == nil {
285
+ return nil, fmt.Errorf("wirecodec: core buffer nil in inline-everything mode for %s", key)
286
+ }
287
+ }
288
+
289
+ var coreRead func(parentBuf buf.Read) (interface{}, error)
290
+
291
+ switch t := valueWireType.(type) {
292
+ case wire.StringType:
293
+ nt := d.slicer.Header().GetFlag(header.HeaderNullTerminatedStringsFlag)
294
+ fromBytes := func(b []byte) string { return string(b) }
295
+ if dedupe {
296
+ r := block.NewDeduplicatingLabelBlockReader[string](blockData, fromBytes, nt)
297
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
298
+ } else {
299
+ r := block.NewLabelBlockReader[string](blockData, fromBytes, nt)
300
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
301
+ }
302
+
303
+ case wire.BytesType:
304
+ fromBytes := func(b []byte) []byte { return b }
305
+ if dedupe {
306
+ r := block.NewDeduplicatingLabelBlockReader[[]byte](blockData, fromBytes, false)
307
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
308
+ } else {
309
+ r := block.NewLabelBlockReader[[]byte](blockData, fromBytes, false)
310
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
311
+ }
312
+
313
+ case wire.VarintType:
314
+ if dedupe {
315
+ return nil, fmt.Errorf("wirecodec: deduping VARINT via label blocks not supported for %s", key)
316
+ }
317
+ r := block.NewUnlabeledVarIntBlockReader(blockData)
318
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
319
+
320
+ case wire.Float64Type:
321
+ if dedupe {
322
+ return nil, fmt.Errorf("wirecodec: deduping FLOAT64 not supported for %s", key)
323
+ }
324
+ fromBytes := func(b []byte) float64 { return math.Float64frombits(binary.LittleEndian.Uint64(b)) }
325
+ r := block.NewFixedSizeBlockReader[float64](blockData, fromBytes, 8)
326
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
327
+
328
+ case wire.FixedType:
329
+ if dedupe {
330
+ return nil, fmt.Errorf("wirecodec: deduping FIXED not supported for %s", key)
331
+ }
332
+ fromBytes := func(b []byte) []byte { return b }
333
+ r := block.NewFixedSizeBlockReader[[]byte](blockData, fromBytes, t.Length)
334
+ coreRead = func(p buf.Read) (interface{}, error) { return r.Read(p) }
335
+
336
+ default:
337
+ return nil, fmt.Errorf("wirecodec: unsupported block value type %s for key %s", wire.Print(valueWireType), key)
338
+ }
339
+
340
+ return &genericBlockReaderWrapper{coreRead: coreRead, blockDataBuffer: blockData}, nil
341
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Elliot Chance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,95 @@
1
+ package orderedmap
2
+
3
+ // Element is an element of a null terminated (non circular) intrusive doubly linked list that contains the key of the correspondent element in the ordered map too.
4
+ type Element[K comparable, V any] struct {
5
+ // Next and previous pointers in the doubly-linked list of elements.
6
+ // To simplify the implementation, internally a list l is implemented
7
+ // as a ring, such that &l.root is both the next element of the last
8
+ // list element (l.Back()) and the previous element of the first list
9
+ // element (l.Front()).
10
+ next, prev *Element[K, V]
11
+
12
+ // The key that corresponds to this element in the ordered map.
13
+ Key K
14
+
15
+ // The value stored with this element.
16
+ Value V
17
+ }
18
+
19
+ // Next returns the next list element or nil.
20
+ func (e *Element[K, V]) Next() *Element[K, V] {
21
+ return e.next
22
+ }
23
+
24
+ // Prev returns the previous list element or nil.
25
+ func (e *Element[K, V]) Prev() *Element[K, V] {
26
+ return e.prev
27
+ }
28
+
29
+ // list represents a null terminated (non circular) intrusive doubly linked list.
30
+ // The list is immediately usable after instantiation without the need of a dedicated initialization.
31
+ type list[K comparable, V any] struct {
32
+ root Element[K, V] // list head and tail
33
+ }
34
+
35
+ func (l *list[K, V]) IsEmpty() bool {
36
+ return l.root.next == nil
37
+ }
38
+
39
+ // Front returns the first element of list l or nil if the list is empty.
40
+ func (l *list[K, V]) Front() *Element[K, V] {
41
+ return l.root.next
42
+ }
43
+
44
+ // Back returns the last element of list l or nil if the list is empty.
45
+ func (l *list[K, V]) Back() *Element[K, V] {
46
+ return l.root.prev
47
+ }
48
+
49
+ // Remove removes e from its list
50
+ func (l *list[K, V]) Remove(e *Element[K, V]) {
51
+ if e.prev == nil {
52
+ l.root.next = e.next
53
+ } else {
54
+ e.prev.next = e.next
55
+ }
56
+ if e.next == nil {
57
+ l.root.prev = e.prev
58
+ } else {
59
+ e.next.prev = e.prev
60
+ }
61
+ e.next = nil // avoid memory leaks
62
+ e.prev = nil // avoid memory leaks
63
+ }
64
+
65
+ // PushFront inserts a new element e with value v at the front of list l and returns e.
66
+ func (l *list[K, V]) PushFront(key K, value V) *Element[K, V] {
67
+ e := &Element[K, V]{Key: key, Value: value}
68
+ if l.root.next == nil {
69
+ // It's the first element
70
+ l.root.next = e
71
+ l.root.prev = e
72
+ return e
73
+ }
74
+
75
+ e.next = l.root.next
76
+ l.root.next.prev = e
77
+ l.root.next = e
78
+ return e
79
+ }
80
+
81
+ // PushBack inserts a new element e with value v at the back of list l and returns e.
82
+ func (l *list[K, V]) PushBack(key K, value V) *Element[K, V] {
83
+ e := &Element[K, V]{Key: key, Value: value}
84
+ if l.root.prev == nil {
85
+ // It's the first element
86
+ l.root.next = e
87
+ l.root.prev = e
88
+ return e
89
+ }
90
+
91
+ e.prev = l.root.prev
92
+ l.root.prev.next = e
93
+ l.root.prev = e
94
+ return e
95
+ }
@@ -0,0 +1,187 @@
1
+ package orderedmap
2
+
3
+ import "iter"
4
+
5
+ type OrderedMap[K comparable, V any] struct {
6
+ kv map[K]*Element[K, V]
7
+ ll list[K, V]
8
+ }
9
+
10
+ func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V] {
11
+ return &OrderedMap[K, V]{
12
+ kv: make(map[K]*Element[K, V]),
13
+ }
14
+ }
15
+
16
+ // NewOrderedMapWithCapacity creates a map with enough pre-allocated space to
17
+ // hold the specified number of elements.
18
+ func NewOrderedMapWithCapacity[K comparable, V any](capacity int) *OrderedMap[K, V] {
19
+ return &OrderedMap[K, V]{
20
+ kv: make(map[K]*Element[K, V], capacity),
21
+ }
22
+ }
23
+
24
+ func NewOrderedMapWithElements[K comparable, V any](els ...*Element[K, V]) *OrderedMap[K, V] {
25
+ om := NewOrderedMapWithCapacity[K, V](len(els))
26
+ for _, el := range els {
27
+ om.Set(el.Key, el.Value)
28
+ }
29
+ return om
30
+ }
31
+
32
+ // Get returns the value for a key. If the key does not exist, the second return
33
+ // parameter will be false and the value will be nil.
34
+ func (m *OrderedMap[K, V]) Get(key K) (value V, ok bool) {
35
+ v, ok := m.kv[key]
36
+ if ok {
37
+ value = v.Value
38
+ }
39
+
40
+ return
41
+ }
42
+
43
+ // Set will set (or replace) a value for a key. If the key was new, then true
44
+ // will be returned. The returned value will be false if the value was replaced
45
+ // (even if the value was the same).
46
+ func (m *OrderedMap[K, V]) Set(key K, value V) bool {
47
+ _, alreadyExist := m.kv[key]
48
+ if alreadyExist {
49
+ m.kv[key].Value = value
50
+ return false
51
+ }
52
+
53
+ element := m.ll.PushBack(key, value)
54
+ m.kv[key] = element
55
+ return true
56
+ }
57
+
58
+ // ReplaceKey replaces an existing key with a new key while preserving order of
59
+ // the value. This function will return true if the operation was successful, or
60
+ // false if 'originalKey' is not found OR 'newKey' already exists (which would be an overwrite).
61
+ func (m *OrderedMap[K, V]) ReplaceKey(originalKey, newKey K) bool {
62
+ element, originalExists := m.kv[originalKey]
63
+ _, newKeyExists := m.kv[newKey]
64
+ if originalExists && !newKeyExists {
65
+ delete(m.kv, originalKey)
66
+ m.kv[newKey] = element
67
+ element.Key = newKey
68
+ return true
69
+ }
70
+ return false
71
+ }
72
+
73
+ // GetOrDefault returns the value for a key. If the key does not exist, returns
74
+ // the default value instead.
75
+ func (m *OrderedMap[K, V]) GetOrDefault(key K, defaultValue V) V {
76
+ if value, ok := m.kv[key]; ok {
77
+ return value.Value
78
+ }
79
+
80
+ return defaultValue
81
+ }
82
+
83
+ // GetElement returns the element for a key. If the key does not exist, the
84
+ // pointer will be nil.
85
+ func (m *OrderedMap[K, V]) GetElement(key K) *Element[K, V] {
86
+ element, ok := m.kv[key]
87
+ if ok {
88
+ return element
89
+ }
90
+
91
+ return nil
92
+ }
93
+
94
+ // Len returns the number of elements in the map.
95
+ func (m *OrderedMap[K, V]) Len() int {
96
+ return len(m.kv)
97
+ }
98
+
99
+ // AllFromFront returns an iterator that yields all elements in the map starting
100
+ // at the front (oldest Set element).
101
+ func (m *OrderedMap[K, V]) AllFromFront() iter.Seq2[K, V] {
102
+ return func(yield func(key K, value V) bool) {
103
+ for el := m.Front(); el != nil; el = el.Next() {
104
+ if !yield(el.Key, el.Value) {
105
+ return
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ // AllFromBack returns an iterator that yields all elements in the map starting
112
+ // at the back (most recent Set element).
113
+ func (m *OrderedMap[K, V]) AllFromBack() iter.Seq2[K, V] {
114
+ return func(yield func(key K, value V) bool) {
115
+ for el := m.Back(); el != nil; el = el.Prev() {
116
+ if !yield(el.Key, el.Value) {
117
+ return
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ // Keys returns an iterator that yields all the keys in the map starting at the
124
+ // front (oldest Set element). To create a slice containing all the map keys,
125
+ // use the slices.Collect function on the returned iterator.
126
+ func (m *OrderedMap[K, V]) Keys() iter.Seq[K] {
127
+ return func(yield func(key K) bool) {
128
+ for el := m.Front(); el != nil; el = el.Next() {
129
+ if !yield(el.Key) {
130
+ return
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ // Values returns an iterator that yields all the values in the map starting at
137
+ // the front (oldest Set element). To create a slice containing all the map
138
+ // values, use the slices.Collect function on the returned iterator.
139
+ func (m *OrderedMap[K, V]) Values() iter.Seq[V] {
140
+ return func(yield func(value V) bool) {
141
+ for el := m.Front(); el != nil; el = el.Next() {
142
+ if !yield(el.Value) {
143
+ return
144
+ }
145
+ }
146
+ }
147
+ }
148
+
149
+ // Delete will remove a key from the map. It will return true if the key was
150
+ // removed (the key did exist).
151
+ func (m *OrderedMap[K, V]) Delete(key K) (didDelete bool) {
152
+ element, ok := m.kv[key]
153
+ if ok {
154
+ m.ll.Remove(element)
155
+ delete(m.kv, key)
156
+ }
157
+
158
+ return ok
159
+ }
160
+
161
+ // Front will return the element that is the first (oldest Set element). If
162
+ // there are no elements this will return nil.
163
+ func (m *OrderedMap[K, V]) Front() *Element[K, V] {
164
+ return m.ll.Front()
165
+ }
166
+
167
+ // Back will return the element that is the last (most recent Set element). If
168
+ // there are no elements this will return nil.
169
+ func (m *OrderedMap[K, V]) Back() *Element[K, V] {
170
+ return m.ll.Back()
171
+ }
172
+
173
+ // Copy returns a new OrderedMap with the same elements.
174
+ // Using Copy while there are concurrent writes may mangle the result.
175
+ func (m *OrderedMap[K, V]) Copy() *OrderedMap[K, V] {
176
+ m2 := NewOrderedMapWithCapacity[K, V](m.Len())
177
+ for el := m.Front(); el != nil; el = el.Next() {
178
+ m2.Set(el.Key, el.Value)
179
+ }
180
+ return m2
181
+ }
182
+
183
+ // Has checks if a key exists in the map.
184
+ func (m *OrderedMap[K, V]) Has(key K) bool {
185
+ _, exists := m.kv[key]
186
+ return exists
187
+ }
@@ -12,6 +12,7 @@ var (
12
12
  ErrNoSuchFile = errors.New("fitz: no such file")
13
13
  ErrCreateContext = errors.New("fitz: cannot create context")
14
14
  ErrOpenDocument = errors.New("fitz: cannot open document")
15
+ ErrEmptyBytes = errors.New("fitz: cannot send empty bytes")
15
16
  ErrOpenMemory = errors.New("fitz: cannot open memory")
16
17
  ErrLoadPage = errors.New("fitz: cannot load page")
17
18
  ErrRunPageContents = errors.New("fitz: cannot run page contents")
@@ -125,6 +125,9 @@ func New(filename string) (f *Document, err error) {
125
125
 
126
126
  // NewFromMemory returns new fitz document from byte slice.
127
127
  func NewFromMemory(b []byte) (f *Document, err error) {
128
+ if len(b) == 0 {
129
+ return nil, ErrEmptyBytes
130
+ }
128
131
  f = &Document{}
129
132
 
130
133
  f.ctx = (*C.struct_fz_context)(unsafe.Pointer(C.fz_new_context_imp(nil, nil, C.store(MaxStore), C.fz_version)))
@@ -64,6 +64,9 @@ func New(filename string) (f *Document, err error) {
64
64
 
65
65
  // NewFromMemory returns new fitz document from byte slice.
66
66
  func NewFromMemory(b []byte) (f *Document, err error) {
67
+ if len(b) == 0 {
68
+ return nil, ErrEmptyBytes
69
+ }
67
70
  f = &Document{}
68
71
 
69
72
  f.ctx = fzNewContextImp(nil, nil, uint64(MaxStore), FzVersion)
@@ -661,11 +664,7 @@ func (b *bundle) call(rValue unsafe.Pointer, aValues ...unsafe.Pointer) {
661
664
 
662
665
  func newBundle(name string, rType *ffi.Type, aTypes ...*ffi.Type) *bundle {
663
666
  b := new(bundle)
664
- var err error
665
-
666
- if b.sym, err = purego.Dlsym(libmupdf, name); err != nil {
667
- panic(err)
668
- }
667
+ b.sym = procAddress(libmupdf, name)
669
668
 
670
669
  nArgs := uint32(len(aTypes))
671
670
 
@@ -19,5 +19,15 @@ func loadLibrary() uintptr {
19
19
  panic(fmt.Errorf("cannot load library: %w", err))
20
20
  }
21
21
 
22
- return uintptr(handle)
22
+ return handle
23
+ }
24
+
25
+ // procAddress returns the address of symbol name.
26
+ func procAddress(handle uintptr, procName string) uintptr {
27
+ addr, err := purego.Dlsym(handle, procName)
28
+ if err != nil {
29
+ panic(fmt.Errorf("cannot get proc address for %s: %w", procName, err))
30
+ }
31
+
32
+ return addr
23
33
  }