@airgap/coinlib-core 0.13.11-beta.1 → 0.13.11-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/actions/Action.d.ts +24 -0
  2. package/actions/Action.js +119 -0
  3. package/actions/Action.js.map +1 -0
  4. package/actions/LinkedAction.d.ts +10 -0
  5. package/actions/LinkedAction.js +95 -0
  6. package/actions/LinkedAction.js.map +1 -0
  7. package/actions/RepeatableAction.d.ts +8 -0
  8. package/actions/RepeatableAction.js +92 -0
  9. package/actions/RepeatableAction.js.map +1 -0
  10. package/actions/SimpleAction.d.ts +7 -0
  11. package/actions/SimpleAction.js +80 -0
  12. package/actions/SimpleAction.js.map +1 -0
  13. package/actions/StateMachine.d.ts +9 -0
  14. package/actions/StateMachine.js +42 -0
  15. package/actions/StateMachine.js.map +1 -0
  16. package/data/KeyPair.d.ts +5 -0
  17. package/data/KeyPair.js +3 -0
  18. package/data/KeyPair.js.map +1 -0
  19. package/data/Lazy.d.ts +14 -0
  20. package/data/Lazy.js +83 -0
  21. package/data/Lazy.js.map +1 -0
  22. package/data/RPCBody.d.ts +7 -0
  23. package/data/RPCBody.js +16 -0
  24. package/data/RPCBody.js.map +1 -0
  25. package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.d.ts +230 -0
  26. package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js +471 -0
  27. package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js.map +1 -0
  28. package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.d.ts +76 -0
  29. package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js +455 -0
  30. package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js.map +1 -0
  31. package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.d.ts +27 -0
  32. package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js +848 -0
  33. package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js.map +1 -0
  34. package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.d.ts +22 -0
  35. package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js +14 -0
  36. package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js.map +1 -0
  37. package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.d.ts +29 -0
  38. package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js +63 -0
  39. package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js.map +1 -0
  40. package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.d.ts +36 -0
  41. package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js +87 -0
  42. package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js.map +1 -0
  43. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.d.ts +8 -0
  44. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js +33 -0
  45. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js.map +1 -0
  46. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.d.ts +11 -0
  47. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.js +5 -0
  48. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/index.js.map +1 -0
  49. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.d.ts +8 -0
  50. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js +43 -0
  51. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js.map +1 -0
  52. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.d.ts +8 -0
  53. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js +37 -0
  54. package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js.map +1 -0
  55. package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.d.ts +73 -0
  56. package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js +552 -0
  57. package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js.map +1 -0
  58. package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.d.ts +73 -0
  59. package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js +552 -0
  60. package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js.map +1 -0
  61. package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.d.ts +18 -0
  62. package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js +29 -0
  63. package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js.map +1 -0
  64. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.d.ts +57 -0
  65. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js +384 -0
  66. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js.map +1 -0
  67. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.d.ts +63 -0
  68. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js +264 -0
  69. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js.map +1 -0
  70. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.d.ts +5 -0
  71. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js +82 -0
  72. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js.map +1 -0
  73. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.d.ts +4 -0
  74. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js +67 -0
  75. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js.map +1 -0
  76. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.d.ts +89 -0
  77. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js +169 -0
  78. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js.map +1 -0
  79. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.d.ts +9 -0
  80. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.js +3 -0
  81. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.js.map +1 -0
  82. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.d.ts +42 -0
  83. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js +270 -0
  84. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js.map +1 -0
  85. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.d.ts +15 -0
  86. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js +80 -0
  87. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js.map +1 -0
  88. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.d.ts +12 -0
  89. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js +184 -0
  90. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js.map +1 -0
  91. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.d.ts +5 -0
  92. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js +81 -0
  93. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js.map +1 -0
  94. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.d.ts +4 -0
  95. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js +76 -0
  96. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js.map +1 -0
  97. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.d.ts +14 -0
  98. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js +150 -0
  99. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js.map +1 -0
  100. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.d.ts +17 -0
  101. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js +41 -0
  102. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js.map +1 -0
  103. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.d.ts +150 -0
  104. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js +217 -0
  105. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js.map +1 -0
  106. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.d.ts +26 -0
  107. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js +115 -0
  108. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +1 -0
  109. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.d.ts +9 -0
  110. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js +35 -0
  111. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +1 -0
  112. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.d.ts +3 -0
  113. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js +26 -0
  114. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js.map +1 -0
  115. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.d.ts +13 -0
  116. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js +52 -0
  117. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js.map +1 -0
  118. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.d.ts +4 -0
  119. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.js +9 -0
  120. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/version.js.map +1 -0
  121. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.d.ts +34 -0
  122. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js +39 -0
  123. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js.map +1 -0
  124. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.d.ts +1590 -0
  125. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js +35 -0
  126. package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js.map +1 -0
  127. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.d.ts +91 -0
  128. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js +127 -0
  129. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js.map +1 -0
  130. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.d.ts +145 -0
  131. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js +270 -0
  132. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js.map +1 -0
  133. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.d.ts +4 -0
  134. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js +33 -0
  135. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js.map +1 -0
  136. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.d.ts +163 -0
  137. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js +438 -0
  138. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js.map +1 -0
  139. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.d.ts +158 -0
  140. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js +254 -0
  141. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js.map +1 -0
  142. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.d.ts +24 -0
  143. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js +126 -0
  144. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js.map +1 -0
  145. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.d.ts +4 -0
  146. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.js +9 -0
  147. package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/version.js.map +1 -0
  148. package/dependencies/src/axios-0.19.0/index.d.ts +152 -0
  149. package/dependencies/src/axios-0.19.0/index.js +1 -0
  150. package/dependencies/src/axios-0.19.0/lib/adapters/http.js +275 -0
  151. package/dependencies/src/axios-0.19.0/lib/adapters/xhr.js +174 -0
  152. package/dependencies/src/axios-0.19.0/lib/axios.js +53 -0
  153. package/dependencies/src/axios-0.19.0/lib/cancel/Cancel.js +19 -0
  154. package/dependencies/src/axios-0.19.0/lib/cancel/CancelToken.js +57 -0
  155. package/dependencies/src/axios-0.19.0/lib/cancel/isCancel.js +5 -0
  156. package/dependencies/src/axios-0.19.0/lib/core/Axios.js +86 -0
  157. package/dependencies/src/axios-0.19.0/lib/core/InterceptorManager.js +52 -0
  158. package/dependencies/src/axios-0.19.0/lib/core/createError.js +18 -0
  159. package/dependencies/src/axios-0.19.0/lib/core/dispatchRequest.js +86 -0
  160. package/dependencies/src/axios-0.19.0/lib/core/enhanceError.js +42 -0
  161. package/dependencies/src/axios-0.19.0/lib/core/mergeConfig.js +51 -0
  162. package/dependencies/src/axios-0.19.0/lib/core/settle.js +25 -0
  163. package/dependencies/src/axios-0.19.0/lib/core/transformData.js +20 -0
  164. package/dependencies/src/axios-0.19.0/lib/defaults.js +98 -0
  165. package/dependencies/src/axios-0.19.0/lib/helpers/bind.js +11 -0
  166. package/dependencies/src/axios-0.19.0/lib/helpers/buildURL.js +71 -0
  167. package/dependencies/src/axios-0.19.0/lib/helpers/combineURLs.js +14 -0
  168. package/dependencies/src/axios-0.19.0/lib/helpers/cookies.js +53 -0
  169. package/dependencies/src/axios-0.19.0/lib/helpers/deprecatedMethod.js +24 -0
  170. package/dependencies/src/axios-0.19.0/lib/helpers/isAbsoluteURL.js +14 -0
  171. package/dependencies/src/axios-0.19.0/lib/helpers/isURLSameOrigin.js +68 -0
  172. package/dependencies/src/axios-0.19.0/lib/helpers/normalizeHeaderName.js +12 -0
  173. package/dependencies/src/axios-0.19.0/lib/helpers/parseHeaders.js +53 -0
  174. package/dependencies/src/axios-0.19.0/lib/helpers/spread.js +27 -0
  175. package/dependencies/src/axios-0.19.0/lib/utils.js +334 -0
  176. package/dependencies/src/axios-0.19.0/package.json +85 -0
  177. package/dependencies/src/base-x-3.0.7/src/index.d.ts +10 -0
  178. package/dependencies/src/base-x-3.0.7/src/index.js +120 -0
  179. package/dependencies/src/base64-js-1.3.1/index.js +152 -0
  180. package/dependencies/src/bech32-0.0.3/index.js +139 -0
  181. package/dependencies/src/bech32-1.1.3/index.js +147 -0
  182. package/dependencies/src/big-integer-1.6.45/BigInteger.d.ts +2393 -0
  183. package/dependencies/src/big-integer-1.6.45/BigInteger.js +1452 -0
  184. package/dependencies/src/bigi-1.4.2/lib/bigi.js +1509 -0
  185. package/dependencies/src/bigi-1.4.2/lib/convert.js +91 -0
  186. package/dependencies/src/bigi-1.4.2/lib/index.js +6 -0
  187. package/dependencies/src/bigi-1.4.2/package.json +55 -0
  188. package/dependencies/src/bignumber.js-9.0.0/bignumber.d.ts +1829 -0
  189. package/dependencies/src/bignumber.js-9.0.0/bignumber.js +2902 -0
  190. package/dependencies/src/bip32-2.0.4/src/bip32.js +290 -0
  191. package/dependencies/src/bip32-2.0.4/src/crypto.js +26 -0
  192. package/dependencies/src/bip32-2.0.4/src/index.js +7 -0
  193. package/dependencies/src/bip32-path-0.4.2/index.js +96 -0
  194. package/dependencies/src/bip39-2.5.0/index.js +153 -0
  195. package/dependencies/src/bip39-2.5.0/wordlists/chinese_simplified.json +2050 -0
  196. package/dependencies/src/bip39-2.5.0/wordlists/chinese_traditional.json +2050 -0
  197. package/dependencies/src/bip39-2.5.0/wordlists/english.json +2050 -0
  198. package/dependencies/src/bip39-2.5.0/wordlists/french.json +2050 -0
  199. package/dependencies/src/bip39-2.5.0/wordlists/italian.json +2050 -0
  200. package/dependencies/src/bip39-2.5.0/wordlists/japanese.json +2050 -0
  201. package/dependencies/src/bip39-2.5.0/wordlists/korean.json +2050 -0
  202. package/dependencies/src/bip39-2.5.0/wordlists/spanish.json +2050 -0
  203. package/dependencies/src/bip66-1.1.5/index.js +113 -0
  204. package/dependencies/src/bitcoin-ops-1.4.1/index.json +120 -0
  205. package/dependencies/src/bitcoin-ops-1.4.1/map.js +9 -0
  206. package/dependencies/src/bitcoinjs-message-2.1.1/index.js +157 -0
  207. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/address.js +109 -0
  208. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/block.js +234 -0
  209. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/bufferWriter.js +40 -0
  210. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/bufferutils.js +65 -0
  211. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/coins.js +53 -0
  212. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/crypto.js +43 -0
  213. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/ecdsa.js +161 -0
  214. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/ecpair.js +155 -0
  215. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/ecsignature.js +97 -0
  216. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/fastcurve.js +92 -0
  217. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/hdnode.js +363 -0
  218. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/index.js +24 -0
  219. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/networks.js +214 -0
  220. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/script.js +214 -0
  221. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/script_number.js +68 -0
  222. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/index.js +74 -0
  223. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/multisig/index.js +4 -0
  224. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/multisig/input.js +71 -0
  225. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/multisig/output.js +64 -0
  226. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/nulldata.js +39 -0
  227. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkey/index.js +4 -0
  228. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkey/input.js +39 -0
  229. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkey/output.js +33 -0
  230. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkeyhash/index.js +4 -0
  231. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkeyhash/input.js +51 -0
  232. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/pubkeyhash/output.js +42 -0
  233. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/scripthash/index.js +4 -0
  234. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/scripthash/input.js +84 -0
  235. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/scripthash/output.js +34 -0
  236. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnesscommitment/index.js +3 -0
  237. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnesscommitment/output.js +42 -0
  238. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnesspubkeyhash/index.js +4 -0
  239. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnesspubkeyhash/input.js +44 -0
  240. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnesspubkeyhash/output.js +33 -0
  241. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnessscripthash/index.js +4 -0
  242. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnessscripthash/input.js +63 -0
  243. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/templates/witnessscripthash/output.js +33 -0
  244. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/transaction.js +1125 -0
  245. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/transaction_builder.js +892 -0
  246. package/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/types.js +55 -0
  247. package/dependencies/src/blake2b-6268e6dd678661e0acc4359e9171b97eb1ebf8ac/index.js +313 -0
  248. package/dependencies/src/blake2b-wasm-193cdb71656c1a6c7f89b05d0327bb9b758d071b/blake2b.js +63 -0
  249. package/dependencies/src/blake2b-wasm-193cdb71656c1a6c7f89b05d0327bb9b758d071b/index.js +128 -0
  250. package/dependencies/src/blakejs-1.1.0/blake2b.js +273 -0
  251. package/dependencies/src/blakejs-1.1.0/blake2s.js +190 -0
  252. package/dependencies/src/blakejs-1.1.0/index.js +15 -0
  253. package/dependencies/src/blakejs-1.1.0/util.js +81 -0
  254. package/dependencies/src/bn.js-4.11.8/lib/bn.js +3427 -0
  255. package/dependencies/src/brorand-1.1.0/index.js +65 -0
  256. package/dependencies/src/bs58-4.0.1/index.js +4 -0
  257. package/dependencies/src/bs58check-2.1.2/base.js +50 -0
  258. package/dependencies/src/bs58check-2.1.2/index.js +12 -0
  259. package/dependencies/src/bs58grscheck-2.1.2/base.js +50 -0
  260. package/dependencies/src/bs58grscheck-2.1.2/index.js +12 -0
  261. package/dependencies/src/buffer-5.6.0/index.d.ts +186 -0
  262. package/dependencies/src/buffer-5.6.0/index.js +1794 -0
  263. package/dependencies/src/buffer-equals-1.0.4/index.js +26 -0
  264. package/dependencies/src/cbor-sync-1.0.4/index.d.ts +11 -0
  265. package/dependencies/src/cbor-sync-1.0.4/index.js +632 -0
  266. package/dependencies/src/cipher-base-1.0.4/index.js +99 -0
  267. package/dependencies/src/cosmjs/index.d.ts +379 -0
  268. package/dependencies/src/cosmjs/index.js +1297 -0
  269. package/dependencies/src/cosmjs/index.js.map +1 -0
  270. package/dependencies/src/create-hash-1.2.0/browser.js +30 -0
  271. package/dependencies/src/create-hash-1.2.0/index.js +1 -0
  272. package/dependencies/src/create-hash-1.2.0/md5.js +5 -0
  273. package/dependencies/src/create-hmac-1.1.4/browser.js +68 -0
  274. package/dependencies/src/create-hmac-1.1.4/index.js +1 -0
  275. package/dependencies/src/create-hmac-1.1.7/browser.js +62 -0
  276. package/dependencies/src/create-hmac-1.1.7/legacy.js +46 -0
  277. package/dependencies/src/cryptocompare-0.5.0/index.js +138 -0
  278. package/dependencies/src/cuint-0.2.2/index.js +2 -0
  279. package/dependencies/src/cuint-0.2.2/lib/uint32.js +451 -0
  280. package/dependencies/src/cuint-0.2.2/lib/uint64.js +648 -0
  281. package/dependencies/src/debug-3.1.0/src/browser.js +195 -0
  282. package/dependencies/src/debug-3.1.0/src/debug.js +225 -0
  283. package/dependencies/src/drbg.js-1.0.1/hash.js +92 -0
  284. package/dependencies/src/drbg.js-1.0.1/hmac.js +71 -0
  285. package/dependencies/src/drbg.js-1.0.1/index.js +4 -0
  286. package/dependencies/src/drbg.js-1.0.1/lib/hash-info.json +27 -0
  287. package/dependencies/src/drbg.js-1.0.1/lib/util.js +36 -0
  288. package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +12 -0
  289. package/dependencies/src/eciesjs-0.3.9/src/index.js +35 -0
  290. package/dependencies/src/eciesjs-0.3.9/src/index.js.map +1 -0
  291. package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.d.ts +12 -0
  292. package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +62 -0
  293. package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js.map +1 -0
  294. package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.d.ts +11 -0
  295. package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +65 -0
  296. package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js.map +1 -0
  297. package/dependencies/src/eciesjs-0.3.9/src/keys/index.d.ts +2 -0
  298. package/dependencies/src/eciesjs-0.3.9/src/keys/index.js +11 -0
  299. package/dependencies/src/eciesjs-0.3.9/src/keys/index.js.map +1 -0
  300. package/dependencies/src/eciesjs-0.3.9/src/utils.d.ts +6 -0
  301. package/dependencies/src/eciesjs-0.3.9/src/utils.js +65 -0
  302. package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -0
  303. package/dependencies/src/ecurve-1.0.6/lib/curve.js +77 -0
  304. package/dependencies/src/ecurve-1.0.6/lib/curves.json +65 -0
  305. package/dependencies/src/ecurve-1.0.6/lib/index.js +10 -0
  306. package/dependencies/src/ecurve-1.0.6/lib/names.js +21 -0
  307. package/dependencies/src/ecurve-1.0.6/lib/point.js +244 -0
  308. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/base.js +374 -0
  309. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/edwards.js +432 -0
  310. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/index.js +8 -0
  311. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/mont.js +178 -0
  312. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curve/short.js +937 -0
  313. package/dependencies/src/elliptic-6.5.1/lib/elliptic/curves.js +206 -0
  314. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/index.js +241 -0
  315. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/key.js +118 -0
  316. package/dependencies/src/elliptic-6.5.1/lib/elliptic/ec/signature.js +134 -0
  317. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/index.js +118 -0
  318. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/key.js +95 -0
  319. package/dependencies/src/elliptic-6.5.1/lib/elliptic/eddsa/signature.js +65 -0
  320. package/dependencies/src/elliptic-6.5.1/lib/elliptic/precomputed/secp256k1.js +780 -0
  321. package/dependencies/src/elliptic-6.5.1/lib/elliptic/utils.js +120 -0
  322. package/dependencies/src/elliptic-6.5.1/lib/elliptic.js +13 -0
  323. package/dependencies/src/elliptic-6.5.1/package.json +55 -0
  324. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/base.js +376 -0
  325. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/edwards.js +432 -0
  326. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/index.js +8 -0
  327. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/mont.js +178 -0
  328. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curve/short.js +937 -0
  329. package/dependencies/src/elliptic-6.5.3/lib/elliptic/curves.js +206 -0
  330. package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/index.js +241 -0
  331. package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/key.js +118 -0
  332. package/dependencies/src/elliptic-6.5.3/lib/elliptic/ec/signature.js +166 -0
  333. package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/index.js +118 -0
  334. package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/key.js +95 -0
  335. package/dependencies/src/elliptic-6.5.3/lib/elliptic/eddsa/signature.js +65 -0
  336. package/dependencies/src/elliptic-6.5.3/lib/elliptic/precomputed/secp256k1.js +780 -0
  337. package/dependencies/src/elliptic-6.5.3/lib/elliptic/utils.js +119 -0
  338. package/dependencies/src/elliptic-6.5.3/lib/elliptic.js +13 -0
  339. package/dependencies/src/elliptic-6.5.3/package.json +55 -0
  340. package/dependencies/src/ethereum-common-0.2.1/bootstrapNodes.json +92 -0
  341. package/dependencies/src/ethereum-common-0.2.1/genesisState.json +8895 -0
  342. package/dependencies/src/ethereum-common-0.2.1/index.js +4 -0
  343. package/dependencies/src/ethereum-common-0.2.1/params.json +245 -0
  344. package/dependencies/src/ethereumjs-tx-1.3.7/index.js +298 -0
  345. package/dependencies/src/ethereumjs-util-5.2.0/index.js +714 -0
  346. package/dependencies/src/ethjs-util-0.1.4/src/index.js +203 -0
  347. package/dependencies/src/follow-redirects-1.5.10/http.js +1 -0
  348. package/dependencies/src/follow-redirects-1.5.10/https.js +1 -0
  349. package/dependencies/src/follow-redirects-1.5.10/index.js +322 -0
  350. package/dependencies/src/futoin-hkdf-1.3.3/hkdf.d.ts +29 -0
  351. package/dependencies/src/futoin-hkdf-1.3.3/hkdf.js +174 -0
  352. package/dependencies/src/groestl-hash-js-ef6a04f1c4d2f0448f0882b5f213ef7a0659baee/index.js +39 -0
  353. package/dependencies/src/groestl-hash-js-ef6a04f1c4d2f0448f0882b5f213ef7a0659baee/lib/groestl.js +1248 -0
  354. package/dependencies/src/groestl-hash-js-ef6a04f1c4d2f0448f0882b5f213ef7a0659baee/lib/helper.js +253 -0
  355. package/dependencies/src/groestl-hash-js-ef6a04f1c4d2f0448f0882b5f213ef7a0659baee/lib/op.js +462 -0
  356. package/dependencies/src/groestlcoinjs-message-2.1.0/index.js +245 -0
  357. package/dependencies/src/hash-base-3.0.4/index.js +95 -0
  358. package/dependencies/src/hash.js-1.1.7/lib/hash/common.js +92 -0
  359. package/dependencies/src/hash.js-1.1.7/lib/hash/hmac.js +47 -0
  360. package/dependencies/src/hash.js-1.1.7/lib/hash/ripemd.js +146 -0
  361. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/1.js +74 -0
  362. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/224.js +30 -0
  363. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/256.js +105 -0
  364. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/384.js +35 -0
  365. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/512.js +330 -0
  366. package/dependencies/src/hash.js-1.1.7/lib/hash/sha/common.js +49 -0
  367. package/dependencies/src/hash.js-1.1.7/lib/hash/sha.js +7 -0
  368. package/dependencies/src/hash.js-1.1.7/lib/hash/utils.js +278 -0
  369. package/dependencies/src/hash.js-1.1.7/lib/hash.js +15 -0
  370. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.d.ts +15 -0
  371. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +101 -0
  372. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js.map +1 -0
  373. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.d.ts +3 -0
  374. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js +37 -0
  375. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -0
  376. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index.d.ts +1 -0
  377. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index.js +34 -0
  378. package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/index.js.map +1 -0
  379. package/dependencies/src/hmac-drbg-1.0.1/lib/hmac-drbg.js +113 -0
  380. package/dependencies/src/idna-uts46-hx-3.4.0/idna-map.js +23865 -0
  381. package/dependencies/src/idna-uts46-hx-3.4.0/index.d.ts +6 -0
  382. package/dependencies/src/idna-uts46-hx-3.4.0/uts46.js +170 -0
  383. package/dependencies/src/ieee754-1.1.13/index.js +84 -0
  384. package/dependencies/src/inherits-2.0.4/inherits.js +9 -0
  385. package/dependencies/src/inherits-2.0.4/inherits_browser.js +27 -0
  386. package/dependencies/src/is-buffer-2.0.3/index.js +11 -0
  387. package/dependencies/src/is-hex-prefixed-1.0.0/src/index.js +13 -0
  388. package/dependencies/src/js-cuint-0.2.2/index.js +2 -0
  389. package/dependencies/src/js-cuint-0.2.2/lib/uint32.js +451 -0
  390. package/dependencies/src/js-cuint-0.2.2/lib/uint64.js +648 -0
  391. package/dependencies/src/keccak-1.0.2/js.js +2 -0
  392. package/dependencies/src/keccak-1.0.2/lib/api/index.js +28 -0
  393. package/dependencies/src/keccak-1.0.2/lib/api/keccak.js +83 -0
  394. package/dependencies/src/keccak-1.0.2/lib/api/shake.js +74 -0
  395. package/dependencies/src/keccak-1.0.2/lib/keccak-state.js +187 -0
  396. package/dependencies/src/keccak-1.0.2/lib/keccak.js +69 -0
  397. package/dependencies/src/md5.js-1.3.5/index.js +146 -0
  398. package/dependencies/src/merkle-lib-2.0.10/fastRoot.js +24 -0
  399. package/dependencies/src/merkle-lib-2.0.10/index.js +34 -0
  400. package/dependencies/src/minimalistic-assert-1.0.1/index.js +11 -0
  401. package/dependencies/src/minimalistic-crypto-utils-1.0.1/lib/utils.js +58 -0
  402. package/dependencies/src/ms-2.1.2/index.js +162 -0
  403. package/dependencies/src/nan-2.14.0/include_dirs.js +1 -0
  404. package/dependencies/src/nanoassert-1.1.0/index.js +22 -0
  405. package/dependencies/src/pako-2.0.3/index.js +18 -0
  406. package/dependencies/src/pako-2.0.3/lib/deflate.js +373 -0
  407. package/dependencies/src/pako-2.0.3/lib/inflate.js +402 -0
  408. package/dependencies/src/pako-2.0.3/lib/utils/common.js +48 -0
  409. package/dependencies/src/pako-2.0.3/lib/utils/strings.js +187 -0
  410. package/dependencies/src/pako-2.0.3/lib/zlib/adler32.js +50 -0
  411. package/dependencies/src/pako-2.0.3/lib/zlib/constants.js +66 -0
  412. package/dependencies/src/pako-2.0.3/lib/zlib/crc32.js +58 -0
  413. package/dependencies/src/pako-2.0.3/lib/zlib/deflate.js +1849 -0
  414. package/dependencies/src/pako-2.0.3/lib/zlib/gzheader.js +58 -0
  415. package/dependencies/src/pako-2.0.3/lib/zlib/inffast.js +347 -0
  416. package/dependencies/src/pako-2.0.3/lib/zlib/inflate.js +1625 -0
  417. package/dependencies/src/pako-2.0.3/lib/zlib/inftrees.js +462 -0
  418. package/dependencies/src/pako-2.0.3/lib/zlib/messages.js +32 -0
  419. package/dependencies/src/pako-2.0.3/lib/zlib/trees.js +1192 -0
  420. package/dependencies/src/pako-2.0.3/lib/zlib/zstream.js +47 -0
  421. package/dependencies/src/pbkdf2-3.0.17/bench/index.js +35 -0
  422. package/dependencies/src/pbkdf2-3.0.17/bench/old.js +47 -0
  423. package/dependencies/src/pbkdf2-3.0.17/browser.js +2 -0
  424. package/dependencies/src/pbkdf2-3.0.17/index.js +31 -0
  425. package/dependencies/src/pbkdf2-3.0.17/lib/async.js +100 -0
  426. package/dependencies/src/pbkdf2-3.0.17/lib/default-encoding.js +10 -0
  427. package/dependencies/src/pbkdf2-3.0.17/lib/precondition.js +28 -0
  428. package/dependencies/src/pbkdf2-3.0.17/lib/sync-browser.js +104 -0
  429. package/dependencies/src/pbkdf2-3.0.17/lib/sync.js +51 -0
  430. package/dependencies/src/punycode-2.1.1/punycode.js +429 -0
  431. package/dependencies/src/pushdata-bitcoin-1.0.1/index.js +77 -0
  432. package/dependencies/src/randombytes-2.1.0/browser.js +50 -0
  433. package/dependencies/src/randombytes-2.1.0/index.js +1 -0
  434. package/dependencies/src/ripemd160-2.0.2/index.js +163 -0
  435. package/dependencies/src/rlp-2.2.3/index.js +230 -0
  436. package/dependencies/src/safe-buffer-5.2.0/index.js +64 -0
  437. package/dependencies/src/secp256k1-3.7.1/elliptic.js +2 -0
  438. package/dependencies/src/secp256k1-3.7.1/lib/assert.js +44 -0
  439. package/dependencies/src/secp256k1-3.7.1/lib/der.js +193 -0
  440. package/dependencies/src/secp256k1-3.7.1/lib/elliptic/index.js +263 -0
  441. package/dependencies/src/secp256k1-3.7.1/lib/index.js +245 -0
  442. package/dependencies/src/secp256k1-3.7.1/lib/messages.json +37 -0
  443. package/dependencies/src/secp256k1-4.0.2/elliptic.js +1 -0
  444. package/dependencies/src/secp256k1-4.0.2/lib/elliptic.js +402 -0
  445. package/dependencies/src/secp256k1-4.0.2/lib/index.js +336 -0
  446. package/dependencies/src/sha.js-2.4.11/hash.js +81 -0
  447. package/dependencies/src/sha.js-2.4.11/index.js +16 -0
  448. package/dependencies/src/sha.js-2.4.11/sha.js +94 -0
  449. package/dependencies/src/sha.js-2.4.11/sha1.js +99 -0
  450. package/dependencies/src/sha.js-2.4.11/sha224.js +53 -0
  451. package/dependencies/src/sha.js-2.4.11/sha256.js +135 -0
  452. package/dependencies/src/sha.js-2.4.11/sha384.js +57 -0
  453. package/dependencies/src/sha.js-2.4.11/sha512.js +260 -0
  454. package/dependencies/src/strip-hex-prefix-1.0.0/src/index.js +14 -0
  455. package/dependencies/src/tiny-secp256k1-1.1.3/js.js +276 -0
  456. package/dependencies/src/tiny-secp256k1-1.1.3/rfc6979.js +62 -0
  457. package/dependencies/src/tweetnacl-1.0.1/nacl.d.ts +98 -0
  458. package/dependencies/src/tweetnacl-1.0.1/nacl.js +1164 -0
  459. package/dependencies/src/tweetnacl-auth-1.0.1/nacl-auth.js +47 -0
  460. package/dependencies/src/typedarray-to-buffer-4.0.0/index.js +17 -0
  461. package/dependencies/src/typeforce-1.18.0/errors.js +110 -0
  462. package/dependencies/src/typeforce-1.18.0/extra.js +91 -0
  463. package/dependencies/src/typeforce-1.18.0/index.js +260 -0
  464. package/dependencies/src/typeforce-1.18.0/native.js +21 -0
  465. package/dependencies/src/unorm-1.6.0/lib/unorm.js +452 -0
  466. package/dependencies/src/utf8-3.0.0/utf8.js +202 -0
  467. package/dependencies/src/validate.js-0.13.1/validate.d.ts +55 -0
  468. package/dependencies/src/validate.js-0.13.1/validate.js +1253 -0
  469. package/dependencies/src/varuint-bitcoin-1.1.2/index.d.ts +13 -0
  470. package/dependencies/src/varuint-bitcoin-1.1.2/index.js +90 -0
  471. package/dependencies/src/wif-2.0.6/index.js +63 -0
  472. package/dependencies/src/xxhashjs-0.2.2/lib/index.js +4 -0
  473. package/dependencies/src/xxhashjs-0.2.2/lib/xxhash.js +389 -0
  474. package/dependencies/src/xxhashjs-0.2.2/lib/xxhash64.js +444 -0
  475. package/errors/coinlib-error.d.ts +30 -0
  476. package/errors/coinlib-error.js +62 -0
  477. package/errors/coinlib-error.js.map +1 -0
  478. package/errors/index.d.ts +156 -0
  479. package/errors/index.js +281 -0
  480. package/errors/index.js.map +1 -0
  481. package/errors/network.d.ts +0 -0
  482. package/errors/network.js +2 -0
  483. package/errors/network.js.map +1 -0
  484. package/index.d.ts +33 -0
  485. package/index.js +58 -0
  486. package/index.js.map +1 -0
  487. package/interfaces/IAirGapAddress.d.ts +10 -0
  488. package/interfaces/IAirGapAddress.js +3 -0
  489. package/interfaces/IAirGapAddress.js.map +1 -0
  490. package/interfaces/IAirGapSignedTransaction.d.ts +1 -0
  491. package/interfaces/IAirGapSignedTransaction.js +3 -0
  492. package/interfaces/IAirGapSignedTransaction.js.map +1 -0
  493. package/interfaces/IAirGapTransaction.d.ts +53 -0
  494. package/interfaces/IAirGapTransaction.js +22 -0
  495. package/interfaces/IAirGapTransaction.js.map +1 -0
  496. package/interfaces/IAirGapWallet.d.ts +6 -0
  497. package/interfaces/IAirGapWallet.js +3 -0
  498. package/interfaces/IAirGapWallet.js.map +1 -0
  499. package/interfaces/JSONConvertible.d.ts +3 -0
  500. package/interfaces/JSONConvertible.js +3 -0
  501. package/interfaces/JSONConvertible.js.map +1 -0
  502. package/interfaces/RPCConvertible.d.ts +3 -0
  503. package/interfaces/RPCConvertible.js +3 -0
  504. package/interfaces/RPCConvertible.js.map +1 -0
  505. package/networks.d.ts +19 -0
  506. package/networks.js +1341 -0
  507. package/networks.js.map +1 -0
  508. package/package.json +1 -5
  509. package/protocols/BlockExplorerProtocol.d.ts +6 -0
  510. package/protocols/BlockExplorerProtocol.js +60 -0
  511. package/protocols/BlockExplorerProtocol.js.map +1 -0
  512. package/protocols/CryptoClient.d.ts +15 -0
  513. package/protocols/CryptoClient.js +84 -0
  514. package/protocols/CryptoClient.js.map +1 -0
  515. package/protocols/Ed25519CryptoClient.d.ts +8 -0
  516. package/protocols/Ed25519CryptoClient.js +107 -0
  517. package/protocols/Ed25519CryptoClient.js.map +1 -0
  518. package/protocols/HasConfigurableContract.d.ts +4 -0
  519. package/protocols/HasConfigurableContract.js +3 -0
  520. package/protocols/HasConfigurableContract.js.map +1 -0
  521. package/protocols/ICoinBaseProtocol.d.ts +107 -0
  522. package/protocols/ICoinBaseProtocol.js +3 -0
  523. package/protocols/ICoinBaseProtocol.js.map +1 -0
  524. package/protocols/ICoinDelegateProtocol.d.ts +40 -0
  525. package/protocols/ICoinDelegateProtocol.js +3 -0
  526. package/protocols/ICoinDelegateProtocol.js.map +1 -0
  527. package/protocols/ICoinOfflineProtocol.d.ts +24 -0
  528. package/protocols/ICoinOfflineProtocol.js +3 -0
  529. package/protocols/ICoinOfflineProtocol.js.map +1 -0
  530. package/protocols/ICoinOnlineProtocol.d.ts +46 -0
  531. package/protocols/ICoinOnlineProtocol.js +3 -0
  532. package/protocols/ICoinOnlineProtocol.js.map +1 -0
  533. package/protocols/ICoinProtocol.d.ts +9 -0
  534. package/protocols/ICoinProtocol.js +3 -0
  535. package/protocols/ICoinProtocol.js.map +1 -0
  536. package/protocols/ICoinSubProtocol.d.ts +22 -0
  537. package/protocols/ICoinSubProtocol.js +9 -0
  538. package/protocols/ICoinSubProtocol.js.map +1 -0
  539. package/protocols/NonExtendedProtocol.d.ts +17 -0
  540. package/protocols/NonExtendedProtocol.js +49 -0
  541. package/protocols/NonExtendedProtocol.js.map +1 -0
  542. package/protocols/Secp256k1CryptoClient.d.ts +8 -0
  543. package/protocols/Secp256k1CryptoClient.js +79 -0
  544. package/protocols/Secp256k1CryptoClient.js.map +1 -0
  545. package/protocols/Sr25519CryptoClient.d.ts +8 -0
  546. package/protocols/Sr25519CryptoClient.js +82 -0
  547. package/protocols/Sr25519CryptoClient.js.map +1 -0
  548. package/types/signed-transaction.d.ts +4 -0
  549. package/types/signed-transaction.js +3 -0
  550. package/types/signed-transaction.js.map +1 -0
  551. package/types/unsigned-transaction.d.ts +5 -0
  552. package/types/unsigned-transaction.js +3 -0
  553. package/types/unsigned-transaction.js.map +1 -0
  554. package/utils/AES.d.ts +10 -0
  555. package/utils/AES.js +165 -0
  556. package/utils/AES.js.map +1 -0
  557. package/utils/ErrorWithData.d.ts +4 -0
  558. package/utils/ErrorWithData.js +29 -0
  559. package/utils/ErrorWithData.js.map +1 -0
  560. package/utils/Network.d.ts +2 -0
  561. package/utils/Network.js +8 -0
  562. package/utils/Network.js.map +1 -0
  563. package/utils/ProtocolBlockExplorer.d.ts +6 -0
  564. package/utils/ProtocolBlockExplorer.js +11 -0
  565. package/utils/ProtocolBlockExplorer.js.map +1 -0
  566. package/utils/ProtocolNetwork.d.ts +15 -0
  567. package/utils/ProtocolNetwork.js +35 -0
  568. package/utils/ProtocolNetwork.js.map +1 -0
  569. package/utils/ProtocolOptions.d.ts +5 -0
  570. package/utils/ProtocolOptions.js +3 -0
  571. package/utils/ProtocolOptions.js.map +1 -0
  572. package/utils/ProtocolSymbols.d.ts +45 -0
  573. package/utils/ProtocolSymbols.js +59 -0
  574. package/utils/ProtocolSymbols.js.map +1 -0
  575. package/utils/array.d.ts +4 -0
  576. package/utils/array.js +36 -0
  577. package/utils/array.js.map +1 -0
  578. package/utils/assert.d.ts +2 -0
  579. package/utils/assert.js +20 -0
  580. package/utils/assert.js.map +1 -0
  581. package/utils/base64Check.d.ts +7 -0
  582. package/utils/base64Check.js +39 -0
  583. package/utils/base64Check.js.map +1 -0
  584. package/utils/blake2b.d.ts +7 -0
  585. package/utils/blake2b.js +23 -0
  586. package/utils/blake2b.js.map +1 -0
  587. package/utils/buffer.d.ts +2 -0
  588. package/utils/buffer.js +8 -0
  589. package/utils/buffer.js.map +1 -0
  590. package/utils/cache.d.ts +15 -0
  591. package/utils/cache.js +97 -0
  592. package/utils/cache.js.map +1 -0
  593. package/utils/error.d.ts +1 -0
  594. package/utils/error.js +8 -0
  595. package/utils/error.js.map +1 -0
  596. package/utils/hex.d.ts +14 -0
  597. package/utils/hex.js +112 -0
  598. package/utils/hex.js.map +1 -0
  599. package/utils/interfaces.d.ts +3 -0
  600. package/utils/interfaces.js +18 -0
  601. package/utils/interfaces.js.map +1 -0
  602. package/utils/object.d.ts +1 -0
  603. package/utils/object.js +23 -0
  604. package/utils/object.js.map +1 -0
  605. package/utils/padStart.d.ts +1 -0
  606. package/utils/padStart.js +20 -0
  607. package/utils/padStart.js.map +1 -0
  608. package/utils/remote-data/HttpRemoteData.d.ts +8 -0
  609. package/utils/remote-data/HttpRemoteData.js +117 -0
  610. package/utils/remote-data/HttpRemoteData.js.map +1 -0
  611. package/utils/remote-data/IpfsRemoteData.d.ts +8 -0
  612. package/utils/remote-data/IpfsRemoteData.js +142 -0
  613. package/utils/remote-data/IpfsRemoteData.js.map +1 -0
  614. package/utils/remote-data/RemoteData.d.ts +11 -0
  615. package/utils/remote-data/RemoteData.js +11 -0
  616. package/utils/remote-data/RemoteData.js.map +1 -0
  617. package/utils/remote-data/RemoteDataFactory.d.ts +11 -0
  618. package/utils/remote-data/RemoteDataFactory.js +29 -0
  619. package/utils/remote-data/RemoteDataFactory.js.map +1 -0
  620. package/utils/remote-data/Sha256RemoteData.d.ts +11 -0
  621. package/utils/remote-data/Sha256RemoteData.js +139 -0
  622. package/utils/remote-data/Sha256RemoteData.js.map +1 -0
  623. package/utils/string.d.ts +7 -0
  624. package/utils/string.js +50 -0
  625. package/utils/string.js.map +1 -0
  626. package/utils/type.d.ts +1 -0
  627. package/utils/type.js +16 -0
  628. package/utils/type.js.map +1 -0
  629. package/utils/xxhash.d.ts +5 -0
  630. package/utils/xxhash.js +18 -0
  631. package/utils/xxhash.js.map +1 -0
  632. package/wallet/AirGapCoinWallet.d.ts +19 -0
  633. package/wallet/AirGapCoinWallet.js +199 -0
  634. package/wallet/AirGapCoinWallet.js.map +1 -0
  635. package/wallet/AirGapMarketWallet.d.ts +40 -0
  636. package/wallet/AirGapMarketWallet.js +221 -0
  637. package/wallet/AirGapMarketWallet.js.map +1 -0
  638. package/wallet/AirGapNFTWallet.d.ts +15 -0
  639. package/wallet/AirGapNFTWallet.js +179 -0
  640. package/wallet/AirGapNFTWallet.js.map +1 -0
  641. package/wallet/AirGapWallet.d.ts +35 -0
  642. package/wallet/AirGapWallet.js +142 -0
  643. package/wallet/AirGapWallet.js.map +1 -0
@@ -0,0 +1,1849 @@
1
+ 'use strict'
2
+
3
+ // (C) 1995-2013 Jean-loup Gailly and Mark Adler
4
+ // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
5
+ //
6
+ // This software is provided 'as-is', without any express or implied
7
+ // warranty. In no event will the authors be held liable for any damages
8
+ // arising from the use of this software.
9
+ //
10
+ // Permission is granted to anyone to use this software for any purpose,
11
+ // including commercial applications, and to alter it and redistribute it
12
+ // freely, subject to the following restrictions:
13
+ //
14
+ // 1. The origin of this software must not be misrepresented; you must not
15
+ // claim that you wrote the original software. If you use this software
16
+ // in a product, an acknowledgment in the product documentation would be
17
+ // appreciated but is not required.
18
+ // 2. Altered source versions must be plainly marked as such, and must not be
19
+ // misrepresented as being the original software.
20
+ // 3. This notice may not be removed or altered from any source distribution.
21
+
22
+ const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = require('./trees')
23
+ const adler32 = require('./adler32')
24
+ const crc32 = require('./crc32')
25
+ const msg = require('./messages')
26
+
27
+ /* Public constants ==========================================================*/
28
+ /* ===========================================================================*/
29
+
30
+ const {
31
+ Z_NO_FLUSH,
32
+ Z_PARTIAL_FLUSH,
33
+ Z_FULL_FLUSH,
34
+ Z_FINISH,
35
+ Z_BLOCK,
36
+ Z_OK,
37
+ Z_STREAM_END,
38
+ Z_STREAM_ERROR,
39
+ Z_DATA_ERROR,
40
+ Z_BUF_ERROR,
41
+ Z_DEFAULT_COMPRESSION,
42
+ Z_FILTERED,
43
+ Z_HUFFMAN_ONLY,
44
+ Z_RLE,
45
+ Z_FIXED,
46
+ Z_DEFAULT_STRATEGY,
47
+ Z_UNKNOWN,
48
+ Z_DEFLATED
49
+ } = require('./constants')
50
+
51
+ /*============================================================================*/
52
+
53
+ const MAX_MEM_LEVEL = 9
54
+ /* Maximum value for memLevel in deflateInit2 */
55
+ const MAX_WBITS = 15
56
+ /* 32K LZ77 window */
57
+ const DEF_MEM_LEVEL = 8
58
+
59
+ const LENGTH_CODES = 29
60
+ /* number of length codes, not counting the special END_BLOCK code */
61
+ const LITERALS = 256
62
+ /* number of literal bytes 0..255 */
63
+ const L_CODES = LITERALS + 1 + LENGTH_CODES
64
+ /* number of Literal or Length codes, including the END_BLOCK code */
65
+ const D_CODES = 30
66
+ /* number of distance codes */
67
+ const BL_CODES = 19
68
+ /* number of codes used to transfer the bit lengths */
69
+ const HEAP_SIZE = 2 * L_CODES + 1
70
+ /* maximum heap size */
71
+ const MAX_BITS = 15
72
+ /* All codes must not exceed MAX_BITS bits */
73
+
74
+ const MIN_MATCH = 3
75
+ const MAX_MATCH = 258
76
+ const MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1
77
+
78
+ const PRESET_DICT = 0x20
79
+
80
+ const INIT_STATE = 42
81
+ const EXTRA_STATE = 69
82
+ const NAME_STATE = 73
83
+ const COMMENT_STATE = 91
84
+ const HCRC_STATE = 103
85
+ const BUSY_STATE = 113
86
+ const FINISH_STATE = 666
87
+
88
+ const BS_NEED_MORE = 1 /* block not completed, need more input or more output */
89
+ const BS_BLOCK_DONE = 2 /* block flush performed */
90
+ const BS_FINISH_STARTED = 3 /* finish started, need only more output at next deflate */
91
+ const BS_FINISH_DONE = 4 /* finish done, accept no more input or output */
92
+
93
+ const OS_CODE = 0x03 // Unix :) . Don't detect, use this default.
94
+
95
+ const err = (strm, errorCode) => {
96
+ strm.msg = msg[errorCode]
97
+ return errorCode
98
+ }
99
+
100
+ const rank = (f) => {
101
+ return (f << 1) - (f > 4 ? 9 : 0)
102
+ }
103
+
104
+ const zero = (buf) => {
105
+ let len = buf.length
106
+ while (--len >= 0) {
107
+ buf[len] = 0
108
+ }
109
+ }
110
+
111
+ /* eslint-disable new-cap */
112
+ let HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask
113
+ // This hash causes less collisions, https://github.com/nodeca/pako/issues/135
114
+ // But breaks binary compatibility
115
+ //let HASH_FAST = (s, prev, data) => ((prev << 8) + (prev >> 8) + (data << 4)) & s.hash_mask;
116
+ let HASH = HASH_ZLIB
117
+
118
+ /* =========================================================================
119
+ * Flush as much pending output as possible. All deflate() output goes
120
+ * through this function so some applications may wish to modify it
121
+ * to avoid allocating a large strm->output buffer and copying into it.
122
+ * (See also read_buf()).
123
+ */
124
+ const flush_pending = (strm) => {
125
+ const s = strm.state
126
+
127
+ //_tr_flush_bits(s);
128
+ let len = s.pending
129
+ if (len > strm.avail_out) {
130
+ len = strm.avail_out
131
+ }
132
+ if (len === 0) {
133
+ return
134
+ }
135
+
136
+ strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out)
137
+ strm.next_out += len
138
+ s.pending_out += len
139
+ strm.total_out += len
140
+ strm.avail_out -= len
141
+ s.pending -= len
142
+ if (s.pending === 0) {
143
+ s.pending_out = 0
144
+ }
145
+ }
146
+
147
+ const flush_block_only = (s, last) => {
148
+ _tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last)
149
+ s.block_start = s.strstart
150
+ flush_pending(s.strm)
151
+ }
152
+
153
+ const put_byte = (s, b) => {
154
+ s.pending_buf[s.pending++] = b
155
+ }
156
+
157
+ /* =========================================================================
158
+ * Put a short in the pending buffer. The 16-bit value is put in MSB order.
159
+ * IN assertion: the stream state is correct and there is enough room in
160
+ * pending_buf.
161
+ */
162
+ const putShortMSB = (s, b) => {
163
+ // put_byte(s, (Byte)(b >> 8));
164
+ // put_byte(s, (Byte)(b & 0xff));
165
+ s.pending_buf[s.pending++] = (b >>> 8) & 0xff
166
+ s.pending_buf[s.pending++] = b & 0xff
167
+ }
168
+
169
+ /* ===========================================================================
170
+ * Read a new buffer from the current input stream, update the adler32
171
+ * and total number of bytes read. All deflate() input goes through
172
+ * this function so some applications may wish to modify it to avoid
173
+ * allocating a large strm->input buffer and copying from it.
174
+ * (See also flush_pending()).
175
+ */
176
+ const read_buf = (strm, buf, start, size) => {
177
+ let len = strm.avail_in
178
+
179
+ if (len > size) {
180
+ len = size
181
+ }
182
+ if (len === 0) {
183
+ return 0
184
+ }
185
+
186
+ strm.avail_in -= len
187
+
188
+ // zmemcpy(buf, strm->next_in, len);
189
+ buf.set(strm.input.subarray(strm.next_in, strm.next_in + len), start)
190
+ if (strm.state.wrap === 1) {
191
+ strm.adler = adler32(strm.adler, buf, len, start)
192
+ } else if (strm.state.wrap === 2) {
193
+ strm.adler = crc32(strm.adler, buf, len, start)
194
+ }
195
+
196
+ strm.next_in += len
197
+ strm.total_in += len
198
+
199
+ return len
200
+ }
201
+
202
+ /* ===========================================================================
203
+ * Set match_start to the longest match starting at the given string and
204
+ * return its length. Matches shorter or equal to prev_length are discarded,
205
+ * in which case the result is equal to prev_length and match_start is
206
+ * garbage.
207
+ * IN assertions: cur_match is the head of the hash chain for the current
208
+ * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
209
+ * OUT assertion: the match length is not greater than s->lookahead.
210
+ */
211
+ const longest_match = (s, cur_match) => {
212
+ let chain_length = s.max_chain_length /* max hash chain length */
213
+ let scan = s.strstart /* current string */
214
+ let match /* matched string */
215
+ let len /* length of current match */
216
+ let best_len = s.prev_length /* best match length so far */
217
+ let nice_match = s.nice_match /* stop if match long enough */
218
+ const limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0 /*NIL*/
219
+
220
+ const _win = s.window // shortcut
221
+
222
+ const wmask = s.w_mask
223
+ const prev = s.prev
224
+
225
+ /* Stop when cur_match becomes <= limit. To simplify the code,
226
+ * we prevent matches with the string of window index 0.
227
+ */
228
+
229
+ const strend = s.strstart + MAX_MATCH
230
+ let scan_end1 = _win[scan + best_len - 1]
231
+ let scan_end = _win[scan + best_len]
232
+
233
+ /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
234
+ * It is easy to get rid of this optimization if necessary.
235
+ */
236
+ // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
237
+
238
+ /* Do not waste too much time if we already have a good match: */
239
+ if (s.prev_length >= s.good_match) {
240
+ chain_length >>= 2
241
+ }
242
+ /* Do not look for matches beyond the end of the input. This is necessary
243
+ * to make deflate deterministic.
244
+ */
245
+ if (nice_match > s.lookahead) {
246
+ nice_match = s.lookahead
247
+ }
248
+
249
+ // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
250
+
251
+ do {
252
+ // Assert(cur_match < s->strstart, "no future");
253
+ match = cur_match
254
+
255
+ /* Skip to next match if the match length cannot increase
256
+ * or if the match length is less than 2. Note that the checks below
257
+ * for insufficient lookahead only occur occasionally for performance
258
+ * reasons. Therefore uninitialized memory will be accessed, and
259
+ * conditional jumps will be made that depend on those values.
260
+ * However the length of the match is limited to the lookahead, so
261
+ * the output of deflate is not affected by the uninitialized values.
262
+ */
263
+
264
+ if (
265
+ _win[match + best_len] !== scan_end ||
266
+ _win[match + best_len - 1] !== scan_end1 ||
267
+ _win[match] !== _win[scan] ||
268
+ _win[++match] !== _win[scan + 1]
269
+ ) {
270
+ continue
271
+ }
272
+
273
+ /* The check at best_len-1 can be removed because it will be made
274
+ * again later. (This heuristic is not always a win.)
275
+ * It is not necessary to compare scan[2] and match[2] since they
276
+ * are always equal when the other bytes match, given that
277
+ * the hash keys are equal and that HASH_BITS >= 8.
278
+ */
279
+ scan += 2
280
+ match++
281
+ // Assert(*scan == *match, "match[2]?");
282
+
283
+ /* We check for insufficient lookahead only every 8th comparison;
284
+ * the 256th check will be made at strstart+258.
285
+ */
286
+ do {
287
+ /*jshint noempty:false*/
288
+ } while (
289
+ _win[++scan] === _win[++match] &&
290
+ _win[++scan] === _win[++match] &&
291
+ _win[++scan] === _win[++match] &&
292
+ _win[++scan] === _win[++match] &&
293
+ _win[++scan] === _win[++match] &&
294
+ _win[++scan] === _win[++match] &&
295
+ _win[++scan] === _win[++match] &&
296
+ _win[++scan] === _win[++match] &&
297
+ scan < strend
298
+ )
299
+
300
+ // Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
301
+
302
+ len = MAX_MATCH - (strend - scan)
303
+ scan = strend - MAX_MATCH
304
+
305
+ if (len > best_len) {
306
+ s.match_start = cur_match
307
+ best_len = len
308
+ if (len >= nice_match) {
309
+ break
310
+ }
311
+ scan_end1 = _win[scan + best_len - 1]
312
+ scan_end = _win[scan + best_len]
313
+ }
314
+ } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0)
315
+
316
+ if (best_len <= s.lookahead) {
317
+ return best_len
318
+ }
319
+ return s.lookahead
320
+ }
321
+
322
+ /* ===========================================================================
323
+ * Fill the window when the lookahead becomes insufficient.
324
+ * Updates strstart and lookahead.
325
+ *
326
+ * IN assertion: lookahead < MIN_LOOKAHEAD
327
+ * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
328
+ * At least one byte has been read, or avail_in == 0; reads are
329
+ * performed for at least two bytes (required for the zip translate_eol
330
+ * option -- not supported here).
331
+ */
332
+ const fill_window = (s) => {
333
+ const _w_size = s.w_size
334
+ let p, n, m, more, str
335
+
336
+ //Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
337
+
338
+ do {
339
+ more = s.window_size - s.lookahead - s.strstart
340
+
341
+ // JS ints have 32 bit, block below not needed
342
+ /* Deal with !@#$% 64K limit: */
343
+ //if (sizeof(int) <= 2) {
344
+ // if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
345
+ // more = wsize;
346
+ //
347
+ // } else if (more == (unsigned)(-1)) {
348
+ // /* Very unlikely, but possible on 16 bit machine if
349
+ // * strstart == 0 && lookahead == 1 (input done a byte at time)
350
+ // */
351
+ // more--;
352
+ // }
353
+ //}
354
+
355
+ /* If the window is almost full and there is insufficient lookahead,
356
+ * move the upper half to the lower one to make room in the upper half.
357
+ */
358
+ if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
359
+ s.window.set(s.window.subarray(_w_size, _w_size + _w_size), 0)
360
+ s.match_start -= _w_size
361
+ s.strstart -= _w_size
362
+ /* we now have strstart >= MAX_DIST */
363
+ s.block_start -= _w_size
364
+
365
+ /* Slide the hash table (could be avoided with 32 bit values
366
+ at the expense of memory usage). We slide even when level == 0
367
+ to keep the hash table consistent if we switch back to level > 0
368
+ later. (Using level 0 permanently is not an optimal usage of
369
+ zlib, so we don't care about this pathological case.)
370
+ */
371
+
372
+ n = s.hash_size
373
+ p = n
374
+
375
+ do {
376
+ m = s.head[--p]
377
+ s.head[p] = m >= _w_size ? m - _w_size : 0
378
+ } while (--n)
379
+
380
+ n = _w_size
381
+ p = n
382
+
383
+ do {
384
+ m = s.prev[--p]
385
+ s.prev[p] = m >= _w_size ? m - _w_size : 0
386
+ /* If n is not on any hash chain, prev[n] is garbage but
387
+ * its value will never be used.
388
+ */
389
+ } while (--n)
390
+
391
+ more += _w_size
392
+ }
393
+ if (s.strm.avail_in === 0) {
394
+ break
395
+ }
396
+
397
+ /* If there was no sliding:
398
+ * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
399
+ * more == window_size - lookahead - strstart
400
+ * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
401
+ * => more >= window_size - 2*WSIZE + 2
402
+ * In the BIG_MEM or MMAP case (not yet supported),
403
+ * window_size == input_size + MIN_LOOKAHEAD &&
404
+ * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
405
+ * Otherwise, window_size == 2*WSIZE so more >= 2.
406
+ * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
407
+ */
408
+ //Assert(more >= 2, "more < 2");
409
+ n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more)
410
+ s.lookahead += n
411
+
412
+ /* Initialize the hash value now that we have some input: */
413
+ if (s.lookahead + s.insert >= MIN_MATCH) {
414
+ str = s.strstart - s.insert
415
+ s.ins_h = s.window[str]
416
+
417
+ /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */
418
+ s.ins_h = HASH(s, s.ins_h, s.window[str + 1])
419
+ //#if MIN_MATCH != 3
420
+ // Call update_hash() MIN_MATCH-3 more times
421
+ //#endif
422
+ while (s.insert) {
423
+ /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
424
+ s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1])
425
+
426
+ s.prev[str & s.w_mask] = s.head[s.ins_h]
427
+ s.head[s.ins_h] = str
428
+ str++
429
+ s.insert--
430
+ if (s.lookahead + s.insert < MIN_MATCH) {
431
+ break
432
+ }
433
+ }
434
+ }
435
+ /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
436
+ * but this is not important since only literal bytes will be emitted.
437
+ */
438
+ } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0)
439
+
440
+ /* If the WIN_INIT bytes after the end of the current data have never been
441
+ * written, then zero those bytes in order to avoid memory check reports of
442
+ * the use of uninitialized (or uninitialised as Julian writes) bytes by
443
+ * the longest match routines. Update the high water mark for the next
444
+ * time through here. WIN_INIT is set to MAX_MATCH since the longest match
445
+ * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
446
+ */
447
+ // if (s.high_water < s.window_size) {
448
+ // const curr = s.strstart + s.lookahead;
449
+ // let init = 0;
450
+ //
451
+ // if (s.high_water < curr) {
452
+ // /* Previous high water mark below current data -- zero WIN_INIT
453
+ // * bytes or up to end of window, whichever is less.
454
+ // */
455
+ // init = s.window_size - curr;
456
+ // if (init > WIN_INIT)
457
+ // init = WIN_INIT;
458
+ // zmemzero(s->window + curr, (unsigned)init);
459
+ // s->high_water = curr + init;
460
+ // }
461
+ // else if (s->high_water < (ulg)curr + WIN_INIT) {
462
+ // /* High water mark at or above current data, but below current data
463
+ // * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
464
+ // * to end of window, whichever is less.
465
+ // */
466
+ // init = (ulg)curr + WIN_INIT - s->high_water;
467
+ // if (init > s->window_size - s->high_water)
468
+ // init = s->window_size - s->high_water;
469
+ // zmemzero(s->window + s->high_water, (unsigned)init);
470
+ // s->high_water += init;
471
+ // }
472
+ // }
473
+ //
474
+ // Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
475
+ // "not enough room for search");
476
+ }
477
+
478
+ /* ===========================================================================
479
+ * Copy without compression as much as possible from the input stream, return
480
+ * the current block state.
481
+ * This function does not insert new strings in the dictionary since
482
+ * uncompressible data is probably not useful. This function is used
483
+ * only for the level=0 compression option.
484
+ * NOTE: this function should be optimized to avoid extra copying from
485
+ * window to pending_buf.
486
+ */
487
+ const deflate_stored = (s, flush) => {
488
+ /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
489
+ * to pending_buf_size, and each stored block has a 5 byte header:
490
+ */
491
+ let max_block_size = 0xffff
492
+
493
+ if (max_block_size > s.pending_buf_size - 5) {
494
+ max_block_size = s.pending_buf_size - 5
495
+ }
496
+
497
+ /* Copy as much as possible from input to output: */
498
+ for (;;) {
499
+ /* Fill the window as much as possible: */
500
+ if (s.lookahead <= 1) {
501
+ //Assert(s->strstart < s->w_size+MAX_DIST(s) ||
502
+ // s->block_start >= (long)s->w_size, "slide too late");
503
+ // if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
504
+ // s.block_start >= s.w_size)) {
505
+ // throw new Error("slide too late");
506
+ // }
507
+
508
+ fill_window(s)
509
+ if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
510
+ return BS_NEED_MORE
511
+ }
512
+
513
+ if (s.lookahead === 0) {
514
+ break
515
+ }
516
+ /* flush the current block */
517
+ }
518
+ //Assert(s->block_start >= 0L, "block gone");
519
+ // if (s.block_start < 0) throw new Error("block gone");
520
+
521
+ s.strstart += s.lookahead
522
+ s.lookahead = 0
523
+
524
+ /* Emit a stored block if pending_buf will be full: */
525
+ const max_start = s.block_start + max_block_size
526
+
527
+ if (s.strstart === 0 || s.strstart >= max_start) {
528
+ /* strstart == 0 is possible when wraparound on 16-bit machine */
529
+ s.lookahead = s.strstart - max_start
530
+ s.strstart = max_start
531
+ /*** FLUSH_BLOCK(s, 0); ***/
532
+ flush_block_only(s, false)
533
+ if (s.strm.avail_out === 0) {
534
+ return BS_NEED_MORE
535
+ }
536
+ /***/
537
+ }
538
+ /* Flush if we may have to slide, otherwise block_start may become
539
+ * negative and the data will be gone:
540
+ */
541
+ if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) {
542
+ /*** FLUSH_BLOCK(s, 0); ***/
543
+ flush_block_only(s, false)
544
+ if (s.strm.avail_out === 0) {
545
+ return BS_NEED_MORE
546
+ }
547
+ /***/
548
+ }
549
+ }
550
+
551
+ s.insert = 0
552
+
553
+ if (flush === Z_FINISH) {
554
+ /*** FLUSH_BLOCK(s, 1); ***/
555
+ flush_block_only(s, true)
556
+ if (s.strm.avail_out === 0) {
557
+ return BS_FINISH_STARTED
558
+ }
559
+ /***/
560
+ return BS_FINISH_DONE
561
+ }
562
+
563
+ if (s.strstart > s.block_start) {
564
+ /*** FLUSH_BLOCK(s, 0); ***/
565
+ flush_block_only(s, false)
566
+ if (s.strm.avail_out === 0) {
567
+ return BS_NEED_MORE
568
+ }
569
+ /***/
570
+ }
571
+
572
+ return BS_NEED_MORE
573
+ }
574
+
575
+ /* ===========================================================================
576
+ * Compress as much as possible from the input stream, return the current
577
+ * block state.
578
+ * This function does not perform lazy evaluation of matches and inserts
579
+ * new strings in the dictionary only for unmatched strings or for short
580
+ * matches. It is used only for the fast compression options.
581
+ */
582
+ const deflate_fast = (s, flush) => {
583
+ let hash_head /* head of the hash chain */
584
+ let bflush /* set if current block must be flushed */
585
+
586
+ for (;;) {
587
+ /* Make sure that we always have enough lookahead, except
588
+ * at the end of the input file. We need MAX_MATCH bytes
589
+ * for the next match, plus MIN_MATCH bytes to insert the
590
+ * string following the next match.
591
+ */
592
+ if (s.lookahead < MIN_LOOKAHEAD) {
593
+ fill_window(s)
594
+ if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
595
+ return BS_NEED_MORE
596
+ }
597
+ if (s.lookahead === 0) {
598
+ break /* flush the current block */
599
+ }
600
+ }
601
+
602
+ /* Insert the string window[strstart .. strstart+2] in the
603
+ * dictionary, and set hash_head to the head of the hash chain:
604
+ */
605
+ hash_head = 0 /*NIL*/
606
+ if (s.lookahead >= MIN_MATCH) {
607
+ /*** INSERT_STRING(s, s.strstart, hash_head); ***/
608
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1])
609
+ hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]
610
+ s.head[s.ins_h] = s.strstart
611
+ /***/
612
+ }
613
+
614
+ /* Find the longest match, discarding those <= prev_length.
615
+ * At this point we have always match_length < MIN_MATCH
616
+ */
617
+ if (hash_head !== 0 /*NIL*/ && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) {
618
+ /* To simplify the code, we prevent matches with the string
619
+ * of window index 0 (in particular we have to avoid a match
620
+ * of the string with itself at the start of the input file).
621
+ */
622
+ s.match_length = longest_match(s, hash_head)
623
+ /* longest_match() sets match_start */
624
+ }
625
+ if (s.match_length >= MIN_MATCH) {
626
+ // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only
627
+
628
+ /*** _tr_tally_dist(s, s.strstart - s.match_start,
629
+ s.match_length - MIN_MATCH, bflush); ***/
630
+ bflush = _tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH)
631
+
632
+ s.lookahead -= s.match_length
633
+
634
+ /* Insert new strings in the hash table only if the match length
635
+ * is not too large. This saves time but degrades compression.
636
+ */
637
+ if (s.match_length <= s.max_lazy_match /*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
638
+ s.match_length-- /* string at strstart already in table */
639
+ do {
640
+ s.strstart++
641
+ /*** INSERT_STRING(s, s.strstart, hash_head); ***/
642
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1])
643
+ hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]
644
+ s.head[s.ins_h] = s.strstart
645
+ /***/
646
+ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
647
+ * always MIN_MATCH bytes ahead.
648
+ */
649
+ } while (--s.match_length !== 0)
650
+ s.strstart++
651
+ } else {
652
+ s.strstart += s.match_length
653
+ s.match_length = 0
654
+ s.ins_h = s.window[s.strstart]
655
+ /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
656
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1])
657
+
658
+ //#if MIN_MATCH != 3
659
+ // Call UPDATE_HASH() MIN_MATCH-3 more times
660
+ //#endif
661
+ /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
662
+ * matter since it will be recomputed at next deflate call.
663
+ */
664
+ }
665
+ } else {
666
+ /* No match, output a literal byte */
667
+ //Tracevv((stderr,"%c", s.window[s.strstart]));
668
+ /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
669
+ bflush = _tr_tally(s, 0, s.window[s.strstart])
670
+
671
+ s.lookahead--
672
+ s.strstart++
673
+ }
674
+ if (bflush) {
675
+ /*** FLUSH_BLOCK(s, 0); ***/
676
+ flush_block_only(s, false)
677
+ if (s.strm.avail_out === 0) {
678
+ return BS_NEED_MORE
679
+ }
680
+ /***/
681
+ }
682
+ }
683
+ s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1
684
+ if (flush === Z_FINISH) {
685
+ /*** FLUSH_BLOCK(s, 1); ***/
686
+ flush_block_only(s, true)
687
+ if (s.strm.avail_out === 0) {
688
+ return BS_FINISH_STARTED
689
+ }
690
+ /***/
691
+ return BS_FINISH_DONE
692
+ }
693
+ if (s.last_lit) {
694
+ /*** FLUSH_BLOCK(s, 0); ***/
695
+ flush_block_only(s, false)
696
+ if (s.strm.avail_out === 0) {
697
+ return BS_NEED_MORE
698
+ }
699
+ /***/
700
+ }
701
+ return BS_BLOCK_DONE
702
+ }
703
+
704
+ /* ===========================================================================
705
+ * Same as above, but achieves better compression. We use a lazy
706
+ * evaluation for matches: a match is finally adopted only if there is
707
+ * no better match at the next window position.
708
+ */
709
+ const deflate_slow = (s, flush) => {
710
+ let hash_head /* head of hash chain */
711
+ let bflush /* set if current block must be flushed */
712
+
713
+ let max_insert
714
+
715
+ /* Process the input block. */
716
+ for (;;) {
717
+ /* Make sure that we always have enough lookahead, except
718
+ * at the end of the input file. We need MAX_MATCH bytes
719
+ * for the next match, plus MIN_MATCH bytes to insert the
720
+ * string following the next match.
721
+ */
722
+ if (s.lookahead < MIN_LOOKAHEAD) {
723
+ fill_window(s)
724
+ if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
725
+ return BS_NEED_MORE
726
+ }
727
+ if (s.lookahead === 0) {
728
+ break
729
+ } /* flush the current block */
730
+ }
731
+
732
+ /* Insert the string window[strstart .. strstart+2] in the
733
+ * dictionary, and set hash_head to the head of the hash chain:
734
+ */
735
+ hash_head = 0 /*NIL*/
736
+ if (s.lookahead >= MIN_MATCH) {
737
+ /*** INSERT_STRING(s, s.strstart, hash_head); ***/
738
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1])
739
+ hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]
740
+ s.head[s.ins_h] = s.strstart
741
+ /***/
742
+ }
743
+
744
+ /* Find the longest match, discarding those <= prev_length.
745
+ */
746
+ s.prev_length = s.match_length
747
+ s.prev_match = s.match_start
748
+ s.match_length = MIN_MATCH - 1
749
+
750
+ if (hash_head !== 0 /*NIL*/ && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD /*MAX_DIST(s)*/) {
751
+ /* To simplify the code, we prevent matches with the string
752
+ * of window index 0 (in particular we have to avoid a match
753
+ * of the string with itself at the start of the input file).
754
+ */
755
+ s.match_length = longest_match(s, hash_head)
756
+ /* longest_match() sets match_start */
757
+
758
+ if (
759
+ s.match_length <= 5 &&
760
+ (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096) /*TOO_FAR*/)
761
+ ) {
762
+ /* If prev_match is also MIN_MATCH, match_start is garbage
763
+ * but we will ignore the current match anyway.
764
+ */
765
+ s.match_length = MIN_MATCH - 1
766
+ }
767
+ }
768
+ /* If there was a match at the previous step and the current
769
+ * match is not better, output the previous match:
770
+ */
771
+ if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
772
+ max_insert = s.strstart + s.lookahead - MIN_MATCH
773
+ /* Do not insert strings in hash table beyond this. */
774
+
775
+ //check_match(s, s.strstart-1, s.prev_match, s.prev_length);
776
+
777
+ /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,
778
+ s.prev_length - MIN_MATCH, bflush);***/
779
+ bflush = _tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH)
780
+ /* Insert in hash table all strings up to the end of the match.
781
+ * strstart-1 and strstart are already inserted. If there is not
782
+ * enough lookahead, the last two strings are not inserted in
783
+ * the hash table.
784
+ */
785
+ s.lookahead -= s.prev_length - 1
786
+ s.prev_length -= 2
787
+ do {
788
+ if (++s.strstart <= max_insert) {
789
+ /*** INSERT_STRING(s, s.strstart, hash_head); ***/
790
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1])
791
+ hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]
792
+ s.head[s.ins_h] = s.strstart
793
+ /***/
794
+ }
795
+ } while (--s.prev_length !== 0)
796
+ s.match_available = 0
797
+ s.match_length = MIN_MATCH - 1
798
+ s.strstart++
799
+
800
+ if (bflush) {
801
+ /*** FLUSH_BLOCK(s, 0); ***/
802
+ flush_block_only(s, false)
803
+ if (s.strm.avail_out === 0) {
804
+ return BS_NEED_MORE
805
+ }
806
+ /***/
807
+ }
808
+ } else if (s.match_available) {
809
+ /* If there was no match at the previous position, output a
810
+ * single literal. If there was a match but the current match
811
+ * is longer, truncate the previous match to a single literal.
812
+ */
813
+ //Tracevv((stderr,"%c", s->window[s->strstart-1]));
814
+ /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
815
+ bflush = _tr_tally(s, 0, s.window[s.strstart - 1])
816
+
817
+ if (bflush) {
818
+ /*** FLUSH_BLOCK_ONLY(s, 0) ***/
819
+ flush_block_only(s, false)
820
+ /***/
821
+ }
822
+ s.strstart++
823
+ s.lookahead--
824
+ if (s.strm.avail_out === 0) {
825
+ return BS_NEED_MORE
826
+ }
827
+ } else {
828
+ /* There is no previous match to compare with, wait for
829
+ * the next step to decide.
830
+ */
831
+ s.match_available = 1
832
+ s.strstart++
833
+ s.lookahead--
834
+ }
835
+ }
836
+ //Assert (flush != Z_NO_FLUSH, "no flush?");
837
+ if (s.match_available) {
838
+ //Tracevv((stderr,"%c", s->window[s->strstart-1]));
839
+ /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/
840
+ bflush = _tr_tally(s, 0, s.window[s.strstart - 1])
841
+
842
+ s.match_available = 0
843
+ }
844
+ s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1
845
+ if (flush === Z_FINISH) {
846
+ /*** FLUSH_BLOCK(s, 1); ***/
847
+ flush_block_only(s, true)
848
+ if (s.strm.avail_out === 0) {
849
+ return BS_FINISH_STARTED
850
+ }
851
+ /***/
852
+ return BS_FINISH_DONE
853
+ }
854
+ if (s.last_lit) {
855
+ /*** FLUSH_BLOCK(s, 0); ***/
856
+ flush_block_only(s, false)
857
+ if (s.strm.avail_out === 0) {
858
+ return BS_NEED_MORE
859
+ }
860
+ /***/
861
+ }
862
+
863
+ return BS_BLOCK_DONE
864
+ }
865
+
866
+ /* ===========================================================================
867
+ * For Z_RLE, simply look for runs of bytes, generate matches only of distance
868
+ * one. Do not maintain a hash table. (It will be regenerated if this run of
869
+ * deflate switches away from Z_RLE.)
870
+ */
871
+ const deflate_rle = (s, flush) => {
872
+ let bflush /* set if current block must be flushed */
873
+ let prev /* byte at distance one to match */
874
+ let scan, strend /* scan goes up to strend for length of run */
875
+
876
+ const _win = s.window
877
+
878
+ for (;;) {
879
+ /* Make sure that we always have enough lookahead, except
880
+ * at the end of the input file. We need MAX_MATCH bytes
881
+ * for the longest run, plus one for the unrolled loop.
882
+ */
883
+ if (s.lookahead <= MAX_MATCH) {
884
+ fill_window(s)
885
+ if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
886
+ return BS_NEED_MORE
887
+ }
888
+ if (s.lookahead === 0) {
889
+ break
890
+ } /* flush the current block */
891
+ }
892
+
893
+ /* See how many times the previous byte repeats */
894
+ s.match_length = 0
895
+ if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
896
+ scan = s.strstart - 1
897
+ prev = _win[scan]
898
+ if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {
899
+ strend = s.strstart + MAX_MATCH
900
+ do {
901
+ /*jshint noempty:false*/
902
+ } while (
903
+ prev === _win[++scan] &&
904
+ prev === _win[++scan] &&
905
+ prev === _win[++scan] &&
906
+ prev === _win[++scan] &&
907
+ prev === _win[++scan] &&
908
+ prev === _win[++scan] &&
909
+ prev === _win[++scan] &&
910
+ prev === _win[++scan] &&
911
+ scan < strend
912
+ )
913
+ s.match_length = MAX_MATCH - (strend - scan)
914
+ if (s.match_length > s.lookahead) {
915
+ s.match_length = s.lookahead
916
+ }
917
+ }
918
+ //Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
919
+ }
920
+
921
+ /* Emit match if have run of MIN_MATCH or longer, else emit literal */
922
+ if (s.match_length >= MIN_MATCH) {
923
+ //check_match(s, s.strstart, s.strstart - 1, s.match_length);
924
+
925
+ /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/
926
+ bflush = _tr_tally(s, 1, s.match_length - MIN_MATCH)
927
+
928
+ s.lookahead -= s.match_length
929
+ s.strstart += s.match_length
930
+ s.match_length = 0
931
+ } else {
932
+ /* No match, output a literal byte */
933
+ //Tracevv((stderr,"%c", s->window[s->strstart]));
934
+ /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
935
+ bflush = _tr_tally(s, 0, s.window[s.strstart])
936
+
937
+ s.lookahead--
938
+ s.strstart++
939
+ }
940
+ if (bflush) {
941
+ /*** FLUSH_BLOCK(s, 0); ***/
942
+ flush_block_only(s, false)
943
+ if (s.strm.avail_out === 0) {
944
+ return BS_NEED_MORE
945
+ }
946
+ /***/
947
+ }
948
+ }
949
+ s.insert = 0
950
+ if (flush === Z_FINISH) {
951
+ /*** FLUSH_BLOCK(s, 1); ***/
952
+ flush_block_only(s, true)
953
+ if (s.strm.avail_out === 0) {
954
+ return BS_FINISH_STARTED
955
+ }
956
+ /***/
957
+ return BS_FINISH_DONE
958
+ }
959
+ if (s.last_lit) {
960
+ /*** FLUSH_BLOCK(s, 0); ***/
961
+ flush_block_only(s, false)
962
+ if (s.strm.avail_out === 0) {
963
+ return BS_NEED_MORE
964
+ }
965
+ /***/
966
+ }
967
+ return BS_BLOCK_DONE
968
+ }
969
+
970
+ /* ===========================================================================
971
+ * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
972
+ * (It will be regenerated if this run of deflate switches away from Huffman.)
973
+ */
974
+ const deflate_huff = (s, flush) => {
975
+ let bflush /* set if current block must be flushed */
976
+
977
+ for (;;) {
978
+ /* Make sure that we have a literal to write. */
979
+ if (s.lookahead === 0) {
980
+ fill_window(s)
981
+ if (s.lookahead === 0) {
982
+ if (flush === Z_NO_FLUSH) {
983
+ return BS_NEED_MORE
984
+ }
985
+ break /* flush the current block */
986
+ }
987
+ }
988
+
989
+ /* Output a literal byte */
990
+ s.match_length = 0
991
+ //Tracevv((stderr,"%c", s->window[s->strstart]));
992
+ /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/
993
+ bflush = _tr_tally(s, 0, s.window[s.strstart])
994
+ s.lookahead--
995
+ s.strstart++
996
+ if (bflush) {
997
+ /*** FLUSH_BLOCK(s, 0); ***/
998
+ flush_block_only(s, false)
999
+ if (s.strm.avail_out === 0) {
1000
+ return BS_NEED_MORE
1001
+ }
1002
+ /***/
1003
+ }
1004
+ }
1005
+ s.insert = 0
1006
+ if (flush === Z_FINISH) {
1007
+ /*** FLUSH_BLOCK(s, 1); ***/
1008
+ flush_block_only(s, true)
1009
+ if (s.strm.avail_out === 0) {
1010
+ return BS_FINISH_STARTED
1011
+ }
1012
+ /***/
1013
+ return BS_FINISH_DONE
1014
+ }
1015
+ if (s.last_lit) {
1016
+ /*** FLUSH_BLOCK(s, 0); ***/
1017
+ flush_block_only(s, false)
1018
+ if (s.strm.avail_out === 0) {
1019
+ return BS_NEED_MORE
1020
+ }
1021
+ /***/
1022
+ }
1023
+ return BS_BLOCK_DONE
1024
+ }
1025
+
1026
+ /* Values for max_lazy_match, good_match and max_chain_length, depending on
1027
+ * the desired pack level (0..9). The values given below have been tuned to
1028
+ * exclude worst case performance for pathological files. Better values may be
1029
+ * found for specific files.
1030
+ */
1031
+ function Config(good_length, max_lazy, nice_length, max_chain, func) {
1032
+ this.good_length = good_length
1033
+ this.max_lazy = max_lazy
1034
+ this.nice_length = nice_length
1035
+ this.max_chain = max_chain
1036
+ this.func = func
1037
+ }
1038
+
1039
+ const configuration_table = [
1040
+ /* good lazy nice chain */
1041
+ new Config(0, 0, 0, 0, deflate_stored) /* 0 store only */,
1042
+ new Config(4, 4, 8, 4, deflate_fast) /* 1 max speed, no lazy matches */,
1043
+ new Config(4, 5, 16, 8, deflate_fast) /* 2 */,
1044
+ new Config(4, 6, 32, 32, deflate_fast) /* 3 */,
1045
+
1046
+ new Config(4, 4, 16, 16, deflate_slow) /* 4 lazy matches */,
1047
+ new Config(8, 16, 32, 32, deflate_slow) /* 5 */,
1048
+ new Config(8, 16, 128, 128, deflate_slow) /* 6 */,
1049
+ new Config(8, 32, 128, 256, deflate_slow) /* 7 */,
1050
+ new Config(32, 128, 258, 1024, deflate_slow) /* 8 */,
1051
+ new Config(32, 258, 258, 4096, deflate_slow) /* 9 max compression */
1052
+ ]
1053
+
1054
+ /* ===========================================================================
1055
+ * Initialize the "longest match" routines for a new zlib stream
1056
+ */
1057
+ const lm_init = (s) => {
1058
+ s.window_size = 2 * s.w_size
1059
+
1060
+ /*** CLEAR_HASH(s); ***/
1061
+ zero(s.head) // Fill with NIL (= 0);
1062
+
1063
+ /* Set the default configuration parameters:
1064
+ */
1065
+ s.max_lazy_match = configuration_table[s.level].max_lazy
1066
+ s.good_match = configuration_table[s.level].good_length
1067
+ s.nice_match = configuration_table[s.level].nice_length
1068
+ s.max_chain_length = configuration_table[s.level].max_chain
1069
+
1070
+ s.strstart = 0
1071
+ s.block_start = 0
1072
+ s.lookahead = 0
1073
+ s.insert = 0
1074
+ s.match_length = s.prev_length = MIN_MATCH - 1
1075
+ s.match_available = 0
1076
+ s.ins_h = 0
1077
+ }
1078
+
1079
+ function DeflateState() {
1080
+ this.strm = null /* pointer back to this zlib stream */
1081
+ this.status = 0 /* as the name implies */
1082
+ this.pending_buf = null /* output still pending */
1083
+ this.pending_buf_size = 0 /* size of pending_buf */
1084
+ this.pending_out = 0 /* next pending byte to output to the stream */
1085
+ this.pending = 0 /* nb of bytes in the pending buffer */
1086
+ this.wrap = 0 /* bit 0 true for zlib, bit 1 true for gzip */
1087
+ this.gzhead = null /* gzip header information to write */
1088
+ this.gzindex = 0 /* where in extra, name, or comment */
1089
+ this.method = Z_DEFLATED /* can only be DEFLATED */
1090
+ this.last_flush = -1 /* value of flush param for previous deflate call */
1091
+
1092
+ this.w_size = 0 /* LZ77 window size (32K by default) */
1093
+ this.w_bits = 0 /* log2(w_size) (8..16) */
1094
+ this.w_mask = 0 /* w_size - 1 */
1095
+
1096
+ this.window = null
1097
+ /* Sliding window. Input bytes are read into the second half of the window,
1098
+ * and move to the first half later to keep a dictionary of at least wSize
1099
+ * bytes. With this organization, matches are limited to a distance of
1100
+ * wSize-MAX_MATCH bytes, but this ensures that IO is always
1101
+ * performed with a length multiple of the block size.
1102
+ */
1103
+
1104
+ this.window_size = 0
1105
+ /* Actual size of window: 2*wSize, except when the user input buffer
1106
+ * is directly used as sliding window.
1107
+ */
1108
+
1109
+ this.prev = null
1110
+ /* Link to older string with same hash index. To limit the size of this
1111
+ * array to 64K, this link is maintained only for the last 32K strings.
1112
+ * An index in this array is thus a window index modulo 32K.
1113
+ */
1114
+
1115
+ this.head = null /* Heads of the hash chains or NIL. */
1116
+
1117
+ this.ins_h = 0 /* hash index of string to be inserted */
1118
+ this.hash_size = 0 /* number of elements in hash table */
1119
+ this.hash_bits = 0 /* log2(hash_size) */
1120
+ this.hash_mask = 0 /* hash_size-1 */
1121
+
1122
+ this.hash_shift = 0
1123
+ /* Number of bits by which ins_h must be shifted at each input
1124
+ * step. It must be such that after MIN_MATCH steps, the oldest
1125
+ * byte no longer takes part in the hash key, that is:
1126
+ * hash_shift * MIN_MATCH >= hash_bits
1127
+ */
1128
+
1129
+ this.block_start = 0
1130
+ /* Window position at the beginning of the current output block. Gets
1131
+ * negative when the window is moved backwards.
1132
+ */
1133
+
1134
+ this.match_length = 0 /* length of best match */
1135
+ this.prev_match = 0 /* previous match */
1136
+ this.match_available = 0 /* set if previous match exists */
1137
+ this.strstart = 0 /* start of string to insert */
1138
+ this.match_start = 0 /* start of matching string */
1139
+ this.lookahead = 0 /* number of valid bytes ahead in window */
1140
+
1141
+ this.prev_length = 0
1142
+ /* Length of the best match at previous step. Matches not greater than this
1143
+ * are discarded. This is used in the lazy match evaluation.
1144
+ */
1145
+
1146
+ this.max_chain_length = 0
1147
+ /* To speed up deflation, hash chains are never searched beyond this
1148
+ * length. A higher limit improves compression ratio but degrades the
1149
+ * speed.
1150
+ */
1151
+
1152
+ this.max_lazy_match = 0
1153
+ /* Attempt to find a better match only when the current match is strictly
1154
+ * smaller than this value. This mechanism is used only for compression
1155
+ * levels >= 4.
1156
+ */
1157
+ // That's alias to max_lazy_match, don't use directly
1158
+ //this.max_insert_length = 0;
1159
+ /* Insert new strings in the hash table only if the match length is not
1160
+ * greater than this length. This saves time but degrades compression.
1161
+ * max_insert_length is used only for compression levels <= 3.
1162
+ */
1163
+
1164
+ this.level = 0 /* compression level (1..9) */
1165
+ this.strategy = 0 /* favor or force Huffman coding*/
1166
+
1167
+ this.good_match = 0
1168
+ /* Use a faster search when the previous match is longer than this */
1169
+
1170
+ this.nice_match = 0 /* Stop searching when current match exceeds this */
1171
+
1172
+ /* used by trees.c: */
1173
+
1174
+ /* Didn't use ct_data typedef below to suppress compiler warning */
1175
+
1176
+ // struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
1177
+ // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
1178
+ // struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
1179
+
1180
+ // Use flat array of DOUBLE size, with interleaved fata,
1181
+ // because JS does not support effective
1182
+ this.dyn_ltree = new Uint16Array(HEAP_SIZE * 2)
1183
+ this.dyn_dtree = new Uint16Array((2 * D_CODES + 1) * 2)
1184
+ this.bl_tree = new Uint16Array((2 * BL_CODES + 1) * 2)
1185
+ zero(this.dyn_ltree)
1186
+ zero(this.dyn_dtree)
1187
+ zero(this.bl_tree)
1188
+
1189
+ this.l_desc = null /* desc. for literal tree */
1190
+ this.d_desc = null /* desc. for distance tree */
1191
+ this.bl_desc = null /* desc. for bit length tree */
1192
+
1193
+ //ush bl_count[MAX_BITS+1];
1194
+ this.bl_count = new Uint16Array(MAX_BITS + 1)
1195
+ /* number of codes at each bit length for an optimal tree */
1196
+
1197
+ //int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
1198
+ this.heap = new Uint16Array(2 * L_CODES + 1) /* heap used to build the Huffman trees */
1199
+ zero(this.heap)
1200
+
1201
+ this.heap_len = 0 /* number of elements in the heap */
1202
+ this.heap_max = 0 /* element of largest frequency */
1203
+ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
1204
+ * The same heap array is used to build all trees.
1205
+ */
1206
+
1207
+ this.depth = new Uint16Array(2 * L_CODES + 1) //uch depth[2*L_CODES+1];
1208
+ zero(this.depth)
1209
+ /* Depth of each subtree used as tie breaker for trees of equal frequency
1210
+ */
1211
+
1212
+ this.l_buf = 0 /* buffer index for literals or lengths */
1213
+
1214
+ this.lit_bufsize = 0
1215
+ /* Size of match buffer for literals/lengths. There are 4 reasons for
1216
+ * limiting lit_bufsize to 64K:
1217
+ * - frequencies can be kept in 16 bit counters
1218
+ * - if compression is not successful for the first block, all input
1219
+ * data is still in the window so we can still emit a stored block even
1220
+ * when input comes from standard input. (This can also be done for
1221
+ * all blocks if lit_bufsize is not greater than 32K.)
1222
+ * - if compression is not successful for a file smaller than 64K, we can
1223
+ * even emit a stored file instead of a stored block (saving 5 bytes).
1224
+ * This is applicable only for zip (not gzip or zlib).
1225
+ * - creating new Huffman trees less frequently may not provide fast
1226
+ * adaptation to changes in the input data statistics. (Take for
1227
+ * example a binary file with poorly compressible code followed by
1228
+ * a highly compressible string table.) Smaller buffer sizes give
1229
+ * fast adaptation but have of course the overhead of transmitting
1230
+ * trees more frequently.
1231
+ * - I can't count above 4
1232
+ */
1233
+
1234
+ this.last_lit = 0 /* running index in l_buf */
1235
+
1236
+ this.d_buf = 0
1237
+ /* Buffer index for distances. To simplify the code, d_buf and l_buf have
1238
+ * the same number of elements. To use different lengths, an extra flag
1239
+ * array would be necessary.
1240
+ */
1241
+
1242
+ this.opt_len = 0 /* bit length of current block with optimal trees */
1243
+ this.static_len = 0 /* bit length of current block with static trees */
1244
+ this.matches = 0 /* number of string matches in current block */
1245
+ this.insert = 0 /* bytes at end of window left to insert */
1246
+
1247
+ this.bi_buf = 0
1248
+ /* Output buffer. bits are inserted starting at the bottom (least
1249
+ * significant bits).
1250
+ */
1251
+ this.bi_valid = 0
1252
+ /* Number of valid bits in bi_buf. All bits above the last valid bit
1253
+ * are always zero.
1254
+ */
1255
+
1256
+ // Used for window memory init. We safely ignore it for JS. That makes
1257
+ // sense only for pointers and memory check tools.
1258
+ //this.high_water = 0;
1259
+ /* High water mark offset in window for initialized bytes -- bytes above
1260
+ * this are set to zero in order to avoid memory check warnings when
1261
+ * longest match routines access bytes past the input. This is then
1262
+ * updated to the new high water mark.
1263
+ */
1264
+ }
1265
+
1266
+ const deflateResetKeep = (strm) => {
1267
+ if (!strm || !strm.state) {
1268
+ return err(strm, Z_STREAM_ERROR)
1269
+ }
1270
+
1271
+ strm.total_in = strm.total_out = 0
1272
+ strm.data_type = Z_UNKNOWN
1273
+
1274
+ const s = strm.state
1275
+ s.pending = 0
1276
+ s.pending_out = 0
1277
+
1278
+ if (s.wrap < 0) {
1279
+ s.wrap = -s.wrap
1280
+ /* was made negative by deflate(..., Z_FINISH); */
1281
+ }
1282
+ s.status = s.wrap ? INIT_STATE : BUSY_STATE
1283
+ strm.adler =
1284
+ s.wrap === 2
1285
+ ? 0 // crc32(0, Z_NULL, 0)
1286
+ : 1 // adler32(0, Z_NULL, 0)
1287
+ s.last_flush = Z_NO_FLUSH
1288
+ _tr_init(s)
1289
+ return Z_OK
1290
+ }
1291
+
1292
+ const deflateReset = (strm) => {
1293
+ const ret = deflateResetKeep(strm)
1294
+ if (ret === Z_OK) {
1295
+ lm_init(strm.state)
1296
+ }
1297
+ return ret
1298
+ }
1299
+
1300
+ const deflateSetHeader = (strm, head) => {
1301
+ if (!strm || !strm.state) {
1302
+ return Z_STREAM_ERROR
1303
+ }
1304
+ if (strm.state.wrap !== 2) {
1305
+ return Z_STREAM_ERROR
1306
+ }
1307
+ strm.state.gzhead = head
1308
+ return Z_OK
1309
+ }
1310
+
1311
+ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
1312
+ if (!strm) {
1313
+ // === Z_NULL
1314
+ return Z_STREAM_ERROR
1315
+ }
1316
+ let wrap = 1
1317
+
1318
+ if (level === Z_DEFAULT_COMPRESSION) {
1319
+ level = 6
1320
+ }
1321
+
1322
+ if (windowBits < 0) {
1323
+ /* suppress zlib wrapper */
1324
+ wrap = 0
1325
+ windowBits = -windowBits
1326
+ } else if (windowBits > 15) {
1327
+ wrap = 2 /* write gzip wrapper instead */
1328
+ windowBits -= 16
1329
+ }
1330
+
1331
+ if (
1332
+ memLevel < 1 ||
1333
+ memLevel > MAX_MEM_LEVEL ||
1334
+ method !== Z_DEFLATED ||
1335
+ windowBits < 8 ||
1336
+ windowBits > 15 ||
1337
+ level < 0 ||
1338
+ level > 9 ||
1339
+ strategy < 0 ||
1340
+ strategy > Z_FIXED
1341
+ ) {
1342
+ return err(strm, Z_STREAM_ERROR)
1343
+ }
1344
+
1345
+ if (windowBits === 8) {
1346
+ windowBits = 9
1347
+ }
1348
+ /* until 256-byte window bug fixed */
1349
+
1350
+ const s = new DeflateState()
1351
+
1352
+ strm.state = s
1353
+ s.strm = strm
1354
+
1355
+ s.wrap = wrap
1356
+ s.gzhead = null
1357
+ s.w_bits = windowBits
1358
+ s.w_size = 1 << s.w_bits
1359
+ s.w_mask = s.w_size - 1
1360
+
1361
+ s.hash_bits = memLevel + 7
1362
+ s.hash_size = 1 << s.hash_bits
1363
+ s.hash_mask = s.hash_size - 1
1364
+ s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH)
1365
+
1366
+ s.window = new Uint8Array(s.w_size * 2)
1367
+ s.head = new Uint16Array(s.hash_size)
1368
+ s.prev = new Uint16Array(s.w_size)
1369
+
1370
+ // Don't need mem init magic for JS.
1371
+ //s.high_water = 0; /* nothing written to s->window yet */
1372
+
1373
+ s.lit_bufsize = 1 << (memLevel + 6) /* 16K elements by default */
1374
+
1375
+ s.pending_buf_size = s.lit_bufsize * 4
1376
+
1377
+ //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
1378
+ //s->pending_buf = (uchf *) overlay;
1379
+ s.pending_buf = new Uint8Array(s.pending_buf_size)
1380
+
1381
+ // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
1382
+ //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
1383
+ s.d_buf = 1 * s.lit_bufsize
1384
+
1385
+ //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
1386
+ s.l_buf = (1 + 2) * s.lit_bufsize
1387
+
1388
+ s.level = level
1389
+ s.strategy = strategy
1390
+ s.method = method
1391
+
1392
+ return deflateReset(strm)
1393
+ }
1394
+
1395
+ const deflateInit = (strm, level) => {
1396
+ return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY)
1397
+ }
1398
+
1399
+ const deflate = (strm, flush) => {
1400
+ let beg, val // for gzip header write only
1401
+
1402
+ if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) {
1403
+ return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR
1404
+ }
1405
+
1406
+ const s = strm.state
1407
+
1408
+ if (!strm.output || (!strm.input && strm.avail_in !== 0) || (s.status === FINISH_STATE && flush !== Z_FINISH)) {
1409
+ return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR)
1410
+ }
1411
+
1412
+ s.strm = strm /* just in case */
1413
+ const old_flush = s.last_flush
1414
+ s.last_flush = flush
1415
+
1416
+ /* Write the header */
1417
+ if (s.status === INIT_STATE) {
1418
+ if (s.wrap === 2) {
1419
+ // GZIP header
1420
+ strm.adler = 0 //crc32(0L, Z_NULL, 0);
1421
+ put_byte(s, 31)
1422
+ put_byte(s, 139)
1423
+ put_byte(s, 8)
1424
+ if (!s.gzhead) {
1425
+ // s->gzhead == Z_NULL
1426
+ put_byte(s, 0)
1427
+ put_byte(s, 0)
1428
+ put_byte(s, 0)
1429
+ put_byte(s, 0)
1430
+ put_byte(s, 0)
1431
+ put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0)
1432
+ put_byte(s, OS_CODE)
1433
+ s.status = BUSY_STATE
1434
+ } else {
1435
+ put_byte(
1436
+ s,
1437
+ (s.gzhead.text ? 1 : 0) +
1438
+ (s.gzhead.hcrc ? 2 : 0) +
1439
+ (!s.gzhead.extra ? 0 : 4) +
1440
+ (!s.gzhead.name ? 0 : 8) +
1441
+ (!s.gzhead.comment ? 0 : 16)
1442
+ )
1443
+ put_byte(s, s.gzhead.time & 0xff)
1444
+ put_byte(s, (s.gzhead.time >> 8) & 0xff)
1445
+ put_byte(s, (s.gzhead.time >> 16) & 0xff)
1446
+ put_byte(s, (s.gzhead.time >> 24) & 0xff)
1447
+ put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0)
1448
+ put_byte(s, s.gzhead.os & 0xff)
1449
+ if (s.gzhead.extra && s.gzhead.extra.length) {
1450
+ put_byte(s, s.gzhead.extra.length & 0xff)
1451
+ put_byte(s, (s.gzhead.extra.length >> 8) & 0xff)
1452
+ }
1453
+ if (s.gzhead.hcrc) {
1454
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0)
1455
+ }
1456
+ s.gzindex = 0
1457
+ s.status = EXTRA_STATE
1458
+ }
1459
+ } // DEFLATE header
1460
+ else {
1461
+ let header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8
1462
+ let level_flags = -1
1463
+
1464
+ if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
1465
+ level_flags = 0
1466
+ } else if (s.level < 6) {
1467
+ level_flags = 1
1468
+ } else if (s.level === 6) {
1469
+ level_flags = 2
1470
+ } else {
1471
+ level_flags = 3
1472
+ }
1473
+ header |= level_flags << 6
1474
+ if (s.strstart !== 0) {
1475
+ header |= PRESET_DICT
1476
+ }
1477
+ header += 31 - (header % 31)
1478
+
1479
+ s.status = BUSY_STATE
1480
+ putShortMSB(s, header)
1481
+
1482
+ /* Save the adler32 of the preset dictionary: */
1483
+ if (s.strstart !== 0) {
1484
+ putShortMSB(s, strm.adler >>> 16)
1485
+ putShortMSB(s, strm.adler & 0xffff)
1486
+ }
1487
+ strm.adler = 1 // adler32(0L, Z_NULL, 0);
1488
+ }
1489
+ }
1490
+
1491
+ //#ifdef GZIP
1492
+ if (s.status === EXTRA_STATE) {
1493
+ if (s.gzhead.extra /* != Z_NULL*/) {
1494
+ beg = s.pending /* start of bytes to update crc */
1495
+
1496
+ while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
1497
+ if (s.pending === s.pending_buf_size) {
1498
+ if (s.gzhead.hcrc && s.pending > beg) {
1499
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1500
+ }
1501
+ flush_pending(strm)
1502
+ beg = s.pending
1503
+ if (s.pending === s.pending_buf_size) {
1504
+ break
1505
+ }
1506
+ }
1507
+ put_byte(s, s.gzhead.extra[s.gzindex] & 0xff)
1508
+ s.gzindex++
1509
+ }
1510
+ if (s.gzhead.hcrc && s.pending > beg) {
1511
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1512
+ }
1513
+ if (s.gzindex === s.gzhead.extra.length) {
1514
+ s.gzindex = 0
1515
+ s.status = NAME_STATE
1516
+ }
1517
+ } else {
1518
+ s.status = NAME_STATE
1519
+ }
1520
+ }
1521
+ if (s.status === NAME_STATE) {
1522
+ if (s.gzhead.name /* != Z_NULL*/) {
1523
+ beg = s.pending /* start of bytes to update crc */
1524
+ //int val;
1525
+
1526
+ do {
1527
+ if (s.pending === s.pending_buf_size) {
1528
+ if (s.gzhead.hcrc && s.pending > beg) {
1529
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1530
+ }
1531
+ flush_pending(strm)
1532
+ beg = s.pending
1533
+ if (s.pending === s.pending_buf_size) {
1534
+ val = 1
1535
+ break
1536
+ }
1537
+ }
1538
+ // JS specific: little magic to add zero terminator to end of string
1539
+ if (s.gzindex < s.gzhead.name.length) {
1540
+ val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff
1541
+ } else {
1542
+ val = 0
1543
+ }
1544
+ put_byte(s, val)
1545
+ } while (val !== 0)
1546
+
1547
+ if (s.gzhead.hcrc && s.pending > beg) {
1548
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1549
+ }
1550
+ if (val === 0) {
1551
+ s.gzindex = 0
1552
+ s.status = COMMENT_STATE
1553
+ }
1554
+ } else {
1555
+ s.status = COMMENT_STATE
1556
+ }
1557
+ }
1558
+ if (s.status === COMMENT_STATE) {
1559
+ if (s.gzhead.comment /* != Z_NULL*/) {
1560
+ beg = s.pending /* start of bytes to update crc */
1561
+ //int val;
1562
+
1563
+ do {
1564
+ if (s.pending === s.pending_buf_size) {
1565
+ if (s.gzhead.hcrc && s.pending > beg) {
1566
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1567
+ }
1568
+ flush_pending(strm)
1569
+ beg = s.pending
1570
+ if (s.pending === s.pending_buf_size) {
1571
+ val = 1
1572
+ break
1573
+ }
1574
+ }
1575
+ // JS specific: little magic to add zero terminator to end of string
1576
+ if (s.gzindex < s.gzhead.comment.length) {
1577
+ val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff
1578
+ } else {
1579
+ val = 0
1580
+ }
1581
+ put_byte(s, val)
1582
+ } while (val !== 0)
1583
+
1584
+ if (s.gzhead.hcrc && s.pending > beg) {
1585
+ strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg)
1586
+ }
1587
+ if (val === 0) {
1588
+ s.status = HCRC_STATE
1589
+ }
1590
+ } else {
1591
+ s.status = HCRC_STATE
1592
+ }
1593
+ }
1594
+ if (s.status === HCRC_STATE) {
1595
+ if (s.gzhead.hcrc) {
1596
+ if (s.pending + 2 > s.pending_buf_size) {
1597
+ flush_pending(strm)
1598
+ }
1599
+ if (s.pending + 2 <= s.pending_buf_size) {
1600
+ put_byte(s, strm.adler & 0xff)
1601
+ put_byte(s, (strm.adler >> 8) & 0xff)
1602
+ strm.adler = 0 //crc32(0L, Z_NULL, 0);
1603
+ s.status = BUSY_STATE
1604
+ }
1605
+ } else {
1606
+ s.status = BUSY_STATE
1607
+ }
1608
+ }
1609
+ //#endif
1610
+
1611
+ /* Flush as much pending output as possible */
1612
+ if (s.pending !== 0) {
1613
+ flush_pending(strm)
1614
+ if (strm.avail_out === 0) {
1615
+ /* Since avail_out is 0, deflate will be called again with
1616
+ * more output space, but possibly with both pending and
1617
+ * avail_in equal to zero. There won't be anything to do,
1618
+ * but this is not an error situation so make sure we
1619
+ * return OK instead of BUF_ERROR at next call of deflate:
1620
+ */
1621
+ s.last_flush = -1
1622
+ return Z_OK
1623
+ }
1624
+
1625
+ /* Make sure there is something to do and avoid duplicate consecutive
1626
+ * flushes. For repeated and useless calls with Z_FINISH, we keep
1627
+ * returning Z_STREAM_END instead of Z_BUF_ERROR.
1628
+ */
1629
+ } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) {
1630
+ return err(strm, Z_BUF_ERROR)
1631
+ }
1632
+
1633
+ /* User must not provide more input after the first FINISH: */
1634
+ if (s.status === FINISH_STATE && strm.avail_in !== 0) {
1635
+ return err(strm, Z_BUF_ERROR)
1636
+ }
1637
+
1638
+ /* Start a new block or continue the current one.
1639
+ */
1640
+ if (strm.avail_in !== 0 || s.lookahead !== 0 || (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {
1641
+ let bstate =
1642
+ s.strategy === Z_HUFFMAN_ONLY
1643
+ ? deflate_huff(s, flush)
1644
+ : s.strategy === Z_RLE
1645
+ ? deflate_rle(s, flush)
1646
+ : configuration_table[s.level].func(s, flush)
1647
+
1648
+ if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
1649
+ s.status = FINISH_STATE
1650
+ }
1651
+ if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {
1652
+ if (strm.avail_out === 0) {
1653
+ s.last_flush = -1
1654
+ /* avoid BUF_ERROR next call, see above */
1655
+ }
1656
+ return Z_OK
1657
+ /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1658
+ * of deflate should use the same flush parameter to make sure
1659
+ * that the flush is complete. So we don't have to output an
1660
+ * empty block here, this will be done at next call. This also
1661
+ * ensures that for a very small output buffer, we emit at most
1662
+ * one empty block.
1663
+ */
1664
+ }
1665
+ if (bstate === BS_BLOCK_DONE) {
1666
+ if (flush === Z_PARTIAL_FLUSH) {
1667
+ _tr_align(s)
1668
+ } else if (flush !== Z_BLOCK) {
1669
+ /* FULL_FLUSH or SYNC_FLUSH */
1670
+
1671
+ _tr_stored_block(s, 0, 0, false)
1672
+ /* For a full flush, this empty block will be recognized
1673
+ * as a special marker by inflate_sync().
1674
+ */
1675
+ if (flush === Z_FULL_FLUSH) {
1676
+ /*** CLEAR_HASH(s); ***/ /* forget history */
1677
+ zero(s.head) // Fill with NIL (= 0);
1678
+
1679
+ if (s.lookahead === 0) {
1680
+ s.strstart = 0
1681
+ s.block_start = 0
1682
+ s.insert = 0
1683
+ }
1684
+ }
1685
+ }
1686
+ flush_pending(strm)
1687
+ if (strm.avail_out === 0) {
1688
+ s.last_flush = -1 /* avoid BUF_ERROR at next call, see above */
1689
+ return Z_OK
1690
+ }
1691
+ }
1692
+ }
1693
+ //Assert(strm->avail_out > 0, "bug2");
1694
+ //if (strm.avail_out <= 0) { throw new Error("bug2");}
1695
+
1696
+ if (flush !== Z_FINISH) {
1697
+ return Z_OK
1698
+ }
1699
+ if (s.wrap <= 0) {
1700
+ return Z_STREAM_END
1701
+ }
1702
+
1703
+ /* Write the trailer */
1704
+ if (s.wrap === 2) {
1705
+ put_byte(s, strm.adler & 0xff)
1706
+ put_byte(s, (strm.adler >> 8) & 0xff)
1707
+ put_byte(s, (strm.adler >> 16) & 0xff)
1708
+ put_byte(s, (strm.adler >> 24) & 0xff)
1709
+ put_byte(s, strm.total_in & 0xff)
1710
+ put_byte(s, (strm.total_in >> 8) & 0xff)
1711
+ put_byte(s, (strm.total_in >> 16) & 0xff)
1712
+ put_byte(s, (strm.total_in >> 24) & 0xff)
1713
+ } else {
1714
+ putShortMSB(s, strm.adler >>> 16)
1715
+ putShortMSB(s, strm.adler & 0xffff)
1716
+ }
1717
+
1718
+ flush_pending(strm)
1719
+ /* If avail_out is zero, the application will call deflate again
1720
+ * to flush the rest.
1721
+ */
1722
+ if (s.wrap > 0) {
1723
+ s.wrap = -s.wrap
1724
+ }
1725
+ /* write the trailer only once! */
1726
+ return s.pending !== 0 ? Z_OK : Z_STREAM_END
1727
+ }
1728
+
1729
+ const deflateEnd = (strm) => {
1730
+ if (!strm /*== Z_NULL*/ || !strm.state /*== Z_NULL*/) {
1731
+ return Z_STREAM_ERROR
1732
+ }
1733
+
1734
+ const status = strm.state.status
1735
+ if (
1736
+ status !== INIT_STATE &&
1737
+ status !== EXTRA_STATE &&
1738
+ status !== NAME_STATE &&
1739
+ status !== COMMENT_STATE &&
1740
+ status !== HCRC_STATE &&
1741
+ status !== BUSY_STATE &&
1742
+ status !== FINISH_STATE
1743
+ ) {
1744
+ return err(strm, Z_STREAM_ERROR)
1745
+ }
1746
+
1747
+ strm.state = null
1748
+
1749
+ return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK
1750
+ }
1751
+
1752
+ /* =========================================================================
1753
+ * Initializes the compression dictionary from the given byte
1754
+ * sequence without producing any compressed output.
1755
+ */
1756
+ const deflateSetDictionary = (strm, dictionary) => {
1757
+ let dictLength = dictionary.length
1758
+
1759
+ if (!strm /*== Z_NULL*/ || !strm.state /*== Z_NULL*/) {
1760
+ return Z_STREAM_ERROR
1761
+ }
1762
+
1763
+ const s = strm.state
1764
+ const wrap = s.wrap
1765
+
1766
+ if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {
1767
+ return Z_STREAM_ERROR
1768
+ }
1769
+
1770
+ /* when using zlib wrappers, compute Adler-32 for provided dictionary */
1771
+ if (wrap === 1) {
1772
+ /* adler32(strm->adler, dictionary, dictLength); */
1773
+ strm.adler = adler32(strm.adler, dictionary, dictLength, 0)
1774
+ }
1775
+
1776
+ s.wrap = 0 /* avoid computing Adler-32 in read_buf */
1777
+
1778
+ /* if dictionary would fill window, just replace the history */
1779
+ if (dictLength >= s.w_size) {
1780
+ if (wrap === 0) {
1781
+ /* already empty otherwise */
1782
+ /*** CLEAR_HASH(s); ***/
1783
+ zero(s.head) // Fill with NIL (= 0);
1784
+ s.strstart = 0
1785
+ s.block_start = 0
1786
+ s.insert = 0
1787
+ }
1788
+ /* use the tail */
1789
+ // dictionary = dictionary.slice(dictLength - s.w_size);
1790
+ let tmpDict = new Uint8Array(s.w_size)
1791
+ tmpDict.set(dictionary.subarray(dictLength - s.w_size, dictLength), 0)
1792
+ dictionary = tmpDict
1793
+ dictLength = s.w_size
1794
+ }
1795
+ /* insert dictionary into window and hash */
1796
+ const avail = strm.avail_in
1797
+ const next = strm.next_in
1798
+ const input = strm.input
1799
+ strm.avail_in = dictLength
1800
+ strm.next_in = 0
1801
+ strm.input = dictionary
1802
+ fill_window(s)
1803
+ while (s.lookahead >= MIN_MATCH) {
1804
+ let str = s.strstart
1805
+ let n = s.lookahead - (MIN_MATCH - 1)
1806
+ do {
1807
+ /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
1808
+ s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1])
1809
+
1810
+ s.prev[str & s.w_mask] = s.head[s.ins_h]
1811
+
1812
+ s.head[s.ins_h] = str
1813
+ str++
1814
+ } while (--n)
1815
+ s.strstart = str
1816
+ s.lookahead = MIN_MATCH - 1
1817
+ fill_window(s)
1818
+ }
1819
+ s.strstart += s.lookahead
1820
+ s.block_start = s.strstart
1821
+ s.insert = s.lookahead
1822
+ s.lookahead = 0
1823
+ s.match_length = s.prev_length = MIN_MATCH - 1
1824
+ s.match_available = 0
1825
+ strm.next_in = next
1826
+ strm.input = input
1827
+ strm.avail_in = avail
1828
+ s.wrap = wrap
1829
+ return Z_OK
1830
+ }
1831
+
1832
+ module.exports.deflateInit = deflateInit
1833
+ module.exports.deflateInit2 = deflateInit2
1834
+ module.exports.deflateReset = deflateReset
1835
+ module.exports.deflateResetKeep = deflateResetKeep
1836
+ module.exports.deflateSetHeader = deflateSetHeader
1837
+ module.exports.deflate = deflate
1838
+ module.exports.deflateEnd = deflateEnd
1839
+ module.exports.deflateSetDictionary = deflateSetDictionary
1840
+ module.exports.deflateInfo = 'pako deflate (from Nodeca project)'
1841
+
1842
+ /* Not implemented
1843
+ module.exports.deflateBound = deflateBound;
1844
+ module.exports.deflateCopy = deflateCopy;
1845
+ module.exports.deflateParams = deflateParams;
1846
+ module.exports.deflatePending = deflatePending;
1847
+ module.exports.deflatePrime = deflatePrime;
1848
+ module.exports.deflateTune = deflateTune;
1849
+ */