capnweb 0.0.0-098dca7 → 0.0.0-0b19df9

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.
@@ -452,7 +452,7 @@ var RpcPayload = class RpcPayload {
452
452
  return hook.dup();
453
453
  } else return hook;
454
454
  }
455
- } else throw new Error("owned payload shouldn't contain raw ReadableStreams");
455
+ } else return streamImpl.createReadableStreamHook(stream);
456
456
  }
457
457
  deepCopy(value, oldParent, property, parent, dupStubs, owner) {
458
458
  switch (typeForRpc(value)) {
@@ -559,8 +559,10 @@ var RpcPayload = class RpcPayload {
559
559
  case "readable": {
560
560
  let stream = value;
561
561
  let hook;
562
- if (owner) hook = owner.getHookForReadableStream(stream, oldParent, dupStubs);
563
- else hook = streamImpl.createReadableStreamHook(stream);
562
+ if (owner) {
563
+ if (owner.source === "owned") throw new Error("Can't copy a ReadableStream.");
564
+ hook = owner.getHookForReadableStream(stream, oldParent, dupStubs);
565
+ } else hook = streamImpl.createReadableStreamHook(stream);
564
566
  this.hooks.push(hook);
565
567
  return stream;
566
568
  }
@@ -1921,10 +1923,11 @@ function estimateEncodedSize(value, seen, depth = 0) {
1921
1923
  var ImportTableEntry = class {
1922
1924
  session;
1923
1925
  importId;
1926
+ pulling;
1924
1927
  constructor(session, importId, pulling) {
1925
1928
  this.session = session;
1926
1929
  this.importId = importId;
1927
- if (pulling) this.activePull = Promise.withResolvers();
1930
+ this.pulling = pulling;
1928
1931
  }
1929
1932
  localRefcount = 0;
1930
1933
  remoteRefcount = 1;
@@ -1955,7 +1958,7 @@ var ImportTableEntry = class {
1955
1958
  }
1956
1959
  async awaitResolution() {
1957
1960
  if (!this.activePull) {
1958
- this.session.sendPull(this.importId);
1961
+ if (!this.pulling) this.session.sendPull(this.importId);
1959
1962
  this.activePull = Promise.withResolvers();
1960
1963
  }
1961
1964
  await this.activePull.promise;
@@ -2185,6 +2188,7 @@ var RpcSessionImpl = class {
2185
2188
  let autoRelease = exp.autoRelease;
2186
2189
  ++this.pullCount;
2187
2190
  exp.pull = resolve().then((payload) => {
2191
+ if (this.exports[exportId] !== exp) return;
2188
2192
  let value = Devaluator.devaluate(payload.value, void 0, this, payload, this.encodingLevel);
2189
2193
  this.send([
2190
2194
  "resolve",
@@ -2193,6 +2197,7 @@ var RpcSessionImpl = class {
2193
2197
  ]);
2194
2198
  if (autoRelease) this.releaseExport(exportId, 1);
2195
2199
  }, (error) => {
2200
+ if (this.exports[exportId] !== exp) return;
2196
2201
  this.send([
2197
2202
  "reject",
2198
2203
  exportId,
@@ -2312,6 +2317,7 @@ var RpcSessionImpl = class {
2312
2317
  value.push(devalue[0]);
2313
2318
  }
2314
2319
  this.send(["push", value]);
2320
+ args?.dispose();
2315
2321
  let entry = new ImportTableEntry(this, this.imports.length, false);
2316
2322
  this.imports.push(entry);
2317
2323
  return new RpcImportHook(true, entry);
@@ -2336,6 +2342,7 @@ var RpcSessionImpl = class {
2336
2342
  value.push(devalue[0]);
2337
2343
  let msg = ["stream", value];
2338
2344
  let size = this.send(msg);
2345
+ args.dispose();
2339
2346
  if (size === void 0) size = estimateEncodedSize(msg);
2340
2347
  let importId = this.imports.length;
2341
2348
  let entry = new ImportTableEntry(this, importId, true);