@nktkas/hyperliquid 0.13.1 → 0.13.2

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 (183) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +33 -17
  3. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  4. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  5. package/esm/deps/jsr.io/@std/bytes/1.0.5/_types.js +2 -0
  6. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  7. package/esm/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.js +1 -1
  9. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  10. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +2 -0
  12. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  13. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.js +1 -1
  14. package/{script/deps/jsr.io/@std/encoding/1.0.6 → esm/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  15. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/hex.js +1 -1
  17. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  18. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/msgpack/1.0.3/_types.js +2 -0
  20. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  21. package/esm/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  22. package/esm/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.js +2 -2
  23. package/esm/mod.d.ts +1 -0
  24. package/esm/mod.d.ts.map +1 -1
  25. package/esm/src/clients/event.d.ts +57 -16
  26. package/esm/src/clients/event.d.ts.map +1 -1
  27. package/esm/src/clients/event.js +72 -16
  28. package/esm/src/clients/public.d.ts +241 -49
  29. package/esm/src/clients/public.d.ts.map +1 -1
  30. package/esm/src/clients/public.js +243 -47
  31. package/esm/src/clients/wallet.d.ts +120 -51
  32. package/esm/src/clients/wallet.d.ts.map +1 -1
  33. package/esm/src/clients/wallet.js +192 -58
  34. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  35. package/esm/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  36. package/esm/src/transports/websocket/hyperliquid_event_target.js +37 -0
  37. package/esm/src/transports/websocket/websocket_request_dispatcher.js +3 -3
  38. package/esm/src/transports/websocket/websocket_transport.d.ts +7 -10
  39. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  40. package/esm/src/transports/websocket/websocket_transport.js +41 -35
  41. package/esm/src/types/exchange/common.d.ts +6 -6
  42. package/esm/src/types/exchange/common.d.ts.map +1 -1
  43. package/esm/src/types/exchange/requests.d.ts +131 -64
  44. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  45. package/esm/src/types/exchange/responses.d.ts +7 -7
  46. package/esm/src/types/exchange/responses.d.ts.map +1 -1
  47. package/esm/src/types/explorer/common.d.ts +15 -15
  48. package/esm/src/types/explorer/common.d.ts.map +1 -1
  49. package/esm/src/types/explorer/requests.d.ts +19 -6
  50. package/esm/src/types/explorer/requests.d.ts.map +1 -1
  51. package/esm/src/types/explorer/responses.d.ts +9 -2
  52. package/esm/src/types/explorer/responses.d.ts.map +1 -1
  53. package/esm/src/types/info/accounts.d.ts +189 -124
  54. package/esm/src/types/info/accounts.d.ts.map +1 -1
  55. package/esm/src/types/info/assets.d.ts +82 -78
  56. package/esm/src/types/info/assets.d.ts.map +1 -1
  57. package/esm/src/types/info/delegations.d.ts +117 -0
  58. package/esm/src/types/info/delegations.d.ts.map +1 -0
  59. package/esm/src/types/info/delegations.js +1 -0
  60. package/esm/src/types/info/orders.d.ts +67 -67
  61. package/esm/src/types/info/orders.d.ts.map +1 -1
  62. package/esm/src/types/info/requests.d.ts +128 -63
  63. package/esm/src/types/info/requests.d.ts.map +1 -1
  64. package/esm/src/types/info/vaults.d.ts +41 -84
  65. package/esm/src/types/info/vaults.d.ts.map +1 -1
  66. package/esm/src/types/subscriptions/common.d.ts +3 -0
  67. package/esm/src/types/subscriptions/common.d.ts.map +1 -1
  68. package/esm/src/types/subscriptions/requests.d.ts +10 -0
  69. package/esm/src/types/subscriptions/requests.d.ts.map +1 -1
  70. package/esm/src/utils/key_sort.d.ts +2 -2
  71. package/esm/src/utils/key_sort.d.ts.map +1 -1
  72. package/esm/src/utils/signing.d.ts +1 -1
  73. package/esm/src/utils/signing.js +2 -2
  74. package/package.json +1 -1
  75. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/mod.js +13 -3
  76. package/script/deps/jsr.io/@derzade/typescript-event-target/1.1.1/src/TypedEventTarget.js +23 -13
  77. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +55 -45
  78. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.js +97 -87
  79. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/crypto.js +14 -4
  80. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.js +288 -278
  81. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.js +238 -228
  82. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts +9 -0
  83. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.d.ts.map +1 -0
  84. package/script/deps/jsr.io/@std/bytes/1.0.5/_types.js +13 -0
  85. package/script/deps/jsr.io/@std/bytes/{1.0.4 → 1.0.5}/concat.d.ts +3 -1
  86. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@std/bytes/1.0.5/concat.js +45 -0
  88. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +9 -0
  89. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +1 -0
  90. package/script/deps/jsr.io/@std/encoding/1.0.7/_types.js +13 -0
  91. package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts.map +1 -1
  92. package/script/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +39 -0
  93. package/{esm/deps/jsr.io/@std/encoding/1.0.6 → script/deps/jsr.io/@std/encoding/1.0.7}/hex.d.ts +3 -1
  94. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  95. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +123 -0
  96. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts +9 -0
  97. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.d.ts.map +1 -0
  98. package/script/deps/jsr.io/@std/msgpack/1.0.3/_types.js +13 -0
  99. package/script/deps/jsr.io/@std/msgpack/{1.0.2 → 1.0.3}/encode.d.ts +3 -1
  100. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.d.ts.map +1 -0
  101. package/script/deps/jsr.io/@std/msgpack/1.0.3/encode.js +250 -0
  102. package/script/mod.d.ts +1 -0
  103. package/script/mod.d.ts.map +1 -1
  104. package/script/mod.js +23 -13
  105. package/script/src/clients/event.d.ts +57 -16
  106. package/script/src/clients/event.d.ts.map +1 -1
  107. package/script/src/clients/event.js +551 -485
  108. package/script/src/clients/public.d.ts +241 -49
  109. package/script/src/clients/public.d.ts.map +1 -1
  110. package/script/src/clients/public.js +914 -708
  111. package/script/src/clients/wallet.d.ts +120 -51
  112. package/script/src/clients/wallet.d.ts.map +1 -1
  113. package/script/src/clients/wallet.js +1121 -977
  114. package/script/src/transports/base.js +25 -15
  115. package/script/src/transports/http/http_transport.js +174 -164
  116. package/script/src/transports/websocket/hyperliquid_event_target.d.ts +27 -21
  117. package/script/src/transports/websocket/hyperliquid_event_target.d.ts.map +1 -1
  118. package/script/src/transports/websocket/hyperliquid_event_target.js +80 -33
  119. package/script/src/transports/websocket/reconnecting_websocket.js +364 -354
  120. package/script/src/transports/websocket/websocket_request_dispatcher.js +196 -186
  121. package/script/src/transports/websocket/websocket_transport.d.ts +7 -10
  122. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  123. package/script/src/transports/websocket/websocket_transport.js +236 -220
  124. package/script/src/types/common.js +12 -2
  125. package/script/src/types/exchange/common.d.ts +6 -6
  126. package/script/src/types/exchange/common.d.ts.map +1 -1
  127. package/script/src/types/exchange/common.js +12 -2
  128. package/script/src/types/exchange/requests.d.ts +131 -64
  129. package/script/src/types/exchange/requests.d.ts.map +1 -1
  130. package/script/src/types/exchange/requests.js +12 -2
  131. package/script/src/types/exchange/responses.d.ts +7 -7
  132. package/script/src/types/exchange/responses.d.ts.map +1 -1
  133. package/script/src/types/exchange/responses.js +12 -2
  134. package/script/src/types/explorer/common.d.ts +15 -15
  135. package/script/src/types/explorer/common.d.ts.map +1 -1
  136. package/script/src/types/explorer/common.js +12 -2
  137. package/script/src/types/explorer/requests.d.ts +19 -6
  138. package/script/src/types/explorer/requests.d.ts.map +1 -1
  139. package/script/src/types/explorer/requests.js +12 -2
  140. package/script/src/types/explorer/responses.d.ts +9 -2
  141. package/script/src/types/explorer/responses.d.ts.map +1 -1
  142. package/script/src/types/explorer/responses.js +12 -2
  143. package/script/src/types/info/accounts.d.ts +189 -124
  144. package/script/src/types/info/accounts.d.ts.map +1 -1
  145. package/script/src/types/info/accounts.js +12 -2
  146. package/script/src/types/info/assets.d.ts +82 -78
  147. package/script/src/types/info/assets.d.ts.map +1 -1
  148. package/script/src/types/info/assets.js +12 -2
  149. package/script/src/types/info/delegations.d.ts +117 -0
  150. package/script/src/types/info/delegations.d.ts.map +1 -0
  151. package/script/src/types/info/delegations.js +12 -0
  152. package/script/src/types/info/orders.d.ts +67 -67
  153. package/script/src/types/info/orders.d.ts.map +1 -1
  154. package/script/src/types/info/orders.js +12 -2
  155. package/script/src/types/info/requests.d.ts +128 -63
  156. package/script/src/types/info/requests.d.ts.map +1 -1
  157. package/script/src/types/info/requests.js +12 -2
  158. package/script/src/types/info/vaults.d.ts +41 -84
  159. package/script/src/types/info/vaults.d.ts.map +1 -1
  160. package/script/src/types/info/vaults.js +12 -2
  161. package/script/src/types/subscriptions/common.d.ts +3 -0
  162. package/script/src/types/subscriptions/common.d.ts.map +1 -1
  163. package/script/src/types/subscriptions/common.js +12 -2
  164. package/script/src/types/subscriptions/requests.d.ts +10 -0
  165. package/script/src/types/subscriptions/requests.d.ts.map +1 -1
  166. package/script/src/types/subscriptions/requests.js +12 -2
  167. package/script/src/utils/key_sort.d.ts +2 -2
  168. package/script/src/utils/key_sort.d.ts.map +1 -1
  169. package/script/src/utils/key_sort.js +133 -123
  170. package/script/src/utils/signing.d.ts +1 -1
  171. package/script/src/utils/signing.js +172 -162
  172. package/esm/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  173. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  174. package/esm/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  175. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.d.ts.map +0 -1
  176. package/script/deps/jsr.io/@std/bytes/1.0.4/concat.js +0 -35
  177. package/script/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +0 -29
  178. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +0 -1
  179. package/script/deps/jsr.io/@std/encoding/1.0.6/hex.js +0 -113
  180. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.d.ts.map +0 -1
  181. package/script/deps/jsr.io/@std/msgpack/1.0.2/encode.js +0 -240
  182. /package/esm/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
  183. /package/script/deps/jsr.io/@std/encoding/{1.0.6 → 1.0.7}/_validate_binary_like.d.ts +0 -0
@@ -1,235 +1,245 @@
1
- "use strict";
2
1
  /**
3
2
  * Utilities for hex, bytes, CSPRNG.
4
3
  * @module
5
4
  */
6
5
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.isLE = void 0;
9
- exports.isBytes = isBytes;
10
- exports.u8 = u8;
11
- exports.u32 = u32;
12
- exports.createView = createView;
13
- exports.rotr = rotr;
14
- exports.rotl = rotl;
15
- exports.byteSwap = byteSwap;
16
- exports.byteSwap32 = byteSwap32;
17
- exports.bytesToHex = bytesToHex;
18
- exports.hexToBytes = hexToBytes;
19
- exports.asyncLoop = asyncLoop;
20
- exports.utf8ToBytes = utf8ToBytes;
21
- exports.toBytes = toBytes;
22
- exports.concatBytes = concatBytes;
23
- exports.checkOpts = checkOpts;
24
- exports.wrapConstructor = wrapConstructor;
25
- exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
26
- exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
27
- exports.randomBytes = randomBytes;
28
- // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
29
- // node.js versions earlier than v19 don't declare it in global scope.
30
- // For node.js, package.json#exports field mapping rewrites import
31
- // from `crypto` to `cryptoNode`, which imports native module.
32
- // Makes the utils un-importable in browsers without a bundler.
33
- // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
34
- const crypto_js_1 = require("./crypto.js");
35
- const _assert_js_1 = require("./_assert.js");
36
- // export { isBytes } from './_assert.js';
37
- // We can't reuse isBytes from _assert, because somehow this causes huge perf issues
38
- function isBytes(a) {
39
- return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
40
- }
41
- // Cast array to different type
42
- function u8(arr) {
43
- return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
44
- }
45
- function u32(arr) {
46
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
47
- }
48
- // Cast array to view
49
- function createView(arr) {
50
- return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
51
- }
52
- /** The rotate right (circular right shift) operation for uint32 */
53
- function rotr(word, shift) {
54
- return (word << (32 - shift)) | (word >>> shift);
55
- }
56
- /** The rotate left (circular left shift) operation for uint32 */
57
- function rotl(word, shift) {
58
- return (word << shift) | ((word >>> (32 - shift)) >>> 0);
59
- }
60
- /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
61
- exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
62
- // The byte swap operation for uint32
63
- function byteSwap(word) {
64
- return (((word << 24) & 0xff000000) |
65
- ((word << 8) & 0xff0000) |
66
- ((word >>> 8) & 0xff00) |
67
- ((word >>> 24) & 0xff));
68
- }
69
- /** Conditionally byte swap if on a big-endian platform */
70
- exports.byteSwapIfBE = exports.isLE
71
- ? (n) => n
72
- : (n) => byteSwap(n);
73
- /** In place byte swap for Uint32Array */
74
- function byteSwap32(arr) {
75
- for (let i = 0; i < arr.length; i++) {
76
- arr[i] = byteSwap(arr[i]);
77
- }
78
- }
79
- // Array where index 0xf0 (240) is mapped to string 'f0'
80
- const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
81
- /**
82
- * Convert byte array to hex string.
83
- * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
84
- */
85
- function bytesToHex(bytes) {
86
- (0, _assert_js_1.abytes)(bytes);
87
- // pre-caching improves the speed 6x
88
- let hex = '';
89
- for (let i = 0; i < bytes.length; i++) {
90
- hex += hexes[bytes[i]];
91
- }
92
- return hex;
93
- }
94
- // We use optimized technique to convert hex string to byte array
95
- const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
96
- function asciiToBase16(ch) {
97
- if (ch >= asciis._0 && ch <= asciis._9)
98
- return ch - asciis._0; // '2' => 50-48
99
- if (ch >= asciis.A && ch <= asciis.F)
100
- return ch - (asciis.A - 10); // 'B' => 66-(65-10)
101
- if (ch >= asciis.a && ch <= asciis.f)
102
- return ch - (asciis.a - 10); // 'b' => 98-(97-10)
103
- return;
104
- }
105
- /**
106
- * Convert hex string to byte array.
107
- * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
108
- */
109
- function hexToBytes(hex) {
110
- if (typeof hex !== 'string')
111
- throw new Error('hex string expected, got ' + typeof hex);
112
- const hl = hex.length;
113
- const al = hl / 2;
114
- if (hl % 2)
115
- throw new Error('hex string expected, got unpadded hex of length ' + hl);
116
- const array = new Uint8Array(al);
117
- for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
118
- const n1 = asciiToBase16(hex.charCodeAt(hi));
119
- const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
120
- if (n1 === undefined || n2 === undefined) {
121
- const char = hex[hi] + hex[hi + 1];
122
- throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
6
+ (function (factory) {
7
+ if (typeof module === "object" && typeof module.exports === "object") {
8
+ var v = factory(require, exports);
9
+ if (v !== undefined) module.exports = v;
10
+ }
11
+ else if (typeof define === "function" && define.amd) {
12
+ define(["require", "exports", "./crypto.js", "./_assert.js"], factory);
13
+ }
14
+ })(function (require, exports) {
15
+ "use strict";
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.isLE = void 0;
18
+ exports.isBytes = isBytes;
19
+ exports.u8 = u8;
20
+ exports.u32 = u32;
21
+ exports.createView = createView;
22
+ exports.rotr = rotr;
23
+ exports.rotl = rotl;
24
+ exports.byteSwap = byteSwap;
25
+ exports.byteSwap32 = byteSwap32;
26
+ exports.bytesToHex = bytesToHex;
27
+ exports.hexToBytes = hexToBytes;
28
+ exports.asyncLoop = asyncLoop;
29
+ exports.utf8ToBytes = utf8ToBytes;
30
+ exports.toBytes = toBytes;
31
+ exports.concatBytes = concatBytes;
32
+ exports.checkOpts = checkOpts;
33
+ exports.wrapConstructor = wrapConstructor;
34
+ exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
35
+ exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
36
+ exports.randomBytes = randomBytes;
37
+ // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
38
+ // node.js versions earlier than v19 don't declare it in global scope.
39
+ // For node.js, package.json#exports field mapping rewrites import
40
+ // from `crypto` to `cryptoNode`, which imports native module.
41
+ // Makes the utils un-importable in browsers without a bundler.
42
+ // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
43
+ const crypto_js_1 = require("./crypto.js");
44
+ const _assert_js_1 = require("./_assert.js");
45
+ // export { isBytes } from './_assert.js';
46
+ // We can't reuse isBytes from _assert, because somehow this causes huge perf issues
47
+ function isBytes(a) {
48
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
49
+ }
50
+ // Cast array to different type
51
+ function u8(arr) {
52
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
53
+ }
54
+ function u32(arr) {
55
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
56
+ }
57
+ // Cast array to view
58
+ function createView(arr) {
59
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
60
+ }
61
+ /** The rotate right (circular right shift) operation for uint32 */
62
+ function rotr(word, shift) {
63
+ return (word << (32 - shift)) | (word >>> shift);
64
+ }
65
+ /** The rotate left (circular left shift) operation for uint32 */
66
+ function rotl(word, shift) {
67
+ return (word << shift) | ((word >>> (32 - shift)) >>> 0);
68
+ }
69
+ /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
70
+ exports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
71
+ // The byte swap operation for uint32
72
+ function byteSwap(word) {
73
+ return (((word << 24) & 0xff000000) |
74
+ ((word << 8) & 0xff0000) |
75
+ ((word >>> 8) & 0xff00) |
76
+ ((word >>> 24) & 0xff));
77
+ }
78
+ /** Conditionally byte swap if on a big-endian platform */
79
+ exports.byteSwapIfBE = exports.isLE
80
+ ? (n) => n
81
+ : (n) => byteSwap(n);
82
+ /** In place byte swap for Uint32Array */
83
+ function byteSwap32(arr) {
84
+ for (let i = 0; i < arr.length; i++) {
85
+ arr[i] = byteSwap(arr[i]);
123
86
  }
124
- array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
125
87
  }
126
- return array;
127
- }
128
- /**
129
- * There is no setImmediate in browser and setTimeout is slow.
130
- * Call of async fn will return Promise, which will be fullfiled only on
131
- * next scheduler queue processing step and this is exactly what we need.
132
- */
133
- const nextTick = async () => { };
134
- exports.nextTick = nextTick;
135
- /** Returns control to thread each 'tick' ms to avoid blocking. */
136
- async function asyncLoop(iters, tick, cb) {
137
- let ts = Date.now();
138
- for (let i = 0; i < iters; i++) {
139
- cb(i);
140
- // Date.now() is not monotonic, so in case if clock goes backwards we return return control too
141
- const diff = Date.now() - ts;
142
- if (diff >= 0 && diff < tick)
143
- continue;
144
- await (0, exports.nextTick)();
145
- ts += diff;
146
- }
147
- }
148
- /**
149
- * Convert JS string to byte array.
150
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
151
- */
152
- function utf8ToBytes(str) {
153
- if (typeof str !== 'string')
154
- throw new Error('utf8ToBytes expected string, got ' + typeof str);
155
- return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
156
- }
157
- /**
158
- * Normalizes (non-hex) string or Uint8Array to Uint8Array.
159
- * Warning: when Uint8Array is passed, it would NOT get copied.
160
- * Keep in mind for future mutable operations.
161
- */
162
- function toBytes(data) {
163
- if (typeof data === 'string')
164
- data = utf8ToBytes(data);
165
- (0, _assert_js_1.abytes)(data);
166
- return data;
167
- }
168
- /**
169
- * Copies several Uint8Arrays into one.
170
- */
171
- function concatBytes(...arrays) {
172
- let sum = 0;
173
- for (let i = 0; i < arrays.length; i++) {
174
- const a = arrays[i];
175
- (0, _assert_js_1.abytes)(a);
176
- sum += a.length;
177
- }
178
- const res = new Uint8Array(sum);
179
- for (let i = 0, pad = 0; i < arrays.length; i++) {
180
- const a = arrays[i];
181
- res.set(a, pad);
182
- pad += a.length;
183
- }
184
- return res;
185
- }
186
- /** For runtime check if class implements interface */
187
- class Hash {
188
- // Safe version that clones internal state
189
- clone() {
190
- return this._cloneInto();
191
- }
192
- }
193
- exports.Hash = Hash;
194
- function checkOpts(defaults, opts) {
195
- if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
196
- throw new Error('Options should be object or undefined');
197
- const merged = Object.assign(defaults, opts);
198
- return merged;
199
- }
200
- /** Wraps hash function, creating an interface on top of it */
201
- function wrapConstructor(hashCons) {
202
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
203
- const tmp = hashCons();
204
- hashC.outputLen = tmp.outputLen;
205
- hashC.blockLen = tmp.blockLen;
206
- hashC.create = () => hashCons();
207
- return hashC;
208
- }
209
- function wrapConstructorWithOpts(hashCons) {
210
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
211
- const tmp = hashCons({});
212
- hashC.outputLen = tmp.outputLen;
213
- hashC.blockLen = tmp.blockLen;
214
- hashC.create = (opts) => hashCons(opts);
215
- return hashC;
216
- }
217
- function wrapXOFConstructorWithOpts(hashCons) {
218
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
219
- const tmp = hashCons({});
220
- hashC.outputLen = tmp.outputLen;
221
- hashC.blockLen = tmp.blockLen;
222
- hashC.create = (opts) => hashCons(opts);
223
- return hashC;
224
- }
225
- /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
226
- function randomBytes(bytesLength = 32) {
227
- if (crypto_js_1.crypto && typeof crypto_js_1.crypto.getRandomValues === 'function') {
228
- return crypto_js_1.crypto.getRandomValues(new Uint8Array(bytesLength));
229
- }
230
- // Legacy Node.js compatibility
231
- if (crypto_js_1.crypto && typeof crypto_js_1.crypto.randomBytes === 'function') {
232
- return crypto_js_1.crypto.randomBytes(bytesLength);
233
- }
234
- throw new Error('crypto.getRandomValues must be defined');
235
- }
88
+ // Array where index 0xf0 (240) is mapped to string 'f0'
89
+ const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
90
+ /**
91
+ * Convert byte array to hex string.
92
+ * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
93
+ */
94
+ function bytesToHex(bytes) {
95
+ (0, _assert_js_1.abytes)(bytes);
96
+ // pre-caching improves the speed 6x
97
+ let hex = '';
98
+ for (let i = 0; i < bytes.length; i++) {
99
+ hex += hexes[bytes[i]];
100
+ }
101
+ return hex;
102
+ }
103
+ // We use optimized technique to convert hex string to byte array
104
+ const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
105
+ function asciiToBase16(ch) {
106
+ if (ch >= asciis._0 && ch <= asciis._9)
107
+ return ch - asciis._0; // '2' => 50-48
108
+ if (ch >= asciis.A && ch <= asciis.F)
109
+ return ch - (asciis.A - 10); // 'B' => 66-(65-10)
110
+ if (ch >= asciis.a && ch <= asciis.f)
111
+ return ch - (asciis.a - 10); // 'b' => 98-(97-10)
112
+ return;
113
+ }
114
+ /**
115
+ * Convert hex string to byte array.
116
+ * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
117
+ */
118
+ function hexToBytes(hex) {
119
+ if (typeof hex !== 'string')
120
+ throw new Error('hex string expected, got ' + typeof hex);
121
+ const hl = hex.length;
122
+ const al = hl / 2;
123
+ if (hl % 2)
124
+ throw new Error('hex string expected, got unpadded hex of length ' + hl);
125
+ const array = new Uint8Array(al);
126
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
127
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
128
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
129
+ if (n1 === undefined || n2 === undefined) {
130
+ const char = hex[hi] + hex[hi + 1];
131
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
132
+ }
133
+ array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
134
+ }
135
+ return array;
136
+ }
137
+ /**
138
+ * There is no setImmediate in browser and setTimeout is slow.
139
+ * Call of async fn will return Promise, which will be fullfiled only on
140
+ * next scheduler queue processing step and this is exactly what we need.
141
+ */
142
+ const nextTick = async () => { };
143
+ exports.nextTick = nextTick;
144
+ /** Returns control to thread each 'tick' ms to avoid blocking. */
145
+ async function asyncLoop(iters, tick, cb) {
146
+ let ts = Date.now();
147
+ for (let i = 0; i < iters; i++) {
148
+ cb(i);
149
+ // Date.now() is not monotonic, so in case if clock goes backwards we return return control too
150
+ const diff = Date.now() - ts;
151
+ if (diff >= 0 && diff < tick)
152
+ continue;
153
+ await (0, exports.nextTick)();
154
+ ts += diff;
155
+ }
156
+ }
157
+ /**
158
+ * Convert JS string to byte array.
159
+ * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
160
+ */
161
+ function utf8ToBytes(str) {
162
+ if (typeof str !== 'string')
163
+ throw new Error('utf8ToBytes expected string, got ' + typeof str);
164
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
165
+ }
166
+ /**
167
+ * Normalizes (non-hex) string or Uint8Array to Uint8Array.
168
+ * Warning: when Uint8Array is passed, it would NOT get copied.
169
+ * Keep in mind for future mutable operations.
170
+ */
171
+ function toBytes(data) {
172
+ if (typeof data === 'string')
173
+ data = utf8ToBytes(data);
174
+ (0, _assert_js_1.abytes)(data);
175
+ return data;
176
+ }
177
+ /**
178
+ * Copies several Uint8Arrays into one.
179
+ */
180
+ function concatBytes(...arrays) {
181
+ let sum = 0;
182
+ for (let i = 0; i < arrays.length; i++) {
183
+ const a = arrays[i];
184
+ (0, _assert_js_1.abytes)(a);
185
+ sum += a.length;
186
+ }
187
+ const res = new Uint8Array(sum);
188
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
189
+ const a = arrays[i];
190
+ res.set(a, pad);
191
+ pad += a.length;
192
+ }
193
+ return res;
194
+ }
195
+ /** For runtime check if class implements interface */
196
+ class Hash {
197
+ // Safe version that clones internal state
198
+ clone() {
199
+ return this._cloneInto();
200
+ }
201
+ }
202
+ exports.Hash = Hash;
203
+ function checkOpts(defaults, opts) {
204
+ if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
205
+ throw new Error('Options should be object or undefined');
206
+ const merged = Object.assign(defaults, opts);
207
+ return merged;
208
+ }
209
+ /** Wraps hash function, creating an interface on top of it */
210
+ function wrapConstructor(hashCons) {
211
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
212
+ const tmp = hashCons();
213
+ hashC.outputLen = tmp.outputLen;
214
+ hashC.blockLen = tmp.blockLen;
215
+ hashC.create = () => hashCons();
216
+ return hashC;
217
+ }
218
+ function wrapConstructorWithOpts(hashCons) {
219
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
220
+ const tmp = hashCons({});
221
+ hashC.outputLen = tmp.outputLen;
222
+ hashC.blockLen = tmp.blockLen;
223
+ hashC.create = (opts) => hashCons(opts);
224
+ return hashC;
225
+ }
226
+ function wrapXOFConstructorWithOpts(hashCons) {
227
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
228
+ const tmp = hashCons({});
229
+ hashC.outputLen = tmp.outputLen;
230
+ hashC.blockLen = tmp.blockLen;
231
+ hashC.create = (opts) => hashCons(opts);
232
+ return hashC;
233
+ }
234
+ /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
235
+ function randomBytes(bytesLength = 32) {
236
+ if (crypto_js_1.crypto && typeof crypto_js_1.crypto.getRandomValues === 'function') {
237
+ return crypto_js_1.crypto.getRandomValues(new Uint8Array(bytesLength));
238
+ }
239
+ // Legacy Node.js compatibility
240
+ if (crypto_js_1.crypto && typeof crypto_js_1.crypto.randomBytes === 'function') {
241
+ return crypto_js_1.crypto.randomBytes(bytesLength);
242
+ }
243
+ throw new Error('crypto.getRandomValues must be defined');
244
+ }
245
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
3
+ *
4
+ * This type is internal utility type and should not be used directly.
5
+ *
6
+ * @internal @private
7
+ */
8
+ export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
9
+ //# sourceMappingURL=_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/bytes/1.0.5/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ (function (factory) {
3
+ if (typeof module === "object" && typeof module.exports === "object") {
4
+ var v = factory(require, exports);
5
+ if (v !== undefined) module.exports = v;
6
+ }
7
+ else if (typeof define === "function" && define.amd) {
8
+ define(["require", "exports"], factory);
9
+ }
10
+ })(function (require, exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ });
@@ -1,3 +1,5 @@
1
+ import type { Uint8Array_ } from "./_types.js";
2
+ export type { Uint8Array_ };
1
3
  /**
2
4
  * Concatenate an array of byte slices into a single slice.
3
5
  *
@@ -15,5 +17,5 @@
15
17
  * assertEquals(concat([a, b]), new Uint8Array([0, 1, 2, 3, 4, 5]));
16
18
  * ```
17
19
  */
18
- export declare function concat(buffers: Uint8Array[]): Uint8Array;
20
+ export declare function concat(buffers: Uint8Array[]): Uint8Array_;
19
21
  //# sourceMappingURL=concat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concat.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/bytes/1.0.5/concat.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,WAAW,CAazD"}
@@ -0,0 +1,45 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ (function (factory) {
4
+ if (typeof module === "object" && typeof module.exports === "object") {
5
+ var v = factory(require, exports);
6
+ if (v !== undefined) module.exports = v;
7
+ }
8
+ else if (typeof define === "function" && define.amd) {
9
+ define(["require", "exports"], factory);
10
+ }
11
+ })(function (require, exports) {
12
+ "use strict";
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.concat = concat;
15
+ /**
16
+ * Concatenate an array of byte slices into a single slice.
17
+ *
18
+ * @param buffers Array of byte slices to concatenate.
19
+ * @returns A new byte slice containing all the input slices concatenated.
20
+ *
21
+ * @example Basic usage
22
+ * ```ts
23
+ * import { concat } from "@std/bytes/concat";
24
+ * import { assertEquals } from "@std/assert";
25
+ *
26
+ * const a = new Uint8Array([0, 1, 2]);
27
+ * const b = new Uint8Array([3, 4, 5]);
28
+ *
29
+ * assertEquals(concat([a, b]), new Uint8Array([0, 1, 2, 3, 4, 5]));
30
+ * ```
31
+ */
32
+ function concat(buffers) {
33
+ let length = 0;
34
+ for (const buffer of buffers) {
35
+ length += buffer.length;
36
+ }
37
+ const output = new Uint8Array(length);
38
+ let index = 0;
39
+ for (const buffer of buffers) {
40
+ output.set(buffer, index);
41
+ index += buffer.length;
42
+ }
43
+ return output;
44
+ }
45
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
3
+ *
4
+ * This type is internal utility type and should not be used directly.
5
+ *
6
+ * @internal @private
7
+ */
8
+ export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
9
+ //# sourceMappingURL=_types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ (function (factory) {
3
+ if (typeof module === "object" && typeof module.exports === "object") {
4
+ var v = factory(require, exports);
5
+ if (v !== undefined) module.exports = v;
6
+ }
7
+ else if (typeof define === "function" && define.amd) {
8
+ define(["require", "exports"], factory);
9
+ }
10
+ })(function (require, exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"_validate_binary_like.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.ts"],"names":[],"mappings":"AAeA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAa9D"}
1
+ {"version":3,"file":"_validate_binary_like.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.ts"],"names":[],"mappings":"AAeA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAa9D"}