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