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