@replit/river 0.15.1 → 0.15.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 (35) hide show
  1. package/README.md +41 -22
  2. package/dist/{builder-660d3140.d.ts → builder-4d392f6c.d.ts} +1 -1
  3. package/dist/{chunk-O6YQ3JAH.js → chunk-5XMMDOLH.js} +148 -37
  4. package/dist/{chunk-MNWOTQWX.js → chunk-MXHIHC3U.js} +1 -1
  5. package/dist/{chunk-5TX4BKAD.js → chunk-NSJVTNVQ.js} +1 -1
  6. package/dist/{connection-162c0f7b.d.ts → connection-94896f3b.d.ts} +1 -1
  7. package/dist/{connection-93daccc3.d.ts → connection-99346822.d.ts} +1 -1
  8. package/dist/{index-76b801f8.d.ts → index-2e402bb8.d.ts} +84 -11
  9. package/dist/router/index.d.cts +3 -3
  10. package/dist/router/index.d.ts +3 -3
  11. package/dist/transport/impls/uds/client.cjs +198 -88
  12. package/dist/transport/impls/uds/client.d.cts +3 -3
  13. package/dist/transport/impls/uds/client.d.ts +3 -3
  14. package/dist/transport/impls/uds/client.js +2 -2
  15. package/dist/transport/impls/uds/server.cjs +67 -69
  16. package/dist/transport/impls/uds/server.d.cts +3 -3
  17. package/dist/transport/impls/uds/server.d.ts +3 -3
  18. package/dist/transport/impls/uds/server.js +2 -2
  19. package/dist/transport/impls/ws/client.cjs +198 -90
  20. package/dist/transport/impls/ws/client.d.cts +3 -3
  21. package/dist/transport/impls/ws/client.d.ts +3 -3
  22. package/dist/transport/impls/ws/client.js +2 -2
  23. package/dist/transport/impls/ws/server.cjs +67 -69
  24. package/dist/transport/impls/ws/server.d.cts +3 -3
  25. package/dist/transport/impls/ws/server.d.ts +3 -3
  26. package/dist/transport/impls/ws/server.js +2 -2
  27. package/dist/transport/index.cjs +198 -90
  28. package/dist/transport/index.d.cts +1 -1
  29. package/dist/transport/index.d.ts +1 -1
  30. package/dist/transport/index.js +1 -1
  31. package/dist/util/testHelpers.cjs +61 -64
  32. package/dist/util/testHelpers.d.cts +10 -4
  33. package/dist/util/testHelpers.d.ts +10 -4
  34. package/dist/util/testHelpers.js +13 -5
  35. package/package.json +1 -1
@@ -134,60 +134,6 @@ var EventDispatcher = class {
134
134
 
135
135
  // transport/session.ts
136
136
  var import_nanoid2 = require("nanoid");
137
-
138
- // codec/json.ts
139
- var encoder = new TextEncoder();
140
- var decoder = new TextDecoder();
141
- function uint8ArrayToBase64(uint8Array) {
142
- let binary = "";
143
- uint8Array.forEach((byte) => {
144
- binary += String.fromCharCode(byte);
145
- });
146
- return btoa(binary);
147
- }
148
- function base64ToUint8Array(base64) {
149
- const binaryString = atob(base64);
150
- const uint8Array = new Uint8Array(binaryString.length);
151
- for (let i = 0; i < binaryString.length; i++) {
152
- uint8Array[i] = binaryString.charCodeAt(i);
153
- }
154
- return uint8Array;
155
- }
156
- var NaiveJsonCodec = {
157
- toBuffer: (obj) => {
158
- return encoder.encode(
159
- JSON.stringify(obj, function replacer(key) {
160
- const val = this[key];
161
- if (val instanceof Uint8Array) {
162
- return { $t: uint8ArrayToBase64(val) };
163
- } else {
164
- return val;
165
- }
166
- })
167
- );
168
- },
169
- fromBuffer: (buff) => {
170
- try {
171
- const parsed = JSON.parse(
172
- decoder.decode(buff),
173
- function reviver(_key, val) {
174
- if (val?.$t) {
175
- return base64ToUint8Array(val.$t);
176
- } else {
177
- return val;
178
- }
179
- }
180
- );
181
- if (typeof parsed === "object")
182
- return parsed;
183
- return null;
184
- } catch {
185
- return null;
186
- }
187
- }
188
- };
189
-
190
- // transport/session.ts
191
137
  var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890abcdefghijklmnopqrstuvxyz", 6);
192
138
  var unsafeId = () => nanoid2();
193
139
  var Connection = class {
@@ -196,15 +142,6 @@ var Connection = class {
196
142
  this.debugId = `conn-${unsafeId()}`;
197
143
  }
198
144
  };
199
- var HEARTBEAT_INTERVAL_MS = 1e3;
200
- var HEARTBEATS_TILL_DEAD = 2;
201
- var SESSION_DISCONNECT_GRACE_MS = 5e3;
202
- var defaultSessionOptions = {
203
- heartbeatIntervalMs: HEARTBEAT_INTERVAL_MS,
204
- heartbeatsUntilDead: HEARTBEATS_TILL_DEAD,
205
- sessionDisconnectGraceMs: SESSION_DISCONNECT_GRACE_MS,
206
- codec: NaiveJsonCodec
207
- };
208
145
  var Session = class {
209
146
  codec;
210
147
  options;
@@ -399,14 +336,147 @@ function coerceErrorString(err) {
399
336
  return `[coerced to error] ${String(err)}`;
400
337
  }
401
338
 
339
+ // transport/rateLimit.ts
340
+ var LeakyBucketRateLimit = class {
341
+ budgetConsumed;
342
+ intervalHandles;
343
+ options;
344
+ constructor(options) {
345
+ this.options = options;
346
+ this.budgetConsumed = /* @__PURE__ */ new Map();
347
+ this.intervalHandles = /* @__PURE__ */ new Map();
348
+ }
349
+ getBackoffMs(user) {
350
+ if (!this.budgetConsumed.has(user))
351
+ return 0;
352
+ const exponent = Math.max(0, this.getBudgetConsumed(user) - 1);
353
+ const jitter = Math.floor(Math.random() * this.options.maxJitterMs);
354
+ const backoffMs = Math.min(
355
+ this.options.baseIntervalMs * 2 ** exponent,
356
+ this.options.maxBackoffMs
357
+ );
358
+ return backoffMs + jitter;
359
+ }
360
+ get totalBudgetRestoreTime() {
361
+ return this.options.budgetRestoreIntervalMs * this.options.attemptBudgetCapacity;
362
+ }
363
+ consumeBudget(user) {
364
+ this.stopLeak(user);
365
+ this.budgetConsumed.set(user, this.getBudgetConsumed(user) + 1);
366
+ }
367
+ getBudgetConsumed(user) {
368
+ return this.budgetConsumed.get(user) ?? 0;
369
+ }
370
+ hasBudget(user) {
371
+ return this.getBudgetConsumed(user) < this.options.attemptBudgetCapacity;
372
+ }
373
+ startRestoringBudget(user) {
374
+ if (this.intervalHandles.has(user)) {
375
+ return;
376
+ }
377
+ const restoreBudgetForUser = () => {
378
+ const currentBudget = this.budgetConsumed.get(user);
379
+ if (!currentBudget) {
380
+ this.stopLeak(user);
381
+ return;
382
+ }
383
+ const newBudget = currentBudget - 1;
384
+ if (newBudget === 0) {
385
+ this.budgetConsumed.delete(user);
386
+ return;
387
+ }
388
+ this.budgetConsumed.set(user, newBudget);
389
+ };
390
+ restoreBudgetForUser();
391
+ const intervalHandle = setInterval(
392
+ restoreBudgetForUser,
393
+ this.options.budgetRestoreIntervalMs
394
+ );
395
+ this.intervalHandles.set(user, intervalHandle);
396
+ }
397
+ stopLeak(user) {
398
+ if (!this.intervalHandles.has(user)) {
399
+ return;
400
+ }
401
+ clearInterval(this.intervalHandles.get(user));
402
+ this.intervalHandles.delete(user);
403
+ }
404
+ close() {
405
+ for (const user of this.intervalHandles.keys()) {
406
+ this.stopLeak(user);
407
+ }
408
+ }
409
+ };
410
+
411
+ // codec/json.ts
412
+ var encoder = new TextEncoder();
413
+ var decoder = new TextDecoder();
414
+ function uint8ArrayToBase64(uint8Array) {
415
+ let binary = "";
416
+ uint8Array.forEach((byte) => {
417
+ binary += String.fromCharCode(byte);
418
+ });
419
+ return btoa(binary);
420
+ }
421
+ function base64ToUint8Array(base64) {
422
+ const binaryString = atob(base64);
423
+ const uint8Array = new Uint8Array(binaryString.length);
424
+ for (let i = 0; i < binaryString.length; i++) {
425
+ uint8Array[i] = binaryString.charCodeAt(i);
426
+ }
427
+ return uint8Array;
428
+ }
429
+ var NaiveJsonCodec = {
430
+ toBuffer: (obj) => {
431
+ return encoder.encode(
432
+ JSON.stringify(obj, function replacer(key) {
433
+ const val = this[key];
434
+ if (val instanceof Uint8Array) {
435
+ return { $t: uint8ArrayToBase64(val) };
436
+ } else {
437
+ return val;
438
+ }
439
+ })
440
+ );
441
+ },
442
+ fromBuffer: (buff) => {
443
+ try {
444
+ const parsed = JSON.parse(
445
+ decoder.decode(buff),
446
+ function reviver(_key, val) {
447
+ if (val?.$t) {
448
+ return base64ToUint8Array(val.$t);
449
+ } else {
450
+ return val;
451
+ }
452
+ }
453
+ );
454
+ if (typeof parsed === "object")
455
+ return parsed;
456
+ return null;
457
+ } catch {
458
+ return null;
459
+ }
460
+ }
461
+ };
462
+
402
463
  // transport/transport.ts
403
- var RECONNECT_JITTER_MAX_MS = 500;
404
- var RECONNECT_INTERVAL_MS = 250;
405
464
  var defaultTransportOptions = {
406
- retryIntervalMs: RECONNECT_INTERVAL_MS,
407
- retryJitterMs: RECONNECT_JITTER_MAX_MS,
408
- retryAttemptsMax: 5,
409
- ...defaultSessionOptions
465
+ heartbeatIntervalMs: 1e3,
466
+ heartbeatsUntilDead: 2,
467
+ sessionDisconnectGraceMs: 5e3,
468
+ codec: NaiveJsonCodec
469
+ };
470
+ var defaultConnectionRetryOptions = {
471
+ baseIntervalMs: 250,
472
+ maxJitterMs: 200,
473
+ maxBackoffMs: 32e3,
474
+ attemptBudgetCapacity: 15,
475
+ budgetRestoreIntervalMs: 200
476
+ };
477
+ var defaultClientTransportOptions = {
478
+ connectionRetryOptions: defaultConnectionRetryOptions,
479
+ ...defaultTransportOptions
410
480
  };
411
481
  var Transport = class {
412
482
  /**
@@ -681,14 +751,26 @@ var Transport = class {
681
751
  }
682
752
  };
683
753
  var ClientTransport = class extends Transport {
754
+ /**
755
+ * The options for this transport.
756
+ */
757
+ options;
684
758
  /**
685
759
  * The map of reconnect promises for each client ID.
686
760
  */
687
761
  inflightConnectionPromises;
762
+ retryBudget;
688
763
  tryReconnecting = true;
689
764
  constructor(clientId, providedOptions) {
690
765
  super(clientId, providedOptions);
766
+ this.options = {
767
+ ...defaultClientTransportOptions,
768
+ ...providedOptions
769
+ };
691
770
  this.inflightConnectionPromises = /* @__PURE__ */ new Map();
771
+ this.retryBudget = new LeakyBucketRateLimit(
772
+ this.options.connectionRetryOptions
773
+ );
692
774
  }
693
775
  handleConnection(conn, to) {
694
776
  if (this.state !== "open")
@@ -719,7 +801,10 @@ var ClientTransport = class extends Transport {
719
801
  log?.info(
720
802
  `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
721
803
  );
722
- void this.connect(to);
804
+ this.inflightConnectionPromises.delete(to);
805
+ if (this.tryReconnecting) {
806
+ void this.connect(to);
807
+ }
723
808
  });
724
809
  conn.addErrorListener((err) => {
725
810
  log?.warn(
@@ -770,41 +855,64 @@ var ClientTransport = class extends Transport {
770
855
  * Manually attempts to connect to a client.
771
856
  * @param to The client ID of the node to connect to.
772
857
  */
773
- async connect(to, attempt = 0) {
774
- if (this.state !== "open" || !this.tryReconnecting) {
858
+ async connect(to) {
859
+ const canProceedWithConnection = () => this.state === "open";
860
+ if (!canProceedWithConnection()) {
775
861
  log?.info(
776
- `${this.clientId} -- transport state is no longer open, not attempting connection`
862
+ `${this.clientId} -- transport state is no longer open, cancelling attempt to connect to ${to}`
777
863
  );
778
864
  return;
779
865
  }
780
866
  let reconnectPromise = this.inflightConnectionPromises.get(to);
781
867
  if (!reconnectPromise) {
782
- reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
868
+ log?.info(`${this.clientId} -- attempting connection to ${to}`);
869
+ const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
870
+ if (!this.retryBudget.hasBudget(to)) {
871
+ const errMsg = `not attempting to connect to ${to}, retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
872
+ log?.warn(`${this.clientId} -- ${errMsg}`);
873
+ this.protocolError(ProtocolError.RetriesExceeded, errMsg);
874
+ return;
875
+ }
876
+ let sleep = Promise.resolve();
877
+ const backoffMs = this.retryBudget.getBackoffMs(to);
878
+ if (backoffMs > 0) {
879
+ sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
880
+ }
881
+ this.retryBudget.consumeBudget(to);
882
+ reconnectPromise = sleep.then(() => {
883
+ if (!canProceedWithConnection()) {
884
+ throw new Error("transport state is no longer open");
885
+ }
886
+ }).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
887
+ if (!canProceedWithConnection()) {
888
+ log?.info(
889
+ `${this.clientId} -- transport state is no longer open, closing pre-handshake connection (id: ${conn.debugId}) to ${to}`
890
+ );
891
+ conn.close();
892
+ throw new Error("transport state is no longer open");
893
+ }
894
+ this.retryBudget.startRestoringBudget(to);
783
895
  this.sendHandshake(to, conn);
784
896
  return conn;
785
897
  });
786
898
  this.inflightConnectionPromises.set(to, reconnectPromise);
899
+ } else {
900
+ log?.info(
901
+ `${this.clientId} -- attempting connection to ${to} (reusing previous attempt)`
902
+ );
787
903
  }
788
904
  try {
789
905
  await reconnectPromise;
790
906
  } catch (error) {
791
- const errStr = coerceErrorString(error);
792
907
  this.inflightConnectionPromises.delete(to);
793
- const shouldRetry = this.state === "open" && this.tryReconnecting;
794
- if (!shouldRetry)
795
- return;
796
- if (attempt >= this.options.retryAttemptsMax) {
797
- const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
798
- log?.error(`${this.clientId} -- ${errMsg}`);
799
- this.protocolError(ProtocolError.RetriesExceeded, errMsg);
800
- return;
908
+ const errStr = coerceErrorString(error);
909
+ if (!this.tryReconnecting || !canProceedWithConnection()) {
910
+ log?.warn(`${this.clientId} -- connection to ${to} failed (${errStr})`);
801
911
  } else {
802
- const jitter = Math.floor(Math.random() * this.options.retryJitterMs);
803
- const backoffMs = this.options.retryIntervalMs * 2 ** attempt + jitter;
804
912
  log?.warn(
805
- `${this.clientId} -- connection to ${to} failed (${errStr}), trying again in ${backoffMs}ms`
913
+ `${this.clientId} -- connection to ${to} failed (${errStr}), retrying`
806
914
  );
807
- setTimeout(() => void this.connect(to, attempt + 1), backoffMs);
915
+ return this.connect(to);
808
916
  }
809
917
  }
810
918
  }
@@ -817,9 +925,9 @@ var ClientTransport = class extends Transport {
817
925
  log?.debug(`${this.clientId} -- sending handshake request to ${to}`);
818
926
  conn.send(this.codec.toBuffer(requestMsg));
819
927
  }
820
- onDisconnect(conn, session) {
821
- this.inflightConnectionPromises.delete(session.to);
822
- super.onDisconnect(conn, session);
928
+ close() {
929
+ this.retryBudget.close();
930
+ super.close();
823
931
  }
824
932
  };
825
933
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
3
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -21,7 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
21
21
  * @param serverId The ID of the server this transport is connecting to.
22
22
  * @param providedOptions An optional object containing configuration options for the transport.
23
23
  */
24
- constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
24
+ constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
25
25
  createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
26
26
  }
27
27
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
3
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -21,7 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
21
21
  * @param serverId The ID of the server this transport is connecting to.
22
22
  * @param providedOptions An optional object containing configuration options for the transport.
23
23
  */
24
- constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
24
+ constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
25
25
  createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
26
26
  }
27
27
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-5TX4BKAD.js";
3
+ } from "../../../chunk-NSJVTNVQ.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-O6YQ3JAH.js";
6
+ } from "../../../chunk-5XMMDOLH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -142,60 +142,6 @@ var EventDispatcher = class {
142
142
 
143
143
  // transport/session.ts
144
144
  var import_nanoid2 = require("nanoid");
145
-
146
- // codec/json.ts
147
- var encoder = new TextEncoder();
148
- var decoder = new TextDecoder();
149
- function uint8ArrayToBase64(uint8Array) {
150
- let binary = "";
151
- uint8Array.forEach((byte) => {
152
- binary += String.fromCharCode(byte);
153
- });
154
- return btoa(binary);
155
- }
156
- function base64ToUint8Array(base64) {
157
- const binaryString = atob(base64);
158
- const uint8Array = new Uint8Array(binaryString.length);
159
- for (let i = 0; i < binaryString.length; i++) {
160
- uint8Array[i] = binaryString.charCodeAt(i);
161
- }
162
- return uint8Array;
163
- }
164
- var NaiveJsonCodec = {
165
- toBuffer: (obj) => {
166
- return encoder.encode(
167
- JSON.stringify(obj, function replacer(key) {
168
- const val = this[key];
169
- if (val instanceof Uint8Array) {
170
- return { $t: uint8ArrayToBase64(val) };
171
- } else {
172
- return val;
173
- }
174
- })
175
- );
176
- },
177
- fromBuffer: (buff) => {
178
- try {
179
- const parsed = JSON.parse(
180
- decoder.decode(buff),
181
- function reviver(_key, val) {
182
- if (val?.$t) {
183
- return base64ToUint8Array(val.$t);
184
- } else {
185
- return val;
186
- }
187
- }
188
- );
189
- if (typeof parsed === "object")
190
- return parsed;
191
- return null;
192
- } catch {
193
- return null;
194
- }
195
- }
196
- };
197
-
198
- // transport/session.ts
199
145
  var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890abcdefghijklmnopqrstuvxyz", 6);
200
146
  var unsafeId = () => nanoid2();
201
147
  var Connection = class {
@@ -204,15 +150,6 @@ var Connection = class {
204
150
  this.debugId = `conn-${unsafeId()}`;
205
151
  }
206
152
  };
207
- var HEARTBEAT_INTERVAL_MS = 1e3;
208
- var HEARTBEATS_TILL_DEAD = 2;
209
- var SESSION_DISCONNECT_GRACE_MS = 5e3;
210
- var defaultSessionOptions = {
211
- heartbeatIntervalMs: HEARTBEAT_INTERVAL_MS,
212
- heartbeatsUntilDead: HEARTBEATS_TILL_DEAD,
213
- sessionDisconnectGraceMs: SESSION_DISCONNECT_GRACE_MS,
214
- codec: NaiveJsonCodec
215
- };
216
153
  var Session = class {
217
154
  codec;
218
155
  options;
@@ -407,14 +344,75 @@ function coerceErrorString(err) {
407
344
  return `[coerced to error] ${String(err)}`;
408
345
  }
409
346
 
347
+ // codec/json.ts
348
+ var encoder = new TextEncoder();
349
+ var decoder = new TextDecoder();
350
+ function uint8ArrayToBase64(uint8Array) {
351
+ let binary = "";
352
+ uint8Array.forEach((byte) => {
353
+ binary += String.fromCharCode(byte);
354
+ });
355
+ return btoa(binary);
356
+ }
357
+ function base64ToUint8Array(base64) {
358
+ const binaryString = atob(base64);
359
+ const uint8Array = new Uint8Array(binaryString.length);
360
+ for (let i = 0; i < binaryString.length; i++) {
361
+ uint8Array[i] = binaryString.charCodeAt(i);
362
+ }
363
+ return uint8Array;
364
+ }
365
+ var NaiveJsonCodec = {
366
+ toBuffer: (obj) => {
367
+ return encoder.encode(
368
+ JSON.stringify(obj, function replacer(key) {
369
+ const val = this[key];
370
+ if (val instanceof Uint8Array) {
371
+ return { $t: uint8ArrayToBase64(val) };
372
+ } else {
373
+ return val;
374
+ }
375
+ })
376
+ );
377
+ },
378
+ fromBuffer: (buff) => {
379
+ try {
380
+ const parsed = JSON.parse(
381
+ decoder.decode(buff),
382
+ function reviver(_key, val) {
383
+ if (val?.$t) {
384
+ return base64ToUint8Array(val.$t);
385
+ } else {
386
+ return val;
387
+ }
388
+ }
389
+ );
390
+ if (typeof parsed === "object")
391
+ return parsed;
392
+ return null;
393
+ } catch {
394
+ return null;
395
+ }
396
+ }
397
+ };
398
+
410
399
  // transport/transport.ts
411
- var RECONNECT_JITTER_MAX_MS = 500;
412
- var RECONNECT_INTERVAL_MS = 250;
413
400
  var defaultTransportOptions = {
414
- retryIntervalMs: RECONNECT_INTERVAL_MS,
415
- retryJitterMs: RECONNECT_JITTER_MAX_MS,
416
- retryAttemptsMax: 5,
417
- ...defaultSessionOptions
401
+ heartbeatIntervalMs: 1e3,
402
+ heartbeatsUntilDead: 2,
403
+ sessionDisconnectGraceMs: 5e3,
404
+ codec: NaiveJsonCodec
405
+ };
406
+ var defaultConnectionRetryOptions = {
407
+ baseIntervalMs: 250,
408
+ maxJitterMs: 200,
409
+ maxBackoffMs: 32e3,
410
+ attemptBudgetCapacity: 15,
411
+ budgetRestoreIntervalMs: 200
412
+ };
413
+ var defaultClientTransportOptions = {
414
+ connectionRetryOptions: defaultConnectionRetryOptions,
415
+ ...defaultTransportOptions
418
416
  };
419
417
  var Transport = class {
420
418
  /**
@@ -1,13 +1,13 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
4
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
8
8
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
9
9
  wss: WebSocketServer;
10
- constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
11
11
  connectionHandler: (ws: WebSocket) => void;
12
12
  close(): void;
13
13
  }
@@ -1,13 +1,13 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
4
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
8
8
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
9
9
  wss: WebSocketServer;
10
- constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
11
11
  connectionHandler: (ws: WebSocket) => void;
12
12
  close(): void;
13
13
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-5TX4BKAD.js";
3
+ } from "../../../chunk-NSJVTNVQ.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-O6YQ3JAH.js";
6
+ } from "../../../chunk-5XMMDOLH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import "../../../chunk-H4BYJELI.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";