capnweb 0.0.0-3d17ba1 → 0.0.0-3f34bfd
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/README.md +112 -695
- package/dist/index-bun.cjs +475 -109
- package/dist/index-bun.cjs.map +1 -1
- package/dist/index-bun.d.cts +173 -24
- package/dist/index-bun.d.ts +173 -24
- package/dist/index-bun.js +473 -110
- package/dist/index-bun.js.map +1 -1
- package/dist/index-workers.cjs +475 -109
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.d.cts +169 -23
- package/dist/index-workers.d.ts +169 -23
- package/dist/index-workers.js +473 -110
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +475 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -23
- package/dist/index.d.ts +169 -23
- package/dist/index.js +473 -110
- package/dist/index.js.map +1 -1
- package/package.json +19 -7
package/dist/index-bun.cjs
CHANGED
|
@@ -43,9 +43,22 @@ function typeForRpc(value) {
|
|
|
43
43
|
case Array.prototype: return "array";
|
|
44
44
|
case Date.prototype: return "date";
|
|
45
45
|
case Uint8Array.prototype:
|
|
46
|
-
case BUFFER_PROTOTYPE:
|
|
46
|
+
case BUFFER_PROTOTYPE:
|
|
47
|
+
case ArrayBuffer.prototype:
|
|
48
|
+
case DataView.prototype:
|
|
49
|
+
case Int8Array.prototype:
|
|
50
|
+
case Uint8ClampedArray.prototype:
|
|
51
|
+
case Int16Array.prototype:
|
|
52
|
+
case Uint16Array.prototype:
|
|
53
|
+
case Int32Array.prototype:
|
|
54
|
+
case Uint32Array.prototype:
|
|
55
|
+
case BigInt64Array.prototype:
|
|
56
|
+
case BigUint64Array.prototype:
|
|
57
|
+
case Float32Array.prototype:
|
|
58
|
+
case Float64Array.prototype: return "bytes";
|
|
47
59
|
case WritableStream.prototype: return "writable";
|
|
48
60
|
case ReadableStream.prototype: return "readable";
|
|
61
|
+
case URL.prototype: return "url";
|
|
49
62
|
case Headers.prototype: return "headers";
|
|
50
63
|
case Request.prototype: return "request";
|
|
51
64
|
case Response.prototype: return "response";
|
|
@@ -79,7 +92,14 @@ let streamImpl = {
|
|
|
79
92
|
};
|
|
80
93
|
var StubHook = class {
|
|
81
94
|
stream(path, args) {
|
|
82
|
-
let
|
|
95
|
+
let hook = this.call(path, args);
|
|
96
|
+
let pulled;
|
|
97
|
+
try {
|
|
98
|
+
pulled = hook.pull();
|
|
99
|
+
} catch (err) {
|
|
100
|
+
hook.dispose();
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
83
103
|
let promise;
|
|
84
104
|
if (pulled instanceof Promise) promise = pulled.then((p) => {
|
|
85
105
|
p.dispose();
|
|
@@ -98,9 +118,11 @@ var ErrorStubHook = class extends StubHook {
|
|
|
98
118
|
this.error = error;
|
|
99
119
|
}
|
|
100
120
|
call(path, args) {
|
|
121
|
+
args.dispose();
|
|
101
122
|
return this;
|
|
102
123
|
}
|
|
103
124
|
map(path, captures, instructions) {
|
|
125
|
+
for (let cap of captures) cap.dispose();
|
|
104
126
|
return this;
|
|
105
127
|
}
|
|
106
128
|
get(path) {
|
|
@@ -224,7 +246,25 @@ var RpcStub$1 = class RpcStub$1 extends RpcTarget$1 {
|
|
|
224
246
|
};
|
|
225
247
|
var RpcPromise$1 = class extends RpcStub$1 {
|
|
226
248
|
constructor(hook, pathIfPromise) {
|
|
227
|
-
super(hook, pathIfPromise);
|
|
249
|
+
if (hook instanceof StubHook) super(hook, pathIfPromise ?? []);
|
|
250
|
+
else {
|
|
251
|
+
if (pathIfPromise !== void 0) throw new TypeError("RpcPromise constructor expected one argument, received two.");
|
|
252
|
+
let kind = typeForRpc(hook);
|
|
253
|
+
if (kind === "rpc-promise") {
|
|
254
|
+
let raw = unwrapStubAndPath(hook);
|
|
255
|
+
if (raw.pathIfPromise.length > 0) super(raw.hook, raw.pathIfPromise);
|
|
256
|
+
else {
|
|
257
|
+
let adopted = raw.hook;
|
|
258
|
+
raw.hook = DISPOSED_HOOK;
|
|
259
|
+
super(adopted, []);
|
|
260
|
+
}
|
|
261
|
+
} else if (kind === "rpc-thenable") super(TargetStubHook.create(hook, void 0), []);
|
|
262
|
+
else {
|
|
263
|
+
let promiseHook = new PromiseStubHook(Promise.resolve(hook).then((value) => new PayloadStubHook(RpcPayload.fromAppReturn(value))));
|
|
264
|
+
promiseHook.ignoreUnhandledRejections();
|
|
265
|
+
super(promiseHook, []);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
228
268
|
}
|
|
229
269
|
then(onfulfilled, onrejected) {
|
|
230
270
|
return pullPromise(this).then(...arguments);
|
|
@@ -380,6 +420,7 @@ var RpcPayload = class RpcPayload {
|
|
|
380
420
|
case "date":
|
|
381
421
|
case "bytes":
|
|
382
422
|
case "blob":
|
|
423
|
+
case "url":
|
|
383
424
|
case "error":
|
|
384
425
|
case "undefined": return value;
|
|
385
426
|
case "array": {
|
|
@@ -513,6 +554,30 @@ var RpcPayload = class RpcPayload {
|
|
|
513
554
|
this.dispose();
|
|
514
555
|
}
|
|
515
556
|
}
|
|
557
|
+
async deliverStreamWrite(writer) {
|
|
558
|
+
try {
|
|
559
|
+
let promises = [];
|
|
560
|
+
this.deliverTo(this, "value", promises);
|
|
561
|
+
if (promises.length > 0) await Promise.all(promises);
|
|
562
|
+
let chunk = this.value[0];
|
|
563
|
+
if ((this.hooks.length > 0 || this.promises.length > 0) && chunk instanceof Object) {
|
|
564
|
+
if (!(Symbol.dispose in chunk)) Object.defineProperty(chunk, Symbol.dispose, {
|
|
565
|
+
value: () => this.dispose(),
|
|
566
|
+
writable: true,
|
|
567
|
+
enumerable: false,
|
|
568
|
+
configurable: true
|
|
569
|
+
});
|
|
570
|
+
await writer.write(chunk);
|
|
571
|
+
return RpcPayload.fromAppReturn(void 0);
|
|
572
|
+
}
|
|
573
|
+
await writer.write(chunk);
|
|
574
|
+
this.dispose();
|
|
575
|
+
return RpcPayload.fromAppReturn(void 0);
|
|
576
|
+
} catch (err) {
|
|
577
|
+
this.dispose();
|
|
578
|
+
throw err;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
516
581
|
async deliverResolve() {
|
|
517
582
|
try {
|
|
518
583
|
let promises = [];
|
|
@@ -553,6 +618,7 @@ var RpcPayload = class RpcPayload {
|
|
|
553
618
|
case "bytes":
|
|
554
619
|
case "blob":
|
|
555
620
|
case "date":
|
|
621
|
+
case "url":
|
|
556
622
|
case "error":
|
|
557
623
|
case "undefined": return;
|
|
558
624
|
case "array": {
|
|
@@ -635,6 +701,7 @@ var RpcPayload = class RpcPayload {
|
|
|
635
701
|
case "rpc-target":
|
|
636
702
|
case "writable":
|
|
637
703
|
case "readable":
|
|
704
|
+
case "url":
|
|
638
705
|
case "headers":
|
|
639
706
|
case "request":
|
|
640
707
|
case "response": return;
|
|
@@ -704,6 +771,7 @@ function followPath(value, parent, path, owner) {
|
|
|
704
771
|
case "blob":
|
|
705
772
|
case "date":
|
|
706
773
|
case "error":
|
|
774
|
+
case "url":
|
|
707
775
|
case "headers":
|
|
708
776
|
case "request":
|
|
709
777
|
case "response":
|
|
@@ -736,17 +804,22 @@ function followPath(value, parent, path, owner) {
|
|
|
736
804
|
}
|
|
737
805
|
var ValueStubHook = class extends StubHook {
|
|
738
806
|
call(path, args) {
|
|
807
|
+
let followResult;
|
|
739
808
|
try {
|
|
740
809
|
let { value, owner } = this.getValue();
|
|
741
|
-
|
|
742
|
-
if (followResult.hook) return followResult.hook.call(followResult.remainingPath, args);
|
|
743
|
-
if (typeof followResult.value != "function") throw new TypeError(`'${path.join(".")}' is not a function.`);
|
|
744
|
-
return new PromiseStubHook(args.deliverCall(followResult.value, followResult.parent).then((payload) => {
|
|
745
|
-
return new PayloadStubHook(payload);
|
|
746
|
-
}));
|
|
810
|
+
followResult = followPath(value, void 0, path, owner);
|
|
747
811
|
} catch (err) {
|
|
812
|
+
args.dispose();
|
|
748
813
|
return new ErrorStubHook(err);
|
|
749
814
|
}
|
|
815
|
+
if (followResult.hook) return followResult.hook.call(followResult.remainingPath, args);
|
|
816
|
+
if (typeof followResult.value != "function") {
|
|
817
|
+
args.dispose();
|
|
818
|
+
return new ErrorStubHook(/* @__PURE__ */ new TypeError(`'${path.join(".")}' is not a function.`));
|
|
819
|
+
}
|
|
820
|
+
return new PromiseStubHook(args.deliverCall(followResult.value, followResult.parent).then((payload) => {
|
|
821
|
+
return new PayloadStubHook(payload);
|
|
822
|
+
}));
|
|
750
823
|
}
|
|
751
824
|
map(path, captures, instructions) {
|
|
752
825
|
try {
|
|
@@ -767,7 +840,10 @@ var ValueStubHook = class extends StubHook {
|
|
|
767
840
|
get(path) {
|
|
768
841
|
try {
|
|
769
842
|
let { value, owner } = this.getValue();
|
|
770
|
-
if (path.length === 0 && owner === null)
|
|
843
|
+
if (path.length === 0 && owner === null) {
|
|
844
|
+
if (value instanceof Object && "then" in value) return this.dup();
|
|
845
|
+
throw new Error("Can't dup an RpcTarget stub as a promise.");
|
|
846
|
+
}
|
|
771
847
|
let followResult = followPath(value, void 0, path, owner);
|
|
772
848
|
if (followResult.hook) return followResult.hook.get(followResult.remainingPath);
|
|
773
849
|
return new PayloadStubHook(RpcPayload.deepCopyFrom(followResult.value, followResult.parent, followResult.owner));
|
|
@@ -870,7 +946,10 @@ var TargetStubHook = class TargetStubHook extends ValueStubHook {
|
|
|
870
946
|
this.target = void 0;
|
|
871
947
|
}
|
|
872
948
|
}
|
|
873
|
-
onBroken(callback) {
|
|
949
|
+
onBroken(callback) {
|
|
950
|
+
let target = this.target;
|
|
951
|
+
if (target && "then" in target) Promise.resolve(target).then(() => {}, callback);
|
|
952
|
+
}
|
|
874
953
|
};
|
|
875
954
|
var PromiseStubHook = class PromiseStubHook extends StubHook {
|
|
876
955
|
promise;
|
|
@@ -884,12 +963,16 @@ var PromiseStubHook = class PromiseStubHook extends StubHook {
|
|
|
884
963
|
}
|
|
885
964
|
call(path, args) {
|
|
886
965
|
args.ensureDeepCopied();
|
|
887
|
-
return new PromiseStubHook(this.promise.then((hook) => hook.call(path, args))
|
|
966
|
+
return new PromiseStubHook(this.promise.then((hook) => hook.call(path, args), (err) => {
|
|
967
|
+
args.dispose();
|
|
968
|
+
throw err;
|
|
969
|
+
}));
|
|
888
970
|
}
|
|
889
971
|
stream(path, args) {
|
|
890
972
|
args.ensureDeepCopied();
|
|
891
|
-
return { promise: this.promise.then((hook) => {
|
|
892
|
-
|
|
973
|
+
return { promise: this.promise.then((hook) => hook.stream(path, args).promise, (err) => {
|
|
974
|
+
args.dispose();
|
|
975
|
+
throw err;
|
|
893
976
|
}) };
|
|
894
977
|
}
|
|
895
978
|
map(path, captures, instructions) {
|
|
@@ -916,10 +999,7 @@ var PromiseStubHook = class PromiseStubHook extends StubHook {
|
|
|
916
999
|
}, (err) => {});
|
|
917
1000
|
}
|
|
918
1001
|
dispose() {
|
|
919
|
-
|
|
920
|
-
else this.promise.then((hook) => {
|
|
921
|
-
hook.dispose();
|
|
922
|
-
}, (err) => {});
|
|
1002
|
+
this.promise.then((hook) => hook.dispose(), () => {});
|
|
923
1003
|
}
|
|
924
1004
|
onBroken(callback) {
|
|
925
1005
|
if (this.resolution) this.resolution.onBroken(callback);
|
|
@@ -931,6 +1011,77 @@ var PromiseStubHook = class PromiseStubHook extends StubHook {
|
|
|
931
1011
|
|
|
932
1012
|
//#endregion
|
|
933
1013
|
//#region src/serialize.ts
|
|
1014
|
+
const DEFAULT_MAX_DEPTH = 256;
|
|
1015
|
+
const DEFAULT_LIMITS = {
|
|
1016
|
+
maxBigIntDigits: 16384,
|
|
1017
|
+
maxDepth: 256,
|
|
1018
|
+
maxMessageSize: 32 * 1024 * 1024
|
|
1019
|
+
};
|
|
1020
|
+
const NATIVE_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
1021
|
+
const BYTE_CONTAINER_TYPE_NAMES = [
|
|
1022
|
+
"ArrayBuffer",
|
|
1023
|
+
"DataView",
|
|
1024
|
+
"Int8Array",
|
|
1025
|
+
"Uint8Array",
|
|
1026
|
+
"Uint8ClampedArray",
|
|
1027
|
+
"Int16Array",
|
|
1028
|
+
"Uint16Array",
|
|
1029
|
+
"Int32Array",
|
|
1030
|
+
"Uint32Array",
|
|
1031
|
+
"BigInt64Array",
|
|
1032
|
+
"BigUint64Array",
|
|
1033
|
+
"Float32Array",
|
|
1034
|
+
"Float64Array"
|
|
1035
|
+
];
|
|
1036
|
+
function isValidByteContainerName(value) {
|
|
1037
|
+
return BYTE_CONTAINER_TYPE_NAMES.includes(value);
|
|
1038
|
+
}
|
|
1039
|
+
const TYPED_ARRAY_ELEMENT_SIZE = {
|
|
1040
|
+
ArrayBuffer: void 0,
|
|
1041
|
+
DataView: void 0,
|
|
1042
|
+
Int8Array: void 0,
|
|
1043
|
+
Uint8Array: void 0,
|
|
1044
|
+
Uint8ClampedArray: void 0,
|
|
1045
|
+
Int16Array: 2,
|
|
1046
|
+
Uint16Array: 2,
|
|
1047
|
+
Int32Array: 4,
|
|
1048
|
+
Uint32Array: 4,
|
|
1049
|
+
BigInt64Array: 8,
|
|
1050
|
+
BigUint64Array: 8,
|
|
1051
|
+
Float32Array: 4,
|
|
1052
|
+
Float64Array: 8
|
|
1053
|
+
};
|
|
1054
|
+
const BYTE_CONTAINER_PROTOTYPES = {
|
|
1055
|
+
ArrayBuffer: ArrayBuffer.prototype,
|
|
1056
|
+
DataView: DataView.prototype,
|
|
1057
|
+
Int8Array: Int8Array.prototype,
|
|
1058
|
+
Uint8ClampedArray: Uint8ClampedArray.prototype,
|
|
1059
|
+
Int16Array: Int16Array.prototype,
|
|
1060
|
+
Uint16Array: Uint16Array.prototype,
|
|
1061
|
+
Int32Array: Int32Array.prototype,
|
|
1062
|
+
Uint32Array: Uint32Array.prototype,
|
|
1063
|
+
BigInt64Array: BigInt64Array.prototype,
|
|
1064
|
+
BigUint64Array: BigUint64Array.prototype,
|
|
1065
|
+
Float32Array: Float32Array.prototype,
|
|
1066
|
+
Float64Array: Float64Array.prototype
|
|
1067
|
+
};
|
|
1068
|
+
const BYTE_CONTAINER_TYPE_BY_PROTOTYPE = /* @__PURE__ */ new Map();
|
|
1069
|
+
for (let type of Object.keys(BYTE_CONTAINER_PROTOTYPES)) BYTE_CONTAINER_TYPE_BY_PROTOTYPE.set(BYTE_CONTAINER_PROTOTYPES[type], type);
|
|
1070
|
+
function swapByteOrder(bytes, elementSize) {
|
|
1071
|
+
if (elementSize !== 2 && elementSize !== 4 && elementSize !== 8) throw new RangeError(`Unsupported element size: ${elementSize}`);
|
|
1072
|
+
let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1073
|
+
for (let offset = 0; offset < bytes.byteLength; offset += elementSize) switch (elementSize) {
|
|
1074
|
+
case 2:
|
|
1075
|
+
view.setUint16(offset, view.getUint16(offset, false), true);
|
|
1076
|
+
break;
|
|
1077
|
+
case 4:
|
|
1078
|
+
view.setUint32(offset, view.getUint32(offset, false), true);
|
|
1079
|
+
break;
|
|
1080
|
+
case 8:
|
|
1081
|
+
view.setBigUint64(offset, view.getBigUint64(offset, false), true);
|
|
1082
|
+
break;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
934
1085
|
var NullExporter = class {
|
|
935
1086
|
exportStub(stub) {
|
|
936
1087
|
throw new Error("Cannot serialize RPC stubs without an RPC session.");
|
|
@@ -951,6 +1102,7 @@ async function streamToBlob(stream, type) {
|
|
|
951
1102
|
return b.type === type ? b : b.slice(0, b.size, type);
|
|
952
1103
|
}
|
|
953
1104
|
const ERROR_TYPES = {
|
|
1105
|
+
__proto__: null,
|
|
954
1106
|
Error,
|
|
955
1107
|
EvalError,
|
|
956
1108
|
RangeError,
|
|
@@ -963,12 +1115,14 @@ const ERROR_TYPES = {
|
|
|
963
1115
|
var Devaluator = class Devaluator {
|
|
964
1116
|
exporter;
|
|
965
1117
|
source;
|
|
966
|
-
|
|
1118
|
+
encodingLevel;
|
|
1119
|
+
constructor(exporter, source, encodingLevel) {
|
|
967
1120
|
this.exporter = exporter;
|
|
968
1121
|
this.source = source;
|
|
1122
|
+
this.encodingLevel = encodingLevel;
|
|
969
1123
|
}
|
|
970
|
-
static devaluate(value, parent, exporter = NULL_EXPORTER, source) {
|
|
971
|
-
let devaluator = new Devaluator(exporter, source);
|
|
1124
|
+
static devaluate(value, parent, exporter = NULL_EXPORTER, source, encodingLevel = "string") {
|
|
1125
|
+
let devaluator = new Devaluator(exporter, source, encodingLevel);
|
|
972
1126
|
try {
|
|
973
1127
|
return devaluator.devaluateImpl(value, parent, 0);
|
|
974
1128
|
} catch (err) {
|
|
@@ -980,7 +1134,7 @@ var Devaluator = class Devaluator {
|
|
|
980
1134
|
}
|
|
981
1135
|
exports;
|
|
982
1136
|
devaluateImpl(value, parent, depth) {
|
|
983
|
-
if (depth >=
|
|
1137
|
+
if (depth >= 256) throw new Error("Serialization exceeded maximum allowed depth. (Does the message contain cycles?)");
|
|
984
1138
|
switch (typeForRpc(value)) {
|
|
985
1139
|
case "unsupported": {
|
|
986
1140
|
let msg;
|
|
@@ -991,10 +1145,12 @@ var Devaluator = class Devaluator {
|
|
|
991
1145
|
}
|
|
992
1146
|
throw new TypeError(msg);
|
|
993
1147
|
}
|
|
994
|
-
case "primitive": if (typeof value === "number" && !isFinite(value))
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1148
|
+
case "primitive": if (typeof value === "number" && !isFinite(value)) {
|
|
1149
|
+
if (this.encodingLevel === "structuredClonable") return value;
|
|
1150
|
+
if (value === Infinity) return ["inf"];
|
|
1151
|
+
else if (value === -Infinity) return ["-inf"];
|
|
1152
|
+
else return ["nan"];
|
|
1153
|
+
} else return value;
|
|
998
1154
|
case "object": {
|
|
999
1155
|
let object = value;
|
|
1000
1156
|
let result = {};
|
|
@@ -1008,23 +1164,49 @@ var Devaluator = class Devaluator {
|
|
|
1008
1164
|
for (let i = 0; i < len; i++) result[i] = this.devaluateImpl(array[i], array, depth + 1);
|
|
1009
1165
|
return [result];
|
|
1010
1166
|
}
|
|
1011
|
-
case "bigint":
|
|
1167
|
+
case "bigint":
|
|
1168
|
+
if (this.encodingLevel === "structuredClonable") return value;
|
|
1169
|
+
return ["bigint", value.toString()];
|
|
1012
1170
|
case "date": {
|
|
1171
|
+
if (this.encodingLevel === "structuredClonable") return value;
|
|
1013
1172
|
const time = value.getTime();
|
|
1014
1173
|
return ["date", Number.isNaN(time) ? null : time];
|
|
1015
1174
|
}
|
|
1016
1175
|
case "bytes": {
|
|
1017
|
-
let
|
|
1018
|
-
|
|
1176
|
+
let alternateTypeName = BYTE_CONTAINER_TYPE_BY_PROTOTYPE.get(Object.getPrototypeOf(value));
|
|
1177
|
+
let bytes;
|
|
1178
|
+
if (alternateTypeName === "ArrayBuffer") bytes = new Uint8Array(value);
|
|
1179
|
+
else if (alternateTypeName === void 0) bytes = value;
|
|
1180
|
+
else {
|
|
1181
|
+
let view = value;
|
|
1182
|
+
bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
|
|
1183
|
+
let elementSize = TYPED_ARRAY_ELEMENT_SIZE[alternateTypeName];
|
|
1184
|
+
if (!NATIVE_LITTLE_ENDIAN && elementSize) {
|
|
1185
|
+
bytes = bytes.slice();
|
|
1186
|
+
swapByteOrder(bytes, elementSize);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (this.encodingLevel === "structuredClonable" || this.encodingLevel === "jsonCompatibleWithBytes") return alternateTypeName === void 0 ? ["bytes", bytes] : [
|
|
1190
|
+
"bytes",
|
|
1191
|
+
bytes,
|
|
1192
|
+
alternateTypeName
|
|
1193
|
+
];
|
|
1019
1194
|
let b64;
|
|
1020
|
-
if (
|
|
1195
|
+
if (bytes.toBase64) b64 = bytes.toBase64({ omitPadding: true });
|
|
1196
|
+
else if (typeof Buffer !== "undefined") b64 = (bytes instanceof Buffer ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)).toString("base64");
|
|
1021
1197
|
else {
|
|
1022
1198
|
let binary = "";
|
|
1023
1199
|
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
1024
1200
|
b64 = btoa(binary);
|
|
1025
1201
|
}
|
|
1026
|
-
|
|
1202
|
+
b64 = b64.replace(/=+$/, "");
|
|
1203
|
+
return alternateTypeName === void 0 ? ["bytes", b64] : [
|
|
1204
|
+
"bytes",
|
|
1205
|
+
b64,
|
|
1206
|
+
alternateTypeName
|
|
1207
|
+
];
|
|
1027
1208
|
}
|
|
1209
|
+
case "url": return ["url", value.href];
|
|
1028
1210
|
case "headers": return ["headers", [...value]];
|
|
1029
1211
|
case "request": {
|
|
1030
1212
|
let req = value;
|
|
@@ -1139,7 +1321,9 @@ var Devaluator = class Devaluator {
|
|
|
1139
1321
|
} else if (rewritten && rewritten.stack) result.push(rewritten.stack);
|
|
1140
1322
|
return result;
|
|
1141
1323
|
}
|
|
1142
|
-
case "undefined":
|
|
1324
|
+
case "undefined":
|
|
1325
|
+
if (this.encodingLevel === "structuredClonable") return;
|
|
1326
|
+
return ["undefined"];
|
|
1143
1327
|
case "stub":
|
|
1144
1328
|
case "rpc-promise": {
|
|
1145
1329
|
if (!this.source) throw new Error("Can't serialize RPC stubs in this context.");
|
|
@@ -1206,6 +1390,9 @@ var NullImporter = class {
|
|
|
1206
1390
|
getPipeReadable(exportId) {
|
|
1207
1391
|
throw new Error("Cannot retrieve pipe readable without an RPC session.");
|
|
1208
1392
|
}
|
|
1393
|
+
getLimits() {
|
|
1394
|
+
return DEFAULT_LIMITS;
|
|
1395
|
+
}
|
|
1209
1396
|
};
|
|
1210
1397
|
const NULL_IMPORTER = new NullImporter();
|
|
1211
1398
|
function fixBrokenRequestBody(request, body) {
|
|
@@ -1222,15 +1409,22 @@ function streamToBlobPromise(stream, type) {
|
|
|
1222
1409
|
}
|
|
1223
1410
|
var Evaluator = class Evaluator {
|
|
1224
1411
|
importer;
|
|
1225
|
-
|
|
1412
|
+
encodingLevel;
|
|
1413
|
+
limits;
|
|
1414
|
+
constructor(importer, encodingLevel = "string") {
|
|
1226
1415
|
this.importer = importer;
|
|
1416
|
+
this.encodingLevel = encodingLevel;
|
|
1417
|
+
this.limits = importer.getLimits();
|
|
1227
1418
|
}
|
|
1228
1419
|
hooks = [];
|
|
1229
1420
|
promises = [];
|
|
1230
1421
|
evaluate(value) {
|
|
1422
|
+
return this.evaluateWithDepth(value, 0);
|
|
1423
|
+
}
|
|
1424
|
+
evaluateWithDepth(value, depth) {
|
|
1231
1425
|
let payload = RpcPayload.forEvaluate(this.hooks, this.promises);
|
|
1232
1426
|
try {
|
|
1233
|
-
payload.value = this.evaluateImpl(value, payload, "value");
|
|
1427
|
+
payload.value = this.evaluateImpl(value, payload, "value", depth);
|
|
1234
1428
|
return payload;
|
|
1235
1429
|
} catch (err) {
|
|
1236
1430
|
payload.dispose();
|
|
@@ -1240,31 +1434,70 @@ var Evaluator = class Evaluator {
|
|
|
1240
1434
|
evaluateCopy(value) {
|
|
1241
1435
|
return this.evaluate(structuredClone(value));
|
|
1242
1436
|
}
|
|
1243
|
-
evaluateImpl(value, parent, property) {
|
|
1437
|
+
evaluateImpl(value, parent, property, depth) {
|
|
1438
|
+
let maxDepth = this.limits.maxDepth;
|
|
1439
|
+
if (depth >= maxDepth) throw new TypeError(`Deserialization exceeded maximum allowed message depth of ${maxDepth}.`);
|
|
1440
|
+
if (this.encodingLevel === "structuredClonable") {
|
|
1441
|
+
if (value instanceof Date || typeof value === "bigint") return value;
|
|
1442
|
+
}
|
|
1244
1443
|
if (value instanceof Array) {
|
|
1245
1444
|
if (value.length == 1 && value[0] instanceof Array) {
|
|
1246
1445
|
let result = value[0];
|
|
1247
|
-
for (let i = 0; i < result.length; i++) result[i] = this.evaluateImpl(result[i], result, i);
|
|
1446
|
+
for (let i = 0; i < result.length; i++) result[i] = this.evaluateImpl(result[i], result, i, depth + 1);
|
|
1248
1447
|
return result;
|
|
1249
1448
|
} else switch (value[0]) {
|
|
1250
1449
|
case "bigint":
|
|
1251
|
-
if (typeof value[1] == "string")
|
|
1450
|
+
if (typeof value[1] == "string") {
|
|
1451
|
+
let digits = value[1];
|
|
1452
|
+
let maxBigIntDigits = this.limits.maxBigIntDigits;
|
|
1453
|
+
if (digits.length > maxBigIntDigits) throw new TypeError(`Deserialized bigint exceeds maximum length of ${maxBigIntDigits} digits.`);
|
|
1454
|
+
return BigInt(digits);
|
|
1455
|
+
}
|
|
1252
1456
|
break;
|
|
1253
1457
|
case "date":
|
|
1254
1458
|
if (value[1] === null) return /* @__PURE__ */ new Date(NaN);
|
|
1255
1459
|
if (typeof value[1] == "number") return new Date(value[1]);
|
|
1256
1460
|
break;
|
|
1257
|
-
case "bytes":
|
|
1258
|
-
|
|
1259
|
-
|
|
1461
|
+
case "bytes": {
|
|
1462
|
+
let bytes;
|
|
1463
|
+
if (value[1] instanceof Uint8Array) bytes = value[1];
|
|
1464
|
+
else if (typeof value[1] == "string") if (typeof Buffer !== "undefined") bytes = Buffer.from(value[1], "base64");
|
|
1465
|
+
else if (Uint8Array.fromBase64) bytes = Uint8Array.fromBase64(value[1]);
|
|
1260
1466
|
else {
|
|
1261
1467
|
let bs = atob(value[1]);
|
|
1262
1468
|
let len = bs.length;
|
|
1263
|
-
|
|
1469
|
+
bytes = new Uint8Array(len);
|
|
1264
1470
|
for (let i = 0; i < len; i++) bytes[i] = bs.charCodeAt(i);
|
|
1265
|
-
return bytes;
|
|
1266
1471
|
}
|
|
1267
|
-
break;
|
|
1472
|
+
else break;
|
|
1473
|
+
if (value.length === 2) return bytes;
|
|
1474
|
+
if (typeof value[2] !== "string") throw new TypeError(`Unknown bytes type marker type: ${typeof value[2]}`);
|
|
1475
|
+
if (!isValidByteContainerName(value[2])) {
|
|
1476
|
+
let marker = value[2].slice(0, 64);
|
|
1477
|
+
throw new TypeError(`Unknown bytes type marker: ${marker}`);
|
|
1478
|
+
}
|
|
1479
|
+
let marker = value[2];
|
|
1480
|
+
let elementSize = TYPED_ARRAY_ELEMENT_SIZE[marker];
|
|
1481
|
+
if (elementSize !== void 0 && bytes.byteLength % elementSize !== 0) throw new TypeError(`Invalid byte length ${bytes.byteLength} for ${marker}; expected a multiple of ${elementSize}`);
|
|
1482
|
+
let buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
1483
|
+
if (!NATIVE_LITTLE_ENDIAN && elementSize !== void 0) swapByteOrder(new Uint8Array(buffer), elementSize);
|
|
1484
|
+
switch (marker) {
|
|
1485
|
+
case "ArrayBuffer": return buffer;
|
|
1486
|
+
case "DataView": return new DataView(buffer);
|
|
1487
|
+
case "Int8Array": return new Int8Array(buffer);
|
|
1488
|
+
case "Uint8Array": return new Uint8Array(buffer);
|
|
1489
|
+
case "Uint8ClampedArray": return new Uint8ClampedArray(buffer);
|
|
1490
|
+
case "Int16Array": return new Int16Array(buffer);
|
|
1491
|
+
case "Uint16Array": return new Uint16Array(buffer);
|
|
1492
|
+
case "Int32Array": return new Int32Array(buffer);
|
|
1493
|
+
case "Uint32Array": return new Uint32Array(buffer);
|
|
1494
|
+
case "BigInt64Array": return new BigInt64Array(buffer);
|
|
1495
|
+
case "BigUint64Array": return new BigUint64Array(buffer);
|
|
1496
|
+
case "Float32Array": return new Float32Array(buffer);
|
|
1497
|
+
case "Float64Array": return new Float64Array(buffer);
|
|
1498
|
+
default:
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1268
1501
|
case "error":
|
|
1269
1502
|
if (value.length >= 3 && typeof value[1] === "string" && typeof value[2] === "string") {
|
|
1270
1503
|
let cls = ERROR_TYPES[value[1]] || Error;
|
|
@@ -1277,7 +1510,11 @@ var Evaluator = class Evaluator {
|
|
|
1277
1510
|
let propsObj = props;
|
|
1278
1511
|
for (let key of Object.keys(propsObj)) {
|
|
1279
1512
|
if (key === "name" || key === "message" || key === "stack") continue;
|
|
1280
|
-
|
|
1513
|
+
if (key in Object.prototype || key === "toJSON") {
|
|
1514
|
+
this.evaluateImpl(propsObj[key], result, key, depth + 1);
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
anyResult[key] = this.evaluateImpl(propsObj[key], result, key, depth + 1);
|
|
1281
1518
|
}
|
|
1282
1519
|
}
|
|
1283
1520
|
return result;
|
|
@@ -1289,6 +1526,9 @@ var Evaluator = class Evaluator {
|
|
|
1289
1526
|
case "inf": return Infinity;
|
|
1290
1527
|
case "-inf": return -Infinity;
|
|
1291
1528
|
case "nan": return NaN;
|
|
1529
|
+
case "url":
|
|
1530
|
+
if (value.length === 2 && typeof value[1] === "string") return new URL(value[1]);
|
|
1531
|
+
break;
|
|
1292
1532
|
case "headers":
|
|
1293
1533
|
if (value.length === 2 && value[1] instanceof Array) return new Headers(value[1]);
|
|
1294
1534
|
break;
|
|
@@ -1298,11 +1538,11 @@ var Evaluator = class Evaluator {
|
|
|
1298
1538
|
let init = value[2];
|
|
1299
1539
|
if (typeof init !== "object" || init === null) break;
|
|
1300
1540
|
if (init.body) {
|
|
1301
|
-
init.body = this.evaluateImpl(init.body, init, "body");
|
|
1541
|
+
init.body = this.evaluateImpl(init.body, init, "body", depth + 1);
|
|
1302
1542
|
if (init.body === null || typeof init.body === "string" || init.body instanceof Uint8Array || init.body instanceof ReadableStream) {} else throw new TypeError("Request body must be of type ReadableStream.");
|
|
1303
1543
|
}
|
|
1304
1544
|
if (init.signal) {
|
|
1305
|
-
init.signal = this.evaluateImpl(init.signal, init, "signal");
|
|
1545
|
+
init.signal = this.evaluateImpl(init.signal, init, "signal", depth + 1);
|
|
1306
1546
|
if (!(init.signal instanceof AbortSignal)) throw new TypeError("Request siganl must be of type AbortSignal.");
|
|
1307
1547
|
}
|
|
1308
1548
|
if (init.headers && !(init.headers instanceof Array)) throw new TypeError("Request headers must be serialized as an array of pairs.");
|
|
@@ -1319,7 +1559,7 @@ var Evaluator = class Evaluator {
|
|
|
1319
1559
|
}
|
|
1320
1560
|
case "response": {
|
|
1321
1561
|
if (value.length !== 3) break;
|
|
1322
|
-
let body = this.evaluateImpl(value[1], parent, property);
|
|
1562
|
+
let body = this.evaluateImpl(value[1], parent, property, depth + 1);
|
|
1323
1563
|
if (body === null || typeof body === "string" || body instanceof Uint8Array || body instanceof ReadableStream) {} else throw new TypeError("Response body must be of type ReadableStream.");
|
|
1324
1564
|
let init = value[2];
|
|
1325
1565
|
if (typeof init !== "object" || init === null) break;
|
|
@@ -1330,7 +1570,7 @@ var Evaluator = class Evaluator {
|
|
|
1330
1570
|
case "blob": {
|
|
1331
1571
|
if (value.length !== 3 || typeof value[1] !== "string") break;
|
|
1332
1572
|
let contentType = value[1];
|
|
1333
|
-
let content = this.evaluateImpl(value[2], parent, property);
|
|
1573
|
+
let content = this.evaluateImpl(value[2], parent, property, depth + 1);
|
|
1334
1574
|
if (!(content instanceof ReadableStream)) throw new TypeError("Blob content must be serialized as a ReadableStream.");
|
|
1335
1575
|
let promise = streamToBlobPromise(content, contentType);
|
|
1336
1576
|
this.promises.push({
|
|
@@ -1371,7 +1611,7 @@ var Evaluator = class Evaluator {
|
|
|
1371
1611
|
if (value.length == 3) return addStub(hook.get(path));
|
|
1372
1612
|
let args = value[3];
|
|
1373
1613
|
if (!(args instanceof Array)) break;
|
|
1374
|
-
args = new Evaluator(this.importer).
|
|
1614
|
+
args = new Evaluator(this.importer).evaluateWithDepth([args], depth);
|
|
1375
1615
|
return addStub(hook.call(path, args));
|
|
1376
1616
|
}
|
|
1377
1617
|
case "remap": {
|
|
@@ -1437,9 +1677,9 @@ var Evaluator = class Evaluator {
|
|
|
1437
1677
|
} else if (value instanceof Object) {
|
|
1438
1678
|
let result = value;
|
|
1439
1679
|
for (let key in result) if (key in Object.prototype || key === "toJSON") {
|
|
1440
|
-
this.evaluateImpl(result[key], result, key);
|
|
1680
|
+
this.evaluateImpl(result[key], result, key, depth + 1);
|
|
1441
1681
|
delete result[key];
|
|
1442
|
-
} else result[key] = this.evaluateImpl(result[key], result, key);
|
|
1682
|
+
} else result[key] = this.evaluateImpl(result[key], result, key, depth + 1);
|
|
1443
1683
|
return result;
|
|
1444
1684
|
} else return value;
|
|
1445
1685
|
}
|
|
@@ -1455,6 +1695,47 @@ function deserialize(value) {
|
|
|
1455
1695
|
|
|
1456
1696
|
//#endregion
|
|
1457
1697
|
//#region src/rpc.ts
|
|
1698
|
+
const ESTIMATED_OBJECT_OVERHEAD = 16;
|
|
1699
|
+
const ESTIMATED_ENTRY_OVERHEAD = 8;
|
|
1700
|
+
const ESTIMATED_BINARY_OVERHEAD = 16;
|
|
1701
|
+
const MAX_ESTIMATE_DEPTH = 64;
|
|
1702
|
+
function estimateStringSize(value) {
|
|
1703
|
+
return 2 + value.length * 3;
|
|
1704
|
+
}
|
|
1705
|
+
function estimateEncodedSize(value, seen, depth = 0) {
|
|
1706
|
+
if (depth >= MAX_ESTIMATE_DEPTH) return ESTIMATED_ENTRY_OVERHEAD;
|
|
1707
|
+
switch (typeof value) {
|
|
1708
|
+
case "string": return estimateStringSize(value);
|
|
1709
|
+
case "number": return 16;
|
|
1710
|
+
case "bigint": return 16;
|
|
1711
|
+
case "boolean": return 8;
|
|
1712
|
+
case "undefined": return 16;
|
|
1713
|
+
case "object": {
|
|
1714
|
+
if (value === null) return 8;
|
|
1715
|
+
if (ArrayBuffer.isView(value)) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;
|
|
1716
|
+
if (value instanceof ArrayBuffer) return ESTIMATED_BINARY_OVERHEAD + value.byteLength;
|
|
1717
|
+
if (typeof Blob !== "undefined" && value instanceof Blob) return ESTIMATED_BINARY_OVERHEAD + value.size;
|
|
1718
|
+
if (value instanceof Date) return 16;
|
|
1719
|
+
seen ??= /* @__PURE__ */ new WeakSet();
|
|
1720
|
+
if (seen.has(value)) return ESTIMATED_ENTRY_OVERHEAD;
|
|
1721
|
+
seen.add(value);
|
|
1722
|
+
if (value instanceof Array) {
|
|
1723
|
+
let size = ESTIMATED_OBJECT_OVERHEAD;
|
|
1724
|
+
for (let item of value) size += ESTIMATED_ENTRY_OVERHEAD + estimateEncodedSize(item, seen, depth + 1);
|
|
1725
|
+
return size;
|
|
1726
|
+
}
|
|
1727
|
+
if (value instanceof Error) {
|
|
1728
|
+
let size = ESTIMATED_OBJECT_OVERHEAD + estimateStringSize(value.name) + estimateStringSize(value.message) + estimateStringSize(value.stack ?? "");
|
|
1729
|
+
for (let key of Object.keys(value)) size += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);
|
|
1730
|
+
return size;
|
|
1731
|
+
}
|
|
1732
|
+
let size = ESTIMATED_OBJECT_OVERHEAD;
|
|
1733
|
+
for (let key of Object.keys(value)) size += ESTIMATED_ENTRY_OVERHEAD + estimateStringSize(key) + estimateEncodedSize(value[key], seen, depth + 1);
|
|
1734
|
+
return size;
|
|
1735
|
+
}
|
|
1736
|
+
default: return 16;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1458
1739
|
var ImportTableEntry = class {
|
|
1459
1740
|
session;
|
|
1460
1741
|
importId;
|
|
@@ -1547,24 +1828,28 @@ var RpcImportHook = class RpcImportHook extends StubHook {
|
|
|
1547
1828
|
if (this.entry) return this.entry;
|
|
1548
1829
|
else throw new Error("This RpcImportHook was already disposed.");
|
|
1549
1830
|
}
|
|
1831
|
+
getEntryTakingOwnership(disposeOwned) {
|
|
1832
|
+
try {
|
|
1833
|
+
return this.getEntry();
|
|
1834
|
+
} catch (err) {
|
|
1835
|
+
disposeOwned();
|
|
1836
|
+
throw err;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1550
1839
|
call(path, args) {
|
|
1551
|
-
let entry = this.
|
|
1840
|
+
let entry = this.getEntryTakingOwnership(() => args.dispose());
|
|
1552
1841
|
if (entry.resolution) return entry.resolution.call(path, args);
|
|
1553
1842
|
else return entry.session.sendCall(entry.importId, path, args);
|
|
1554
1843
|
}
|
|
1555
1844
|
stream(path, args) {
|
|
1556
|
-
let entry = this.
|
|
1845
|
+
let entry = this.getEntryTakingOwnership(() => args.dispose());
|
|
1557
1846
|
if (entry.resolution) return entry.resolution.stream(path, args);
|
|
1558
1847
|
else return entry.session.sendStream(entry.importId, path, args);
|
|
1559
1848
|
}
|
|
1560
1849
|
map(path, captures, instructions) {
|
|
1561
|
-
let entry
|
|
1562
|
-
try {
|
|
1563
|
-
entry = this.getEntry();
|
|
1564
|
-
} catch (err) {
|
|
1850
|
+
let entry = this.getEntryTakingOwnership(() => {
|
|
1565
1851
|
for (let cap of captures) cap.dispose();
|
|
1566
|
-
|
|
1567
|
-
}
|
|
1852
|
+
});
|
|
1568
1853
|
if (entry.resolution) return entry.resolution.map(path, captures, instructions);
|
|
1569
1854
|
else return entry.session.sendMap(entry.importId, path, captures, instructions);
|
|
1570
1855
|
}
|
|
@@ -1620,9 +1905,24 @@ var RpcSessionImpl = class {
|
|
|
1620
1905
|
onBatchDone;
|
|
1621
1906
|
pullCount = 0;
|
|
1622
1907
|
onBrokenCallbacks = [];
|
|
1908
|
+
encodingLevel;
|
|
1909
|
+
limits;
|
|
1623
1910
|
constructor(transport, mainHook, options) {
|
|
1624
1911
|
this.transport = transport;
|
|
1625
1912
|
this.options = options;
|
|
1913
|
+
let level = "string";
|
|
1914
|
+
if ("encodingLevel" in transport) {
|
|
1915
|
+
let raw = transport.encodingLevel;
|
|
1916
|
+
if (raw !== void 0) {
|
|
1917
|
+
if (raw !== "string" && raw !== "jsonCompatible" && raw !== "jsonCompatibleWithBytes" && raw !== "structuredClonable") throw new TypeError(`Unknown transport encodingLevel: ${String(raw)}`);
|
|
1918
|
+
level = raw;
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
this.encodingLevel = level;
|
|
1922
|
+
this.limits = {
|
|
1923
|
+
...DEFAULT_LIMITS,
|
|
1924
|
+
...options.limits
|
|
1925
|
+
};
|
|
1626
1926
|
this.exports.push({
|
|
1627
1927
|
hook: mainHook,
|
|
1628
1928
|
refcount: 1
|
|
@@ -1703,7 +2003,7 @@ var RpcSessionImpl = class {
|
|
|
1703
2003
|
let autoRelease = exp.autoRelease;
|
|
1704
2004
|
++this.pullCount;
|
|
1705
2005
|
exp.pull = resolve().then((payload) => {
|
|
1706
|
-
let value = Devaluator.devaluate(payload.value, void 0, this, payload);
|
|
2006
|
+
let value = Devaluator.devaluate(payload.value, void 0, this, payload, this.encodingLevel);
|
|
1707
2007
|
this.send([
|
|
1708
2008
|
"resolve",
|
|
1709
2009
|
exportId,
|
|
@@ -1714,7 +2014,7 @@ var RpcSessionImpl = class {
|
|
|
1714
2014
|
this.send([
|
|
1715
2015
|
"reject",
|
|
1716
2016
|
exportId,
|
|
1717
|
-
Devaluator.devaluate(error, void 0, this)
|
|
2017
|
+
Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)
|
|
1718
2018
|
]);
|
|
1719
2019
|
if (autoRelease) this.releaseExport(exportId, 1);
|
|
1720
2020
|
}).catch((error) => {
|
|
@@ -1722,7 +2022,7 @@ var RpcSessionImpl = class {
|
|
|
1722
2022
|
this.send([
|
|
1723
2023
|
"reject",
|
|
1724
2024
|
exportId,
|
|
1725
|
-
Devaluator.devaluate(error, void 0, this)
|
|
2025
|
+
Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)
|
|
1726
2026
|
]);
|
|
1727
2027
|
if (autoRelease) this.releaseExport(exportId, 1);
|
|
1728
2028
|
} catch (error2) {
|
|
@@ -1765,6 +2065,9 @@ var RpcSessionImpl = class {
|
|
|
1765
2065
|
entry.pipeReadable = void 0;
|
|
1766
2066
|
return readable;
|
|
1767
2067
|
}
|
|
2068
|
+
getLimits() {
|
|
2069
|
+
return this.limits;
|
|
2070
|
+
}
|
|
1768
2071
|
createPipe(readable, readableHook) {
|
|
1769
2072
|
if (this.abortReason) throw this.abortReason;
|
|
1770
2073
|
this.send(["pipe"]);
|
|
@@ -1778,27 +2081,52 @@ var RpcSessionImpl = class {
|
|
|
1778
2081
|
}
|
|
1779
2082
|
send(msg) {
|
|
1780
2083
|
if (this.abortReason !== void 0) return 0;
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
msgText = JSON.stringify(msg);
|
|
1784
|
-
} catch (err) {
|
|
2084
|
+
if (this.encodingLevel === "string") {
|
|
2085
|
+
let msgText;
|
|
1785
2086
|
try {
|
|
1786
|
-
|
|
1787
|
-
} catch (
|
|
1788
|
-
|
|
2087
|
+
msgText = JSON.stringify(msg);
|
|
2088
|
+
} catch (err) {
|
|
2089
|
+
try {
|
|
2090
|
+
this.abort(err);
|
|
2091
|
+
} catch (err2) {}
|
|
2092
|
+
throw err;
|
|
2093
|
+
}
|
|
2094
|
+
try {
|
|
2095
|
+
let sent = this.transport.send(msgText);
|
|
2096
|
+
if (sent !== void 0 && typeof sent.catch === "function") sent.catch((err) => this.abort(err, false));
|
|
2097
|
+
} catch (err) {
|
|
2098
|
+
queueMicrotask(() => this.abort(err, false));
|
|
2099
|
+
}
|
|
2100
|
+
return msgText.length;
|
|
2101
|
+
} else try {
|
|
2102
|
+
let size = this.transport.send(msg);
|
|
2103
|
+
if (typeof size === "number") return size;
|
|
2104
|
+
let thenable = size;
|
|
2105
|
+
if (thenable && typeof thenable.then === "function") Promise.resolve(thenable).catch((err) => this.abort(err, false));
|
|
2106
|
+
return;
|
|
2107
|
+
} catch (err) {
|
|
2108
|
+
queueMicrotask(() => this.abort(err, false));
|
|
2109
|
+
return;
|
|
1789
2110
|
}
|
|
1790
|
-
this.transport.send(msgText).catch((err) => this.abort(err, false));
|
|
1791
|
-
return msgText.length;
|
|
1792
2111
|
}
|
|
1793
2112
|
sendCall(id, path, args) {
|
|
1794
|
-
if (this.abortReason)
|
|
2113
|
+
if (this.abortReason) {
|
|
2114
|
+
args?.dispose();
|
|
2115
|
+
throw this.abortReason;
|
|
2116
|
+
}
|
|
1795
2117
|
let value = [
|
|
1796
2118
|
"pipeline",
|
|
1797
2119
|
id,
|
|
1798
2120
|
path
|
|
1799
2121
|
];
|
|
1800
2122
|
if (args) {
|
|
1801
|
-
let devalue
|
|
2123
|
+
let devalue;
|
|
2124
|
+
try {
|
|
2125
|
+
devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);
|
|
2126
|
+
} catch (err) {
|
|
2127
|
+
args.dispose();
|
|
2128
|
+
throw err;
|
|
2129
|
+
}
|
|
1802
2130
|
value.push(devalue[0]);
|
|
1803
2131
|
}
|
|
1804
2132
|
this.send(["push", value]);
|
|
@@ -1807,15 +2135,26 @@ var RpcSessionImpl = class {
|
|
|
1807
2135
|
return new RpcImportHook(true, entry);
|
|
1808
2136
|
}
|
|
1809
2137
|
sendStream(id, path, args) {
|
|
1810
|
-
if (this.abortReason)
|
|
2138
|
+
if (this.abortReason) {
|
|
2139
|
+
args.dispose();
|
|
2140
|
+
throw this.abortReason;
|
|
2141
|
+
}
|
|
1811
2142
|
let value = [
|
|
1812
2143
|
"pipeline",
|
|
1813
2144
|
id,
|
|
1814
2145
|
path
|
|
1815
2146
|
];
|
|
1816
|
-
let devalue
|
|
2147
|
+
let devalue;
|
|
2148
|
+
try {
|
|
2149
|
+
devalue = Devaluator.devaluate(args.value, void 0, this, args, this.encodingLevel);
|
|
2150
|
+
} catch (err) {
|
|
2151
|
+
args.dispose();
|
|
2152
|
+
throw err;
|
|
2153
|
+
}
|
|
1817
2154
|
value.push(devalue[0]);
|
|
1818
|
-
let
|
|
2155
|
+
let msg = ["stream", value];
|
|
2156
|
+
let size = this.send(msg);
|
|
2157
|
+
if (size === void 0) size = estimateEncodedSize(msg);
|
|
1819
2158
|
let importId = this.imports.length;
|
|
1820
2159
|
let entry = new ImportTableEntry(this, importId, true);
|
|
1821
2160
|
entry.remoteRefcount = 0;
|
|
@@ -1871,7 +2210,14 @@ var RpcSessionImpl = class {
|
|
|
1871
2210
|
this.cancelReadLoop?.(error);
|
|
1872
2211
|
this.cancelReadLoop = void 0;
|
|
1873
2212
|
if (trySendAbortMessage) try {
|
|
1874
|
-
|
|
2213
|
+
let abortMsg = ["abort", Devaluator.devaluate(error, void 0, this, void 0, this.encodingLevel)];
|
|
2214
|
+
if (this.encodingLevel === "string") {
|
|
2215
|
+
let sent = this.transport.send(JSON.stringify(abortMsg));
|
|
2216
|
+
if (sent !== void 0 && typeof sent.catch === "function") sent.catch((err) => {});
|
|
2217
|
+
} else {
|
|
2218
|
+
let result = this.transport.send(abortMsg);
|
|
2219
|
+
if (result && typeof result.then === "function") Promise.resolve(result).catch((err) => {});
|
|
2220
|
+
}
|
|
1875
2221
|
} catch (err) {}
|
|
1876
2222
|
if (error === void 0) error = "undefined";
|
|
1877
2223
|
this.abortReason = error;
|
|
@@ -1893,18 +2239,19 @@ var RpcSessionImpl = class {
|
|
|
1893
2239
|
while (!this.abortReason) {
|
|
1894
2240
|
let readCanceled = Promise.withResolvers();
|
|
1895
2241
|
this.cancelReadLoop = readCanceled.reject;
|
|
1896
|
-
let
|
|
2242
|
+
let raw;
|
|
1897
2243
|
try {
|
|
1898
|
-
|
|
2244
|
+
raw = await Promise.race([this.transport.receive(), readCanceled.promise]);
|
|
1899
2245
|
} finally {
|
|
1900
2246
|
if (this.cancelReadLoop === readCanceled.reject) this.cancelReadLoop = void 0;
|
|
1901
2247
|
}
|
|
1902
|
-
|
|
2248
|
+
if (this.encodingLevel === "string" && raw.length > this.limits.maxMessageSize) throw new TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);
|
|
1903
2249
|
if (this.abortReason) break;
|
|
2250
|
+
let msg = this.encodingLevel === "string" ? JSON.parse(raw) : raw;
|
|
1904
2251
|
if (msg instanceof Array) switch (msg[0]) {
|
|
1905
2252
|
case "push":
|
|
1906
2253
|
if (msg.length > 1) {
|
|
1907
|
-
let hook = new PayloadStubHook(new Evaluator(this).evaluate(msg[1]));
|
|
2254
|
+
let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));
|
|
1908
2255
|
hook.ignoreUnhandledRejections();
|
|
1909
2256
|
this.exports.push({
|
|
1910
2257
|
hook,
|
|
@@ -1915,7 +2262,7 @@ var RpcSessionImpl = class {
|
|
|
1915
2262
|
break;
|
|
1916
2263
|
case "stream":
|
|
1917
2264
|
if (msg.length > 1) {
|
|
1918
|
-
let hook = new PayloadStubHook(new Evaluator(this).evaluate(msg[1]));
|
|
2265
|
+
let hook = new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[1]));
|
|
1919
2266
|
hook.ignoreUnhandledRejections();
|
|
1920
2267
|
let exportId = this.exports.length;
|
|
1921
2268
|
this.exports.push({
|
|
@@ -1950,13 +2297,13 @@ var RpcSessionImpl = class {
|
|
|
1950
2297
|
let importId = msg[1];
|
|
1951
2298
|
if (typeof importId == "number" && msg.length > 2) {
|
|
1952
2299
|
let imp = this.imports[importId];
|
|
1953
|
-
if (imp) if (msg[0] == "resolve") imp.resolve(new PayloadStubHook(new Evaluator(this).evaluate(msg[2])));
|
|
2300
|
+
if (imp) if (msg[0] == "resolve") imp.resolve(new PayloadStubHook(new Evaluator(this, this.encodingLevel).evaluate(msg[2])));
|
|
1954
2301
|
else {
|
|
1955
|
-
let payload = new Evaluator(this).evaluate(msg[2]);
|
|
2302
|
+
let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[2]);
|
|
1956
2303
|
payload.dispose();
|
|
1957
2304
|
imp.resolve(new ErrorStubHook(payload.value));
|
|
1958
2305
|
}
|
|
1959
|
-
else if (msg[0] == "resolve") new Evaluator(this).evaluate(msg[2]).dispose();
|
|
2306
|
+
else if (msg[0] == "resolve") new Evaluator(this, this.encodingLevel).evaluate(msg[2]).dispose();
|
|
1960
2307
|
continue;
|
|
1961
2308
|
}
|
|
1962
2309
|
break;
|
|
@@ -1971,9 +2318,9 @@ var RpcSessionImpl = class {
|
|
|
1971
2318
|
break;
|
|
1972
2319
|
}
|
|
1973
2320
|
case "abort": {
|
|
1974
|
-
let payload = new Evaluator(this).evaluate(msg[1]);
|
|
2321
|
+
let payload = new Evaluator(this, this.encodingLevel).evaluate(msg[1]);
|
|
1975
2322
|
payload.dispose();
|
|
1976
|
-
this.abort(payload, false);
|
|
2323
|
+
this.abort(payload.value, false);
|
|
1977
2324
|
break;
|
|
1978
2325
|
}
|
|
1979
2326
|
}
|
|
@@ -2024,6 +2371,8 @@ var RpcSession$1 = class {
|
|
|
2024
2371
|
|
|
2025
2372
|
//#endregion
|
|
2026
2373
|
//#region src/websocket.ts
|
|
2374
|
+
/** Close-frame reason max UTF-8 bytes: 125 payload - 2-byte status (RFC 6455 section 5.5). */
|
|
2375
|
+
const MAX_CLOSE_REASON_BYTES = 123;
|
|
2027
2376
|
function newWebSocketRpcSession$1(webSocket, localMain, options) {
|
|
2028
2377
|
if (typeof webSocket === "string") webSocket = new WebSocket(webSocket);
|
|
2029
2378
|
return new RpcSession$1(new WebSocketTransport(webSocket), localMain, options).getRemoteMain();
|
|
@@ -2043,9 +2392,14 @@ function newWorkersWebSocketRpcResponse(request, localMain, options) {
|
|
|
2043
2392
|
webSocket: pair[1]
|
|
2044
2393
|
});
|
|
2045
2394
|
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Generic WebSocket transport. Default `T = string` is backward-compatible and satisfies
|
|
2397
|
+
* `RpcTransport`. Use `T = ArrayBuffer` as a building block for binary transports.
|
|
2398
|
+
*/
|
|
2046
2399
|
var WebSocketTransport = class {
|
|
2047
2400
|
constructor(webSocket) {
|
|
2048
2401
|
this.#webSocket = webSocket;
|
|
2402
|
+
webSocket.binaryType = "arraybuffer";
|
|
2049
2403
|
if (webSocket.readyState === WebSocket.CONNECTING) {
|
|
2050
2404
|
this.#sendQueue = [];
|
|
2051
2405
|
webSocket.addEventListener("open", (event) => {
|
|
@@ -2058,12 +2412,12 @@ var WebSocketTransport = class {
|
|
|
2058
2412
|
});
|
|
2059
2413
|
}
|
|
2060
2414
|
webSocket.addEventListener("message", (event) => {
|
|
2061
|
-
if (this.#error) {} else if (typeof event.data === "string") if (this.#receiveResolver) {
|
|
2415
|
+
if (this.#error) {} else if (typeof event.data === "string" || event.data instanceof ArrayBuffer) if (this.#receiveResolver) {
|
|
2062
2416
|
this.#receiveResolver(event.data);
|
|
2063
2417
|
this.#receiveResolver = void 0;
|
|
2064
2418
|
this.#receiveRejecter = void 0;
|
|
2065
2419
|
} else this.#receiveQueue.push(event.data);
|
|
2066
|
-
else this.#receivedError(/* @__PURE__ */ new TypeError("Received
|
|
2420
|
+
else this.#receivedError(/* @__PURE__ */ new TypeError("Received unexpected message type from WebSocket."));
|
|
2067
2421
|
});
|
|
2068
2422
|
webSocket.addEventListener("close", (event) => {
|
|
2069
2423
|
this.#receivedError(/* @__PURE__ */ new Error(`Peer closed WebSocket: ${event.code} ${event.reason}`));
|
|
@@ -2078,13 +2432,13 @@ var WebSocketTransport = class {
|
|
|
2078
2432
|
#receiveRejecter;
|
|
2079
2433
|
#receiveQueue = [];
|
|
2080
2434
|
#error;
|
|
2081
|
-
|
|
2435
|
+
send(message) {
|
|
2082
2436
|
if (this.#sendQueue === void 0) this.#webSocket.send(message);
|
|
2083
2437
|
else this.#sendQueue.push(message);
|
|
2084
2438
|
}
|
|
2085
|
-
|
|
2086
|
-
if (this.#receiveQueue.length > 0) return this.#receiveQueue.shift();
|
|
2087
|
-
else if (this.#error)
|
|
2439
|
+
receive() {
|
|
2440
|
+
if (this.#receiveQueue.length > 0) return Promise.resolve(this.#receiveQueue.shift());
|
|
2441
|
+
else if (this.#error) return Promise.reject(this.#error);
|
|
2088
2442
|
else return new Promise((resolve, reject) => {
|
|
2089
2443
|
this.#receiveResolver = resolve;
|
|
2090
2444
|
this.#receiveRejecter = reject;
|
|
@@ -2094,6 +2448,8 @@ var WebSocketTransport = class {
|
|
|
2094
2448
|
let message;
|
|
2095
2449
|
if (reason instanceof Error) message = reason.message;
|
|
2096
2450
|
else message = `${reason}`;
|
|
2451
|
+
let reasonBytes = new TextEncoder().encode(message);
|
|
2452
|
+
if (reasonBytes.length > 123) message = new TextDecoder().decode(reasonBytes.subarray(0, 123), { stream: true });
|
|
2097
2453
|
this.#webSocket.close(3e3, message);
|
|
2098
2454
|
if (!this.#error) this.#error = reason;
|
|
2099
2455
|
}
|
|
@@ -2111,6 +2467,7 @@ var WebSocketTransport = class {
|
|
|
2111
2467
|
|
|
2112
2468
|
//#endregion
|
|
2113
2469
|
//#region src/batch.ts
|
|
2470
|
+
const yieldToMacrotask = typeof setImmediate === "function" ? () => new Promise((resolve) => setImmediate(resolve)) : () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
2114
2471
|
var BatchClientTransport = class {
|
|
2115
2472
|
constructor(sendBatch) {
|
|
2116
2473
|
this.#promise = this.#scheduleBatch(sendBatch);
|
|
@@ -2119,7 +2476,7 @@ var BatchClientTransport = class {
|
|
|
2119
2476
|
#aborted;
|
|
2120
2477
|
#batchToSend = [];
|
|
2121
2478
|
#batchToReceive = null;
|
|
2122
|
-
|
|
2479
|
+
send(message) {
|
|
2123
2480
|
if (this.#batchToSend !== null) this.#batchToSend.push(message);
|
|
2124
2481
|
}
|
|
2125
2482
|
async receive() {
|
|
@@ -2132,7 +2489,7 @@ var BatchClientTransport = class {
|
|
|
2132
2489
|
this.#aborted = reason;
|
|
2133
2490
|
}
|
|
2134
2491
|
async #scheduleBatch(sendBatch) {
|
|
2135
|
-
await
|
|
2492
|
+
await yieldToMacrotask();
|
|
2136
2493
|
if (this.#aborted !== void 0) throw this.#aborted;
|
|
2137
2494
|
let batch = this.#batchToSend;
|
|
2138
2495
|
this.#batchToSend = null;
|
|
@@ -2161,7 +2518,7 @@ var BatchServerTransport = class {
|
|
|
2161
2518
|
#batchToSend = [];
|
|
2162
2519
|
#batchToReceive;
|
|
2163
2520
|
#allReceived = Promise.withResolvers();
|
|
2164
|
-
|
|
2521
|
+
send(message) {
|
|
2165
2522
|
this.#batchToSend.push(message);
|
|
2166
2523
|
}
|
|
2167
2524
|
async receive() {
|
|
@@ -2210,7 +2567,11 @@ async function newHttpBatchRpcResponse(request, localMain, options) {
|
|
|
2210
2567
|
* @param options Optional RPC session options. You can also pass headers to set on the response.
|
|
2211
2568
|
*/
|
|
2212
2569
|
async function nodeHttpBatchRpcResponse(request, response, localMain, options) {
|
|
2213
|
-
if (request.method !== "POST")
|
|
2570
|
+
if (request.method !== "POST") {
|
|
2571
|
+
response.writeHead(405, "This endpoint only accepts POST requests.", options?.headers);
|
|
2572
|
+
response.end();
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2214
2575
|
let body = await new Promise((resolve, reject) => {
|
|
2215
2576
|
let chunks = [];
|
|
2216
2577
|
request.on("data", (chunk) => {
|
|
@@ -2235,17 +2596,17 @@ function newMessagePortRpcSession$1(port, localMain, options) {
|
|
|
2235
2596
|
return new RpcSession$1(new MessagePortTransport(port), localMain, options).getRemoteMain();
|
|
2236
2597
|
}
|
|
2237
2598
|
var MessagePortTransport = class {
|
|
2599
|
+
encodingLevel = "structuredClonable";
|
|
2238
2600
|
constructor(port) {
|
|
2239
2601
|
this.#port = port;
|
|
2240
2602
|
port.start();
|
|
2241
2603
|
port.addEventListener("message", (event) => {
|
|
2242
2604
|
if (this.#error) {} else if (event.data === null) this.#receivedError(/* @__PURE__ */ new Error("Peer closed MessagePort connection."));
|
|
2243
|
-
else if (
|
|
2605
|
+
else if (this.#receiveResolver) {
|
|
2244
2606
|
this.#receiveResolver(event.data);
|
|
2245
2607
|
this.#receiveResolver = void 0;
|
|
2246
2608
|
this.#receiveRejecter = void 0;
|
|
2247
2609
|
} else this.#receiveQueue.push(event.data);
|
|
2248
|
-
else this.#receivedError(/* @__PURE__ */ new TypeError("Received non-string message from MessagePort."));
|
|
2249
2610
|
});
|
|
2250
2611
|
port.addEventListener("messageerror", (event) => {
|
|
2251
2612
|
this.#receivedError(/* @__PURE__ */ new Error("MessagePort message error."));
|
|
@@ -2256,7 +2617,7 @@ var MessagePortTransport = class {
|
|
|
2256
2617
|
#receiveRejecter;
|
|
2257
2618
|
#receiveQueue = [];
|
|
2258
2619
|
#error;
|
|
2259
|
-
|
|
2620
|
+
send(message) {
|
|
2260
2621
|
if (this.#error) throw this.#error;
|
|
2261
2622
|
this.#port.postMessage(message);
|
|
2262
2623
|
}
|
|
@@ -2420,9 +2781,11 @@ var MapVariableHook = class extends StubHook {
|
|
|
2420
2781
|
else throwMapperBuilderUseError();
|
|
2421
2782
|
}
|
|
2422
2783
|
call(path, args) {
|
|
2784
|
+
args.dispose();
|
|
2423
2785
|
throwMapperBuilderUseError();
|
|
2424
2786
|
}
|
|
2425
2787
|
map(path, captures, instructions) {
|
|
2788
|
+
for (let cap of captures) cap.dispose();
|
|
2426
2789
|
throwMapperBuilderUseError();
|
|
2427
2790
|
}
|
|
2428
2791
|
pull() {
|
|
@@ -2475,6 +2838,9 @@ var MapApplicator = class {
|
|
|
2475
2838
|
getPipeReadable(exportId) {
|
|
2476
2839
|
throw new Error("A mapper function cannot use pipe readables.");
|
|
2477
2840
|
}
|
|
2841
|
+
getLimits() {
|
|
2842
|
+
return DEFAULT_LIMITS;
|
|
2843
|
+
}
|
|
2478
2844
|
};
|
|
2479
2845
|
function applyMapToElement(input, parent, owner, captures, instructions) {
|
|
2480
2846
|
let mapper = new MapApplicator(captures, new PayloadStubHook(RpcPayload.deepCopyFrom(input, parent, owner)));
|
|
@@ -2530,14 +2896,11 @@ var WritableStreamStubHook = class WritableStreamStubHook extends StubHook {
|
|
|
2530
2896
|
let state = this.getState();
|
|
2531
2897
|
if (path.length !== 1 || typeof path[0] !== "string") throw new Error("WritableStream stub only supports direct method calls");
|
|
2532
2898
|
const method = path[0];
|
|
2533
|
-
if (method !== "write" && method !== "close" && method !== "abort") {
|
|
2534
|
-
args.dispose();
|
|
2535
|
-
throw new Error(`Unknown WritableStream method: ${method}`);
|
|
2536
|
-
}
|
|
2899
|
+
if (method !== "write" && method !== "close" && method !== "abort") throw new Error(`Unknown WritableStream method: ${method}`);
|
|
2537
2900
|
if (method === "close" || method === "abort") state.closed = true;
|
|
2538
|
-
|
|
2539
|
-
return new PromiseStubHook(args.deliverCall(func, state.writer).then((payload) => new PayloadStubHook(payload)));
|
|
2901
|
+
return new PromiseStubHook((method === "write" ? args.deliverStreamWrite(state.writer) : args.deliverCall(state.writer[method], state.writer)).then((payload) => new PayloadStubHook(payload)));
|
|
2540
2902
|
} catch (err) {
|
|
2903
|
+
args.dispose();
|
|
2541
2904
|
return new ErrorStubHook(err);
|
|
2542
2905
|
}
|
|
2543
2906
|
}
|
|
@@ -2813,12 +3176,12 @@ let newMessagePortRpcSession = newMessagePortRpcSession$1;
|
|
|
2813
3176
|
* credentials as parameters and returns the authorized API), then cross-origin requests should
|
|
2814
3177
|
* be safe.
|
|
2815
3178
|
*/
|
|
2816
|
-
async function newWorkersRpcResponse(request, localMain) {
|
|
3179
|
+
async function newWorkersRpcResponse(request, localMain, options) {
|
|
2817
3180
|
if (request.method === "POST") {
|
|
2818
|
-
let response = await newHttpBatchRpcResponse(request, localMain);
|
|
3181
|
+
let response = await newHttpBatchRpcResponse(request, localMain, options);
|
|
2819
3182
|
response.headers.set("Access-Control-Allow-Origin", "*");
|
|
2820
3183
|
return response;
|
|
2821
|
-
} else if (request.headers.get("Upgrade")?.toLowerCase() === "websocket") return newWorkersWebSocketRpcResponse(request, localMain);
|
|
3184
|
+
} else if (request.headers.get("Upgrade")?.toLowerCase() === "websocket") return newWorkersWebSocketRpcResponse(request, localMain, options);
|
|
2822
3185
|
else return new Response("This endpoint only accepts POST or WebSocket requests.", { status: 400 });
|
|
2823
3186
|
}
|
|
2824
3187
|
|
|
@@ -2940,10 +3303,13 @@ let newBunWebSocketRpcSession = newBunWebSocketRpcSession$1;
|
|
|
2940
3303
|
|
|
2941
3304
|
//#endregion
|
|
2942
3305
|
exports.BunWebSocketTransport = BunWebSocketTransport;
|
|
3306
|
+
exports.DEFAULT_LIMITS = DEFAULT_LIMITS;
|
|
3307
|
+
exports.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
|
|
2943
3308
|
exports.RpcPromise = RpcPromise;
|
|
2944
3309
|
exports.RpcSession = RpcSession;
|
|
2945
3310
|
exports.RpcStub = RpcStub;
|
|
2946
3311
|
exports.RpcTarget = RpcTarget;
|
|
3312
|
+
exports.WebSocketTransport = WebSocketTransport;
|
|
2947
3313
|
exports.deserialize = deserialize;
|
|
2948
3314
|
exports.newBunWebSocketRpcHandler = newBunWebSocketRpcHandler;
|
|
2949
3315
|
exports.newBunWebSocketRpcSession = newBunWebSocketRpcSession;
|