seroval-plugins 1.6.4 → 1.6.6

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.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_web = require("./web-Cz0hD_-8.cjs");
2
+ const require_web = require("./web-BSPcNbIH.cjs");
3
3
  Object.defineProperty(exports, "web", {
4
4
  enumerable: true,
5
5
  get: function() {
package/dist/dev/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as web_exports } from "./web-43VA2W_p.js";
1
+ import { t as web_exports } from "./web-CWqRG00W.js";
2
2
  export { web_exports as web };
@@ -50,7 +50,7 @@ const AbortSignalPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
50
50
  return PROMISE_TO_ABORT_SIGNAL.toString();
51
51
  },
52
52
  deserialize() {
53
- return PROMISE_TO_ABORT_SIGNAL;
53
+ throw new Error("seroval-plugins/web/AbortControllerFactoryPlugin cannot be deserialized directly.");
54
54
  }
55
55
  })],
56
56
  test(value) {
@@ -83,7 +83,11 @@ const AbortSignalPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
83
83
  },
84
84
  deserialize(node, ctx) {
85
85
  if (node.reason) return AbortSignal.abort(ctx.deserialize(node.reason));
86
- if (node.controller) return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
86
+ if (node.controller) {
87
+ const controller = ctx.deserialize(node.controller);
88
+ if (!(controller instanceof Promise)) throw new Error("Expected a Promise source.");
89
+ return PROMISE_TO_ABORT_SIGNAL(controller).signal;
90
+ }
87
91
  return new AbortController().signal;
88
92
  }
89
93
  });
@@ -445,15 +449,17 @@ const ReadableStreamFactoryPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
445
449
  });
446
450
  async function drainStream(stream, reader) {
447
451
  try {
448
- const result = await reader.read();
449
- if (result.done) {
450
- stream.return(result.value);
451
- reader.releaseLock();
452
- } else {
452
+ while (true) {
453
+ const result = await reader.read();
454
+ if (result.done) {
455
+ stream.return(result.value);
456
+ reader.releaseLock();
457
+ break;
458
+ }
453
459
  stream.next(result.value);
454
- await drainStream(stream, reader);
455
460
  }
456
461
  } catch (error) {
462
+ reader.releaseLock();
457
463
  stream.throw(error);
458
464
  }
459
465
  }
@@ -502,6 +508,7 @@ const ReadableStreamPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
502
508
  },
503
509
  deserialize(node, ctx) {
504
510
  const stream = ctx.deserialize(node.stream);
511
+ if (!stream || typeof stream !== "object" || !(0, seroval.isStream)(stream)) throw new Error("Expected a stream source.");
505
512
  return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
506
513
  }
507
514
  });
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { createPlugin, createStream } from "seroval";
2
+ import { createPlugin, createStream, isStream } from "seroval";
3
3
  //#region web/abort-signal.ts
4
4
  const PROMISE_TO_ABORT_SIGNAL = (promise) => {
5
5
  const controller = new AbortController();
@@ -39,7 +39,7 @@ const AbortSignalPlugin = /* @__PURE__ */ createPlugin({
39
39
  return PROMISE_TO_ABORT_SIGNAL.toString();
40
40
  },
41
41
  deserialize() {
42
- return PROMISE_TO_ABORT_SIGNAL;
42
+ throw new Error("seroval-plugins/web/AbortControllerFactoryPlugin cannot be deserialized directly.");
43
43
  }
44
44
  })],
45
45
  test(value) {
@@ -72,7 +72,11 @@ const AbortSignalPlugin = /* @__PURE__ */ createPlugin({
72
72
  },
73
73
  deserialize(node, ctx) {
74
74
  if (node.reason) return AbortSignal.abort(ctx.deserialize(node.reason));
75
- if (node.controller) return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
75
+ if (node.controller) {
76
+ const controller = ctx.deserialize(node.controller);
77
+ if (!(controller instanceof Promise)) throw new Error("Expected a Promise source.");
78
+ return PROMISE_TO_ABORT_SIGNAL(controller).signal;
79
+ }
76
80
  return new AbortController().signal;
77
81
  }
78
82
  });
@@ -434,15 +438,17 @@ const ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin({
434
438
  });
435
439
  async function drainStream(stream, reader) {
436
440
  try {
437
- const result = await reader.read();
438
- if (result.done) {
439
- stream.return(result.value);
440
- reader.releaseLock();
441
- } else {
441
+ while (true) {
442
+ const result = await reader.read();
443
+ if (result.done) {
444
+ stream.return(result.value);
445
+ reader.releaseLock();
446
+ break;
447
+ }
442
448
  stream.next(result.value);
443
- await drainStream(stream, reader);
444
449
  }
445
450
  } catch (error) {
451
+ reader.releaseLock();
446
452
  stream.throw(error);
447
453
  }
448
454
  }
@@ -491,6 +497,7 @@ const ReadableStreamPlugin = /* @__PURE__ */ createPlugin({
491
497
  },
492
498
  deserialize(node, ctx) {
493
499
  const stream = ctx.deserialize(node.stream);
500
+ if (!stream || typeof stream !== "object" || !isStream(stream)) throw new Error("Expected a stream source.");
494
501
  return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
495
502
  }
496
503
  });
package/dist/dev/web.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_web = require("./web-Cz0hD_-8.cjs");
2
+ const require_web = require("./web-BSPcNbIH.cjs");
3
3
  exports.AbortSignalPlugin = require_web.AbortSignalPlugin;
4
4
  exports.BlobPlugin = require_web.BlobPlugin;
5
5
  exports.CustomEventPlugin = require_web.CustomEventPlugin;
package/dist/dev/web.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as RequestPlugin, c as HeadersPlugin, d as EventPlugin, f as DOMExceptionPlugin, h as AbortSignalPlugin, i as ResponsePlugin, l as FormDataPlugin, m as BlobPlugin, n as URLSearchParamsPlugin, o as ReadableStreamPlugin, p as CustomEventPlugin, r as URLPlugin, s as ImageDataPlugin, u as FilePlugin } from "./web-43VA2W_p.js";
1
+ import { a as RequestPlugin, c as HeadersPlugin, d as EventPlugin, f as DOMExceptionPlugin, h as AbortSignalPlugin, i as ResponsePlugin, l as FormDataPlugin, m as BlobPlugin, n as URLSearchParamsPlugin, o as ReadableStreamPlugin, p as CustomEventPlugin, r as URLPlugin, s as ImageDataPlugin, u as FilePlugin } from "./web-CWqRG00W.js";
2
2
  export { AbortSignalPlugin, BlobPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FilePlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_web = require("./web-Cz0hD_-8.cjs");
2
+ const require_web = require("./web-BSPcNbIH.cjs");
3
3
  Object.defineProperty(exports, "web", {
4
4
  enumerable: true,
5
5
  get: function() {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as web_exports } from "./web-43VA2W_p.js";
1
+ import { t as web_exports } from "./web-CWqRG00W.js";
2
2
  export { web_exports as web };
@@ -50,7 +50,7 @@ const AbortSignalPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
50
50
  return PROMISE_TO_ABORT_SIGNAL.toString();
51
51
  },
52
52
  deserialize() {
53
- return PROMISE_TO_ABORT_SIGNAL;
53
+ throw new Error("seroval-plugins/web/AbortControllerFactoryPlugin cannot be deserialized directly.");
54
54
  }
55
55
  })],
56
56
  test(value) {
@@ -83,7 +83,11 @@ const AbortSignalPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
83
83
  },
84
84
  deserialize(node, ctx) {
85
85
  if (node.reason) return AbortSignal.abort(ctx.deserialize(node.reason));
86
- if (node.controller) return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
86
+ if (node.controller) {
87
+ const controller = ctx.deserialize(node.controller);
88
+ if (!(controller instanceof Promise)) throw new Error("Expected a Promise source.");
89
+ return PROMISE_TO_ABORT_SIGNAL(controller).signal;
90
+ }
87
91
  return new AbortController().signal;
88
92
  }
89
93
  });
@@ -445,15 +449,17 @@ const ReadableStreamFactoryPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
445
449
  });
446
450
  async function drainStream(stream, reader) {
447
451
  try {
448
- const result = await reader.read();
449
- if (result.done) {
450
- stream.return(result.value);
451
- reader.releaseLock();
452
- } else {
452
+ while (true) {
453
+ const result = await reader.read();
454
+ if (result.done) {
455
+ stream.return(result.value);
456
+ reader.releaseLock();
457
+ break;
458
+ }
453
459
  stream.next(result.value);
454
- await drainStream(stream, reader);
455
460
  }
456
461
  } catch (error) {
462
+ reader.releaseLock();
457
463
  stream.throw(error);
458
464
  }
459
465
  }
@@ -502,6 +508,7 @@ const ReadableStreamPlugin = /* @__PURE__ */ (0, seroval.createPlugin)({
502
508
  },
503
509
  deserialize(node, ctx) {
504
510
  const stream = ctx.deserialize(node.stream);
511
+ if (!stream || typeof stream !== "object" || !(0, seroval.isStream)(stream)) throw new Error("Expected a stream source.");
505
512
  return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
506
513
  }
507
514
  });
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { createPlugin, createStream } from "seroval";
2
+ import { createPlugin, createStream, isStream } from "seroval";
3
3
  //#region web/abort-signal.ts
4
4
  const PROMISE_TO_ABORT_SIGNAL = (promise) => {
5
5
  const controller = new AbortController();
@@ -39,7 +39,7 @@ const AbortSignalPlugin = /* @__PURE__ */ createPlugin({
39
39
  return PROMISE_TO_ABORT_SIGNAL.toString();
40
40
  },
41
41
  deserialize() {
42
- return PROMISE_TO_ABORT_SIGNAL;
42
+ throw new Error("seroval-plugins/web/AbortControllerFactoryPlugin cannot be deserialized directly.");
43
43
  }
44
44
  })],
45
45
  test(value) {
@@ -72,7 +72,11 @@ const AbortSignalPlugin = /* @__PURE__ */ createPlugin({
72
72
  },
73
73
  deserialize(node, ctx) {
74
74
  if (node.reason) return AbortSignal.abort(ctx.deserialize(node.reason));
75
- if (node.controller) return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
75
+ if (node.controller) {
76
+ const controller = ctx.deserialize(node.controller);
77
+ if (!(controller instanceof Promise)) throw new Error("Expected a Promise source.");
78
+ return PROMISE_TO_ABORT_SIGNAL(controller).signal;
79
+ }
76
80
  return new AbortController().signal;
77
81
  }
78
82
  });
@@ -434,15 +438,17 @@ const ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin({
434
438
  });
435
439
  async function drainStream(stream, reader) {
436
440
  try {
437
- const result = await reader.read();
438
- if (result.done) {
439
- stream.return(result.value);
440
- reader.releaseLock();
441
- } else {
441
+ while (true) {
442
+ const result = await reader.read();
443
+ if (result.done) {
444
+ stream.return(result.value);
445
+ reader.releaseLock();
446
+ break;
447
+ }
442
448
  stream.next(result.value);
443
- await drainStream(stream, reader);
444
449
  }
445
450
  } catch (error) {
451
+ reader.releaseLock();
446
452
  stream.throw(error);
447
453
  }
448
454
  }
@@ -491,6 +497,7 @@ const ReadableStreamPlugin = /* @__PURE__ */ createPlugin({
491
497
  },
492
498
  deserialize(node, ctx) {
493
499
  const stream = ctx.deserialize(node.stream);
500
+ if (!stream || typeof stream !== "object" || !isStream(stream)) throw new Error("Expected a stream source.");
494
501
  return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
495
502
  }
496
503
  });
package/dist/web.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_web = require("./web-Cz0hD_-8.cjs");
2
+ const require_web = require("./web-BSPcNbIH.cjs");
3
3
  exports.AbortSignalPlugin = require_web.AbortSignalPlugin;
4
4
  exports.BlobPlugin = require_web.BlobPlugin;
5
5
  exports.CustomEventPlugin = require_web.CustomEventPlugin;
package/dist/web.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as RequestPlugin, c as HeadersPlugin, d as EventPlugin, f as DOMExceptionPlugin, h as AbortSignalPlugin, i as ResponsePlugin, l as FormDataPlugin, m as BlobPlugin, n as URLSearchParamsPlugin, o as ReadableStreamPlugin, p as CustomEventPlugin, r as URLPlugin, s as ImageDataPlugin, u as FilePlugin } from "./web-43VA2W_p.js";
1
+ import { a as RequestPlugin, c as HeadersPlugin, d as EventPlugin, f as DOMExceptionPlugin, h as AbortSignalPlugin, i as ResponsePlugin, l as FormDataPlugin, m as BlobPlugin, n as URLSearchParamsPlugin, o as ReadableStreamPlugin, p as CustomEventPlugin, r as URLPlugin, s as ImageDataPlugin, u as FilePlugin } from "./web-CWqRG00W.js";
2
2
  export { AbortSignalPlugin, BlobPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FilePlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "seroval-plugins",
3
3
  "type": "module",
4
- "version": "1.6.4",
4
+ "version": "1.6.6",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -16,7 +16,7 @@
16
16
  "@types/node": "^26.2.0",
17
17
  "@vitest/ui": "^4.1.10",
18
18
  "esbuild": "^0.28.2",
19
- "seroval": "1.6.4",
19
+ "seroval": "1.6.6",
20
20
  "tsdown": "^0.22.14",
21
21
  "tslib": "^2.8.1",
22
22
  "typescript": "^7.0.2",