seroval-plugins 1.5.6 → 1.6.0

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.
Files changed (59) hide show
  1. package/dist/index-Col4D1Sf.d.ts +46 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2 -0
  4. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  5. package/dist/web-43VA2W_p.js +650 -0
  6. package/dist/web.d.ts +2 -0
  7. package/dist/web.js +2 -0
  8. package/package.json +11 -21
  9. package/dist/cjs/development/web.cjs +0 -826
  10. package/dist/cjs/development/web.cjs.map +0 -7
  11. package/dist/cjs/production/web.cjs +0 -1
  12. package/dist/esm/development/web.mjs +0 -803
  13. package/dist/esm/development/web.mjs.map +0 -7
  14. package/dist/esm/production/web.mjs +0 -1
  15. package/dist/types/web/abort-signal.d.ts +0 -3
  16. package/dist/types/web/abort-signal.d.ts.map +0 -1
  17. package/dist/types/web/blob.d.ts +0 -3
  18. package/dist/types/web/blob.d.ts.map +0 -1
  19. package/dist/types/web/custom-event.d.ts +0 -3
  20. package/dist/types/web/custom-event.d.ts.map +0 -1
  21. package/dist/types/web/dom-exception.d.ts +0 -3
  22. package/dist/types/web/dom-exception.d.ts.map +0 -1
  23. package/dist/types/web/event.d.ts +0 -3
  24. package/dist/types/web/event.d.ts.map +0 -1
  25. package/dist/types/web/file.d.ts +0 -3
  26. package/dist/types/web/file.d.ts.map +0 -1
  27. package/dist/types/web/form-data.d.ts +0 -3
  28. package/dist/types/web/form-data.d.ts.map +0 -1
  29. package/dist/types/web/headers.d.ts +0 -3
  30. package/dist/types/web/headers.d.ts.map +0 -1
  31. package/dist/types/web/image-data.d.ts +0 -3
  32. package/dist/types/web/image-data.d.ts.map +0 -1
  33. package/dist/types/web/index.d.ts +0 -15
  34. package/dist/types/web/index.d.ts.map +0 -1
  35. package/dist/types/web/readable-stream.d.ts +0 -3
  36. package/dist/types/web/readable-stream.d.ts.map +0 -1
  37. package/dist/types/web/request.d.ts +0 -3
  38. package/dist/types/web/request.d.ts.map +0 -1
  39. package/dist/types/web/response.d.ts +0 -3
  40. package/dist/types/web/response.d.ts.map +0 -1
  41. package/dist/types/web/url-search-params.d.ts +0 -3
  42. package/dist/types/web/url-search-params.d.ts.map +0 -1
  43. package/dist/types/web/url.d.ts +0 -3
  44. package/dist/types/web/url.d.ts.map +0 -1
  45. package/web/abort-signal.ts +0 -131
  46. package/web/blob.ts +0 -41
  47. package/web/custom-event.ts +0 -66
  48. package/web/dom-exception.ts +0 -57
  49. package/web/event.ts +0 -62
  50. package/web/file.ts +0 -50
  51. package/web/form-data.ts +0 -105
  52. package/web/headers.ts +0 -49
  53. package/web/image-data.ts +0 -74
  54. package/web/index.ts +0 -14
  55. package/web/readable-stream.ts +0 -148
  56. package/web/request.ts +0 -82
  57. package/web/response.ts +0 -65
  58. package/web/url-search-params.ts +0 -40
  59. package/web/url.ts +0 -37
@@ -0,0 +1,46 @@
1
+ //#region web/abort-signal.d.ts
2
+ declare const AbortSignalPlugin: any;
3
+ //#endregion
4
+ //#region web/blob.d.ts
5
+ declare const BlobPlugin: any;
6
+ //#endregion
7
+ //#region web/custom-event.d.ts
8
+ declare const CustomEventPlugin: any;
9
+ //#endregion
10
+ //#region web/dom-exception.d.ts
11
+ declare const DOMExceptionPlugin: any;
12
+ //#endregion
13
+ //#region web/event.d.ts
14
+ declare const EventPlugin: any;
15
+ //#endregion
16
+ //#region web/file.d.ts
17
+ declare const FilePlugin: any;
18
+ //#endregion
19
+ //#region web/form-data.d.ts
20
+ declare const FormDataPlugin: any;
21
+ //#endregion
22
+ //#region web/headers.d.ts
23
+ declare const HeadersPlugin: any;
24
+ //#endregion
25
+ //#region web/image-data.d.ts
26
+ declare const ImageDataPlugin: any;
27
+ //#endregion
28
+ //#region web/readable-stream.d.ts
29
+ declare const ReadableStreamPlugin: any;
30
+ //#endregion
31
+ //#region web/request.d.ts
32
+ declare const RequestPlugin: any;
33
+ //#endregion
34
+ //#region web/response.d.ts
35
+ declare const ResponsePlugin: any;
36
+ //#endregion
37
+ //#region web/url.d.ts
38
+ declare const URLPlugin: any;
39
+ //#endregion
40
+ //#region web/url-search-params.d.ts
41
+ declare const URLSearchParamsPlugin: any;
42
+ declare namespace index_d_exports {
43
+ export { AbortSignalPlugin, BlobPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FilePlugin, FormDataPlugin, HeadersPlugin, ImageDataPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLPlugin, URLSearchParamsPlugin };
44
+ }
45
+ //#endregion
46
+ export { RequestPlugin as a, HeadersPlugin as c, EventPlugin as d, DOMExceptionPlugin as f, AbortSignalPlugin as h, ResponsePlugin as i, FormDataPlugin as l, BlobPlugin as m, URLSearchParamsPlugin as n, ReadableStreamPlugin as o, CustomEventPlugin as p, URLPlugin as r, ImageDataPlugin as s, index_d_exports as t, FilePlugin as u };
@@ -0,0 +1,2 @@
1
+ import { t as index_d_exports } from "./index-Col4D1Sf.js";
2
+ export { index_d_exports as web };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as web_exports } from "./web-43VA2W_p.js";
2
+ export { web_exports as web };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
@@ -0,0 +1,650 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { createPlugin, createStream } from "seroval";
3
+ //#region web/abort-signal.ts
4
+ const PROMISE_TO_ABORT_SIGNAL = (promise) => {
5
+ const controller = new AbortController();
6
+ const abort = controller.abort.bind(controller);
7
+ promise.then(abort, abort);
8
+ return controller;
9
+ };
10
+ function resolveAbortSignalResult(resolve) {
11
+ resolve(this.reason);
12
+ }
13
+ function resolveAbortSignal(resolve) {
14
+ this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), { once: true });
15
+ }
16
+ function abortSignalToPromise(signal) {
17
+ return new Promise(resolveAbortSignal.bind(signal));
18
+ }
19
+ const ABORT_CONTROLLER = {};
20
+ const AbortSignalPlugin = /* @__PURE__ */ createPlugin({
21
+ tag: "seroval-plugins/web/AbortSignal",
22
+ extends: [/* @__PURE__ */ createPlugin({
23
+ tag: "seroval-plugins/web/AbortControllerFactoryPlugin",
24
+ test(value) {
25
+ return value === ABORT_CONTROLLER;
26
+ },
27
+ parse: {
28
+ sync() {
29
+ return ABORT_CONTROLLER;
30
+ },
31
+ async async() {
32
+ return await Promise.resolve(ABORT_CONTROLLER);
33
+ },
34
+ stream() {
35
+ return ABORT_CONTROLLER;
36
+ }
37
+ },
38
+ serialize() {
39
+ return PROMISE_TO_ABORT_SIGNAL.toString();
40
+ },
41
+ deserialize() {
42
+ return PROMISE_TO_ABORT_SIGNAL;
43
+ }
44
+ })],
45
+ test(value) {
46
+ if (typeof AbortSignal === "undefined") return false;
47
+ return value instanceof AbortSignal;
48
+ },
49
+ parse: {
50
+ sync(value, ctx) {
51
+ if (value.aborted) return { reason: ctx.parse(value.reason) };
52
+ return {};
53
+ },
54
+ async async(value, ctx) {
55
+ if (value.aborted) return { reason: await ctx.parse(value.reason) };
56
+ const result = await abortSignalToPromise(value);
57
+ return { reason: await ctx.parse(result) };
58
+ },
59
+ stream(value, ctx) {
60
+ if (value.aborted) return { reason: ctx.parse(value.reason) };
61
+ const promise = abortSignalToPromise(value);
62
+ return {
63
+ factory: ctx.parse(ABORT_CONTROLLER),
64
+ controller: ctx.parse(promise)
65
+ };
66
+ }
67
+ },
68
+ serialize(node, ctx) {
69
+ if (node.reason) return "AbortSignal.abort(" + ctx.serialize(node.reason) + ")";
70
+ if (node.controller && node.factory) return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.controller) + ").signal";
71
+ return "(new AbortController).signal";
72
+ },
73
+ deserialize(node, ctx) {
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;
76
+ return new AbortController().signal;
77
+ }
78
+ });
79
+ //#endregion
80
+ //#region web/blob.ts
81
+ const BlobPlugin = /* @__PURE__ */ createPlugin({
82
+ tag: "seroval-plugins/web/Blob",
83
+ test(value) {
84
+ if (typeof Blob === "undefined") return false;
85
+ return value instanceof Blob;
86
+ },
87
+ parse: { async async(value, ctx) {
88
+ return {
89
+ type: await ctx.parse(value.type),
90
+ buffer: await ctx.parse(await value.arrayBuffer())
91
+ };
92
+ } },
93
+ serialize(node, ctx) {
94
+ return "new Blob([" + ctx.serialize(node.buffer) + "],{type:" + ctx.serialize(node.type) + "})";
95
+ },
96
+ deserialize(node, ctx) {
97
+ return new Blob([ctx.deserialize(node.buffer)], { type: ctx.deserialize(node.type) });
98
+ }
99
+ });
100
+ //#endregion
101
+ //#region web/custom-event.ts
102
+ function createCustomEventOptions(current) {
103
+ return {
104
+ detail: current.detail,
105
+ bubbles: current.bubbles,
106
+ cancelable: current.cancelable,
107
+ composed: current.composed
108
+ };
109
+ }
110
+ const CustomEventPlugin = /* @__PURE__ */ createPlugin({
111
+ tag: "seroval-plugins/web/CustomEvent",
112
+ test(value) {
113
+ if (typeof CustomEvent === "undefined") return false;
114
+ return value instanceof CustomEvent;
115
+ },
116
+ parse: {
117
+ sync(value, ctx) {
118
+ return {
119
+ type: ctx.parse(value.type),
120
+ options: ctx.parse(createCustomEventOptions(value))
121
+ };
122
+ },
123
+ async async(value, ctx) {
124
+ return {
125
+ type: await ctx.parse(value.type),
126
+ options: await ctx.parse(createCustomEventOptions(value))
127
+ };
128
+ },
129
+ stream(value, ctx) {
130
+ return {
131
+ type: ctx.parse(value.type),
132
+ options: ctx.parse(createCustomEventOptions(value))
133
+ };
134
+ }
135
+ },
136
+ serialize(node, ctx) {
137
+ return "new CustomEvent(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
138
+ },
139
+ deserialize(node, ctx) {
140
+ return new CustomEvent(ctx.deserialize(node.type), ctx.deserialize(node.options));
141
+ }
142
+ });
143
+ //#endregion
144
+ //#region web/dom-exception.ts
145
+ const DOMExceptionPlugin = /* @__PURE__ */ createPlugin({
146
+ tag: "seroval-plugins/web/DOMException",
147
+ test(value) {
148
+ if (typeof DOMException === "undefined") return false;
149
+ return value instanceof DOMException;
150
+ },
151
+ parse: {
152
+ sync(value, ctx) {
153
+ return {
154
+ name: ctx.parse(value.name),
155
+ message: ctx.parse(value.message)
156
+ };
157
+ },
158
+ async async(value, ctx) {
159
+ return {
160
+ name: await ctx.parse(value.name),
161
+ message: await ctx.parse(value.message)
162
+ };
163
+ },
164
+ stream(value, ctx) {
165
+ return {
166
+ name: ctx.parse(value.name),
167
+ message: ctx.parse(value.message)
168
+ };
169
+ }
170
+ },
171
+ serialize(node, ctx) {
172
+ return "new DOMException(" + ctx.serialize(node.message) + "," + ctx.serialize(node.name) + ")";
173
+ },
174
+ deserialize(node, ctx) {
175
+ return new DOMException(ctx.deserialize(node.message), ctx.deserialize(node.name));
176
+ }
177
+ });
178
+ //#endregion
179
+ //#region web/event.ts
180
+ function createEventOptions(current) {
181
+ return {
182
+ bubbles: current.bubbles,
183
+ cancelable: current.cancelable,
184
+ composed: current.composed
185
+ };
186
+ }
187
+ const EventPlugin = /* @__PURE__ */ createPlugin({
188
+ tag: "seroval-plugins/web/Event",
189
+ test(value) {
190
+ if (typeof Event === "undefined") return false;
191
+ return value instanceof Event;
192
+ },
193
+ parse: {
194
+ sync(value, ctx) {
195
+ return {
196
+ type: ctx.parse(value.type),
197
+ options: ctx.parse(createEventOptions(value))
198
+ };
199
+ },
200
+ async async(value, ctx) {
201
+ return {
202
+ type: await ctx.parse(value.type),
203
+ options: await ctx.parse(createEventOptions(value))
204
+ };
205
+ },
206
+ stream(value, ctx) {
207
+ return {
208
+ type: ctx.parse(value.type),
209
+ options: ctx.parse(createEventOptions(value))
210
+ };
211
+ }
212
+ },
213
+ serialize(node, ctx) {
214
+ return "new Event(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
215
+ },
216
+ deserialize(node, ctx) {
217
+ return new Event(ctx.deserialize(node.type), ctx.deserialize(node.options));
218
+ }
219
+ });
220
+ //#endregion
221
+ //#region web/file.ts
222
+ const FilePlugin = /* @__PURE__ */ createPlugin({
223
+ tag: "seroval-plugins/web/File",
224
+ test(value) {
225
+ if (typeof File === "undefined") return false;
226
+ return value instanceof File;
227
+ },
228
+ parse: { async async(value, ctx) {
229
+ return {
230
+ name: await ctx.parse(value.name),
231
+ options: await ctx.parse({
232
+ type: value.type,
233
+ lastModified: value.lastModified
234
+ }),
235
+ buffer: await ctx.parse(await value.arrayBuffer())
236
+ };
237
+ } },
238
+ serialize(node, ctx) {
239
+ return "new File([" + ctx.serialize(node.buffer) + "]," + ctx.serialize(node.name) + "," + ctx.serialize(node.options) + ")";
240
+ },
241
+ deserialize(node, ctx) {
242
+ return new File([ctx.deserialize(node.buffer)], ctx.deserialize(node.name), ctx.deserialize(node.options));
243
+ }
244
+ });
245
+ //#endregion
246
+ //#region web/form-data.ts
247
+ function convertFormData(instance) {
248
+ const items = [];
249
+ instance.forEach((value, key) => {
250
+ items.push([key, value]);
251
+ });
252
+ return items;
253
+ }
254
+ const FORM_DATA_FACTORY = {};
255
+ const FORM_DATA_FACTORY_CONSTRUCTOR = (e, f = new FormData(), i = 0, s = e.length, t) => {
256
+ for (; i < s; i++) {
257
+ t = e[i];
258
+ f.append(t[0], t[1]);
259
+ }
260
+ return f;
261
+ };
262
+ const FormDataPlugin = /* @__PURE__ */ createPlugin({
263
+ tag: "seroval-plugins/web/FormData",
264
+ extends: [FilePlugin, /* @__PURE__ */ createPlugin({
265
+ tag: "seroval-plugins/web/FormDataFactory",
266
+ test(value) {
267
+ return value === FORM_DATA_FACTORY;
268
+ },
269
+ parse: {
270
+ sync() {
271
+ return FORM_DATA_FACTORY;
272
+ },
273
+ async async() {
274
+ return await Promise.resolve(FORM_DATA_FACTORY);
275
+ },
276
+ stream() {
277
+ return FORM_DATA_FACTORY;
278
+ }
279
+ },
280
+ serialize() {
281
+ return FORM_DATA_FACTORY_CONSTRUCTOR.toString();
282
+ },
283
+ deserialize() {
284
+ return FORM_DATA_FACTORY;
285
+ }
286
+ })],
287
+ test(value) {
288
+ if (typeof FormData === "undefined") return false;
289
+ return value instanceof FormData;
290
+ },
291
+ parse: {
292
+ sync(value, ctx) {
293
+ return {
294
+ factory: ctx.parse(FORM_DATA_FACTORY),
295
+ entries: ctx.parse(convertFormData(value))
296
+ };
297
+ },
298
+ async async(value, ctx) {
299
+ return {
300
+ factory: await ctx.parse(FORM_DATA_FACTORY),
301
+ entries: await ctx.parse(convertFormData(value))
302
+ };
303
+ },
304
+ stream(value, ctx) {
305
+ return {
306
+ factory: ctx.parse(FORM_DATA_FACTORY),
307
+ entries: ctx.parse(convertFormData(value))
308
+ };
309
+ }
310
+ },
311
+ serialize(node, ctx) {
312
+ return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.entries) + ")";
313
+ },
314
+ deserialize(node, ctx) {
315
+ return FORM_DATA_FACTORY_CONSTRUCTOR(ctx.deserialize(node.entries));
316
+ }
317
+ });
318
+ //#endregion
319
+ //#region web/headers.ts
320
+ function convertHeaders(instance) {
321
+ const items = [];
322
+ instance.forEach((value, key) => {
323
+ items.push([key, value]);
324
+ });
325
+ return items;
326
+ }
327
+ const HeadersPlugin = /* @__PURE__ */ createPlugin({
328
+ tag: "seroval-plugins/web/Headers",
329
+ test(value) {
330
+ if (typeof Headers === "undefined") return false;
331
+ return value instanceof Headers;
332
+ },
333
+ parse: {
334
+ sync(value, ctx) {
335
+ return { value: ctx.parse(convertHeaders(value)) };
336
+ },
337
+ async async(value, ctx) {
338
+ return { value: await ctx.parse(convertHeaders(value)) };
339
+ },
340
+ stream(value, ctx) {
341
+ return { value: ctx.parse(convertHeaders(value)) };
342
+ }
343
+ },
344
+ serialize(node, ctx) {
345
+ return "new Headers(" + ctx.serialize(node.value) + ")";
346
+ },
347
+ deserialize(node, ctx) {
348
+ return new Headers(ctx.deserialize(node.value));
349
+ }
350
+ });
351
+ //#endregion
352
+ //#region web/image-data.ts
353
+ const ImageDataPlugin = /* @__PURE__ */ createPlugin({
354
+ tag: "seroval-plugins/web/ImageData",
355
+ test(value) {
356
+ if (typeof ImageData === "undefined") return false;
357
+ return value instanceof ImageData;
358
+ },
359
+ parse: {
360
+ sync(value, ctx) {
361
+ return {
362
+ data: ctx.parse(value.data),
363
+ width: ctx.parse(value.width),
364
+ height: ctx.parse(value.height),
365
+ options: ctx.parse({ colorSpace: value.colorSpace })
366
+ };
367
+ },
368
+ async async(value, ctx) {
369
+ return {
370
+ data: await ctx.parse(value.data),
371
+ width: await ctx.parse(value.width),
372
+ height: await ctx.parse(value.height),
373
+ options: await ctx.parse({ colorSpace: value.colorSpace })
374
+ };
375
+ },
376
+ stream(value, ctx) {
377
+ return {
378
+ data: ctx.parse(value.data),
379
+ width: ctx.parse(value.width),
380
+ height: ctx.parse(value.height),
381
+ options: ctx.parse({ colorSpace: value.colorSpace })
382
+ };
383
+ }
384
+ },
385
+ serialize(node, ctx) {
386
+ return "new ImageData(" + ctx.serialize(node.data) + "," + ctx.serialize(node.width) + "," + ctx.serialize(node.height) + "," + ctx.serialize(node.options) + ")";
387
+ },
388
+ deserialize(node, ctx) {
389
+ return new ImageData(ctx.deserialize(node.data), ctx.deserialize(node.width), ctx.deserialize(node.height), ctx.deserialize(node.options));
390
+ }
391
+ });
392
+ //#endregion
393
+ //#region web/readable-stream.ts
394
+ const READABLE_STREAM_FACTORY = {};
395
+ const READABLE_STREAM_FACTORY_CONSTRUCTOR = (stream) => new ReadableStream({ start(controller) {
396
+ stream.on({
397
+ next(value) {
398
+ try {
399
+ controller.enqueue(value);
400
+ } catch (_error) {}
401
+ },
402
+ throw(value) {
403
+ controller.error(value);
404
+ },
405
+ return() {
406
+ try {
407
+ controller.close();
408
+ } catch (_error) {}
409
+ }
410
+ });
411
+ } });
412
+ const ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin({
413
+ tag: "seroval-plugins/web/ReadableStreamFactory",
414
+ test(value) {
415
+ return value === READABLE_STREAM_FACTORY;
416
+ },
417
+ parse: {
418
+ sync() {
419
+ return READABLE_STREAM_FACTORY;
420
+ },
421
+ async async() {
422
+ return await Promise.resolve(READABLE_STREAM_FACTORY);
423
+ },
424
+ stream() {
425
+ return READABLE_STREAM_FACTORY;
426
+ }
427
+ },
428
+ serialize() {
429
+ return READABLE_STREAM_FACTORY_CONSTRUCTOR.toString();
430
+ },
431
+ deserialize() {
432
+ return READABLE_STREAM_FACTORY;
433
+ }
434
+ });
435
+ async function drainStream(stream, reader) {
436
+ try {
437
+ const result = await reader.read();
438
+ if (result.done) {
439
+ stream.return(result.value);
440
+ reader.releaseLock();
441
+ } else {
442
+ stream.next(result.value);
443
+ await drainStream(stream, reader);
444
+ }
445
+ } catch (error) {
446
+ stream.throw(error);
447
+ }
448
+ }
449
+ function cleanupStream(reader) {
450
+ reader.cancel().catch(() => {});
451
+ reader.releaseLock();
452
+ }
453
+ function toStream(value) {
454
+ const stream = createStream();
455
+ const reader = value.getReader();
456
+ const cleanup = cleanupStream.bind(null, reader);
457
+ drainStream(stream, reader).catch(cleanup);
458
+ return [stream, cleanup];
459
+ }
460
+ const ReadableStreamPlugin = /* @__PURE__ */ createPlugin({
461
+ tag: "seroval/plugins/web/ReadableStream",
462
+ extends: [ReadableStreamFactoryPlugin],
463
+ test(value) {
464
+ if (typeof ReadableStream === "undefined") return false;
465
+ return value instanceof ReadableStream;
466
+ },
467
+ parse: {
468
+ sync(_value, ctx) {
469
+ return {
470
+ factory: ctx.parse(READABLE_STREAM_FACTORY),
471
+ stream: ctx.parse(createStream())
472
+ };
473
+ },
474
+ async async(value, ctx) {
475
+ return {
476
+ factory: await ctx.parse(READABLE_STREAM_FACTORY),
477
+ stream: await ctx.parse(toStream(value)[0])
478
+ };
479
+ },
480
+ stream(value, ctx) {
481
+ const [stream, cleanup] = toStream(value);
482
+ ctx.addCleanup(cleanup);
483
+ return {
484
+ factory: ctx.parse(READABLE_STREAM_FACTORY),
485
+ stream: ctx.parse(stream)
486
+ };
487
+ }
488
+ },
489
+ serialize(node, ctx) {
490
+ return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
491
+ },
492
+ deserialize(node, ctx) {
493
+ const stream = ctx.deserialize(node.stream);
494
+ return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
495
+ }
496
+ });
497
+ //#endregion
498
+ //#region web/request.ts
499
+ function createRequestOptions(current, body) {
500
+ return {
501
+ body,
502
+ cache: current.cache,
503
+ credentials: current.credentials,
504
+ headers: current.headers,
505
+ integrity: current.integrity,
506
+ keepalive: current.keepalive,
507
+ method: current.method,
508
+ mode: current.mode,
509
+ redirect: current.redirect,
510
+ referrer: current.referrer,
511
+ referrerPolicy: current.referrerPolicy
512
+ };
513
+ }
514
+ const RequestPlugin = /* @__PURE__ */ createPlugin({
515
+ tag: "seroval-plugins/web/Request",
516
+ extends: [ReadableStreamPlugin, HeadersPlugin],
517
+ test(value) {
518
+ if (typeof Request === "undefined") return false;
519
+ return value instanceof Request;
520
+ },
521
+ parse: {
522
+ async async(value, ctx) {
523
+ return {
524
+ url: await ctx.parse(value.url),
525
+ options: await ctx.parse(createRequestOptions(value, value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null))
526
+ };
527
+ },
528
+ stream(value, ctx) {
529
+ return {
530
+ url: ctx.parse(value.url),
531
+ options: ctx.parse(createRequestOptions(value, value.body && !value.bodyUsed ? value.clone().body : null))
532
+ };
533
+ }
534
+ },
535
+ serialize(node, ctx) {
536
+ return "new Request(" + ctx.serialize(node.url) + "," + ctx.serialize(node.options) + ")";
537
+ },
538
+ deserialize(node, ctx) {
539
+ return new Request(ctx.deserialize(node.url), ctx.deserialize(node.options));
540
+ }
541
+ });
542
+ //#endregion
543
+ //#region web/response.ts
544
+ function createResponseOptions(current) {
545
+ return {
546
+ headers: current.headers,
547
+ status: current.status,
548
+ statusText: current.statusText
549
+ };
550
+ }
551
+ const ResponsePlugin = /* @__PURE__ */ createPlugin({
552
+ tag: "seroval-plugins/web/Response",
553
+ extends: [ReadableStreamPlugin, HeadersPlugin],
554
+ test(value) {
555
+ if (typeof Response === "undefined") return false;
556
+ return value instanceof Response;
557
+ },
558
+ parse: {
559
+ async async(value, ctx) {
560
+ return {
561
+ body: await ctx.parse(value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null),
562
+ options: await ctx.parse(createResponseOptions(value))
563
+ };
564
+ },
565
+ stream(value, ctx) {
566
+ return {
567
+ body: ctx.parse(value.body && !value.bodyUsed ? value.clone().body : null),
568
+ options: ctx.parse(createResponseOptions(value))
569
+ };
570
+ }
571
+ },
572
+ serialize(node, ctx) {
573
+ return "new Response(" + ctx.serialize(node.body) + "," + ctx.serialize(node.options) + ")";
574
+ },
575
+ deserialize(node, ctx) {
576
+ return new Response(ctx.deserialize(node.body), ctx.deserialize(node.options));
577
+ }
578
+ });
579
+ //#endregion
580
+ //#region web/url.ts
581
+ const URLPlugin = /* @__PURE__ */ createPlugin({
582
+ tag: "seroval-plugins/web/URL",
583
+ test(value) {
584
+ if (typeof URL === "undefined") return false;
585
+ return value instanceof URL;
586
+ },
587
+ parse: {
588
+ sync(value, ctx) {
589
+ return { value: ctx.parse(value.href) };
590
+ },
591
+ async async(value, ctx) {
592
+ return { value: await ctx.parse(value.href) };
593
+ },
594
+ stream(value, ctx) {
595
+ return { value: ctx.parse(value.href) };
596
+ }
597
+ },
598
+ serialize(node, ctx) {
599
+ return "new URL(" + ctx.serialize(node.value) + ")";
600
+ },
601
+ deserialize(node, ctx) {
602
+ return new URL(ctx.deserialize(node.value));
603
+ }
604
+ });
605
+ //#endregion
606
+ //#region web/url-search-params.ts
607
+ const URLSearchParamsPlugin = /* @__PURE__ */ createPlugin({
608
+ tag: "seroval-plugins/web/URLSearchParams",
609
+ test(value) {
610
+ if (typeof URLSearchParams === "undefined") return false;
611
+ return value instanceof URLSearchParams;
612
+ },
613
+ parse: {
614
+ sync(value, ctx) {
615
+ return { value: ctx.parse(value.toString()) };
616
+ },
617
+ async async(value, ctx) {
618
+ return { value: await ctx.parse(value.toString()) };
619
+ },
620
+ stream(value, ctx) {
621
+ return { value: ctx.parse(value.toString()) };
622
+ }
623
+ },
624
+ serialize(node, ctx) {
625
+ return "new URLSearchParams(" + ctx.serialize(node.value) + ")";
626
+ },
627
+ deserialize(node, ctx) {
628
+ return new URLSearchParams(ctx.deserialize(node.value));
629
+ }
630
+ });
631
+ //#endregion
632
+ //#region web/index.ts
633
+ var web_exports = /* @__PURE__ */ __exportAll({
634
+ AbortSignalPlugin: () => AbortSignalPlugin,
635
+ BlobPlugin: () => BlobPlugin,
636
+ CustomEventPlugin: () => CustomEventPlugin,
637
+ DOMExceptionPlugin: () => DOMExceptionPlugin,
638
+ EventPlugin: () => EventPlugin,
639
+ FilePlugin: () => FilePlugin,
640
+ FormDataPlugin: () => FormDataPlugin,
641
+ HeadersPlugin: () => HeadersPlugin,
642
+ ImageDataPlugin: () => ImageDataPlugin,
643
+ ReadableStreamPlugin: () => ReadableStreamPlugin,
644
+ RequestPlugin: () => RequestPlugin,
645
+ ResponsePlugin: () => ResponsePlugin,
646
+ URLPlugin: () => URLPlugin,
647
+ URLSearchParamsPlugin: () => URLSearchParamsPlugin
648
+ });
649
+ //#endregion
650
+ export { RequestPlugin as a, HeadersPlugin as c, EventPlugin as d, DOMExceptionPlugin as f, AbortSignalPlugin as h, ResponsePlugin as i, FormDataPlugin as l, BlobPlugin as m, URLSearchParamsPlugin as n, ReadableStreamPlugin as o, CustomEventPlugin as p, URLPlugin as r, ImageDataPlugin as s, web_exports as t, FilePlugin as u };