@replit/river 0.209.1 → 0.209.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 (44) hide show
  1. package/dist/{chunk-2AV3IIW5.js → chunk-EHTVQM2C.js} +304 -287
  2. package/dist/chunk-EHTVQM2C.js.map +1 -0
  3. package/dist/{chunk-UC4MQ5FP.js → chunk-I24PIZXW.js} +2 -2
  4. package/dist/{chunk-2DRHPFKM.js → chunk-JRBDMLR3.js} +2 -2
  5. package/dist/{client-Cvl0bF5y.d.ts → client-BzJwq-hg.d.ts} +1 -1
  6. package/dist/{client-CRY4aeRv.d.cts → client-aETS93z1.d.cts} +1 -1
  7. package/dist/codec/index.js +2 -2
  8. package/dist/{connection-BphUYGjL.d.ts → connection-b1wd5XrC.d.ts} +1 -1
  9. package/dist/{connection-BVE0wfE7.d.cts → connection-hUWlS-hg.d.cts} +1 -1
  10. package/dist/router/index.cjs +304 -285
  11. package/dist/router/index.cjs.map +1 -1
  12. package/dist/router/index.d.cts +7 -7
  13. package/dist/router/index.d.ts +7 -7
  14. package/dist/router/index.js +5 -1
  15. package/dist/{server-BKZTIlAc.d.cts → server-BBgDVOzk.d.cts} +1 -1
  16. package/dist/{server-hDGOXIRA.d.ts → server-DZ0Yzmpf.d.ts} +1 -1
  17. package/dist/{services-9I3wdkpy.d.cts → services-C53K219K.d.cts} +91 -6
  18. package/dist/{services-BFGny14R.d.ts → services-DYik59tk.d.ts} +91 -6
  19. package/dist/testUtil/index.cjs +1 -1
  20. package/dist/testUtil/index.cjs.map +1 -1
  21. package/dist/testUtil/index.d.cts +4 -4
  22. package/dist/testUtil/index.d.ts +4 -4
  23. package/dist/testUtil/index.js +2 -2
  24. package/dist/transport/impls/ws/client.cjs +1 -1
  25. package/dist/transport/impls/ws/client.cjs.map +1 -1
  26. package/dist/transport/impls/ws/client.d.cts +3 -3
  27. package/dist/transport/impls/ws/client.d.ts +3 -3
  28. package/dist/transport/impls/ws/client.js +3 -3
  29. package/dist/transport/impls/ws/server.cjs +1 -1
  30. package/dist/transport/impls/ws/server.cjs.map +1 -1
  31. package/dist/transport/impls/ws/server.d.cts +3 -3
  32. package/dist/transport/impls/ws/server.d.ts +3 -3
  33. package/dist/transport/impls/ws/server.js +3 -3
  34. package/dist/transport/index.cjs +1 -1
  35. package/dist/transport/index.cjs.map +1 -1
  36. package/dist/transport/index.d.cts +4 -4
  37. package/dist/transport/index.d.ts +4 -4
  38. package/dist/transport/index.js +2 -2
  39. package/dist/{common-MmS1PQN7.d.cts → transport-CxjUaGhi.d.cts} +232 -232
  40. package/dist/{common-yodP-WNy.d.ts → transport-DwEB67zY.d.ts} +232 -232
  41. package/package.json +1 -1
  42. package/dist/chunk-2AV3IIW5.js.map +0 -1
  43. /package/dist/{chunk-UC4MQ5FP.js.map → chunk-I24PIZXW.js.map} +0 -0
  44. /package/dist/{chunk-2DRHPFKM.js.map → chunk-JRBDMLR3.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,258 @@ 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
+ /**
483
+ * Consumes the {@link Readable} and returns an {@link AsyncIterator} that can be used
484
+ * to iterate over the values in the {@link Readable}.
485
+ */
486
+ [Symbol.asyncIterator]() {
487
+ if (this.locked) {
488
+ throw new TypeError("Readable is already locked");
489
+ }
490
+ this.locked = true;
491
+ let didSignalBreak = false;
492
+ return {
493
+ next: async () => {
494
+ if (didSignalBreak) {
495
+ return {
496
+ done: true,
497
+ value: void 0
498
+ };
499
+ }
500
+ while (this.queue.length === 0) {
501
+ if (this.closed && !this.brokenWithValuesLeftToRead) {
502
+ return {
503
+ done: true,
504
+ value: void 0
505
+ };
506
+ }
507
+ if (this.broken) {
508
+ didSignalBreak = true;
509
+ return {
510
+ done: false,
511
+ value: Err(ReadableBrokenError)
512
+ };
513
+ }
514
+ if (!this.next) {
515
+ this.next = createPromiseWithResolvers();
516
+ }
517
+ await this.next.promise;
518
+ this.next = null;
519
+ }
520
+ const value = this.queue.shift();
521
+ return { done: false, value };
522
+ },
523
+ return: async () => {
524
+ this.break();
525
+ return { done: true, value: void 0 };
526
+ }
527
+ };
528
+ }
529
+ /**
530
+ * Collects all the values from the {@link Readable} into an array.
531
+ *
532
+ * @see {@link Readable}'s typedoc for more information
533
+ */
534
+ async collect() {
535
+ const array = [];
536
+ for await (const value of this) {
537
+ array.push(value);
538
+ }
539
+ return array;
540
+ }
541
+ /**
542
+ * Breaks the {@link Readable} and signals an error to any iterators waiting for the next value.
543
+ *
544
+ * @see {@link Readable}'s typedoc for more information
545
+ */
546
+ break() {
547
+ if (this.broken) {
548
+ return;
549
+ }
550
+ this.locked = true;
551
+ this.broken = true;
552
+ this.brokenWithValuesLeftToRead = this.queue.length > 0;
553
+ this.queue.length = 0;
554
+ this.next?.resolve();
555
+ }
556
+ /**
557
+ * Whether the {@link Readable} is readable.
558
+ *
559
+ * @see {@link Readable}'s typedoc for more information
560
+ */
561
+ isReadable() {
562
+ return !this.locked && !this.broken;
563
+ }
564
+ /**
565
+ * Pushes a value to be read.
566
+ */
567
+ _pushValue(value) {
568
+ if (this.broken) {
569
+ return;
570
+ }
571
+ if (this.closed) {
572
+ throw new Error("Cannot push to closed Readable");
573
+ }
574
+ this.queue.push(value);
575
+ this.next?.resolve();
576
+ }
577
+ /**
578
+ * Triggers the close of the {@link Readable}. Make sure to push all remaining
579
+ * values before calling this method.
580
+ */
581
+ _triggerClose() {
582
+ if (this.closed) {
583
+ throw new Error("Unexpected closing multiple times");
584
+ }
585
+ this.closed = true;
586
+ this.next?.resolve();
587
+ }
588
+ /**
589
+ * @internal meant for use within river, not exposed as a public API
590
+ */
591
+ _hasValuesInQueue() {
592
+ return this.queue.length > 0;
593
+ }
594
+ /**
595
+ * Whether the {@link Readable} is closed.
596
+ */
597
+ isClosed() {
598
+ return this.closed;
599
+ }
600
+ };
601
+ var WritableImpl = class {
602
+ /**
603
+ * Passed via constructor to pass on calls to {@link write}
604
+ */
605
+ writeCb;
606
+ /**
607
+ * Passed via constructor to pass on calls to {@link close}
608
+ */
609
+ closeCb;
610
+ /**
611
+ * Whether {@link close} was called, and {@link Writable} is not writable anymore.
612
+ */
613
+ closed = false;
614
+ constructor(callbacks) {
615
+ this.writeCb = callbacks.writeCb;
616
+ this.closeCb = callbacks.closeCb;
617
+ }
618
+ write(value) {
619
+ if (this.closed) {
620
+ throw new Error("Cannot write to closed Writable");
621
+ }
622
+ this.writeCb(value);
623
+ }
624
+ isWritable() {
625
+ return !this.closed;
626
+ }
627
+ close() {
628
+ if (this.closed) {
629
+ return;
630
+ }
631
+ this.closed = true;
632
+ this.writeCb = () => void 0;
633
+ this.closeCb();
634
+ this.closeCb = () => void 0;
635
+ }
636
+ /**
637
+ * @internal meant for use within river, not exposed as a public API
638
+ */
639
+ isClosed() {
640
+ return this.closed;
641
+ }
642
+ };
643
+
644
+ // router/procedures.ts
645
+ var import_typebox4 = require("@sinclair/typebox");
398
646
  function rpc({
399
647
  requestInit,
400
648
  responseData,
401
- responseError = import_typebox3.Type.Never(),
649
+ responseError = import_typebox4.Type.Never(),
402
650
  description,
403
651
  handler
404
652
  }) {
@@ -415,7 +663,7 @@ function upload({
415
663
  requestInit,
416
664
  requestData,
417
665
  responseData,
418
- responseError = import_typebox3.Type.Never(),
666
+ responseError = import_typebox4.Type.Never(),
419
667
  description,
420
668
  handler
421
669
  }) {
@@ -432,7 +680,7 @@ function upload({
432
680
  function subscription({
433
681
  requestInit,
434
682
  responseData,
435
- responseError = import_typebox3.Type.Never(),
683
+ responseError = import_typebox4.Type.Never(),
436
684
  description,
437
685
  handler
438
686
  }) {
@@ -449,7 +697,7 @@ function stream({
449
697
  requestInit,
450
698
  requestData,
451
699
  responseData,
452
- responseError = import_typebox3.Type.Never(),
700
+ responseError = import_typebox4.Type.Never(),
453
701
  description,
454
702
  handler
455
703
  }) {
@@ -471,7 +719,7 @@ var Procedure = {
471
719
  };
472
720
 
473
721
  // transport/message.ts
474
- var import_typebox4 = require("@sinclair/typebox");
722
+ var import_typebox5 = require("@sinclair/typebox");
475
723
 
476
724
  // transport/id.ts
477
725
  var import_nanoid = require("nanoid");
@@ -481,90 +729,90 @@ var alphabet = (0, import_nanoid.customAlphabet)(
481
729
  var generateId = () => alphabet(12);
482
730
 
483
731
  // 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()
732
+ var TransportMessageSchema = (t) => import_typebox5.Type.Object({
733
+ id: import_typebox5.Type.String(),
734
+ from: import_typebox5.Type.String(),
735
+ to: import_typebox5.Type.String(),
736
+ seq: import_typebox5.Type.Integer(),
737
+ ack: import_typebox5.Type.Integer(),
738
+ serviceName: import_typebox5.Type.Optional(import_typebox5.Type.String()),
739
+ procedureName: import_typebox5.Type.Optional(import_typebox5.Type.String()),
740
+ streamId: import_typebox5.Type.String(),
741
+ controlFlags: import_typebox5.Type.Integer(),
742
+ tracing: import_typebox5.Type.Optional(
743
+ import_typebox5.Type.Object({
744
+ traceparent: import_typebox5.Type.String(),
745
+ tracestate: import_typebox5.Type.String()
498
746
  })
499
747
  ),
500
748
  payload: t
501
749
  });
502
- var ControlMessageAckSchema = import_typebox4.Type.Object({
503
- type: import_typebox4.Type.Literal("ACK")
750
+ var ControlMessageAckSchema = import_typebox5.Type.Object({
751
+ type: import_typebox5.Type.Literal("ACK")
504
752
  });
505
- var ControlMessageCloseSchema = import_typebox4.Type.Object({
506
- type: import_typebox4.Type.Literal("CLOSE")
753
+ var ControlMessageCloseSchema = import_typebox5.Type.Object({
754
+ type: import_typebox5.Type.Literal("CLOSE")
507
755
  });
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(),
756
+ var ControlMessageHandshakeRequestSchema = import_typebox5.Type.Object({
757
+ type: import_typebox5.Type.Literal("HANDSHAKE_REQ"),
758
+ protocolVersion: import_typebox5.Type.String(),
759
+ sessionId: import_typebox5.Type.String(),
512
760
  /**
513
761
  * Specifies what the server's expected session state (from the pov of the client). This can be
514
762
  * used by the server to know whether this is a new or a reestablished connection, and whether it
515
763
  * is compatible with what it already has.
516
764
  */
517
- expectedSessionState: import_typebox4.Type.Object({
765
+ expectedSessionState: import_typebox5.Type.Object({
518
766
  // what the client expects the server to send next
519
- nextExpectedSeq: import_typebox4.Type.Integer(),
520
- nextSentSeq: import_typebox4.Type.Integer()
767
+ nextExpectedSeq: import_typebox5.Type.Integer(),
768
+ nextSentSeq: import_typebox5.Type.Integer()
521
769
  }),
522
- metadata: import_typebox4.Type.Optional(import_typebox4.Type.Unknown())
770
+ metadata: import_typebox5.Type.Optional(import_typebox5.Type.Unknown())
523
771
  });
524
- var HandshakeErrorRetriableResponseCodes = import_typebox4.Type.Union([
525
- import_typebox4.Type.Literal("SESSION_STATE_MISMATCH")
772
+ var HandshakeErrorRetriableResponseCodes = import_typebox5.Type.Union([
773
+ import_typebox5.Type.Literal("SESSION_STATE_MISMATCH")
526
774
  ]);
527
- var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox4.Type.Union([
775
+ var HandshakeErrorCustomHandlerFatalResponseCodes = import_typebox5.Type.Union([
528
776
  // The custom validation handler rejected the handler because the client is unsupported.
529
- import_typebox4.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
777
+ import_typebox5.Type.Literal("REJECTED_UNSUPPORTED_CLIENT"),
530
778
  // The custom validation handler rejected the handshake.
531
- import_typebox4.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
779
+ import_typebox5.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
532
780
  ]);
533
- var HandshakeErrorFatalResponseCodes = import_typebox4.Type.Union([
781
+ var HandshakeErrorFatalResponseCodes = import_typebox5.Type.Union([
534
782
  HandshakeErrorCustomHandlerFatalResponseCodes,
535
783
  // The ciient sent a handshake that doesn't comply with the extended handshake metadata.
536
- import_typebox4.Type.Literal("MALFORMED_HANDSHAKE_META"),
784
+ import_typebox5.Type.Literal("MALFORMED_HANDSHAKE_META"),
537
785
  // The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
538
- import_typebox4.Type.Literal("MALFORMED_HANDSHAKE"),
786
+ import_typebox5.Type.Literal("MALFORMED_HANDSHAKE"),
539
787
  // The client's protocol version does not match the server's.
540
- import_typebox4.Type.Literal("PROTOCOL_VERSION_MISMATCH")
788
+ import_typebox5.Type.Literal("PROTOCOL_VERSION_MISMATCH")
541
789
  ]);
542
- var HandshakeErrorResponseCodes = import_typebox4.Type.Union([
790
+ var HandshakeErrorResponseCodes = import_typebox5.Type.Union([
543
791
  HandshakeErrorRetriableResponseCodes,
544
792
  HandshakeErrorFatalResponseCodes
545
793
  ]);
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()
794
+ var ControlMessageHandshakeResponseSchema = import_typebox5.Type.Object({
795
+ type: import_typebox5.Type.Literal("HANDSHAKE_RESP"),
796
+ status: import_typebox5.Type.Union([
797
+ import_typebox5.Type.Object({
798
+ ok: import_typebox5.Type.Literal(true),
799
+ sessionId: import_typebox5.Type.String()
552
800
  }),
553
- import_typebox4.Type.Object({
554
- ok: import_typebox4.Type.Literal(false),
555
- reason: import_typebox4.Type.String(),
801
+ import_typebox5.Type.Object({
802
+ ok: import_typebox5.Type.Literal(false),
803
+ reason: import_typebox5.Type.String(),
556
804
  code: HandshakeErrorResponseCodes
557
805
  })
558
806
  ])
559
807
  });
560
- var ControlMessagePayloadSchema = import_typebox4.Type.Union([
808
+ var ControlMessagePayloadSchema = import_typebox5.Type.Union([
561
809
  ControlMessageCloseSchema,
562
810
  ControlMessageAckSchema,
563
811
  ControlMessageHandshakeRequestSchema,
564
812
  ControlMessageHandshakeResponseSchema
565
813
  ]);
566
814
  var OpaqueTransportMessageSchema = TransportMessageSchema(
567
- import_typebox4.Type.Unknown()
815
+ import_typebox5.Type.Unknown()
568
816
  );
569
817
  function closeStreamMessage(streamId) {
570
818
  return {
@@ -601,35 +849,6 @@ function isStreamCancel(controlFlag) {
601
849
  );
602
850
  }
603
851
 
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
852
  // tracing/index.ts
634
853
  var import_api = require("@opentelemetry/api");
635
854
  function getPropagationContext(ctx) {
@@ -706,208 +925,6 @@ function recordRiverError(span, error) {
706
925
  });
707
926
  }
708
927
 
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
928
  // router/client.ts
912
929
  var import_value = require("@sinclair/typebox/value");
913
930
  var noop = () => {
@@ -1924,7 +1941,7 @@ function createServerHandshakeOptions(schema, validate) {
1924
1941
  }
1925
1942
 
1926
1943
  // package.json
1927
- var version = "0.209.1";
1944
+ var version = "0.209.3";
1928
1945
  // Annotate the CommonJS export names for ESM import in node:
1929
1946
  0 && (module.exports = {
1930
1947
  CANCEL_CODE,
@@ -1933,6 +1950,8 @@ var version = "0.209.1";
1933
1950
  Ok,
1934
1951
  Procedure,
1935
1952
  RIVER_VERSION,
1953
+ RawReadable,
1954
+ ReadableBrokenError,
1936
1955
  ReaderErrorSchema,
1937
1956
  UNCAUGHT_ERROR_CODE,
1938
1957
  UNEXPECTED_DISCONNECT_CODE,