@ai-ecoverse/slicc-kernel 1.154.2 → 1.154.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7245,7 +7245,7 @@ var KERNEL_VERSION, OS_RELEASE;
7245
7245
  var init_version = __esm({
7246
7246
  "src/version.ts"() {
7247
7247
  "use strict";
7248
- KERNEL_VERSION = true ? "1.154.2" : "0.0.0-dev";
7248
+ KERNEL_VERSION = true ? "1.154.3" : "0.0.0-dev";
7249
7249
  OS_RELEASE = "6.0.0-slicc";
7250
7250
  }
7251
7251
  });
package/dist/node.js CHANGED
@@ -186,6 +186,7 @@ function embedderAsker(port) {
186
186
  void asked.body.cancel(message3.error.message).catch(() => void 0);
187
187
  push(asked, message3.error);
188
188
  } else if ("progress" in message3) asked.progress(message3.progress);
189
+ else if ("bodyCancel" in message3) void asked.body.cancel("the page").catch(() => void 0);
189
190
  else void sendBody(message3.id, asked);
190
191
  };
191
192
  return { hookFor, answer: answer2 };
@@ -213,7 +214,8 @@ function bodyStream(id2, state, post) {
213
214
  const next3 = state.body.shift();
214
215
  if (next3) controller.enqueue(next3);
215
216
  else controller.close();
216
- }
217
+ },
218
+ cancel: () => post({ id: id2, bodyCancel: true })
217
219
  },
218
220
  { highWaterMark: 0 }
219
221
  );
@@ -234,14 +236,16 @@ function embedderAnswerer(port, hookFor) {
234
236
  throw Object.assign(new Error(`this page does not answer ${ask.kind}`), {
235
237
  name: "NotSupportedError"
236
238
  });
239
+ const body = bodyStream(ask.id, state, post);
237
240
  const reply = await hook.handle({
238
241
  kind: ask.kind,
239
242
  options: ask.options,
240
- body: bodyStream(ask.id, state, post),
243
+ body,
241
244
  stamp: ask.stamp,
242
245
  signal: state.abort.signal,
243
246
  progress: (line) => post({ id: ask.id, progress: String(line) })
244
247
  });
248
+ if (!(reply instanceof ReadableStream)) post({ id: ask.id, bodyCancel: true });
245
249
  state.reader = bytesOf(reply).getReader();
246
250
  post({ id: ask.id, ready: true });
247
251
  } catch (err) {
@@ -3562,7 +3566,7 @@ function satisfies(version, range2) {
3562
3566
  }
3563
3567
 
3564
3568
  // src/version.ts
3565
- var KERNEL_VERSION = true ? "1.154.2" : "0.0.0-dev";
3569
+ var KERNEL_VERSION = true ? "1.154.3" : "0.0.0-dev";
3566
3570
  var OS_RELEASE = "6.0.0-slicc";
3567
3571
  function procVersion() {
3568
3572
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -7957,6 +7961,7 @@ var BodyPipe = class {
7957
7961
  queue = [];
7958
7962
  size = 0;
7959
7963
  ended = false;
7964
+ dropped = false;
7960
7965
  wake;
7961
7966
  room;
7962
7967
  stream;
@@ -7975,7 +7980,8 @@ var BodyPipe = class {
7975
7980
  this.room?.();
7976
7981
  controller.enqueue(next3);
7977
7982
  } else controller.close();
7978
- }
7983
+ },
7984
+ cancel: () => this.drop()
7979
7985
  },
7980
7986
  { highWaterMark: 0 }
7981
7987
  );
@@ -7983,8 +7989,14 @@ var BodyPipe = class {
7983
7989
  get full() {
7984
7990
  return this.size >= EMBEDDER_WINDOW;
7985
7991
  }
7992
+ drop() {
7993
+ this.dropped = true;
7994
+ this.queue = [];
7995
+ this.size = 0;
7996
+ this.end();
7997
+ }
7986
7998
  push(bytes) {
7987
- if (bytes.length === 0) return;
7999
+ if (bytes.length === 0 || this.dropped) return;
7988
8000
  this.queue.push(bytes.slice());
7989
8001
  this.size += bytes.length;
7990
8002
  this.wake?.();
@@ -8000,6 +8012,30 @@ var BodyPipe = class {
8000
8012
  this.room?.();
8001
8013
  }
8002
8014
  };
8015
+ function endsWith(stream2, ended) {
8016
+ const reader = stream2.getReader();
8017
+ return new ReadableStream(
8018
+ {
8019
+ pull: async (controller) => {
8020
+ let got;
8021
+ try {
8022
+ got = await reader.read();
8023
+ } catch (err) {
8024
+ ended();
8025
+ throw err;
8026
+ }
8027
+ if (!got.done) return controller.enqueue(got.value);
8028
+ ended();
8029
+ controller.close();
8030
+ },
8031
+ cancel: (reason) => {
8032
+ ended();
8033
+ return reader.cancel(reason);
8034
+ }
8035
+ },
8036
+ { highWaterMark: 0 }
8037
+ );
8038
+ }
8003
8039
  function replyStream(reply) {
8004
8040
  if (reply instanceof ReadableStream) return reply;
8005
8041
  const bytes = typeof reply === "string" ? new TextEncoder().encode(reply) : reply instanceof Uint8Array ? reply : new Uint8Array(0);
@@ -8074,7 +8110,10 @@ var EmbedderChannel = class {
8074
8110
  signal: this.abort.signal,
8075
8111
  progress
8076
8112
  })
8077
- ).then((reply) => replyStream(reply).getReader());
8113
+ ).then((reply) => {
8114
+ if (!(reply instanceof ReadableStream)) body.drop();
8115
+ return endsWith(replyStream(reply), () => body.drop()).getReader();
8116
+ });
8078
8117
  this.replied = asked.catch((err) => {
8079
8118
  body.end();
8080
8119
  throw this.fail(err);