@replit/river 0.209.0 → 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.
- package/dist/{chunk-TVN2TB6X.js → chunk-DVAIJ57I.js} +10 -10
- package/dist/{chunk-RATCBAZE.js → chunk-L3KNTJU3.js} +316 -303
- package/dist/chunk-L3KNTJU3.js.map +1 -0
- package/dist/{chunk-LPWARXI3.js → chunk-OTL2R22H.js} +2 -2
- package/dist/{client-aETS93z1.d.cts → client-BX3IXUA2.d.cts} +1 -1
- package/dist/{client-BzJwq-hg.d.ts → client-CBak1h8Q.d.ts} +1 -1
- package/dist/codec/index.js +2 -2
- package/dist/{connection-hUWlS-hg.d.cts → connection-_eetKnva.d.cts} +1 -1
- package/dist/{connection-b1wd5XrC.d.ts → connection-zMlysQKs.d.ts} +1 -1
- package/dist/{transport-CxjUaGhi.d.cts → handshake-B3iu79B0.d.cts} +102 -102
- package/dist/{transport-DwEB67zY.d.ts → handshake-DNinPBA3.d.ts} +102 -102
- package/dist/router/index.cjs +300 -285
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +7 -7
- package/dist/router/index.d.ts +7 -7
- package/dist/router/index.js +5 -1
- package/dist/{server-BBgDVOzk.d.cts → server-BV7GXuhz.d.cts} +1 -1
- package/dist/{server-DZ0Yzmpf.d.ts → server-B_H1zn-R.d.ts} +1 -1
- package/dist/{services-DC_uol9A.d.cts → services-BIMmk-v4.d.cts} +97 -4
- package/dist/{services-DBvjc-Mq.d.ts → services-DtsSIaec.d.ts} +97 -4
- package/dist/testUtil/index.cjs +1 -1
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +4 -4
- package/dist/testUtil/index.d.ts +4 -4
- package/dist/testUtil/index.js +3 -3
- package/dist/transport/impls/ws/client.cjs +1 -1
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +3 -3
- package/dist/transport/impls/ws/client.d.ts +3 -3
- package/dist/transport/impls/ws/client.js +3 -3
- package/dist/transport/impls/ws/server.cjs +1 -1
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +3 -3
- package/dist/transport/impls/ws/server.d.ts +3 -3
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +1 -1
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +4 -4
- package/dist/transport/index.d.ts +4 -4
- package/dist/transport/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-RATCBAZE.js.map +0 -1
- /package/dist/{chunk-TVN2TB6X.js.map → chunk-DVAIJ57I.js.map} +0 -0
- /package/dist/{chunk-LPWARXI3.js.map → chunk-OTL2R22H.js.map} +0 -0
|
@@ -354,12 +354,254 @@ var ServiceScaffold = class {
|
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
// router/
|
|
357
|
+
// router/result.ts
|
|
358
358
|
import { Type as Type3 } from "@sinclair/typebox";
|
|
359
|
+
var AnyResultSchema = Type3.Union([
|
|
360
|
+
Type3.Object({
|
|
361
|
+
ok: Type3.Literal(false),
|
|
362
|
+
payload: Type3.Object({
|
|
363
|
+
code: Type3.String(),
|
|
364
|
+
message: Type3.String(),
|
|
365
|
+
extras: Type3.Optional(Type3.Unknown())
|
|
366
|
+
})
|
|
367
|
+
}),
|
|
368
|
+
Type3.Object({
|
|
369
|
+
ok: Type3.Literal(true),
|
|
370
|
+
payload: Type3.Unknown()
|
|
371
|
+
})
|
|
372
|
+
]);
|
|
373
|
+
function Ok(payload) {
|
|
374
|
+
return {
|
|
375
|
+
ok: true,
|
|
376
|
+
payload
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function Err(error) {
|
|
380
|
+
return {
|
|
381
|
+
ok: false,
|
|
382
|
+
payload: error
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// router/streams.ts
|
|
387
|
+
var ReadableBrokenError = {
|
|
388
|
+
code: "READABLE_BROKEN",
|
|
389
|
+
message: "Readable was broken before it is fully consumed"
|
|
390
|
+
};
|
|
391
|
+
function createPromiseWithResolvers() {
|
|
392
|
+
let resolve;
|
|
393
|
+
let reject;
|
|
394
|
+
const promise = new Promise((res, rej) => {
|
|
395
|
+
resolve = res;
|
|
396
|
+
reject = rej;
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
promise,
|
|
400
|
+
// @ts-expect-error promise callbacks are sync
|
|
401
|
+
resolve,
|
|
402
|
+
// @ts-expect-error promise callbacks are sync
|
|
403
|
+
reject
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
var ReadableImpl = class {
|
|
407
|
+
/**
|
|
408
|
+
* Whether the {@link Readable} is closed.
|
|
409
|
+
*
|
|
410
|
+
* Closed {@link Readable}s are done receiving values, but that doesn't affect
|
|
411
|
+
* any other aspect of the {@link Readable} such as it's consumability.
|
|
412
|
+
*/
|
|
413
|
+
closed = false;
|
|
414
|
+
/**
|
|
415
|
+
* Whether the {@link Readable} is locked.
|
|
416
|
+
*
|
|
417
|
+
* @see {@link Readable}'s typedoc to understand locking
|
|
418
|
+
*/
|
|
419
|
+
locked = false;
|
|
420
|
+
/**
|
|
421
|
+
* Whether {@link break} was called.
|
|
422
|
+
*
|
|
423
|
+
* @see {@link break} for more information
|
|
424
|
+
*/
|
|
425
|
+
broken = false;
|
|
426
|
+
/**
|
|
427
|
+
* This flag allows us to avoid emitting a {@link ReadableBrokenError} after {@link break} was called
|
|
428
|
+
* in cases where the {@link queue} is fully consumed and {@link ReadableImpl} is {@link closed}. This is just an
|
|
429
|
+
* ergonomic feature to avoid emitting an error in our iteration when we don't have to.
|
|
430
|
+
*/
|
|
431
|
+
brokenWithValuesLeftToRead = false;
|
|
432
|
+
/**
|
|
433
|
+
* A list of values that have been pushed to the {@link ReadableImpl} but not yet emitted to the user.
|
|
434
|
+
*/
|
|
435
|
+
queue = [];
|
|
436
|
+
/**
|
|
437
|
+
* Used by methods in the class to signal to the iterator that it
|
|
438
|
+
* should check for the next value.
|
|
439
|
+
*/
|
|
440
|
+
next = null;
|
|
441
|
+
[Symbol.asyncIterator]() {
|
|
442
|
+
if (this.locked) {
|
|
443
|
+
throw new TypeError("Readable is already locked");
|
|
444
|
+
}
|
|
445
|
+
this.locked = true;
|
|
446
|
+
let didSignalBreak = false;
|
|
447
|
+
return {
|
|
448
|
+
next: async () => {
|
|
449
|
+
if (didSignalBreak) {
|
|
450
|
+
return {
|
|
451
|
+
done: true,
|
|
452
|
+
value: void 0
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
while (this.queue.length === 0) {
|
|
456
|
+
if (this.closed && !this.brokenWithValuesLeftToRead) {
|
|
457
|
+
return {
|
|
458
|
+
done: true,
|
|
459
|
+
value: void 0
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
if (this.broken) {
|
|
463
|
+
didSignalBreak = true;
|
|
464
|
+
return {
|
|
465
|
+
done: false,
|
|
466
|
+
value: Err(ReadableBrokenError)
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
if (!this.next) {
|
|
470
|
+
this.next = createPromiseWithResolvers();
|
|
471
|
+
}
|
|
472
|
+
await this.next.promise;
|
|
473
|
+
this.next = null;
|
|
474
|
+
}
|
|
475
|
+
const value = this.queue.shift();
|
|
476
|
+
return { done: false, value };
|
|
477
|
+
},
|
|
478
|
+
return: () => {
|
|
479
|
+
this.break();
|
|
480
|
+
return { done: true, value: void 0 };
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Collects all the values from the {@link Readable} into an array.
|
|
486
|
+
*
|
|
487
|
+
* @see {@link Readable}'s typedoc for more information
|
|
488
|
+
*/
|
|
489
|
+
async collect() {
|
|
490
|
+
const array = [];
|
|
491
|
+
for await (const value of this) {
|
|
492
|
+
array.push(value);
|
|
493
|
+
}
|
|
494
|
+
return array;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Breaks the {@link Readable} and signals an error to any iterators waiting for the next value.
|
|
498
|
+
*
|
|
499
|
+
* @see {@link Readable}'s typedoc for more information
|
|
500
|
+
*/
|
|
501
|
+
break() {
|
|
502
|
+
if (this.broken) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.locked = true;
|
|
506
|
+
this.broken = true;
|
|
507
|
+
this.brokenWithValuesLeftToRead = this.queue.length > 0;
|
|
508
|
+
this.queue.length = 0;
|
|
509
|
+
this.next?.resolve();
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Whether the {@link Readable} is readable.
|
|
513
|
+
*
|
|
514
|
+
* @see {@link Readable}'s typedoc for more information
|
|
515
|
+
*/
|
|
516
|
+
isReadable() {
|
|
517
|
+
return !this.locked && !this.broken;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Pushes a value to be read.
|
|
521
|
+
*/
|
|
522
|
+
_pushValue(value) {
|
|
523
|
+
if (this.broken) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (this.closed) {
|
|
527
|
+
throw new Error("Cannot push to closed Readable");
|
|
528
|
+
}
|
|
529
|
+
this.queue.push(value);
|
|
530
|
+
this.next?.resolve();
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Triggers the close of the {@link Readable}. Make sure to push all remaining
|
|
534
|
+
* values before calling this method.
|
|
535
|
+
*/
|
|
536
|
+
_triggerClose() {
|
|
537
|
+
if (this.closed) {
|
|
538
|
+
throw new Error("Unexpected closing multiple times");
|
|
539
|
+
}
|
|
540
|
+
this.closed = true;
|
|
541
|
+
this.next?.resolve();
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* @internal meant for use within river, not exposed as a public API
|
|
545
|
+
*/
|
|
546
|
+
_hasValuesInQueue() {
|
|
547
|
+
return this.queue.length > 0;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Whether the {@link Readable} is closed.
|
|
551
|
+
*/
|
|
552
|
+
isClosed() {
|
|
553
|
+
return this.closed;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
var WritableImpl = class {
|
|
557
|
+
/**
|
|
558
|
+
* Passed via constructor to pass on calls to {@link write}
|
|
559
|
+
*/
|
|
560
|
+
writeCb;
|
|
561
|
+
/**
|
|
562
|
+
* Passed via constructor to pass on calls to {@link close}
|
|
563
|
+
*/
|
|
564
|
+
closeCb;
|
|
565
|
+
/**
|
|
566
|
+
* Whether {@link close} was called, and {@link Writable} is not writable anymore.
|
|
567
|
+
*/
|
|
568
|
+
closed = false;
|
|
569
|
+
constructor(callbacks) {
|
|
570
|
+
this.writeCb = callbacks.writeCb;
|
|
571
|
+
this.closeCb = callbacks.closeCb;
|
|
572
|
+
}
|
|
573
|
+
write(value) {
|
|
574
|
+
if (this.closed) {
|
|
575
|
+
throw new Error("Cannot write to closed Writable");
|
|
576
|
+
}
|
|
577
|
+
this.writeCb(value);
|
|
578
|
+
}
|
|
579
|
+
isWritable() {
|
|
580
|
+
return !this.closed;
|
|
581
|
+
}
|
|
582
|
+
close() {
|
|
583
|
+
if (this.closed) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this.closed = true;
|
|
587
|
+
this.writeCb = () => void 0;
|
|
588
|
+
this.closeCb();
|
|
589
|
+
this.closeCb = () => void 0;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* @internal meant for use within river, not exposed as a public API
|
|
593
|
+
*/
|
|
594
|
+
isClosed() {
|
|
595
|
+
return this.closed;
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// router/procedures.ts
|
|
600
|
+
import { Type as Type4 } from "@sinclair/typebox";
|
|
359
601
|
function rpc({
|
|
360
602
|
requestInit,
|
|
361
603
|
responseData,
|
|
362
|
-
responseError =
|
|
604
|
+
responseError = Type4.Never(),
|
|
363
605
|
description,
|
|
364
606
|
handler
|
|
365
607
|
}) {
|
|
@@ -376,7 +618,7 @@ function upload({
|
|
|
376
618
|
requestInit,
|
|
377
619
|
requestData,
|
|
378
620
|
responseData,
|
|
379
|
-
responseError =
|
|
621
|
+
responseError = Type4.Never(),
|
|
380
622
|
description,
|
|
381
623
|
handler
|
|
382
624
|
}) {
|
|
@@ -393,7 +635,7 @@ function upload({
|
|
|
393
635
|
function subscription({
|
|
394
636
|
requestInit,
|
|
395
637
|
responseData,
|
|
396
|
-
responseError =
|
|
638
|
+
responseError = Type4.Never(),
|
|
397
639
|
description,
|
|
398
640
|
handler
|
|
399
641
|
}) {
|
|
@@ -410,7 +652,7 @@ function stream({
|
|
|
410
652
|
requestInit,
|
|
411
653
|
requestData,
|
|
412
654
|
responseData,
|
|
413
|
-
responseError =
|
|
655
|
+
responseError = Type4.Never(),
|
|
414
656
|
description,
|
|
415
657
|
handler
|
|
416
658
|
}) {
|
|
@@ -432,7 +674,7 @@ var Procedure = {
|
|
|
432
674
|
};
|
|
433
675
|
|
|
434
676
|
// transport/message.ts
|
|
435
|
-
import { Type as
|
|
677
|
+
import { Type as Type5 } from "@sinclair/typebox";
|
|
436
678
|
|
|
437
679
|
// transport/id.ts
|
|
438
680
|
import { customAlphabet } from "nanoid";
|
|
@@ -442,95 +684,95 @@ var alphabet = customAlphabet(
|
|
|
442
684
|
var generateId = () => alphabet(12);
|
|
443
685
|
|
|
444
686
|
// transport/message.ts
|
|
445
|
-
var TransportMessageSchema = (t) =>
|
|
446
|
-
id:
|
|
447
|
-
from:
|
|
448
|
-
to:
|
|
449
|
-
seq:
|
|
450
|
-
ack:
|
|
451
|
-
serviceName:
|
|
452
|
-
procedureName:
|
|
453
|
-
streamId:
|
|
454
|
-
controlFlags:
|
|
455
|
-
tracing:
|
|
456
|
-
|
|
457
|
-
traceparent:
|
|
458
|
-
tracestate:
|
|
687
|
+
var TransportMessageSchema = (t) => Type5.Object({
|
|
688
|
+
id: Type5.String(),
|
|
689
|
+
from: Type5.String(),
|
|
690
|
+
to: Type5.String(),
|
|
691
|
+
seq: Type5.Integer(),
|
|
692
|
+
ack: Type5.Integer(),
|
|
693
|
+
serviceName: Type5.Optional(Type5.String()),
|
|
694
|
+
procedureName: Type5.Optional(Type5.String()),
|
|
695
|
+
streamId: Type5.String(),
|
|
696
|
+
controlFlags: Type5.Integer(),
|
|
697
|
+
tracing: Type5.Optional(
|
|
698
|
+
Type5.Object({
|
|
699
|
+
traceparent: Type5.String(),
|
|
700
|
+
tracestate: Type5.String()
|
|
459
701
|
})
|
|
460
702
|
),
|
|
461
703
|
payload: t
|
|
462
704
|
});
|
|
463
|
-
var ControlMessageAckSchema =
|
|
464
|
-
type:
|
|
705
|
+
var ControlMessageAckSchema = Type5.Object({
|
|
706
|
+
type: Type5.Literal("ACK")
|
|
465
707
|
});
|
|
466
|
-
var ControlMessageCloseSchema =
|
|
467
|
-
type:
|
|
708
|
+
var ControlMessageCloseSchema = Type5.Object({
|
|
709
|
+
type: Type5.Literal("CLOSE")
|
|
468
710
|
});
|
|
469
711
|
var currentProtocolVersion = "v2.0";
|
|
470
712
|
var acceptedProtocolVersions = ["v1.1", currentProtocolVersion];
|
|
471
713
|
function isAcceptedProtocolVersion(version2) {
|
|
472
714
|
return acceptedProtocolVersions.includes(version2);
|
|
473
715
|
}
|
|
474
|
-
var ControlMessageHandshakeRequestSchema =
|
|
475
|
-
type:
|
|
476
|
-
protocolVersion:
|
|
477
|
-
sessionId:
|
|
716
|
+
var ControlMessageHandshakeRequestSchema = Type5.Object({
|
|
717
|
+
type: Type5.Literal("HANDSHAKE_REQ"),
|
|
718
|
+
protocolVersion: Type5.String(),
|
|
719
|
+
sessionId: Type5.String(),
|
|
478
720
|
/**
|
|
479
721
|
* Specifies what the server's expected session state (from the pov of the client). This can be
|
|
480
722
|
* used by the server to know whether this is a new or a reestablished connection, and whether it
|
|
481
723
|
* is compatible with what it already has.
|
|
482
724
|
*/
|
|
483
|
-
expectedSessionState:
|
|
725
|
+
expectedSessionState: Type5.Object({
|
|
484
726
|
// what the client expects the server to send next
|
|
485
|
-
nextExpectedSeq:
|
|
486
|
-
nextSentSeq:
|
|
727
|
+
nextExpectedSeq: Type5.Integer(),
|
|
728
|
+
nextSentSeq: Type5.Integer()
|
|
487
729
|
}),
|
|
488
|
-
metadata:
|
|
730
|
+
metadata: Type5.Optional(Type5.Unknown())
|
|
489
731
|
});
|
|
490
|
-
var HandshakeErrorRetriableResponseCodes =
|
|
491
|
-
|
|
732
|
+
var HandshakeErrorRetriableResponseCodes = Type5.Union([
|
|
733
|
+
Type5.Literal("SESSION_STATE_MISMATCH")
|
|
492
734
|
]);
|
|
493
|
-
var HandshakeErrorCustomHandlerFatalResponseCodes =
|
|
735
|
+
var HandshakeErrorCustomHandlerFatalResponseCodes = Type5.Union([
|
|
494
736
|
// The custom validation handler rejected the handler because the client is unsupported.
|
|
495
|
-
|
|
737
|
+
Type5.Literal("REJECTED_UNSUPPORTED_CLIENT"),
|
|
496
738
|
// The custom validation handler rejected the handshake.
|
|
497
|
-
|
|
739
|
+
Type5.Literal("REJECTED_BY_CUSTOM_HANDLER")
|
|
498
740
|
]);
|
|
499
|
-
var HandshakeErrorFatalResponseCodes =
|
|
741
|
+
var HandshakeErrorFatalResponseCodes = Type5.Union([
|
|
500
742
|
HandshakeErrorCustomHandlerFatalResponseCodes,
|
|
501
743
|
// The ciient sent a handshake that doesn't comply with the extended handshake metadata.
|
|
502
|
-
|
|
744
|
+
Type5.Literal("MALFORMED_HANDSHAKE_META"),
|
|
503
745
|
// The ciient sent a handshake that doesn't comply with ControlMessageHandshakeRequestSchema.
|
|
504
|
-
|
|
746
|
+
Type5.Literal("MALFORMED_HANDSHAKE"),
|
|
505
747
|
// The client's protocol version does not match the server's.
|
|
506
|
-
|
|
748
|
+
Type5.Literal("PROTOCOL_VERSION_MISMATCH")
|
|
507
749
|
]);
|
|
508
|
-
var HandshakeErrorResponseCodes =
|
|
750
|
+
var HandshakeErrorResponseCodes = Type5.Union([
|
|
509
751
|
HandshakeErrorRetriableResponseCodes,
|
|
510
752
|
HandshakeErrorFatalResponseCodes
|
|
511
753
|
]);
|
|
512
|
-
var ControlMessageHandshakeResponseSchema =
|
|
513
|
-
type:
|
|
514
|
-
status:
|
|
515
|
-
|
|
516
|
-
ok:
|
|
517
|
-
sessionId:
|
|
754
|
+
var ControlMessageHandshakeResponseSchema = Type5.Object({
|
|
755
|
+
type: Type5.Literal("HANDSHAKE_RESP"),
|
|
756
|
+
status: Type5.Union([
|
|
757
|
+
Type5.Object({
|
|
758
|
+
ok: Type5.Literal(true),
|
|
759
|
+
sessionId: Type5.String()
|
|
518
760
|
}),
|
|
519
|
-
|
|
520
|
-
ok:
|
|
521
|
-
reason:
|
|
761
|
+
Type5.Object({
|
|
762
|
+
ok: Type5.Literal(false),
|
|
763
|
+
reason: Type5.String(),
|
|
522
764
|
code: HandshakeErrorResponseCodes
|
|
523
765
|
})
|
|
524
766
|
])
|
|
525
767
|
});
|
|
526
|
-
var ControlMessagePayloadSchema =
|
|
768
|
+
var ControlMessagePayloadSchema = Type5.Union([
|
|
527
769
|
ControlMessageCloseSchema,
|
|
528
770
|
ControlMessageAckSchema,
|
|
529
771
|
ControlMessageHandshakeRequestSchema,
|
|
530
772
|
ControlMessageHandshakeResponseSchema
|
|
531
773
|
]);
|
|
532
774
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
533
|
-
|
|
775
|
+
Type5.Unknown()
|
|
534
776
|
);
|
|
535
777
|
function handshakeRequestMessage({
|
|
536
778
|
from,
|
|
@@ -615,35 +857,6 @@ function isStreamCancel(controlFlag) {
|
|
|
615
857
|
);
|
|
616
858
|
}
|
|
617
859
|
|
|
618
|
-
// router/result.ts
|
|
619
|
-
import { Type as Type5 } from "@sinclair/typebox";
|
|
620
|
-
var AnyResultSchema = Type5.Union([
|
|
621
|
-
Type5.Object({
|
|
622
|
-
ok: Type5.Literal(false),
|
|
623
|
-
payload: Type5.Object({
|
|
624
|
-
code: Type5.String(),
|
|
625
|
-
message: Type5.String(),
|
|
626
|
-
extras: Type5.Optional(Type5.Unknown())
|
|
627
|
-
})
|
|
628
|
-
}),
|
|
629
|
-
Type5.Object({
|
|
630
|
-
ok: Type5.Literal(true),
|
|
631
|
-
payload: Type5.Unknown()
|
|
632
|
-
})
|
|
633
|
-
]);
|
|
634
|
-
function Ok(payload) {
|
|
635
|
-
return {
|
|
636
|
-
ok: true,
|
|
637
|
-
payload
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
function Err(error) {
|
|
641
|
-
return {
|
|
642
|
-
ok: false,
|
|
643
|
-
payload: error
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
|
|
647
860
|
// tracing/index.ts
|
|
648
861
|
import {
|
|
649
862
|
SpanKind,
|
|
@@ -761,208 +974,6 @@ function getTracer() {
|
|
|
761
974
|
return trace.getTracer("river", version);
|
|
762
975
|
}
|
|
763
976
|
|
|
764
|
-
// router/streams.ts
|
|
765
|
-
var ReadableBrokenError = {
|
|
766
|
-
code: "READABLE_BROKEN",
|
|
767
|
-
message: "Readable was broken before it is fully consumed"
|
|
768
|
-
};
|
|
769
|
-
function createPromiseWithResolvers() {
|
|
770
|
-
let resolve;
|
|
771
|
-
let reject;
|
|
772
|
-
const promise = new Promise((res, rej) => {
|
|
773
|
-
resolve = res;
|
|
774
|
-
reject = rej;
|
|
775
|
-
});
|
|
776
|
-
return {
|
|
777
|
-
promise,
|
|
778
|
-
// @ts-expect-error promise callbacks are sync
|
|
779
|
-
resolve,
|
|
780
|
-
// @ts-expect-error promise callbacks are sync
|
|
781
|
-
reject
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
var ReadableImpl = class {
|
|
785
|
-
/**
|
|
786
|
-
* Whether the {@link Readable} is closed.
|
|
787
|
-
*
|
|
788
|
-
* Closed {@link Readable}s are done receiving values, but that doesn't affect
|
|
789
|
-
* any other aspect of the {@link Readable} such as it's consumability.
|
|
790
|
-
*/
|
|
791
|
-
closed = false;
|
|
792
|
-
/**
|
|
793
|
-
* Whether the {@link Readable} is locked.
|
|
794
|
-
*
|
|
795
|
-
* @see {@link Readable}'s typedoc to understand locking
|
|
796
|
-
*/
|
|
797
|
-
locked = false;
|
|
798
|
-
/**
|
|
799
|
-
* Whether {@link break} was called.
|
|
800
|
-
*
|
|
801
|
-
* @see {@link break} for more information
|
|
802
|
-
*/
|
|
803
|
-
broken = false;
|
|
804
|
-
/**
|
|
805
|
-
* This flag allows us to avoid emitting a {@link ReadableBrokenError} after {@link break} was called
|
|
806
|
-
* in cases where the {@link queue} is fully consumed and {@link ReadableImpl} is {@link closed}. This is just an
|
|
807
|
-
* ergonomic feature to avoid emitting an error in our iteration when we don't have to.
|
|
808
|
-
*/
|
|
809
|
-
brokenWithValuesLeftToRead = false;
|
|
810
|
-
/**
|
|
811
|
-
* A list of values that have been pushed to the {@link ReadableImpl} but not yet emitted to the user.
|
|
812
|
-
*/
|
|
813
|
-
queue = [];
|
|
814
|
-
/**
|
|
815
|
-
* Used by methods in the class to signal to the iterator that it
|
|
816
|
-
* should check for the next value.
|
|
817
|
-
*/
|
|
818
|
-
next = null;
|
|
819
|
-
[Symbol.asyncIterator]() {
|
|
820
|
-
if (this.locked) {
|
|
821
|
-
throw new TypeError("Readable is already locked");
|
|
822
|
-
}
|
|
823
|
-
this.locked = true;
|
|
824
|
-
let didSignalBreak = false;
|
|
825
|
-
return {
|
|
826
|
-
next: async () => {
|
|
827
|
-
if (didSignalBreak) {
|
|
828
|
-
return {
|
|
829
|
-
done: true,
|
|
830
|
-
value: void 0
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
while (this.queue.length === 0) {
|
|
834
|
-
if (this.closed && !this.brokenWithValuesLeftToRead) {
|
|
835
|
-
return {
|
|
836
|
-
done: true,
|
|
837
|
-
value: void 0
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
if (this.broken) {
|
|
841
|
-
didSignalBreak = true;
|
|
842
|
-
return {
|
|
843
|
-
done: false,
|
|
844
|
-
value: Err(ReadableBrokenError)
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
if (!this.next) {
|
|
848
|
-
this.next = createPromiseWithResolvers();
|
|
849
|
-
}
|
|
850
|
-
await this.next.promise;
|
|
851
|
-
this.next = null;
|
|
852
|
-
}
|
|
853
|
-
const value = this.queue.shift();
|
|
854
|
-
return { done: false, value };
|
|
855
|
-
},
|
|
856
|
-
return: () => {
|
|
857
|
-
this.break();
|
|
858
|
-
return { done: true, value: void 0 };
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
async collect() {
|
|
863
|
-
const array = [];
|
|
864
|
-
for await (const value of this) {
|
|
865
|
-
array.push(value);
|
|
866
|
-
}
|
|
867
|
-
return array;
|
|
868
|
-
}
|
|
869
|
-
break() {
|
|
870
|
-
if (this.broken) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
this.locked = true;
|
|
874
|
-
this.broken = true;
|
|
875
|
-
this.brokenWithValuesLeftToRead = this.queue.length > 0;
|
|
876
|
-
this.queue.length = 0;
|
|
877
|
-
this.next?.resolve();
|
|
878
|
-
}
|
|
879
|
-
isReadable() {
|
|
880
|
-
return !this.locked && !this.broken;
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* @internal meant for use within river, not exposed as a public API
|
|
884
|
-
*
|
|
885
|
-
* Pushes a value to be read.
|
|
886
|
-
*/
|
|
887
|
-
_pushValue(value) {
|
|
888
|
-
if (this.broken) {
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
if (this.closed) {
|
|
892
|
-
throw new Error("Cannot push to closed Readable");
|
|
893
|
-
}
|
|
894
|
-
this.queue.push(value);
|
|
895
|
-
this.next?.resolve();
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* @internal meant for use within river, not exposed as a public API
|
|
899
|
-
*
|
|
900
|
-
* Triggers the close of the {@link Readable}. Make sure to push all remaining
|
|
901
|
-
* values before calling this method.
|
|
902
|
-
*/
|
|
903
|
-
_triggerClose() {
|
|
904
|
-
if (this.closed) {
|
|
905
|
-
throw new Error("Unexpected closing multiple times");
|
|
906
|
-
}
|
|
907
|
-
this.closed = true;
|
|
908
|
-
this.next?.resolve();
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* @internal meant for use within river, not exposed as a public API
|
|
912
|
-
*/
|
|
913
|
-
_hasValuesInQueue() {
|
|
914
|
-
return this.queue.length > 0;
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* @internal meant for use within river, not exposed as a public API
|
|
918
|
-
*/
|
|
919
|
-
isClosed() {
|
|
920
|
-
return this.closed;
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
var WritableImpl = class {
|
|
924
|
-
/**
|
|
925
|
-
* Passed via constructor to pass on calls to {@link write}
|
|
926
|
-
*/
|
|
927
|
-
writeCb;
|
|
928
|
-
/**
|
|
929
|
-
* Passed via constructor to pass on calls to {@link close}
|
|
930
|
-
*/
|
|
931
|
-
closeCb;
|
|
932
|
-
/**
|
|
933
|
-
* Whether {@link close} was called, and {@link Writable} is not writable anymore.
|
|
934
|
-
*/
|
|
935
|
-
closed = false;
|
|
936
|
-
constructor(callbacks) {
|
|
937
|
-
this.writeCb = callbacks.writeCb;
|
|
938
|
-
this.closeCb = callbacks.closeCb;
|
|
939
|
-
}
|
|
940
|
-
write(value) {
|
|
941
|
-
if (this.closed) {
|
|
942
|
-
throw new Error("Cannot write to closed Writable");
|
|
943
|
-
}
|
|
944
|
-
this.writeCb(value);
|
|
945
|
-
}
|
|
946
|
-
isWritable() {
|
|
947
|
-
return !this.closed;
|
|
948
|
-
}
|
|
949
|
-
close() {
|
|
950
|
-
if (this.closed) {
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
this.closed = true;
|
|
954
|
-
this.writeCb = () => void 0;
|
|
955
|
-
this.closeCb();
|
|
956
|
-
this.closeCb = () => void 0;
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* @internal meant for use within river, not exposed as a public API
|
|
960
|
-
*/
|
|
961
|
-
isClosed() {
|
|
962
|
-
return this.closed;
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
|
|
966
977
|
// router/client.ts
|
|
967
978
|
import { Value } from "@sinclair/typebox/value";
|
|
968
979
|
var noop = () => {
|
|
@@ -1979,9 +1990,23 @@ function createServerHandshakeOptions(schema, validate) {
|
|
|
1979
1990
|
}
|
|
1980
1991
|
|
|
1981
1992
|
// package.json
|
|
1982
|
-
var version = "0.209.
|
|
1993
|
+
var version = "0.209.2";
|
|
1983
1994
|
|
|
1984
1995
|
export {
|
|
1996
|
+
UNCAUGHT_ERROR_CODE,
|
|
1997
|
+
UNEXPECTED_DISCONNECT_CODE,
|
|
1998
|
+
INVALID_REQUEST_CODE,
|
|
1999
|
+
CANCEL_CODE,
|
|
2000
|
+
ReaderErrorSchema,
|
|
2001
|
+
flattenErrorType,
|
|
2002
|
+
serializeSchemaV1Compat,
|
|
2003
|
+
serializeSchema,
|
|
2004
|
+
createServiceSchema,
|
|
2005
|
+
Ok,
|
|
2006
|
+
Err,
|
|
2007
|
+
ReadableBrokenError,
|
|
2008
|
+
ReadableImpl,
|
|
2009
|
+
Procedure,
|
|
1985
2010
|
generateId,
|
|
1986
2011
|
TransportMessageSchema,
|
|
1987
2012
|
currentProtocolVersion,
|
|
@@ -1995,27 +2020,15 @@ export {
|
|
|
1995
2020
|
handshakeRequestMessage,
|
|
1996
2021
|
handshakeResponseMessage,
|
|
1997
2022
|
isAck,
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
ReaderErrorSchema,
|
|
2003
|
-
flattenErrorType,
|
|
2004
|
-
serializeSchemaV1Compat,
|
|
2005
|
-
serializeSchema,
|
|
2006
|
-
createServiceSchema,
|
|
2007
|
-
Procedure,
|
|
2008
|
-
Ok,
|
|
2009
|
-
Err,
|
|
2023
|
+
getPropagationContext,
|
|
2024
|
+
createSessionTelemetryInfo,
|
|
2025
|
+
createConnectionTelemetryInfo,
|
|
2026
|
+
getTracer,
|
|
2010
2027
|
createClient,
|
|
2011
2028
|
coerceErrorString,
|
|
2012
2029
|
createServer,
|
|
2013
2030
|
createClientHandshakeOptions,
|
|
2014
2031
|
createServerHandshakeOptions,
|
|
2015
|
-
version
|
|
2016
|
-
getPropagationContext,
|
|
2017
|
-
createSessionTelemetryInfo,
|
|
2018
|
-
createConnectionTelemetryInfo,
|
|
2019
|
-
getTracer
|
|
2032
|
+
version
|
|
2020
2033
|
};
|
|
2021
|
-
//# sourceMappingURL=chunk-
|
|
2034
|
+
//# sourceMappingURL=chunk-L3KNTJU3.js.map
|