capnweb 0.0.0-07032e2 → 0.0.0-098dca7
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/index-bun.cjs +63 -1
- package/dist/index-bun.cjs.map +1 -1
- package/dist/index-bun.d.cts +4 -1
- package/dist/index-bun.d.ts +4 -1
- package/dist/index-bun.js +63 -1
- package/dist/index-bun.js.map +1 -1
- package/dist/index-workers.cjs +63 -1
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.js +63 -1
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +63 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +63 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index-bun.d.cts
CHANGED
|
@@ -207,9 +207,12 @@ declare class RpcPromise$1 extends RpcStub$1 {
|
|
|
207
207
|
finally(onfinally?: (() => void) | undefined | null): Promise<unknown>;
|
|
208
208
|
toString(): string;
|
|
209
209
|
}
|
|
210
|
+
type PropertyName = string | number | {
|
|
211
|
+
mapKey: unknown;
|
|
212
|
+
};
|
|
210
213
|
type LocatedPromise = {
|
|
211
214
|
parent: object;
|
|
212
|
-
property:
|
|
215
|
+
property: PropertyName;
|
|
213
216
|
promise: RpcPromise$1;
|
|
214
217
|
};
|
|
215
218
|
declare class RpcPayload {
|
package/dist/index-bun.d.ts
CHANGED
|
@@ -207,9 +207,12 @@ declare class RpcPromise$1 extends RpcStub$1 {
|
|
|
207
207
|
finally(onfinally?: (() => void) | undefined | null): Promise<unknown>;
|
|
208
208
|
toString(): string;
|
|
209
209
|
}
|
|
210
|
+
type PropertyName = string | number | {
|
|
211
|
+
mapKey: unknown;
|
|
212
|
+
};
|
|
210
213
|
type LocatedPromise = {
|
|
211
214
|
parent: object;
|
|
212
|
-
property:
|
|
215
|
+
property: PropertyName;
|
|
213
216
|
promise: RpcPromise$1;
|
|
214
217
|
};
|
|
215
218
|
declare class RpcPayload {
|
package/dist/index-bun.js
CHANGED
|
@@ -42,6 +42,7 @@ function typeForRpc(value) {
|
|
|
42
42
|
case Date.prototype: return "date";
|
|
43
43
|
case RegExp.prototype: return "regexp";
|
|
44
44
|
case Set.prototype: return "set";
|
|
45
|
+
case Map.prototype: return "map";
|
|
45
46
|
case Uint8Array.prototype:
|
|
46
47
|
case BUFFER_PROTOTYPE:
|
|
47
48
|
case ArrayBuffer.prototype:
|
|
@@ -305,6 +306,9 @@ async function pullPromise(promise) {
|
|
|
305
306
|
if (pathIfPromise.length > 0) hook = hook.get(pathIfPromise);
|
|
306
307
|
return (await hook.pull()).deliverResolve();
|
|
307
308
|
}
|
|
309
|
+
function mapKeyToPropertyName(key) {
|
|
310
|
+
return typeof key === "string" || typeof key === "number" ? key : { mapKey: key };
|
|
311
|
+
}
|
|
308
312
|
var RpcPayload = class RpcPayload {
|
|
309
313
|
value;
|
|
310
314
|
source;
|
|
@@ -449,6 +453,20 @@ var RpcPayload = class RpcPayload {
|
|
|
449
453
|
}
|
|
450
454
|
return result;
|
|
451
455
|
}
|
|
456
|
+
case "map": {
|
|
457
|
+
let map = value;
|
|
458
|
+
let entries = [...map];
|
|
459
|
+
for (let [key] of entries) {
|
|
460
|
+
let kind = typeForRpc(key);
|
|
461
|
+
if (kind === "rpc-promise" || kind === "rpc-thenable") throw new TypeError("Cannot pass a promise as a key of a Map. Await the value before using it as a key.");
|
|
462
|
+
}
|
|
463
|
+
let result = /* @__PURE__ */ new Map();
|
|
464
|
+
for (let [key, val] of entries) {
|
|
465
|
+
let keyCopy = this.deepCopy(key, map, -1, result, dupStubs, owner);
|
|
466
|
+
result.set(keyCopy, this.deepCopy(val, map, mapKeyToPropertyName(keyCopy), result, dupStubs, owner));
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
452
470
|
case "object": {
|
|
453
471
|
let result = {};
|
|
454
472
|
let object = value;
|
|
@@ -550,7 +568,8 @@ var RpcPayload = class RpcPayload {
|
|
|
550
568
|
this.ensureDeepCopied();
|
|
551
569
|
if (this.value instanceof RpcPromise$1) RpcPayload.deliverRpcPromiseTo(this.value, parent, property, promises);
|
|
552
570
|
else {
|
|
553
|
-
parent
|
|
571
|
+
if (parent instanceof Map) parent.set(typeof property === "object" ? property.mapKey : property, this.value);
|
|
572
|
+
else parent[property] = this.value;
|
|
554
573
|
for (let record of this.promises) RpcPayload.deliverRpcPromiseTo(record.promise, record.parent, record.property, promises);
|
|
555
574
|
}
|
|
556
575
|
}
|
|
@@ -656,6 +675,14 @@ var RpcPayload = class RpcPayload {
|
|
|
656
675
|
for (let element of set) this.disposeImpl(element, set);
|
|
657
676
|
return;
|
|
658
677
|
}
|
|
678
|
+
case "map": {
|
|
679
|
+
let map = value;
|
|
680
|
+
for (let [key, val] of map) {
|
|
681
|
+
this.disposeImpl(key, map);
|
|
682
|
+
this.disposeImpl(val, map);
|
|
683
|
+
}
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
659
686
|
case "object": {
|
|
660
687
|
let object = value;
|
|
661
688
|
for (let i in object) this.disposeImpl(object[i], object);
|
|
@@ -746,6 +773,14 @@ var RpcPayload = class RpcPayload {
|
|
|
746
773
|
for (let element of set) this.ignoreUnhandledRejectionsImpl(element);
|
|
747
774
|
return;
|
|
748
775
|
}
|
|
776
|
+
case "map": {
|
|
777
|
+
let map = value;
|
|
778
|
+
for (let [key, val] of map) {
|
|
779
|
+
this.ignoreUnhandledRejectionsImpl(key);
|
|
780
|
+
this.ignoreUnhandledRejectionsImpl(val);
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
749
784
|
case "object": {
|
|
750
785
|
let object = value;
|
|
751
786
|
for (let i in object) this.ignoreUnhandledRejectionsImpl(object[i]);
|
|
@@ -806,6 +841,7 @@ function followPath(value, parent, path, owner) {
|
|
|
806
841
|
case "blob":
|
|
807
842
|
case "date":
|
|
808
843
|
case "set":
|
|
844
|
+
case "map":
|
|
809
845
|
case "error":
|
|
810
846
|
case "url":
|
|
811
847
|
case "regexp":
|
|
@@ -1212,6 +1248,18 @@ var Devaluator = class Devaluator {
|
|
|
1212
1248
|
for (let element of setElements) elements.push(this.devaluateImpl(element, set, depth + 1));
|
|
1213
1249
|
return ["set", elements];
|
|
1214
1250
|
}
|
|
1251
|
+
case "map": {
|
|
1252
|
+
let map = value;
|
|
1253
|
+
let mapEntries = [...map];
|
|
1254
|
+
let entries = [];
|
|
1255
|
+
for (let [key] of mapEntries) switch (typeForRpc(key)) {
|
|
1256
|
+
case "blob": throw new TypeError("Cannot serialize a Blob as a key of a Map.");
|
|
1257
|
+
case "rpc-promise":
|
|
1258
|
+
case "rpc-thenable": throw new TypeError("Cannot serialize a promise as a key of a Map. Await the value before using it as a key.");
|
|
1259
|
+
}
|
|
1260
|
+
for (let [key, val] of mapEntries) entries.push([this.devaluateImpl(key, map, depth + 1), this.devaluateImpl(val, map, depth + 1)]);
|
|
1261
|
+
return ["map", entries];
|
|
1262
|
+
}
|
|
1215
1263
|
case "bigint":
|
|
1216
1264
|
if (this.encodingLevel === "structuredClonable") return value;
|
|
1217
1265
|
return ["bigint", value.toString()];
|
|
@@ -1538,6 +1586,20 @@ var Evaluator = class Evaluator {
|
|
|
1538
1586
|
return set;
|
|
1539
1587
|
}
|
|
1540
1588
|
break;
|
|
1589
|
+
case "map":
|
|
1590
|
+
if (value.length === 2 && value[1] instanceof Array) {
|
|
1591
|
+
let entries = value[1];
|
|
1592
|
+
let map = /* @__PURE__ */ new Map();
|
|
1593
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1594
|
+
let entry = entries[i];
|
|
1595
|
+
if (!(entry instanceof Array) || entry.length !== 2) throw new TypeError("Map entries must be serialized as key/value pairs.");
|
|
1596
|
+
let key = this.evaluateImpl(entry[0], map, i, depth + 1);
|
|
1597
|
+
if (key instanceof RpcPromise$1) throw new TypeError("Cannot deserialize a promise as a key of a Map.");
|
|
1598
|
+
map.set(key, this.evaluateImpl(entry[1], map, mapKeyToPropertyName(key), depth + 1));
|
|
1599
|
+
}
|
|
1600
|
+
return map;
|
|
1601
|
+
}
|
|
1602
|
+
break;
|
|
1541
1603
|
case "bytes": {
|
|
1542
1604
|
let bytes;
|
|
1543
1605
|
if (value[1] instanceof Uint8Array) bytes = value[1];
|