@replit/river 0.209.1 → 0.209.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 (44) hide show
  1. package/dist/{chunk-UC4MQ5FP.js → chunk-DVAIJ57I.js} +10 -10
  2. package/dist/{chunk-2AV3IIW5.js → chunk-L3KNTJU3.js} +316 -303
  3. package/dist/chunk-L3KNTJU3.js.map +1 -0
  4. package/dist/{chunk-2DRHPFKM.js → chunk-OTL2R22H.js} +2 -2
  5. package/dist/{client-CRY4aeRv.d.cts → client-BX3IXUA2.d.cts} +1 -1
  6. package/dist/{client-Cvl0bF5y.d.ts → client-CBak1h8Q.d.ts} +1 -1
  7. package/dist/codec/index.js +2 -2
  8. package/dist/{connection-BVE0wfE7.d.cts → connection-_eetKnva.d.cts} +1 -1
  9. package/dist/{connection-BphUYGjL.d.ts → connection-zMlysQKs.d.ts} +1 -1
  10. package/dist/{common-MmS1PQN7.d.cts → handshake-B3iu79B0.d.cts} +131 -131
  11. package/dist/{common-yodP-WNy.d.ts → handshake-DNinPBA3.d.ts} +131 -131
  12. package/dist/router/index.cjs +300 -285
  13. package/dist/router/index.cjs.map +1 -1
  14. package/dist/router/index.d.cts +7 -7
  15. package/dist/router/index.d.ts +7 -7
  16. package/dist/router/index.js +5 -1
  17. package/dist/{server-BKZTIlAc.d.cts → server-BV7GXuhz.d.cts} +1 -1
  18. package/dist/{server-hDGOXIRA.d.ts → server-B_H1zn-R.d.ts} +1 -1
  19. package/dist/{services-9I3wdkpy.d.cts → services-BIMmk-v4.d.cts} +96 -3
  20. package/dist/{services-BFGny14R.d.ts → services-DtsSIaec.d.ts} +96 -3
  21. package/dist/testUtil/index.cjs +1 -1
  22. package/dist/testUtil/index.cjs.map +1 -1
  23. package/dist/testUtil/index.d.cts +4 -4
  24. package/dist/testUtil/index.d.ts +4 -4
  25. package/dist/testUtil/index.js +3 -3
  26. package/dist/transport/impls/ws/client.cjs +1 -1
  27. package/dist/transport/impls/ws/client.cjs.map +1 -1
  28. package/dist/transport/impls/ws/client.d.cts +3 -3
  29. package/dist/transport/impls/ws/client.d.ts +3 -3
  30. package/dist/transport/impls/ws/client.js +3 -3
  31. package/dist/transport/impls/ws/server.cjs +1 -1
  32. package/dist/transport/impls/ws/server.cjs.map +1 -1
  33. package/dist/transport/impls/ws/server.d.cts +3 -3
  34. package/dist/transport/impls/ws/server.d.ts +3 -3
  35. package/dist/transport/impls/ws/server.js +3 -3
  36. package/dist/transport/index.cjs +1 -1
  37. package/dist/transport/index.cjs.map +1 -1
  38. package/dist/transport/index.d.cts +3 -3
  39. package/dist/transport/index.d.ts +3 -3
  40. package/dist/transport/index.js +3 -3
  41. package/package.json +1 -1
  42. package/dist/chunk-2AV3IIW5.js.map +0 -1
  43. /package/dist/{chunk-UC4MQ5FP.js.map → chunk-DVAIJ57I.js.map} +0 -0
  44. /package/dist/{chunk-2DRHPFKM.js.map → chunk-OTL2R22H.js.map} +0 -0
@@ -26,6 +26,8 @@ __export(router_exports, {
26
26
  Ok: () => Ok,
27
27
  Procedure: () => Procedure,
28
28
  RIVER_VERSION: () => version,
29
+ RawReadable: () => ReadableImpl,
30
+ ReadableBrokenError: () => ReadableBrokenError,
29
31
  ReaderErrorSchema: () => ReaderErrorSchema,
30
32
  UNCAUGHT_ERROR_CODE: () => UNCAUGHT_ERROR_CODE,
31
33
  UNEXPECTED_DISCONNECT_CODE: () => UNEXPECTED_DISCONNECT_CODE,
@@ -393,12 +395,254 @@ var ServiceScaffold = class {
393
395
  }
394
396
  };
395
397
 
396
- // router/procedures.ts
398
+ // router/result.ts
397
399
  var import_typebox3 = require("@sinclair/typebox");
400
+ var AnyResultSchema = import_typebox3.Type.Union([
401
+ import_typebox3.Type.Object({
402
+ ok: import_typebox3.Type.Literal(false),
403
+ payload: import_typebox3.Type.Object({
404
+ code: import_typebox3.Type.String(),
405
+ message: import_typebox3.Type.String(),
406
+ extras: import_typebox3.Type.Optional(import_typebox3.Type.Unknown())
407
+ })
408
+ }),
409
+ import_typebox3.Type.Object({
410
+ ok: import_typebox3.Type.Literal(true),
411
+ payload: import_typebox3.Type.Unknown()
412
+ })
413
+ ]);
414
+ function Ok(payload) {
415
+ return {
416
+ ok: true,
417
+ payload
418
+ };
419
+ }
420
+ function Err(error) {
421
+ return {
422
+ ok: false,
423
+ payload: error
424
+ };
425
+ }
426
+
427
+ // router/streams.ts
428
+ var ReadableBrokenError = {
429
+ code: "READABLE_BROKEN",
430
+ message: "Readable was broken before it is fully consumed"
431
+ };
432
+ function createPromiseWithResolvers() {
433
+ let resolve;
434
+ let reject;
435
+ const promise = new Promise((res, rej) => {
436
+ resolve = res;
437
+ reject = rej;
438
+ });
439
+ return {
440
+ promise,
441
+ // @ts-expect-error promise callbacks are sync
442
+ resolve,
443
+ // @ts-expect-error promise callbacks are sync
444
+ reject
445
+ };
446
+ }
447
+ var ReadableImpl = class {
448
+ /**
449
+ * Whether the {@link Readable} is closed.
450
+ *
451
+ * Closed {@link Readable}s are done receiving values, but that doesn't affect
452
+ * any other aspect of the {@link Readable} such as it's consumability.
453
+ */
454
+ closed = false;
455
+ /**
456
+ * Whether the {@link Readable} is locked.
457
+ *
458
+ * @see {@link Readable}'s typedoc to understand locking
459
+ */
460
+ locked = false;
461
+ /**
462
+ * Whether {@link break} was called.
463
+ *
464
+ * @see {@link break} for more information
465
+ */
466
+ broken = false;
467
+ /**
468
+ * This flag allows us to avoid emitting a {@link ReadableBrokenError} after {@link break} was called
469
+ * in cases where the {@link queue} is fully consumed and {@link ReadableImpl} is {@link closed}. This is just an
470
+ * ergonomic feature to avoid emitting an error in our iteration when we don't have to.
471
+ */
472
+ brokenWithValuesLeftToRead = false;
473
+ /**
474
+ * A list of values that have been pushed to the {@link ReadableImpl} but not yet emitted to the user.
475
+ */
476
+ queue = [];
477
+ /**
478
+ * Used by methods in the class to signal to the iterator that it
479
+ * should check for the next value.
480
+ */
481
+ next = null;
482
+ [Symbol.asyncIterator]() {
483
+ if (this.locked) {
484
+ throw new TypeError("Readable is already locked");
485
+ }
486
+ this.locked = true;
487
+ let didSignalBreak = false;
488
+ return {
489
+ next: async () => {
490
+ if (didSignalBreak) {
491
+ return {
492
+ done: true,
493
+ value: void 0
494
+ };
495
+ }
496
+ while (this.queue.length === 0) {
497
+ if (this.closed && !this.brokenWithValuesLeftToRead) {
498
+ return {
499
+ done: true,
500
+ value: void 0
501
+ };
502
+ }
503
+ if (this.broken) {
504
+ didSignalBreak = true;
505
+ return {
506
+ done: false,
507
+ value: Err(ReadableBrokenError)
508
+ };
509
+ }
510
+ if (!this.next) {
511
+ this.next = createPromiseWithResolvers();
512
+ }
513
+ await this.next.promise;
514
+ this.next = null;
515
+ }
516
+ const value = this.queue.shift();
517
+ return { done: false, value };
518
+ },
519
+ return: () => {
520
+ this.break();
521
+ return { done: true, value: void 0 };
522
+ }
523
+ };
524
+ }
525
+ /**
526
+ * Collects all the values from the {@link Readable} into an array.
527
+ *
528
+ * @see {@link Readable}'s typedoc for more information
529
+ */
530
+ async collect() {
531
+ const array = [];
532
+ for await (const value of this) {
533
+ array.push(value);
534
+ }
535
+ return array;
536
+ }
537
+ /**
538
+ * Breaks the {@link Readable} and signals an error to any iterators waiting for the next value.
539
+ *
540
+ * @see {@link Readable}'s typedoc for more information
541
+ */
542
+ break() {
543
+ if (this.broken) {
544
+ return;
545
+ }
546
+ this.locked = true;
547
+ this.broken = true;
548
+ this.brokenWithValuesLeftToRead = this.queue.length > 0;
549
+ this.queue.length = 0;
550
+ this.next?.resolve();
551
+ }
552
+ /**
553
+ * Whether the {@link Readable} is readable.
554
+ *
555
+ * @see {@link Readable}'s typedoc for more information
556
+ */
557
+ isReadable() {
558
+ return !this.locked && !this.broken;
559
+ }
560
+ /**
561
+ * Pushes a value to be read.
562
+ */
563
+ _pushValue(value) {
564
+ if (this.broken) {
565
+ return;
566
+ }
567
+ if (this.closed) {
568
+ throw new Error("Cannot push to closed Readable");
569
+ }
570
+ this.queue.push(value);
571
+ this.next?.resolve();
572
+ }
573
+ /**
574
+ * Triggers the close of the {@link Readable}. Make sure to push all remaining
575
+ * values before calling this method.
576
+ */
577
+ _triggerClose() {
578
+ if (this.closed) {
579
+ throw new Error("Unexpected closing multiple times");
580
+ }
581
+ this.closed = true;
582
+ this.next?.resolve();
583
+ }
584
+ /**
585
+ * @internal meant for use within river, not exposed as a public API
586
+ */
587
+ _hasValuesInQueue() {
588
+ return this.queue.length > 0;
589
+ }
590
+ /**
591
+ * Whether the {@link Readable} is closed.
592
+ */
593
+ isClosed() {
594
+ return this.closed;
595
+ }
596
+ };
597
+ var WritableImpl = class {
598
+ /**
599
+ * Passed via constructor to pass on calls to {@link write}
600
+ */
601
+ writeCb;
602
+ /**
603
+ * Passed via constructor to pass on calls to {@link close}
604
+ */
605
+ closeCb;
606
+ /**
607
+ * Whether {@link close} was called, and {@link Writable} is not writable anymore.
608
+ */
609
+ closed = false;
610
+ constructor(callbacks) {
611
+ this.writeCb = callbacks.writeCb;
612
+ this.closeCb = callbacks.closeCb;
613
+ }
614
+ write(value) {
615
+ if (this.closed) {
616
+ throw new Error("Cannot write to closed Writable");
617
+ }
618
+ this.writeCb(value);
619
+ }
620
+ isWritable() {
621
+ return !this.closed;
622
+ }
623
+ close() {
624
+ if (this.closed) {
625
+ return;
626
+ }
627
+ this.closed = true;
628
+ this.writeCb = () => void 0;
629
+ this.closeCb();
630
+ this.closeCb = () => void 0;
631
+ }
632
+ /**
633
+ * @internal meant for use within river, not exposed as a public API
634
+ */
635
+ isClosed() {
636
+ return this.closed;
637
+ }
638
+ };
639
+
640
+ // router/procedures.ts
641
+ var import_typebox4 = require("@sinclair/typebox");
398
642
  function rpc({
399
643
  requestInit,
400
644
  responseData,
401
- responseError = import_typebox3.Type.Never(),
645
+ responseError = import_typebox4.Type.Never(),
402
646
  description,
403
647
  handler
404
648
  }) {
@@ -415,7 +659,7 @@ function upload({
415
659
  requestInit,
416
660
  requestData,
417
661
  responseData,
418
- responseError = import_typebox3.Type.Never(),
662
+ responseError = import_typebox4.Type.Never(),
419
663
  description,
420
664
  handler
421
665
  }) {
@@ -432,7 +676,7 @@ function upload({
432
676
  function subscription({
433
677
  requestInit,
434
678
  responseData,
435
- responseError = import_typebox3.Type.Never(),
679
+ responseError = import_typebox4.Type.Never(),
436
680
  description,
437
681
  handler
438
682
  }) {
@@ -449,7 +693,7 @@ function stream({
449
693
  requestInit,
450
694
  requestData,
451
695
  responseData,
452
- responseError = import_typebox3.Type.Never(),
696
+ responseError = import_typebox4.Type.Never(),
453
697
  description,
454
698
  handler
455
699
  }) {
@@ -471,7 +715,7 @@ var Procedure = {
471
715
  };
472
716
 
473
717
  // transport/message.ts
474
- var import_typebox4 = require("@sinclair/typebox");
718
+ var import_typebox5 = require("@sinclair/typebox");
475
719
 
476
720
  // transport/id.ts
477
721
  var import_nanoid = require("nanoid");
@@ -481,90 +725,90 @@ var alphabet = (0, import_nanoid.customAlphabet)(
481
725
  var generateId = () => alphabet(12);
482
726
 
483
727
  // transport/message.ts
484
- var TransportMessageSchema = (t) => import_typebox4.Type.Object({
485
- id: import_typebox4.Type.String(),
486
- from: import_typebox4.Type.String(),
487
- to: import_typebox4.Type.String(),
488
- seq: import_typebox4.Type.Integer(),
489
- ack: import_typebox4.Type.Integer(),
490
- serviceName: import_typebox4.Type.Optional(import_typebox4.Type.String()),
491
- procedureName: import_typebox4.Type.Optional(import_typebox4.Type.String()),
492
- streamId: import_typebox4.Type.String(),
493
- controlFlags: import_typebox4.Type.Integer(),
494
- tracing: import_typebox4.Type.Optional(
495
- import_typebox4.Type.Object({
496
- traceparent: import_typebox4.Type.String(),
497
- tracestate: import_typebox4.Type.String()
728
+ var TransportMessageSchema = (t) => import_typebox5.Type.Object({
729
+ id: import_typebox5.Type.String(),
730
+ from: import_typebox5.Type.String(),
731
+ to: import_typebox5.Type.String(),
732
+ seq: import_typebox5.Type.Integer(),
733
+ ack: import_typebox5.Type.Integer(),
734
+ serviceName: import_typebox5.Type.Optional(import_typebox5.Type.String()),
735
+ procedureName: import_typebox5.Type.Optional(import_typebox5.Type.String()),
736
+ streamId: import_typebox5.Type.String(),
737
+ controlFlags: import_typebox5.Type.Integer(),
738
+ tracing: import_typebox5.Type.Optional(
739
+ import_typebox5.Type.Object({
740
+ traceparent: import_typebox5.Type.String(),
741
+ tracestate: import_typebox5.Type.String()
498
742
  })
499
743
  ),
500
744
  payload: t
501
745
  });
502
- var ControlMessageAckSchema = import_typebox4.Type.Object({
503
- type: import_typebox4.Type.Literal("ACK")
746
+ var ControlMessageAckSchema = import_typebox5.Type.Object({
747
+ type: import_typebox5.Type.Literal("ACK")
504
748
  });
505
- var ControlMessageCloseSchema = import_typebox4.Type.Object({
506
- type: import_typebox4.Type.Literal("CLOSE")
749
+ var ControlMessageCloseSchema = import_typebox5.Type.Object({
750
+ type: import_typebox5.Type.Literal("CLOSE")
507
751
  });
508
- var ControlMessageHandshakeRequestSchema = import_typebox4.Type.Object({
509
- type: import_typebox4.Type.Literal("HANDSHAKE_REQ"),
510
- protocolVersion: import_typebox4.Type.String(),
511
- sessionId: import_typebox4.Type.String(),
752
+ var ControlMessageHandshakeRequestSchema = import_typebox5.Type.Object({
753
+ type: import_typebox5.Type.Literal("HANDSHAKE_REQ"),
754
+ protocolVersion: import_typebox5.Type.String(),
755
+ sessionId: import_typebox5.Type.String(),
512
756
  /**
513
757
  * Specifies what the server's expected session state (from the pov of the client). This can be
514
758
  * used by the server to know whether this is a new or a reestablished connection, and whether it
515
759
  * is compatible with what it already has.
516
760
  */
517
- expectedSessionState: import_typebox4.Type.Object({
761
+ expectedSessionState: import_typebox5.Type.Object({
518
762
  // what the client expects the server to send next
519
- nextExpectedSeq: import_typebox4.Type.Integer(),
520
- nextSentSeq: import_typebox4.Type.Integer()
763
+ nextExpectedSeq: import_typebox5.Type.Integer(),
764
+ nextSentSeq: import_typebox5.Type.Integer()
521
765
  }),
522
- metadata: import_typebox4.Type.Optional(import_typebox4.Type.Unknown())
766
+ metadata: import_typebox5.Type.Optional(import_typebox5.Type.Unknown())
523
767
  });
524
- var HandshakeErrorRetriableResponseCodes = import_typebox4.Type.Union([
525
- import_typebox4.Type.Literal("SESSION_STATE_MISMATCH")
768
+ var HandshakeErrorRetriableResponseCodes = import_typebox5.Type.Union([
769
+ import_typebox5.Type.Literal("SESSION_STATE_MISMATCH")
526
770
  ]);
527
- var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox4.Type.Union([
771
+ var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox5.Type.Union([
528
772
  // The custom validation handler rejected the handler because the client is unsupported.
529
- import_typebox4.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
773
+ import_typebox5.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
530
774
  // The custom validation handler rejected the handshake.
531
- import_typebox4.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
775
+ import_typebox5.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
532
776
  ]);
533
- var HandshakeErrorFatalResponseCodes = import_typebox4.Type.Union([
777
+ var HandshakeErrorFatalResponseCodes = import_typebox5.Type.Union([
534
778
  HandshakeErrorCustomHandlerFatalResponseCodes,
535
779
  // The ciient sent a handshake that doesn't comply with the extended handshake metadata.
536
- import_typebox4.Type.Literal("MALFORMED_HANDSHAKE_META"),
780
+ import_typebox5.Type.Literal("MALFORMED_HANDSHAKE_META"),
537
781
  // The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
538
- import_typebox4.Type.Literal("MALFORMED_HANDSHAKE"),
782
+ import_typebox5.Type.Literal("MALFORMED_HANDSHAKE"),
539
783
  // The client's protocol version does not match the server's.
540
- import_typebox4.Type.Literal("PROTOCOL_VERSION_MISMATCH")
784
+ import_typebox5.Type.Literal("PROTOCOL_VERSION_MISMATCH")
541
785
  ]);
542
- var HandshakeErrorResponseCodes = import_typebox4.Type.Union([
786
+ var HandshakeErrorResponseCodes = import_typebox5.Type.Union([
543
787
  HandshakeErrorRetriableResponseCodes,
544
788
  HandshakeErrorFatalResponseCodes
545
789
  ]);
546
- var ControlMessageHandshakeResponseSchema = import_typebox4.Type.Object({
547
- type: import_typebox4.Type.Literal("HANDSHAKE_RESP"),
548
- status: import_typebox4.Type.Union([
549
- import_typebox4.Type.Object({
550
- ok: import_typebox4.Type.Literal(true),
551
- sessionId: import_typebox4.Type.String()
790
+ var ControlMessageHandshakeResponseSchema = import_typebox5.Type.Object({
791
+ type: import_typebox5.Type.Literal("HANDSHAKE_RESP"),
792
+ status: import_typebox5.Type.Union([
793
+ import_typebox5.Type.Object({
794
+ ok: import_typebox5.Type.Literal(true),
795
+ sessionId: import_typebox5.Type.String()
552
796
  }),
553
- import_typebox4.Type.Object({
554
- ok: import_typebox4.Type.Literal(false),
555
- reason: import_typebox4.Type.String(),
797
+ import_typebox5.Type.Object({
798
+ ok: import_typebox5.Type.Literal(false),
799
+ reason: import_typebox5.Type.String(),
556
800
  code: HandshakeErrorResponseCodes
557
801
  })
558
802
  ])
559
803
  });
560
- var ControlMessagePayloadSchema = import_typebox4.Type.Union([
804
+ var ControlMessagePayloadSchema = import_typebox5.Type.Union([
561
805
  ControlMessageCloseSchema,
562
806
  ControlMessageAckSchema,
563
807
  ControlMessageHandshakeRequestSchema,
564
808
  ControlMessageHandshakeResponseSchema
565
809
  ]);
566
810
  var OpaqueTransportMessageSchema = TransportMessageSchema(
567
- import_typebox4.Type.Unknown()
811
+ import_typebox5.Type.Unknown()
568
812
  );
569
813
  function closeStreamMessage(streamId) {
570
814
  return {
@@ -601,35 +845,6 @@ function isStreamCancel(controlFlag) {
601
845
  );
602
846
  }
603
847
 
604
- // router/result.ts
605
- var import_typebox5 = require("@sinclair/typebox");
606
- var AnyResultSchema = import_typebox5.Type.Union([
607
- import_typebox5.Type.Object({
608
- ok: import_typebox5.Type.Literal(false),
609
- payload: import_typebox5.Type.Object({
610
- code: import_typebox5.Type.String(),
611
- message: import_typebox5.Type.String(),
612
- extras: import_typebox5.Type.Optional(import_typebox5.Type.Unknown())
613
- })
614
- }),
615
- import_typebox5.Type.Object({
616
- ok: import_typebox5.Type.Literal(true),
617
- payload: import_typebox5.Type.Unknown()
618
- })
619
- ]);
620
- function Ok(payload) {
621
- return {
622
- ok: true,
623
- payload
624
- };
625
- }
626
- function Err(error) {
627
- return {
628
- ok: false,
629
- payload: error
630
- };
631
- }
632
-
633
848
  // tracing/index.ts
634
849
  var import_api = require("@opentelemetry/api");
635
850
  function getPropagationContext(ctx) {
@@ -706,208 +921,6 @@ function recordRiverError(span, error) {
706
921
  });
707
922
  }
708
923
 
709
- // router/streams.ts
710
- var ReadableBrokenError = {
711
- code: "READABLE_BROKEN",
712
- message: "Readable was broken before it is fully consumed"
713
- };
714
- function createPromiseWithResolvers() {
715
- let resolve;
716
- let reject;
717
- const promise = new Promise((res, rej) => {
718
- resolve = res;
719
- reject = rej;
720
- });
721
- return {
722
- promise,
723
- // @ts-expect-error promise callbacks are sync
724
- resolve,
725
- // @ts-expect-error promise callbacks are sync
726
- reject
727
- };
728
- }
729
- var ReadableImpl = class {
730
- /**
731
- * Whether the {@link Readable} is closed.
732
- *
733
- * Closed {@link Readable}s are done receiving values, but that doesn't affect
734
- * any other aspect of the {@link Readable} such as it's consumability.
735
- */
736
- closed = false;
737
- /**
738
- * Whether the {@link Readable} is locked.
739
- *
740
- * @see {@link Readable}'s typedoc to understand locking
741
- */
742
- locked = false;
743
- /**
744
- * Whether {@link break} was called.
745
- *
746
- * @see {@link break} for more information
747
- */
748
- broken = false;
749
- /**
750
- * This flag allows us to avoid emitting a {@link ReadableBrokenError} after {@link break} was called
751
- * in cases where the {@link queue} is fully consumed and {@link ReadableImpl} is {@link closed}. This is just an
752
- * ergonomic feature to avoid emitting an error in our iteration when we don't have to.
753
- */
754
- brokenWithValuesLeftToRead = false;
755
- /**
756
- * A list of values that have been pushed to the {@link ReadableImpl} but not yet emitted to the user.
757
- */
758
- queue = [];
759
- /**
760
- * Used by methods in the class to signal to the iterator that it
761
- * should check for the next value.
762
- */
763
- next = null;
764
- [Symbol.asyncIterator]() {
765
- if (this.locked) {
766
- throw new TypeError("Readable is already locked");
767
- }
768
- this.locked = true;
769
- let didSignalBreak = false;
770
- return {
771
- next: async () => {
772
- if (didSignalBreak) {
773
- return {
774
- done: true,
775
- value: void 0
776
- };
777
- }
778
- while (this.queue.length === 0) {
779
- if (this.closed && !this.brokenWithValuesLeftToRead) {
780
- return {
781
- done: true,
782
- value: void 0
783
- };
784
- }
785
- if (this.broken) {
786
- didSignalBreak = true;
787
- return {
788
- done: false,
789
- value: Err(ReadableBrokenError)
790
- };
791
- }
792
- if (!this.next) {
793
- this.next = createPromiseWithResolvers();
794
- }
795
- await this.next.promise;
796
- this.next = null;
797
- }
798
- const value = this.queue.shift();
799
- return { done: false, value };
800
- },
801
- return: () => {
802
- this.break();
803
- return { done: true, value: void 0 };
804
- }
805
- };
806
- }
807
- async collect() {
808
- const array = [];
809
- for await (const value of this) {
810
- array.push(value);
811
- }
812
- return array;
813
- }
814
- break() {
815
- if (this.broken) {
816
- return;
817
- }
818
- this.locked = true;
819
- this.broken = true;
820
- this.brokenWithValuesLeftToRead = this.queue.length > 0;
821
- this.queue.length = 0;
822
- this.next?.resolve();
823
- }
824
- isReadable() {
825
- return !this.locked && !this.broken;
826
- }
827
- /**
828
- * @internal meant for use within river, not exposed as a public API
829
- *
830
- * Pushes a value to be read.
831
- */
832
- _pushValue(value) {
833
- if (this.broken) {
834
- return;
835
- }
836
- if (this.closed) {
837
- throw new Error("Cannot push to closed Readable");
838
- }
839
- this.queue.push(value);
840
- this.next?.resolve();
841
- }
842
- /**
843
- * @internal meant for use within river, not exposed as a public API
844
- *
845
- * Triggers the close of the {@link Readable}. Make sure to push all remaining
846
- * values before calling this method.
847
- */
848
- _triggerClose() {
849
- if (this.closed) {
850
- throw new Error("Unexpected closing multiple times");
851
- }
852
- this.closed = true;
853
- this.next?.resolve();
854
- }
855
- /**
856
- * @internal meant for use within river, not exposed as a public API
857
- */
858
- _hasValuesInQueue() {
859
- return this.queue.length > 0;
860
- }
861
- /**
862
- * @internal meant for use within river, not exposed as a public API
863
- */
864
- isClosed() {
865
- return this.closed;
866
- }
867
- };
868
- var WritableImpl = class {
869
- /**
870
- * Passed via constructor to pass on calls to {@link write}
871
- */
872
- writeCb;
873
- /**
874
- * Passed via constructor to pass on calls to {@link close}
875
- */
876
- closeCb;
877
- /**
878
- * Whether {@link close} was called, and {@link Writable} is not writable anymore.
879
- */
880
- closed = false;
881
- constructor(callbacks) {
882
- this.writeCb = callbacks.writeCb;
883
- this.closeCb = callbacks.closeCb;
884
- }
885
- write(value) {
886
- if (this.closed) {
887
- throw new Error("Cannot write to closed Writable");
888
- }
889
- this.writeCb(value);
890
- }
891
- isWritable() {
892
- return !this.closed;
893
- }
894
- close() {
895
- if (this.closed) {
896
- return;
897
- }
898
- this.closed = true;
899
- this.writeCb = () => void 0;
900
- this.closeCb();
901
- this.closeCb = () => void 0;
902
- }
903
- /**
904
- * @internal meant for use within river, not exposed as a public API
905
- */
906
- isClosed() {
907
- return this.closed;
908
- }
909
- };
910
-
911
924
  // router/client.ts
912
925
  var import_value = require("@sinclair/typebox/value");
913
926
  var noop = () => {
@@ -1924,7 +1937,7 @@ function createServerHandshakeOptions(schema, validate) {
1924
1937
  }
1925
1938
 
1926
1939
  // package.json
1927
- var version = "0.209.1";
1940
+ var version = "0.209.2";
1928
1941
  // Annotate the CommonJS export names for ESM import in node:
1929
1942
  0 && (module.exports = {
1930
1943
  CANCEL_CODE,
@@ -1933,6 +1946,8 @@ var version = "0.209.1";
1933
1946
  Ok,
1934
1947
  Procedure,
1935
1948
  RIVER_VERSION,
1949
+ RawReadable,
1950
+ ReadableBrokenError,
1936
1951
  ReaderErrorSchema,
1937
1952
  UNCAUGHT_ERROR_CODE,
1938
1953
  UNEXPECTED_DISCONNECT_CODE,