@0xarchive/sdk 0.1.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,763 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ OxArchive: () => OxArchive,
24
+ OxArchiveError: () => OxArchiveError,
25
+ OxArchiveWs: () => OxArchiveWs,
26
+ default: () => OxArchive
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/types.ts
31
+ var OxArchiveError = class extends Error {
32
+ code;
33
+ requestId;
34
+ constructor(message, code, requestId) {
35
+ super(message);
36
+ this.name = "OxArchiveError";
37
+ this.code = code;
38
+ this.requestId = requestId;
39
+ }
40
+ };
41
+
42
+ // src/http.ts
43
+ var HttpClient = class {
44
+ baseUrl;
45
+ apiKey;
46
+ timeout;
47
+ constructor(options) {
48
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
49
+ this.apiKey = options.apiKey;
50
+ this.timeout = options.timeout;
51
+ }
52
+ /**
53
+ * Make a GET request to the API
54
+ */
55
+ async get(path, params) {
56
+ const url = new URL(`${this.baseUrl}${path}`);
57
+ if (params) {
58
+ for (const [key, value] of Object.entries(params)) {
59
+ if (value !== void 0 && value !== null) {
60
+ url.searchParams.set(key, String(value));
61
+ }
62
+ }
63
+ }
64
+ const controller = new AbortController();
65
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
66
+ try {
67
+ const response = await fetch(url.toString(), {
68
+ method: "GET",
69
+ headers: {
70
+ "X-API-Key": this.apiKey,
71
+ "Content-Type": "application/json"
72
+ },
73
+ signal: controller.signal
74
+ });
75
+ clearTimeout(timeoutId);
76
+ const data = await response.json();
77
+ if (!response.ok) {
78
+ const error = data;
79
+ throw new OxArchiveError(
80
+ error.error || `Request failed with status ${response.status}`,
81
+ response.status,
82
+ data.request_id
83
+ );
84
+ }
85
+ return data;
86
+ } catch (error) {
87
+ clearTimeout(timeoutId);
88
+ if (error instanceof OxArchiveError) {
89
+ throw error;
90
+ }
91
+ if (error instanceof Error && error.name === "AbortError") {
92
+ throw new OxArchiveError(`Request timeout after ${this.timeout}ms`, 408);
93
+ }
94
+ throw new OxArchiveError(
95
+ error instanceof Error ? error.message : "Unknown error",
96
+ 500
97
+ );
98
+ }
99
+ }
100
+ };
101
+
102
+ // src/resources/orderbook.ts
103
+ var OrderBookResource = class {
104
+ constructor(http) {
105
+ this.http = http;
106
+ }
107
+ /**
108
+ * Get order book snapshot for a coin
109
+ *
110
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
111
+ * @param params - Optional parameters
112
+ * @returns Order book snapshot
113
+ */
114
+ async get(coin, params) {
115
+ const response = await this.http.get(
116
+ `/v1/orderbook/${coin.toUpperCase()}`,
117
+ params
118
+ );
119
+ return response.data;
120
+ }
121
+ /**
122
+ * Get historical order book snapshots
123
+ *
124
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
125
+ * @param params - Time range and pagination parameters
126
+ * @returns Array of order book snapshots
127
+ */
128
+ async history(coin, params) {
129
+ const response = await this.http.get(
130
+ `/v1/orderbook/${coin.toUpperCase()}/history`,
131
+ params
132
+ );
133
+ return response.data;
134
+ }
135
+ };
136
+
137
+ // src/resources/trades.ts
138
+ var TradesResource = class {
139
+ constructor(http) {
140
+ this.http = http;
141
+ }
142
+ /**
143
+ * Get trade history for a coin
144
+ *
145
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
146
+ * @param params - Time range and pagination parameters
147
+ * @returns Array of trades
148
+ */
149
+ async list(coin, params) {
150
+ const response = await this.http.get(
151
+ `/v1/trades/${coin.toUpperCase()}`,
152
+ params
153
+ );
154
+ return response.data;
155
+ }
156
+ /**
157
+ * Get most recent trades for a coin
158
+ *
159
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
160
+ * @param limit - Number of trades to return (default: 100)
161
+ * @returns Array of recent trades
162
+ */
163
+ async recent(coin, limit) {
164
+ const response = await this.http.get(
165
+ `/v1/trades/${coin.toUpperCase()}/recent`,
166
+ { limit }
167
+ );
168
+ return response.data;
169
+ }
170
+ };
171
+
172
+ // src/resources/candles.ts
173
+ var CandlesResource = class {
174
+ constructor(http) {
175
+ this.http = http;
176
+ }
177
+ /**
178
+ * Get OHLCV candles for a coin
179
+ *
180
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
181
+ * @param params - Interval, time range, and pagination parameters
182
+ * @returns Array of candles
183
+ */
184
+ async list(coin, params) {
185
+ const response = await this.http.get(
186
+ `/v1/candles/${coin.toUpperCase()}`,
187
+ params
188
+ );
189
+ return response.data;
190
+ }
191
+ };
192
+
193
+ // src/resources/instruments.ts
194
+ var InstrumentsResource = class {
195
+ constructor(http) {
196
+ this.http = http;
197
+ }
198
+ /**
199
+ * List all available trading instruments
200
+ *
201
+ * @returns Array of instruments
202
+ */
203
+ async list() {
204
+ const response = await this.http.get(
205
+ "/v1/instruments"
206
+ );
207
+ return response.data;
208
+ }
209
+ /**
210
+ * Get a specific instrument by coin symbol
211
+ *
212
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
213
+ * @returns Instrument details
214
+ */
215
+ async get(coin) {
216
+ const response = await this.http.get(
217
+ `/v1/instruments/${coin.toUpperCase()}`
218
+ );
219
+ return response.data;
220
+ }
221
+ };
222
+
223
+ // src/resources/funding.ts
224
+ var FundingResource = class {
225
+ constructor(http) {
226
+ this.http = http;
227
+ }
228
+ /**
229
+ * Get funding rate history for a coin
230
+ *
231
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
232
+ * @param params - Time range and pagination parameters
233
+ * @returns Array of funding rate records
234
+ */
235
+ async history(coin, params) {
236
+ const response = await this.http.get(
237
+ `/v1/funding/${coin.toUpperCase()}`,
238
+ params
239
+ );
240
+ return response.data;
241
+ }
242
+ /**
243
+ * Get current funding rate for a coin
244
+ *
245
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
246
+ * @returns Current funding rate
247
+ */
248
+ async current(coin) {
249
+ const response = await this.http.get(
250
+ `/v1/funding/${coin.toUpperCase()}/current`
251
+ );
252
+ return response.data;
253
+ }
254
+ };
255
+
256
+ // src/resources/openinterest.ts
257
+ var OpenInterestResource = class {
258
+ constructor(http) {
259
+ this.http = http;
260
+ }
261
+ /**
262
+ * Get open interest history for a coin
263
+ *
264
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
265
+ * @param params - Time range and pagination parameters
266
+ * @returns Array of open interest records
267
+ */
268
+ async history(coin, params) {
269
+ const response = await this.http.get(
270
+ `/v1/openinterest/${coin.toUpperCase()}`,
271
+ params
272
+ );
273
+ return response.data;
274
+ }
275
+ /**
276
+ * Get current open interest for a coin
277
+ *
278
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
279
+ * @returns Current open interest
280
+ */
281
+ async current(coin) {
282
+ const response = await this.http.get(
283
+ `/v1/openinterest/${coin.toUpperCase()}/current`
284
+ );
285
+ return response.data;
286
+ }
287
+ };
288
+
289
+ // src/client.ts
290
+ var DEFAULT_BASE_URL = "https://api.0xarchive.io";
291
+ var DEFAULT_TIMEOUT = 3e4;
292
+ var OxArchive = class {
293
+ http;
294
+ /**
295
+ * Order book data (L2 snapshots from April 2023)
296
+ */
297
+ orderbook;
298
+ /**
299
+ * Trade/fill history
300
+ */
301
+ trades;
302
+ /**
303
+ * OHLCV candles
304
+ */
305
+ candles;
306
+ /**
307
+ * Trading instruments metadata
308
+ */
309
+ instruments;
310
+ /**
311
+ * Funding rates
312
+ */
313
+ funding;
314
+ /**
315
+ * Open interest
316
+ */
317
+ openInterest;
318
+ /**
319
+ * Create a new 0xarchive client
320
+ *
321
+ * @param options - Client configuration options
322
+ */
323
+ constructor(options) {
324
+ if (!options.apiKey) {
325
+ throw new Error("API key is required. Get one at https://0xarchive.io/signup");
326
+ }
327
+ this.http = new HttpClient({
328
+ baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
329
+ apiKey: options.apiKey,
330
+ timeout: options.timeout ?? DEFAULT_TIMEOUT
331
+ });
332
+ this.orderbook = new OrderBookResource(this.http);
333
+ this.trades = new TradesResource(this.http);
334
+ this.candles = new CandlesResource(this.http);
335
+ this.instruments = new InstrumentsResource(this.http);
336
+ this.funding = new FundingResource(this.http);
337
+ this.openInterest = new OpenInterestResource(this.http);
338
+ }
339
+ };
340
+
341
+ // src/websocket.ts
342
+ var DEFAULT_WS_URL = "wss://ws.0xarchive.io";
343
+ var DEFAULT_PING_INTERVAL = 3e4;
344
+ var DEFAULT_RECONNECT_DELAY = 1e3;
345
+ var DEFAULT_MAX_RECONNECT_ATTEMPTS = 10;
346
+ var OxArchiveWs = class {
347
+ ws = null;
348
+ options;
349
+ handlers = {};
350
+ subscriptions = /* @__PURE__ */ new Set();
351
+ state = "disconnected";
352
+ reconnectAttempts = 0;
353
+ pingTimer = null;
354
+ reconnectTimer = null;
355
+ constructor(options) {
356
+ this.options = {
357
+ apiKey: options.apiKey,
358
+ wsUrl: options.wsUrl ?? DEFAULT_WS_URL,
359
+ autoReconnect: options.autoReconnect ?? true,
360
+ reconnectDelay: options.reconnectDelay ?? DEFAULT_RECONNECT_DELAY,
361
+ maxReconnectAttempts: options.maxReconnectAttempts ?? DEFAULT_MAX_RECONNECT_ATTEMPTS,
362
+ pingInterval: options.pingInterval ?? DEFAULT_PING_INTERVAL
363
+ };
364
+ }
365
+ /**
366
+ * Connect to the WebSocket server
367
+ */
368
+ connect(handlers) {
369
+ if (handlers) {
370
+ this.handlers = handlers;
371
+ }
372
+ this.setState("connecting");
373
+ const url = `${this.options.wsUrl}?apiKey=${encodeURIComponent(this.options.apiKey)}`;
374
+ this.ws = new WebSocket(url);
375
+ this.ws.onopen = () => {
376
+ this.reconnectAttempts = 0;
377
+ this.setState("connected");
378
+ this.startPing();
379
+ this.resubscribe();
380
+ this.handlers.onOpen?.();
381
+ };
382
+ this.ws.onclose = (event) => {
383
+ this.stopPing();
384
+ this.handlers.onClose?.(event.code, event.reason);
385
+ if (this.options.autoReconnect && this.state !== "disconnected") {
386
+ this.scheduleReconnect();
387
+ } else {
388
+ this.setState("disconnected");
389
+ }
390
+ };
391
+ this.ws.onerror = () => {
392
+ const error = new Error("WebSocket connection error");
393
+ this.handlers.onError?.(error);
394
+ };
395
+ this.ws.onmessage = (event) => {
396
+ try {
397
+ const message = JSON.parse(event.data);
398
+ this.handlers.onMessage?.(message);
399
+ } catch {
400
+ }
401
+ };
402
+ }
403
+ /**
404
+ * Disconnect from the WebSocket server
405
+ */
406
+ disconnect() {
407
+ this.setState("disconnected");
408
+ this.stopPing();
409
+ this.clearReconnectTimer();
410
+ if (this.ws) {
411
+ this.ws.close(1e3, "Client disconnect");
412
+ this.ws = null;
413
+ }
414
+ }
415
+ /**
416
+ * Subscribe to a channel
417
+ */
418
+ subscribe(channel, coin) {
419
+ const key = this.subscriptionKey(channel, coin);
420
+ this.subscriptions.add(key);
421
+ if (this.isConnected()) {
422
+ this.send({ op: "subscribe", channel, coin });
423
+ }
424
+ }
425
+ /**
426
+ * Subscribe to order book updates for a coin
427
+ */
428
+ subscribeOrderbook(coin) {
429
+ this.subscribe("orderbook", coin);
430
+ }
431
+ /**
432
+ * Subscribe to trades for a coin
433
+ */
434
+ subscribeTrades(coin) {
435
+ this.subscribe("trades", coin);
436
+ }
437
+ /**
438
+ * Subscribe to ticker updates for a coin
439
+ */
440
+ subscribeTicker(coin) {
441
+ this.subscribe("ticker", coin);
442
+ }
443
+ /**
444
+ * Subscribe to all tickers
445
+ */
446
+ subscribeAllTickers() {
447
+ this.subscribe("all_tickers");
448
+ }
449
+ /**
450
+ * Unsubscribe from a channel
451
+ */
452
+ unsubscribe(channel, coin) {
453
+ const key = this.subscriptionKey(channel, coin);
454
+ this.subscriptions.delete(key);
455
+ if (this.isConnected()) {
456
+ this.send({ op: "unsubscribe", channel, coin });
457
+ }
458
+ }
459
+ /**
460
+ * Unsubscribe from order book updates for a coin
461
+ */
462
+ unsubscribeOrderbook(coin) {
463
+ this.unsubscribe("orderbook", coin);
464
+ }
465
+ /**
466
+ * Unsubscribe from trades for a coin
467
+ */
468
+ unsubscribeTrades(coin) {
469
+ this.unsubscribe("trades", coin);
470
+ }
471
+ /**
472
+ * Unsubscribe from ticker updates for a coin
473
+ */
474
+ unsubscribeTicker(coin) {
475
+ this.unsubscribe("ticker", coin);
476
+ }
477
+ /**
478
+ * Unsubscribe from all tickers
479
+ */
480
+ unsubscribeAllTickers() {
481
+ this.unsubscribe("all_tickers");
482
+ }
483
+ // ==========================================================================
484
+ // Historical Replay (Option B) - Like Tardis.dev
485
+ // ==========================================================================
486
+ /**
487
+ * Start historical replay with timing preserved
488
+ *
489
+ * @param channel - Data channel to replay
490
+ * @param coin - Trading pair (e.g., 'BTC', 'ETH')
491
+ * @param options - Replay options
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * ws.replay('orderbook', 'BTC', {
496
+ * start: Date.now() - 86400000, // 24 hours ago
497
+ * speed: 10 // 10x faster than real-time
498
+ * });
499
+ * ```
500
+ */
501
+ replay(channel, coin, options) {
502
+ this.send({
503
+ op: "replay",
504
+ channel,
505
+ coin,
506
+ start: options.start,
507
+ end: options.end,
508
+ speed: options.speed ?? 1
509
+ });
510
+ }
511
+ /**
512
+ * Pause the current replay
513
+ */
514
+ replayPause() {
515
+ this.send({ op: "replay.pause" });
516
+ }
517
+ /**
518
+ * Resume a paused replay
519
+ */
520
+ replayResume() {
521
+ this.send({ op: "replay.resume" });
522
+ }
523
+ /**
524
+ * Seek to a specific timestamp in the replay
525
+ * @param timestamp - Unix timestamp in milliseconds
526
+ */
527
+ replaySeek(timestamp) {
528
+ this.send({ op: "replay.seek", timestamp });
529
+ }
530
+ /**
531
+ * Stop the current replay
532
+ */
533
+ replayStop() {
534
+ this.send({ op: "replay.stop" });
535
+ }
536
+ // ==========================================================================
537
+ // Bulk Streaming (Option D) - Like Databento
538
+ // ==========================================================================
539
+ /**
540
+ * Start bulk streaming for fast data download
541
+ *
542
+ * @param channel - Data channel to stream
543
+ * @param coin - Trading pair (e.g., 'BTC', 'ETH')
544
+ * @param options - Stream options
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * ws.stream('orderbook', 'ETH', {
549
+ * start: Date.now() - 3600000, // 1 hour ago
550
+ * end: Date.now(),
551
+ * batchSize: 1000
552
+ * });
553
+ * ```
554
+ */
555
+ stream(channel, coin, options) {
556
+ this.send({
557
+ op: "stream",
558
+ channel,
559
+ coin,
560
+ start: options.start,
561
+ end: options.end,
562
+ batch_size: options.batchSize ?? 1e3
563
+ });
564
+ }
565
+ /**
566
+ * Stop the current bulk stream
567
+ */
568
+ streamStop() {
569
+ this.send({ op: "stream.stop" });
570
+ }
571
+ // ==========================================================================
572
+ // Event Handlers for Replay/Stream
573
+ // ==========================================================================
574
+ /**
575
+ * Handle historical data points (replay mode)
576
+ */
577
+ onHistoricalData(handler) {
578
+ const originalHandler = this.handlers.onMessage;
579
+ this.handlers.onMessage = (message) => {
580
+ if (message.type === "historical_data") {
581
+ const msg = message;
582
+ handler(msg.coin, msg.timestamp, msg.data);
583
+ }
584
+ originalHandler?.(message);
585
+ };
586
+ }
587
+ /**
588
+ * Handle batched data (bulk stream mode)
589
+ */
590
+ onBatch(handler) {
591
+ const originalHandler = this.handlers.onMessage;
592
+ this.handlers.onMessage = (message) => {
593
+ if (message.type === "historical_batch") {
594
+ const msg = message;
595
+ handler(msg.coin, msg.records);
596
+ }
597
+ originalHandler?.(message);
598
+ };
599
+ }
600
+ /**
601
+ * Handle replay started event
602
+ */
603
+ onReplayStart(handler) {
604
+ const originalHandler = this.handlers.onMessage;
605
+ this.handlers.onMessage = (message) => {
606
+ if (message.type === "replay_started") {
607
+ const msg = message;
608
+ handler(msg.channel, msg.coin, msg.total_records, msg.speed);
609
+ }
610
+ originalHandler?.(message);
611
+ };
612
+ }
613
+ /**
614
+ * Handle replay completed event
615
+ */
616
+ onReplayComplete(handler) {
617
+ const originalHandler = this.handlers.onMessage;
618
+ this.handlers.onMessage = (message) => {
619
+ if (message.type === "replay_completed") {
620
+ const msg = message;
621
+ handler(msg.channel, msg.coin, msg.records_sent);
622
+ }
623
+ originalHandler?.(message);
624
+ };
625
+ }
626
+ /**
627
+ * Handle stream started event
628
+ */
629
+ onStreamStart(handler) {
630
+ const originalHandler = this.handlers.onMessage;
631
+ this.handlers.onMessage = (message) => {
632
+ if (message.type === "stream_started") {
633
+ const msg = message;
634
+ handler(msg.channel, msg.coin, msg.total_records);
635
+ }
636
+ originalHandler?.(message);
637
+ };
638
+ }
639
+ /**
640
+ * Handle stream progress event
641
+ */
642
+ onStreamProgress(handler) {
643
+ const originalHandler = this.handlers.onMessage;
644
+ this.handlers.onMessage = (message) => {
645
+ if (message.type === "stream_progress") {
646
+ const msg = message;
647
+ handler(msg.records_sent, msg.total_records, msg.progress_pct);
648
+ }
649
+ originalHandler?.(message);
650
+ };
651
+ }
652
+ /**
653
+ * Handle stream completed event
654
+ */
655
+ onStreamComplete(handler) {
656
+ const originalHandler = this.handlers.onMessage;
657
+ this.handlers.onMessage = (message) => {
658
+ if (message.type === "stream_completed") {
659
+ const msg = message;
660
+ handler(msg.channel, msg.coin, msg.records_sent);
661
+ }
662
+ originalHandler?.(message);
663
+ };
664
+ }
665
+ /**
666
+ * Get current connection state
667
+ */
668
+ getState() {
669
+ return this.state;
670
+ }
671
+ /**
672
+ * Check if connected
673
+ */
674
+ isConnected() {
675
+ return this.ws?.readyState === WebSocket.OPEN;
676
+ }
677
+ /**
678
+ * Set event handlers after construction
679
+ */
680
+ on(event, handler) {
681
+ this.handlers[event] = handler;
682
+ }
683
+ /**
684
+ * Helper to handle typed orderbook data
685
+ */
686
+ onOrderbook(handler) {
687
+ const originalHandler = this.handlers.onMessage;
688
+ this.handlers.onMessage = (message) => {
689
+ if (message.type === "data" && message.channel === "orderbook") {
690
+ handler(message.coin, message.data);
691
+ }
692
+ originalHandler?.(message);
693
+ };
694
+ }
695
+ /**
696
+ * Helper to handle typed trade data
697
+ */
698
+ onTrades(handler) {
699
+ const originalHandler = this.handlers.onMessage;
700
+ this.handlers.onMessage = (message) => {
701
+ if (message.type === "data" && message.channel === "trades") {
702
+ handler(message.coin, message.data);
703
+ }
704
+ originalHandler?.(message);
705
+ };
706
+ }
707
+ // Private methods
708
+ send(message) {
709
+ if (this.ws?.readyState === WebSocket.OPEN) {
710
+ this.ws.send(JSON.stringify(message));
711
+ }
712
+ }
713
+ setState(state) {
714
+ this.state = state;
715
+ this.handlers.onStateChange?.(state);
716
+ }
717
+ startPing() {
718
+ this.stopPing();
719
+ this.pingTimer = setInterval(() => {
720
+ this.send({ op: "ping" });
721
+ }, this.options.pingInterval);
722
+ }
723
+ stopPing() {
724
+ if (this.pingTimer) {
725
+ clearInterval(this.pingTimer);
726
+ this.pingTimer = null;
727
+ }
728
+ }
729
+ subscriptionKey(channel, coin) {
730
+ return coin ? `${channel}:${coin}` : channel;
731
+ }
732
+ resubscribe() {
733
+ for (const key of this.subscriptions) {
734
+ const [channel, coin] = key.split(":");
735
+ this.send({ op: "subscribe", channel, coin });
736
+ }
737
+ }
738
+ scheduleReconnect() {
739
+ if (this.reconnectAttempts >= this.options.maxReconnectAttempts) {
740
+ this.setState("disconnected");
741
+ return;
742
+ }
743
+ this.setState("reconnecting");
744
+ this.reconnectAttempts++;
745
+ const delay = this.options.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1);
746
+ this.reconnectTimer = setTimeout(() => {
747
+ this.connect();
748
+ }, delay);
749
+ }
750
+ clearReconnectTimer() {
751
+ if (this.reconnectTimer) {
752
+ clearTimeout(this.reconnectTimer);
753
+ this.reconnectTimer = null;
754
+ }
755
+ }
756
+ };
757
+ // Annotate the CommonJS export names for ESM import in node:
758
+ 0 && (module.exports = {
759
+ OxArchive,
760
+ OxArchiveError,
761
+ OxArchiveWs
762
+ });
763
+ //# sourceMappingURL=index.js.map