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
@@ -1,803 +0,0 @@
1
- // web/abort-signal.ts
2
- import { createPlugin } from "seroval";
3
- var PROMISE_TO_ABORT_SIGNAL = (promise) => {
4
- const controller = new AbortController();
5
- const abort = controller.abort.bind(controller);
6
- promise.then(abort, abort);
7
- return controller;
8
- };
9
- function resolveAbortSignalResult(resolve) {
10
- resolve(this.reason);
11
- }
12
- function resolveAbortSignal(resolve) {
13
- this.addEventListener("abort", resolveAbortSignalResult.bind(this, resolve), {
14
- once: true
15
- });
16
- }
17
- function abortSignalToPromise(signal) {
18
- return new Promise(resolveAbortSignal.bind(signal));
19
- }
20
- var ABORT_CONTROLLER = {};
21
- var AbortControllerFactoryPlugin = /* @__PURE__ */ createPlugin({
22
- tag: "seroval-plugins/web/AbortControllerFactoryPlugin",
23
- test(value) {
24
- return value === ABORT_CONTROLLER;
25
- },
26
- parse: {
27
- sync() {
28
- return ABORT_CONTROLLER;
29
- },
30
- async async() {
31
- return await Promise.resolve(ABORT_CONTROLLER);
32
- },
33
- stream() {
34
- return ABORT_CONTROLLER;
35
- }
36
- },
37
- serialize() {
38
- return PROMISE_TO_ABORT_SIGNAL.toString();
39
- },
40
- deserialize() {
41
- return PROMISE_TO_ABORT_SIGNAL;
42
- }
43
- });
44
- var AbortSignalPlugin = /* @__PURE__ */ createPlugin({
45
- tag: "seroval-plugins/web/AbortSignal",
46
- extends: [AbortControllerFactoryPlugin],
47
- test(value) {
48
- if (typeof AbortSignal === "undefined") {
49
- return false;
50
- }
51
- return value instanceof AbortSignal;
52
- },
53
- parse: {
54
- sync(value, ctx) {
55
- if (value.aborted) {
56
- return {
57
- reason: ctx.parse(value.reason)
58
- };
59
- }
60
- return {};
61
- },
62
- async async(value, ctx) {
63
- if (value.aborted) {
64
- return {
65
- reason: await ctx.parse(value.reason)
66
- };
67
- }
68
- const result = await abortSignalToPromise(value);
69
- return {
70
- reason: await ctx.parse(result)
71
- };
72
- },
73
- stream(value, ctx) {
74
- if (value.aborted) {
75
- return {
76
- reason: ctx.parse(value.reason)
77
- };
78
- }
79
- const promise = abortSignalToPromise(value);
80
- return {
81
- factory: ctx.parse(ABORT_CONTROLLER),
82
- controller: ctx.parse(promise)
83
- };
84
- }
85
- },
86
- serialize(node, ctx) {
87
- if (node.reason) {
88
- return "AbortSignal.abort(" + ctx.serialize(node.reason) + ")";
89
- }
90
- if (node.controller && node.factory) {
91
- return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.controller) + ").signal";
92
- }
93
- return "(new AbortController).signal";
94
- },
95
- deserialize(node, ctx) {
96
- if (node.reason) {
97
- return AbortSignal.abort(ctx.deserialize(node.reason));
98
- }
99
- if (node.controller) {
100
- return PROMISE_TO_ABORT_SIGNAL(ctx.deserialize(node.controller)).signal;
101
- }
102
- const controller = new AbortController();
103
- return controller.signal;
104
- }
105
- });
106
- var abort_signal_default = AbortSignalPlugin;
107
-
108
- // web/blob.ts
109
- import { createPlugin as createPlugin2 } from "seroval";
110
- var BlobPlugin = /* @__PURE__ */ createPlugin2({
111
- tag: "seroval-plugins/web/Blob",
112
- test(value) {
113
- if (typeof Blob === "undefined") {
114
- return false;
115
- }
116
- return value instanceof Blob;
117
- },
118
- parse: {
119
- async async(value, ctx) {
120
- return {
121
- type: await ctx.parse(value.type),
122
- buffer: await ctx.parse(await value.arrayBuffer())
123
- };
124
- }
125
- },
126
- serialize(node, ctx) {
127
- return "new Blob([" + ctx.serialize(node.buffer) + "],{type:" + ctx.serialize(node.type) + "})";
128
- },
129
- deserialize(node, ctx) {
130
- return new Blob([ctx.deserialize(node.buffer)], {
131
- type: ctx.deserialize(node.type)
132
- });
133
- }
134
- });
135
- var blob_default = BlobPlugin;
136
-
137
- // web/custom-event.ts
138
- import { createPlugin as createPlugin3 } from "seroval";
139
- function createCustomEventOptions(current) {
140
- return {
141
- detail: current.detail,
142
- bubbles: current.bubbles,
143
- cancelable: current.cancelable,
144
- composed: current.composed
145
- };
146
- }
147
- var CustomEventPlugin = /* @__PURE__ */ createPlugin3({
148
- tag: "seroval-plugins/web/CustomEvent",
149
- test(value) {
150
- if (typeof CustomEvent === "undefined") {
151
- return false;
152
- }
153
- return value instanceof CustomEvent;
154
- },
155
- parse: {
156
- sync(value, ctx) {
157
- return {
158
- type: ctx.parse(value.type),
159
- options: ctx.parse(createCustomEventOptions(value))
160
- };
161
- },
162
- async async(value, ctx) {
163
- return {
164
- type: await ctx.parse(value.type),
165
- options: await ctx.parse(createCustomEventOptions(value))
166
- };
167
- },
168
- stream(value, ctx) {
169
- return {
170
- type: ctx.parse(value.type),
171
- options: ctx.parse(createCustomEventOptions(value))
172
- };
173
- }
174
- },
175
- serialize(node, ctx) {
176
- return "new CustomEvent(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
177
- },
178
- deserialize(node, ctx) {
179
- return new CustomEvent(
180
- ctx.deserialize(node.type),
181
- ctx.deserialize(node.options)
182
- );
183
- }
184
- });
185
- var custom_event_default = CustomEventPlugin;
186
-
187
- // web/dom-exception.ts
188
- import { createPlugin as createPlugin4 } from "seroval";
189
- var DOMExceptionPlugin = /* @__PURE__ */ createPlugin4({
190
- tag: "seroval-plugins/web/DOMException",
191
- test(value) {
192
- if (typeof DOMException === "undefined") {
193
- return false;
194
- }
195
- return value instanceof DOMException;
196
- },
197
- parse: {
198
- sync(value, ctx) {
199
- return {
200
- name: ctx.parse(value.name),
201
- message: ctx.parse(value.message)
202
- };
203
- },
204
- async async(value, ctx) {
205
- return {
206
- name: await ctx.parse(value.name),
207
- message: await ctx.parse(value.message)
208
- };
209
- },
210
- stream(value, ctx) {
211
- return {
212
- name: ctx.parse(value.name),
213
- message: ctx.parse(value.message)
214
- };
215
- }
216
- },
217
- serialize(node, ctx) {
218
- return "new DOMException(" + ctx.serialize(node.message) + "," + ctx.serialize(node.name) + ")";
219
- },
220
- deserialize(node, ctx) {
221
- return new DOMException(
222
- ctx.deserialize(node.message),
223
- ctx.deserialize(node.name)
224
- );
225
- }
226
- });
227
- var dom_exception_default = DOMExceptionPlugin;
228
-
229
- // web/event.ts
230
- import { createPlugin as createPlugin5 } from "seroval";
231
- function createEventOptions(current) {
232
- return {
233
- bubbles: current.bubbles,
234
- cancelable: current.cancelable,
235
- composed: current.composed
236
- };
237
- }
238
- var EventPlugin = /* @__PURE__ */ createPlugin5({
239
- tag: "seroval-plugins/web/Event",
240
- test(value) {
241
- if (typeof Event === "undefined") {
242
- return false;
243
- }
244
- return value instanceof Event;
245
- },
246
- parse: {
247
- sync(value, ctx) {
248
- return {
249
- type: ctx.parse(value.type),
250
- options: ctx.parse(createEventOptions(value))
251
- };
252
- },
253
- async async(value, ctx) {
254
- return {
255
- type: await ctx.parse(value.type),
256
- options: await ctx.parse(createEventOptions(value))
257
- };
258
- },
259
- stream(value, ctx) {
260
- return {
261
- type: ctx.parse(value.type),
262
- options: ctx.parse(createEventOptions(value))
263
- };
264
- }
265
- },
266
- serialize(node, ctx) {
267
- return "new Event(" + ctx.serialize(node.type) + "," + ctx.serialize(node.options) + ")";
268
- },
269
- deserialize(node, ctx) {
270
- return new Event(
271
- ctx.deserialize(node.type),
272
- ctx.deserialize(node.options)
273
- );
274
- }
275
- });
276
- var event_default = EventPlugin;
277
-
278
- // web/file.ts
279
- import { createPlugin as createPlugin6 } from "seroval";
280
- var FilePlugin = /* @__PURE__ */ createPlugin6({
281
- tag: "seroval-plugins/web/File",
282
- test(value) {
283
- if (typeof File === "undefined") {
284
- return false;
285
- }
286
- return value instanceof File;
287
- },
288
- parse: {
289
- async async(value, ctx) {
290
- return {
291
- name: await ctx.parse(value.name),
292
- options: await ctx.parse({
293
- type: value.type,
294
- lastModified: value.lastModified
295
- }),
296
- buffer: await ctx.parse(await value.arrayBuffer())
297
- };
298
- }
299
- },
300
- serialize(node, ctx) {
301
- return "new File([" + ctx.serialize(node.buffer) + "]," + ctx.serialize(node.name) + "," + ctx.serialize(node.options) + ")";
302
- },
303
- deserialize(node, ctx) {
304
- return new File(
305
- [ctx.deserialize(node.buffer)],
306
- ctx.deserialize(node.name),
307
- ctx.deserialize(node.options)
308
- );
309
- }
310
- });
311
- var file_default = FilePlugin;
312
-
313
- // web/form-data.ts
314
- import { createPlugin as createPlugin7 } from "seroval";
315
- function convertFormData(instance) {
316
- const items = [];
317
- instance.forEach((value, key) => {
318
- items.push([key, value]);
319
- });
320
- return items;
321
- }
322
- var FORM_DATA_FACTORY = {};
323
- var FORM_DATA_FACTORY_CONSTRUCTOR = (e, f = new FormData(), i = 0, s = e.length, t) => {
324
- for (; i < s; i++) {
325
- t = e[i];
326
- f.append(t[0], t[1]);
327
- }
328
- return f;
329
- };
330
- var FormDataFactoryPlugin = /* @__PURE__ */ createPlugin7({
331
- tag: "seroval-plugins/web/FormDataFactory",
332
- test(value) {
333
- return value === FORM_DATA_FACTORY;
334
- },
335
- parse: {
336
- sync() {
337
- return FORM_DATA_FACTORY;
338
- },
339
- async async() {
340
- return await Promise.resolve(FORM_DATA_FACTORY);
341
- },
342
- stream() {
343
- return FORM_DATA_FACTORY;
344
- }
345
- },
346
- serialize() {
347
- return FORM_DATA_FACTORY_CONSTRUCTOR.toString();
348
- },
349
- deserialize() {
350
- return FORM_DATA_FACTORY;
351
- }
352
- });
353
- var FormDataPlugin = /* @__PURE__ */ createPlugin7({
354
- tag: "seroval-plugins/web/FormData",
355
- extends: [file_default, FormDataFactoryPlugin],
356
- test(value) {
357
- if (typeof FormData === "undefined") {
358
- return false;
359
- }
360
- return value instanceof FormData;
361
- },
362
- parse: {
363
- sync(value, ctx) {
364
- return {
365
- factory: ctx.parse(FORM_DATA_FACTORY),
366
- entries: ctx.parse(convertFormData(value))
367
- };
368
- },
369
- async async(value, ctx) {
370
- return {
371
- factory: await ctx.parse(FORM_DATA_FACTORY),
372
- entries: await ctx.parse(convertFormData(value))
373
- };
374
- },
375
- stream(value, ctx) {
376
- return {
377
- factory: ctx.parse(FORM_DATA_FACTORY),
378
- entries: ctx.parse(convertFormData(value))
379
- };
380
- }
381
- },
382
- serialize(node, ctx) {
383
- return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.entries) + ")";
384
- },
385
- deserialize(node, ctx) {
386
- return FORM_DATA_FACTORY_CONSTRUCTOR(
387
- ctx.deserialize(node.entries)
388
- );
389
- }
390
- });
391
- var form_data_default = FormDataPlugin;
392
-
393
- // web/headers.ts
394
- import { createPlugin as createPlugin8 } from "seroval";
395
- function convertHeaders(instance) {
396
- const items = [];
397
- instance.forEach((value, key) => {
398
- items.push([key, value]);
399
- });
400
- return items;
401
- }
402
- var HeadersPlugin = /* @__PURE__ */ createPlugin8({
403
- tag: "seroval-plugins/web/Headers",
404
- test(value) {
405
- if (typeof Headers === "undefined") {
406
- return false;
407
- }
408
- return value instanceof Headers;
409
- },
410
- parse: {
411
- sync(value, ctx) {
412
- return {
413
- value: ctx.parse(convertHeaders(value))
414
- };
415
- },
416
- async async(value, ctx) {
417
- return {
418
- value: await ctx.parse(convertHeaders(value))
419
- };
420
- },
421
- stream(value, ctx) {
422
- return {
423
- value: ctx.parse(convertHeaders(value))
424
- };
425
- }
426
- },
427
- serialize(node, ctx) {
428
- return "new Headers(" + ctx.serialize(node.value) + ")";
429
- },
430
- deserialize(node, ctx) {
431
- return new Headers(ctx.deserialize(node.value));
432
- }
433
- });
434
- var headers_default = HeadersPlugin;
435
-
436
- // web/image-data.ts
437
- import { createPlugin as createPlugin9 } from "seroval";
438
- var ImageDataPlugin = /* @__PURE__ */ createPlugin9({
439
- tag: "seroval-plugins/web/ImageData",
440
- test(value) {
441
- if (typeof ImageData === "undefined") {
442
- return false;
443
- }
444
- return value instanceof ImageData;
445
- },
446
- parse: {
447
- sync(value, ctx) {
448
- return {
449
- data: ctx.parse(value.data),
450
- width: ctx.parse(value.width),
451
- height: ctx.parse(value.height),
452
- options: ctx.parse({
453
- colorSpace: value.colorSpace
454
- })
455
- };
456
- },
457
- async async(value, ctx) {
458
- return {
459
- data: await ctx.parse(value.data),
460
- width: await ctx.parse(value.width),
461
- height: await ctx.parse(value.height),
462
- options: await ctx.parse({
463
- colorSpace: value.colorSpace
464
- })
465
- };
466
- },
467
- stream(value, ctx) {
468
- return {
469
- data: ctx.parse(value.data),
470
- width: ctx.parse(value.width),
471
- height: ctx.parse(value.height),
472
- options: ctx.parse({
473
- colorSpace: value.colorSpace
474
- })
475
- };
476
- }
477
- },
478
- serialize(node, ctx) {
479
- return "new ImageData(" + ctx.serialize(node.data) + "," + ctx.serialize(node.width) + "," + ctx.serialize(node.height) + "," + ctx.serialize(node.options) + ")";
480
- },
481
- deserialize(node, ctx) {
482
- return new ImageData(
483
- ctx.deserialize(node.data),
484
- ctx.deserialize(node.width),
485
- ctx.deserialize(node.height),
486
- ctx.deserialize(node.options)
487
- );
488
- }
489
- });
490
- var image_data_default = ImageDataPlugin;
491
-
492
- // web/readable-stream.ts
493
- import { createPlugin as createPlugin10, createStream } from "seroval";
494
- var READABLE_STREAM_FACTORY = {};
495
- var READABLE_STREAM_FACTORY_CONSTRUCTOR = (stream) => new ReadableStream({
496
- start: (controller) => {
497
- stream.on({
498
- next: (value) => {
499
- try {
500
- controller.enqueue(value);
501
- } catch (_error) {
502
- }
503
- },
504
- throw: (value) => {
505
- controller.error(value);
506
- },
507
- return: () => {
508
- try {
509
- controller.close();
510
- } catch (_error) {
511
- }
512
- }
513
- });
514
- }
515
- });
516
- var ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin10({
517
- tag: "seroval-plugins/web/ReadableStreamFactory",
518
- test(value) {
519
- return value === READABLE_STREAM_FACTORY;
520
- },
521
- parse: {
522
- sync() {
523
- return READABLE_STREAM_FACTORY;
524
- },
525
- async async() {
526
- return await Promise.resolve(READABLE_STREAM_FACTORY);
527
- },
528
- stream() {
529
- return READABLE_STREAM_FACTORY;
530
- }
531
- },
532
- serialize() {
533
- return READABLE_STREAM_FACTORY_CONSTRUCTOR.toString();
534
- },
535
- deserialize() {
536
- return READABLE_STREAM_FACTORY;
537
- }
538
- });
539
- async function drainStream(stream, reader) {
540
- try {
541
- const result = await reader.read();
542
- if (result.done) {
543
- stream.return(result.value);
544
- reader.releaseLock();
545
- } else {
546
- stream.next(result.value);
547
- await drainStream(stream, reader);
548
- }
549
- } catch (error) {
550
- stream.throw(error);
551
- }
552
- }
553
- function cleanupStream(reader) {
554
- reader.cancel().catch(() => {
555
- });
556
- reader.releaseLock();
557
- }
558
- function toStream(value) {
559
- const stream = createStream();
560
- const reader = value.getReader();
561
- const cleanup = cleanupStream.bind(null, reader);
562
- drainStream(stream, reader).catch(cleanup);
563
- return [stream, cleanup];
564
- }
565
- var ReadableStreamPlugin = /* @__PURE__ */ createPlugin10({
566
- tag: "seroval/plugins/web/ReadableStream",
567
- extends: [ReadableStreamFactoryPlugin],
568
- test(value) {
569
- if (typeof ReadableStream === "undefined") {
570
- return false;
571
- }
572
- return value instanceof ReadableStream;
573
- },
574
- parse: {
575
- sync(_value, ctx) {
576
- return {
577
- factory: ctx.parse(READABLE_STREAM_FACTORY),
578
- stream: ctx.parse(createStream())
579
- };
580
- },
581
- async async(value, ctx) {
582
- return {
583
- factory: await ctx.parse(READABLE_STREAM_FACTORY),
584
- stream: await ctx.parse(toStream(value)[0])
585
- };
586
- },
587
- stream(value, ctx) {
588
- const [stream, cleanup] = toStream(value);
589
- ctx.addCleanup(cleanup);
590
- return {
591
- factory: ctx.parse(READABLE_STREAM_FACTORY),
592
- stream: ctx.parse(stream)
593
- };
594
- }
595
- },
596
- serialize(node, ctx) {
597
- return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
598
- },
599
- deserialize(node, ctx) {
600
- const stream = ctx.deserialize(node.stream);
601
- return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
602
- }
603
- });
604
- var readable_stream_default = ReadableStreamPlugin;
605
-
606
- // web/request.ts
607
- import { createPlugin as createPlugin11 } from "seroval";
608
- function createRequestOptions(current, body) {
609
- return {
610
- body,
611
- cache: current.cache,
612
- credentials: current.credentials,
613
- headers: current.headers,
614
- integrity: current.integrity,
615
- keepalive: current.keepalive,
616
- method: current.method,
617
- mode: current.mode,
618
- redirect: current.redirect,
619
- referrer: current.referrer,
620
- referrerPolicy: current.referrerPolicy
621
- };
622
- }
623
- var RequestPlugin = /* @__PURE__ */ createPlugin11({
624
- tag: "seroval-plugins/web/Request",
625
- extends: [readable_stream_default, headers_default],
626
- test(value) {
627
- if (typeof Request === "undefined") {
628
- return false;
629
- }
630
- return value instanceof Request;
631
- },
632
- parse: {
633
- async async(value, ctx) {
634
- return {
635
- url: await ctx.parse(value.url),
636
- options: await ctx.parse(
637
- createRequestOptions(
638
- value,
639
- value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null
640
- )
641
- )
642
- };
643
- },
644
- stream(value, ctx) {
645
- return {
646
- url: ctx.parse(value.url),
647
- options: ctx.parse(
648
- createRequestOptions(
649
- value,
650
- value.body && !value.bodyUsed ? value.clone().body : null
651
- )
652
- )
653
- };
654
- }
655
- },
656
- serialize(node, ctx) {
657
- return "new Request(" + ctx.serialize(node.url) + "," + ctx.serialize(node.options) + ")";
658
- },
659
- deserialize(node, ctx) {
660
- return new Request(
661
- ctx.deserialize(node.url),
662
- ctx.deserialize(node.options)
663
- );
664
- }
665
- });
666
- var request_default = RequestPlugin;
667
-
668
- // web/response.ts
669
- import { createPlugin as createPlugin12 } from "seroval";
670
- function createResponseOptions(current) {
671
- return {
672
- headers: current.headers,
673
- status: current.status,
674
- statusText: current.statusText
675
- };
676
- }
677
- var ResponsePlugin = /* @__PURE__ */ createPlugin12({
678
- tag: "seroval-plugins/web/Response",
679
- extends: [readable_stream_default, headers_default],
680
- test(value) {
681
- if (typeof Response === "undefined") {
682
- return false;
683
- }
684
- return value instanceof Response;
685
- },
686
- parse: {
687
- async async(value, ctx) {
688
- return {
689
- body: await ctx.parse(
690
- value.body && !value.bodyUsed ? await value.clone().arrayBuffer() : null
691
- ),
692
- options: await ctx.parse(createResponseOptions(value))
693
- };
694
- },
695
- stream(value, ctx) {
696
- return {
697
- body: ctx.parse(
698
- value.body && !value.bodyUsed ? value.clone().body : null
699
- ),
700
- options: ctx.parse(createResponseOptions(value))
701
- };
702
- }
703
- },
704
- serialize(node, ctx) {
705
- return "new Response(" + ctx.serialize(node.body) + "," + ctx.serialize(node.options) + ")";
706
- },
707
- deserialize(node, ctx) {
708
- return new Response(
709
- ctx.deserialize(node.body),
710
- ctx.deserialize(node.options)
711
- );
712
- }
713
- });
714
- var response_default = ResponsePlugin;
715
-
716
- // web/url.ts
717
- import { createPlugin as createPlugin13 } from "seroval";
718
- var URLPlugin = /* @__PURE__ */ createPlugin13({
719
- tag: "seroval-plugins/web/URL",
720
- test(value) {
721
- if (typeof URL === "undefined") {
722
- return false;
723
- }
724
- return value instanceof URL;
725
- },
726
- parse: {
727
- sync(value, ctx) {
728
- return {
729
- value: ctx.parse(value.href)
730
- };
731
- },
732
- async async(value, ctx) {
733
- return {
734
- value: await ctx.parse(value.href)
735
- };
736
- },
737
- stream(value, ctx) {
738
- return {
739
- value: ctx.parse(value.href)
740
- };
741
- }
742
- },
743
- serialize(node, ctx) {
744
- return "new URL(" + ctx.serialize(node.value) + ")";
745
- },
746
- deserialize(node, ctx) {
747
- return new URL(ctx.deserialize(node.value));
748
- }
749
- });
750
- var url_default = URLPlugin;
751
-
752
- // web/url-search-params.ts
753
- import { createPlugin as createPlugin14 } from "seroval";
754
- var URLSearchParamsPlugin = /* @__PURE__ */ createPlugin14({
755
- tag: "seroval-plugins/web/URLSearchParams",
756
- test(value) {
757
- if (typeof URLSearchParams === "undefined") {
758
- return false;
759
- }
760
- return value instanceof URLSearchParams;
761
- },
762
- parse: {
763
- sync(value, ctx) {
764
- return {
765
- value: ctx.parse(value.toString())
766
- };
767
- },
768
- async async(value, ctx) {
769
- return {
770
- value: await ctx.parse(value.toString())
771
- };
772
- },
773
- stream(value, ctx) {
774
- return {
775
- value: ctx.parse(value.toString())
776
- };
777
- }
778
- },
779
- serialize(node, ctx) {
780
- return "new URLSearchParams(" + ctx.serialize(node.value) + ")";
781
- },
782
- deserialize(node, ctx) {
783
- return new URLSearchParams(ctx.deserialize(node.value));
784
- }
785
- });
786
- var url_search_params_default = URLSearchParamsPlugin;
787
- export {
788
- abort_signal_default as AbortSignalPlugin,
789
- blob_default as BlobPlugin,
790
- custom_event_default as CustomEventPlugin,
791
- dom_exception_default as DOMExceptionPlugin,
792
- event_default as EventPlugin,
793
- file_default as FilePlugin,
794
- form_data_default as FormDataPlugin,
795
- headers_default as HeadersPlugin,
796
- image_data_default as ImageDataPlugin,
797
- readable_stream_default as ReadableStreamPlugin,
798
- request_default as RequestPlugin,
799
- response_default as ResponsePlugin,
800
- url_default as URLPlugin,
801
- url_search_params_default as URLSearchParamsPlugin
802
- };
803
- //# sourceMappingURL=web.mjs.map