seroval-plugins 1.5.5 → 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.
- package/dist/index-Col4D1Sf.d.ts +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/web-43VA2W_p.js +650 -0
- package/dist/web.d.ts +2 -0
- package/dist/web.js +2 -0
- package/package.json +11 -21
- package/dist/cjs/development/web.cjs +0 -826
- package/dist/cjs/development/web.cjs.map +0 -7
- package/dist/cjs/production/web.cjs +0 -1
- package/dist/esm/development/web.mjs +0 -803
- package/dist/esm/development/web.mjs.map +0 -7
- package/dist/esm/production/web.mjs +0 -1
- package/dist/types/web/abort-signal.d.ts +0 -3
- package/dist/types/web/abort-signal.d.ts.map +0 -1
- package/dist/types/web/blob.d.ts +0 -3
- package/dist/types/web/blob.d.ts.map +0 -1
- package/dist/types/web/custom-event.d.ts +0 -3
- package/dist/types/web/custom-event.d.ts.map +0 -1
- package/dist/types/web/dom-exception.d.ts +0 -3
- package/dist/types/web/dom-exception.d.ts.map +0 -1
- package/dist/types/web/event.d.ts +0 -3
- package/dist/types/web/event.d.ts.map +0 -1
- package/dist/types/web/file.d.ts +0 -3
- package/dist/types/web/file.d.ts.map +0 -1
- package/dist/types/web/form-data.d.ts +0 -3
- package/dist/types/web/form-data.d.ts.map +0 -1
- package/dist/types/web/headers.d.ts +0 -3
- package/dist/types/web/headers.d.ts.map +0 -1
- package/dist/types/web/image-data.d.ts +0 -3
- package/dist/types/web/image-data.d.ts.map +0 -1
- package/dist/types/web/index.d.ts +0 -15
- package/dist/types/web/index.d.ts.map +0 -1
- package/dist/types/web/readable-stream.d.ts +0 -3
- package/dist/types/web/readable-stream.d.ts.map +0 -1
- package/dist/types/web/request.d.ts +0 -3
- package/dist/types/web/request.d.ts.map +0 -1
- package/dist/types/web/response.d.ts +0 -3
- package/dist/types/web/response.d.ts.map +0 -1
- package/dist/types/web/url-search-params.d.ts +0 -3
- package/dist/types/web/url-search-params.d.ts.map +0 -1
- package/dist/types/web/url.d.ts +0 -3
- package/dist/types/web/url.d.ts.map +0 -1
- package/web/abort-signal.ts +0 -131
- package/web/blob.ts +0 -41
- package/web/custom-event.ts +0 -66
- package/web/dom-exception.ts +0 -57
- package/web/event.ts +0 -62
- package/web/file.ts +0 -50
- package/web/form-data.ts +0 -105
- package/web/headers.ts +0 -49
- package/web/image-data.ts +0 -74
- package/web/index.ts +0 -14
- package/web/readable-stream.ts +0 -148
- package/web/request.ts +0 -82
- package/web/response.ts +0 -65
- package/web/url-search-params.ts +0 -40
- package/web/url.ts +0 -37
package/web/file.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
|
|
4
|
-
type FileNode = {
|
|
5
|
-
name: SerovalNode;
|
|
6
|
-
options: SerovalNode;
|
|
7
|
-
buffer: SerovalNode;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const FilePlugin = /* @__PURE__ */ createPlugin<File, FileNode>({
|
|
11
|
-
tag: 'seroval-plugins/web/File',
|
|
12
|
-
test(value) {
|
|
13
|
-
if (typeof File === 'undefined') {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return value instanceof File;
|
|
17
|
-
},
|
|
18
|
-
parse: {
|
|
19
|
-
async async(value, ctx) {
|
|
20
|
-
return {
|
|
21
|
-
name: await ctx.parse(value.name),
|
|
22
|
-
options: await ctx.parse({
|
|
23
|
-
type: value.type,
|
|
24
|
-
lastModified: value.lastModified,
|
|
25
|
-
}),
|
|
26
|
-
buffer: await ctx.parse(await value.arrayBuffer()),
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
serialize(node, ctx) {
|
|
31
|
-
return (
|
|
32
|
-
'new File([' +
|
|
33
|
-
ctx.serialize(node.buffer) +
|
|
34
|
-
'],' +
|
|
35
|
-
ctx.serialize(node.name) +
|
|
36
|
-
',' +
|
|
37
|
-
ctx.serialize(node.options) +
|
|
38
|
-
')'
|
|
39
|
-
);
|
|
40
|
-
},
|
|
41
|
-
deserialize(node, ctx) {
|
|
42
|
-
return new File(
|
|
43
|
-
[ctx.deserialize(node.buffer) as ArrayBuffer],
|
|
44
|
-
ctx.deserialize(node.name) as string,
|
|
45
|
-
ctx.deserialize(node.options) as FilePropertyBag,
|
|
46
|
-
);
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export default FilePlugin;
|
package/web/form-data.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
import FilePlugin from './file';
|
|
4
|
-
|
|
5
|
-
type FormDataInit = [key: string, value: FormDataEntryValue][];
|
|
6
|
-
|
|
7
|
-
function convertFormData(instance: FormData): FormDataInit {
|
|
8
|
-
const items: FormDataInit = [];
|
|
9
|
-
instance.forEach((value, key) => {
|
|
10
|
-
items.push([key, value]);
|
|
11
|
-
});
|
|
12
|
-
return items;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const FORM_DATA_FACTORY = {};
|
|
16
|
-
|
|
17
|
-
const FORM_DATA_FACTORY_CONSTRUCTOR = (
|
|
18
|
-
e: [key: string, value: FormDataEntryValue][],
|
|
19
|
-
f = new FormData(),
|
|
20
|
-
i = 0,
|
|
21
|
-
s = e.length,
|
|
22
|
-
t?: [key: string, value: FormDataEntryValue],
|
|
23
|
-
) => {
|
|
24
|
-
for (; i < s; i++) {
|
|
25
|
-
t = e[i];
|
|
26
|
-
f.append(t[0], t[1]);
|
|
27
|
-
}
|
|
28
|
-
return f;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const FormDataFactoryPlugin = /* @__PURE__ */ createPlugin<object, {}>({
|
|
32
|
-
tag: 'seroval-plugins/web/FormDataFactory',
|
|
33
|
-
test(value) {
|
|
34
|
-
return value === FORM_DATA_FACTORY;
|
|
35
|
-
},
|
|
36
|
-
parse: {
|
|
37
|
-
sync() {
|
|
38
|
-
return FORM_DATA_FACTORY;
|
|
39
|
-
},
|
|
40
|
-
async async() {
|
|
41
|
-
return await Promise.resolve(FORM_DATA_FACTORY);
|
|
42
|
-
},
|
|
43
|
-
stream() {
|
|
44
|
-
return FORM_DATA_FACTORY;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
serialize() {
|
|
48
|
-
return FORM_DATA_FACTORY_CONSTRUCTOR.toString();
|
|
49
|
-
},
|
|
50
|
-
deserialize() {
|
|
51
|
-
return FORM_DATA_FACTORY;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
type FormDataNode = {
|
|
56
|
-
factory: SerovalNode;
|
|
57
|
-
entries: SerovalNode;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const FormDataPlugin = /* @__PURE__ */ createPlugin<FormData, FormDataNode>({
|
|
61
|
-
tag: 'seroval-plugins/web/FormData',
|
|
62
|
-
extends: [FilePlugin, FormDataFactoryPlugin],
|
|
63
|
-
test(value) {
|
|
64
|
-
if (typeof FormData === 'undefined') {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return value instanceof FormData;
|
|
68
|
-
},
|
|
69
|
-
parse: {
|
|
70
|
-
sync(value, ctx) {
|
|
71
|
-
return {
|
|
72
|
-
factory: ctx.parse(FORM_DATA_FACTORY),
|
|
73
|
-
entries: ctx.parse(convertFormData(value)),
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
async async(value, ctx) {
|
|
77
|
-
return {
|
|
78
|
-
factory: await ctx.parse(FORM_DATA_FACTORY),
|
|
79
|
-
entries: await ctx.parse(convertFormData(value)),
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
stream(value, ctx) {
|
|
83
|
-
return {
|
|
84
|
-
factory: ctx.parse(FORM_DATA_FACTORY),
|
|
85
|
-
entries: ctx.parse(convertFormData(value)),
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
serialize(node, ctx) {
|
|
90
|
-
return (
|
|
91
|
-
'(' +
|
|
92
|
-
ctx.serialize(node.factory) +
|
|
93
|
-
')(' +
|
|
94
|
-
ctx.serialize(node.entries) +
|
|
95
|
-
')'
|
|
96
|
-
);
|
|
97
|
-
},
|
|
98
|
-
deserialize(node, ctx) {
|
|
99
|
-
return FORM_DATA_FACTORY_CONSTRUCTOR(
|
|
100
|
-
ctx.deserialize(node.entries) as FormDataInit,
|
|
101
|
-
);
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export default FormDataPlugin;
|
package/web/headers.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
|
|
4
|
-
function convertHeaders(instance: Headers): HeadersInit {
|
|
5
|
-
const items: HeadersInit = [];
|
|
6
|
-
// biome-ignore lint/complexity/noForEach: <explanation>
|
|
7
|
-
instance.forEach((value, key) => {
|
|
8
|
-
items.push([key, value]);
|
|
9
|
-
});
|
|
10
|
-
return items;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const HeadersPlugin = /* @__PURE__ */ createPlugin<
|
|
14
|
-
Headers,
|
|
15
|
-
{ value: SerovalNode }
|
|
16
|
-
>({
|
|
17
|
-
tag: 'seroval-plugins/web/Headers',
|
|
18
|
-
test(value) {
|
|
19
|
-
if (typeof Headers === 'undefined') {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return value instanceof Headers;
|
|
23
|
-
},
|
|
24
|
-
parse: {
|
|
25
|
-
sync(value, ctx) {
|
|
26
|
-
return {
|
|
27
|
-
value: ctx.parse(convertHeaders(value)),
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
async async(value, ctx) {
|
|
31
|
-
return {
|
|
32
|
-
value: await ctx.parse(convertHeaders(value)),
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
stream(value, ctx) {
|
|
36
|
-
return {
|
|
37
|
-
value: ctx.parse(convertHeaders(value)),
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
serialize(node, ctx) {
|
|
42
|
-
return 'new Headers(' + ctx.serialize(node.value) + ')';
|
|
43
|
-
},
|
|
44
|
-
deserialize(node, ctx) {
|
|
45
|
-
return new Headers(ctx.deserialize(node.value) as HeadersInit);
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export default HeadersPlugin;
|
package/web/image-data.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
|
|
4
|
-
type ImageDataNode = {
|
|
5
|
-
data: SerovalNode;
|
|
6
|
-
width: SerovalNode;
|
|
7
|
-
height: SerovalNode;
|
|
8
|
-
options: SerovalNode;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const ImageDataPlugin = /* @__PURE__ */ createPlugin<ImageData, ImageDataNode>({
|
|
12
|
-
tag: 'seroval-plugins/web/ImageData',
|
|
13
|
-
test(value) {
|
|
14
|
-
if (typeof ImageData === 'undefined') {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return value instanceof ImageData;
|
|
18
|
-
},
|
|
19
|
-
parse: {
|
|
20
|
-
sync(value, ctx) {
|
|
21
|
-
return {
|
|
22
|
-
data: ctx.parse(value.data),
|
|
23
|
-
width: ctx.parse(value.width),
|
|
24
|
-
height: ctx.parse(value.height),
|
|
25
|
-
options: ctx.parse({
|
|
26
|
-
colorSpace: value.colorSpace,
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
async async(value, ctx) {
|
|
31
|
-
return {
|
|
32
|
-
data: await ctx.parse(value.data),
|
|
33
|
-
width: await ctx.parse(value.width),
|
|
34
|
-
height: await ctx.parse(value.height),
|
|
35
|
-
options: await ctx.parse({
|
|
36
|
-
colorSpace: value.colorSpace,
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
stream(value, ctx) {
|
|
41
|
-
return {
|
|
42
|
-
data: ctx.parse(value.data),
|
|
43
|
-
width: ctx.parse(value.width),
|
|
44
|
-
height: ctx.parse(value.height),
|
|
45
|
-
options: ctx.parse({
|
|
46
|
-
colorSpace: value.colorSpace,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
serialize(node, ctx) {
|
|
52
|
-
return (
|
|
53
|
-
'new ImageData(' +
|
|
54
|
-
ctx.serialize(node.data) +
|
|
55
|
-
',' +
|
|
56
|
-
ctx.serialize(node.width) +
|
|
57
|
-
',' +
|
|
58
|
-
ctx.serialize(node.height) +
|
|
59
|
-
',' +
|
|
60
|
-
ctx.serialize(node.options) +
|
|
61
|
-
')'
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
deserialize(node, ctx) {
|
|
65
|
-
return new ImageData(
|
|
66
|
-
ctx.deserialize(node.data) as Uint8ClampedArray<ArrayBuffer>,
|
|
67
|
-
ctx.deserialize(node.width) as number,
|
|
68
|
-
ctx.deserialize(node.height) as number,
|
|
69
|
-
ctx.deserialize(node.options) as ImageDataSettings,
|
|
70
|
-
);
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export default ImageDataPlugin;
|
package/web/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { default as AbortSignalPlugin } from './abort-signal';
|
|
2
|
-
export { default as BlobPlugin } from './blob';
|
|
3
|
-
export { default as CustomEventPlugin } from './custom-event';
|
|
4
|
-
export { default as DOMExceptionPlugin } from './dom-exception';
|
|
5
|
-
export { default as EventPlugin } from './event';
|
|
6
|
-
export { default as FilePlugin } from './file';
|
|
7
|
-
export { default as FormDataPlugin } from './form-data';
|
|
8
|
-
export { default as HeadersPlugin } from './headers';
|
|
9
|
-
export { default as ImageDataPlugin } from './image-data';
|
|
10
|
-
export { default as ReadableStreamPlugin } from './readable-stream';
|
|
11
|
-
export { default as RequestPlugin } from './request';
|
|
12
|
-
export { default as ResponsePlugin } from './response';
|
|
13
|
-
export { default as URLPlugin } from './url';
|
|
14
|
-
export { default as URLSearchParamsPlugin } from './url-search-params';
|
package/web/readable-stream.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode, Stream } from 'seroval';
|
|
2
|
-
import { createPlugin, createStream } from 'seroval';
|
|
3
|
-
|
|
4
|
-
const READABLE_STREAM_FACTORY = {};
|
|
5
|
-
|
|
6
|
-
const READABLE_STREAM_FACTORY_CONSTRUCTOR = (stream: Stream<unknown>) =>
|
|
7
|
-
new ReadableStream({
|
|
8
|
-
start: controller => {
|
|
9
|
-
stream.on({
|
|
10
|
-
next: value => {
|
|
11
|
-
try {
|
|
12
|
-
controller.enqueue(value);
|
|
13
|
-
} catch (_error) {
|
|
14
|
-
// no-op
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
throw: value => {
|
|
18
|
-
controller.error(value);
|
|
19
|
-
},
|
|
20
|
-
return: () => {
|
|
21
|
-
try {
|
|
22
|
-
controller.close();
|
|
23
|
-
} catch (_error) {
|
|
24
|
-
// no-op
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const ReadableStreamFactoryPlugin = /* @__PURE__ */ createPlugin<object, {}>({
|
|
32
|
-
tag: 'seroval-plugins/web/ReadableStreamFactory',
|
|
33
|
-
test(value) {
|
|
34
|
-
return value === READABLE_STREAM_FACTORY;
|
|
35
|
-
},
|
|
36
|
-
parse: {
|
|
37
|
-
sync() {
|
|
38
|
-
return READABLE_STREAM_FACTORY;
|
|
39
|
-
},
|
|
40
|
-
async async() {
|
|
41
|
-
return await Promise.resolve(READABLE_STREAM_FACTORY);
|
|
42
|
-
},
|
|
43
|
-
stream() {
|
|
44
|
-
return READABLE_STREAM_FACTORY;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
serialize() {
|
|
48
|
-
return READABLE_STREAM_FACTORY_CONSTRUCTOR.toString();
|
|
49
|
-
},
|
|
50
|
-
deserialize() {
|
|
51
|
-
return READABLE_STREAM_FACTORY;
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
async function drainStream<T>(
|
|
56
|
-
stream: Stream<T | undefined>,
|
|
57
|
-
reader: ReadableStreamDefaultReader<T>,
|
|
58
|
-
): Promise<void> {
|
|
59
|
-
try {
|
|
60
|
-
const result = await reader.read();
|
|
61
|
-
if (result.done) {
|
|
62
|
-
stream.return(result.value);
|
|
63
|
-
reader.releaseLock();
|
|
64
|
-
} else {
|
|
65
|
-
stream.next(result.value);
|
|
66
|
-
await drainStream(stream, reader);
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
stream.throw(error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function cleanupStream<T>(reader: ReadableStreamDefaultReader<T>): void {
|
|
74
|
-
reader.cancel().catch(() => {
|
|
75
|
-
// no-op
|
|
76
|
-
});
|
|
77
|
-
reader.releaseLock();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function toStream<T>(
|
|
81
|
-
value: ReadableStream<T>,
|
|
82
|
-
): [Stream<T | undefined>, () => void] {
|
|
83
|
-
const stream = createStream<T | undefined>();
|
|
84
|
-
|
|
85
|
-
const reader = value.getReader();
|
|
86
|
-
|
|
87
|
-
const cleanup = cleanupStream.bind(null, reader);
|
|
88
|
-
|
|
89
|
-
drainStream(stream, reader).catch(cleanup);
|
|
90
|
-
|
|
91
|
-
return [stream, cleanup];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type ReadableStreamNode = {
|
|
95
|
-
factory: SerovalNode;
|
|
96
|
-
stream: SerovalNode;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const ReadableStreamPlugin = /* @__PURE__ */ createPlugin<
|
|
100
|
-
ReadableStream,
|
|
101
|
-
ReadableStreamNode
|
|
102
|
-
>({
|
|
103
|
-
tag: 'seroval/plugins/web/ReadableStream',
|
|
104
|
-
extends: [ReadableStreamFactoryPlugin],
|
|
105
|
-
test(value) {
|
|
106
|
-
if (typeof ReadableStream === 'undefined') {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return value instanceof ReadableStream;
|
|
110
|
-
},
|
|
111
|
-
parse: {
|
|
112
|
-
sync(_value, ctx) {
|
|
113
|
-
return {
|
|
114
|
-
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
115
|
-
stream: ctx.parse(createStream()),
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
async async(value, ctx) {
|
|
119
|
-
return {
|
|
120
|
-
factory: await ctx.parse(READABLE_STREAM_FACTORY),
|
|
121
|
-
stream: await ctx.parse(toStream(value)[0]),
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
stream(value, ctx) {
|
|
125
|
-
const [stream, cleanup] = toStream(value);
|
|
126
|
-
ctx.addCleanup(cleanup);
|
|
127
|
-
return {
|
|
128
|
-
factory: ctx.parse(READABLE_STREAM_FACTORY),
|
|
129
|
-
stream: ctx.parse(stream),
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
serialize(node, ctx) {
|
|
134
|
-
return (
|
|
135
|
-
'(' +
|
|
136
|
-
ctx.serialize(node.factory) +
|
|
137
|
-
')(' +
|
|
138
|
-
ctx.serialize(node.stream) +
|
|
139
|
-
')'
|
|
140
|
-
);
|
|
141
|
-
},
|
|
142
|
-
deserialize(node, ctx) {
|
|
143
|
-
const stream = ctx.deserialize(node.stream) as Stream<any>;
|
|
144
|
-
return READABLE_STREAM_FACTORY_CONSTRUCTOR(stream);
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
export default ReadableStreamPlugin;
|
package/web/request.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
import HeadersPlugin from './headers';
|
|
4
|
-
import ReadableStreamPlugin from './readable-stream';
|
|
5
|
-
|
|
6
|
-
function createRequestOptions(
|
|
7
|
-
current: Request,
|
|
8
|
-
body: ArrayBuffer | ReadableStream | null,
|
|
9
|
-
): RequestInit {
|
|
10
|
-
return {
|
|
11
|
-
body,
|
|
12
|
-
cache: current.cache,
|
|
13
|
-
credentials: current.credentials,
|
|
14
|
-
headers: current.headers,
|
|
15
|
-
integrity: current.integrity,
|
|
16
|
-
keepalive: current.keepalive,
|
|
17
|
-
method: current.method,
|
|
18
|
-
mode: current.mode,
|
|
19
|
-
redirect: current.redirect,
|
|
20
|
-
referrer: current.referrer,
|
|
21
|
-
referrerPolicy: current.referrerPolicy,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type RequestNode = {
|
|
26
|
-
url: SerovalNode;
|
|
27
|
-
options: SerovalNode;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const RequestPlugin = /* @__PURE__ */ createPlugin<Request, RequestNode>({
|
|
31
|
-
tag: 'seroval-plugins/web/Request',
|
|
32
|
-
extends: [ReadableStreamPlugin, HeadersPlugin],
|
|
33
|
-
test(value) {
|
|
34
|
-
if (typeof Request === 'undefined') {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return value instanceof Request;
|
|
38
|
-
},
|
|
39
|
-
parse: {
|
|
40
|
-
async async(value, ctx) {
|
|
41
|
-
return {
|
|
42
|
-
url: await ctx.parse(value.url),
|
|
43
|
-
options: await ctx.parse(
|
|
44
|
-
createRequestOptions(
|
|
45
|
-
value,
|
|
46
|
-
value.body && !value.bodyUsed
|
|
47
|
-
? await value.clone().arrayBuffer()
|
|
48
|
-
: null,
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
stream(value, ctx) {
|
|
54
|
-
return {
|
|
55
|
-
url: ctx.parse(value.url),
|
|
56
|
-
options: ctx.parse(
|
|
57
|
-
createRequestOptions(
|
|
58
|
-
value,
|
|
59
|
-
value.body && !value.bodyUsed ? value.clone().body : null,
|
|
60
|
-
),
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
serialize(node, ctx) {
|
|
66
|
-
return (
|
|
67
|
-
'new Request(' +
|
|
68
|
-
ctx.serialize(node.url) +
|
|
69
|
-
',' +
|
|
70
|
-
ctx.serialize(node.options) +
|
|
71
|
-
')'
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
deserialize(node, ctx) {
|
|
75
|
-
return new Request(
|
|
76
|
-
ctx.deserialize(node.url) as string,
|
|
77
|
-
ctx.deserialize(node.options) as RequestInit,
|
|
78
|
-
);
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export default RequestPlugin;
|
package/web/response.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
import HeadersPlugin from './headers';
|
|
4
|
-
import ReadableStreamPlugin from './readable-stream';
|
|
5
|
-
|
|
6
|
-
function createResponseOptions(current: Response): ResponseInit {
|
|
7
|
-
return {
|
|
8
|
-
headers: current.headers,
|
|
9
|
-
status: current.status,
|
|
10
|
-
statusText: current.statusText,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type ResponseNode = {
|
|
15
|
-
body: SerovalNode;
|
|
16
|
-
options: SerovalNode;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const ResponsePlugin = /* @__PURE__ */ createPlugin<Response, ResponseNode>({
|
|
20
|
-
tag: 'seroval-plugins/web/Response',
|
|
21
|
-
extends: [ReadableStreamPlugin, HeadersPlugin],
|
|
22
|
-
test(value) {
|
|
23
|
-
if (typeof Response === 'undefined') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return value instanceof Response;
|
|
27
|
-
},
|
|
28
|
-
parse: {
|
|
29
|
-
async async(value, ctx) {
|
|
30
|
-
return {
|
|
31
|
-
body: await ctx.parse(
|
|
32
|
-
value.body && !value.bodyUsed
|
|
33
|
-
? await value.clone().arrayBuffer()
|
|
34
|
-
: null,
|
|
35
|
-
),
|
|
36
|
-
options: await ctx.parse(createResponseOptions(value)),
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
stream(value, ctx) {
|
|
40
|
-
return {
|
|
41
|
-
body: ctx.parse(
|
|
42
|
-
value.body && !value.bodyUsed ? value.clone().body : null,
|
|
43
|
-
),
|
|
44
|
-
options: ctx.parse(createResponseOptions(value)),
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
serialize(node, ctx) {
|
|
49
|
-
return (
|
|
50
|
-
'new Response(' +
|
|
51
|
-
ctx.serialize(node.body) +
|
|
52
|
-
',' +
|
|
53
|
-
ctx.serialize(node.options) +
|
|
54
|
-
')'
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
deserialize(node, ctx) {
|
|
58
|
-
return new Response(
|
|
59
|
-
ctx.deserialize(node.body) as BodyInit,
|
|
60
|
-
ctx.deserialize(node.options) as ResponseInit,
|
|
61
|
-
);
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export default ResponsePlugin;
|
package/web/url-search-params.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
|
|
4
|
-
const URLSearchParamsPlugin = /* @__PURE__ */ createPlugin<
|
|
5
|
-
URLSearchParams,
|
|
6
|
-
{ value: SerovalNode }
|
|
7
|
-
>({
|
|
8
|
-
tag: 'seroval-plugins/web/URLSearchParams',
|
|
9
|
-
test(value) {
|
|
10
|
-
if (typeof URLSearchParams === 'undefined') {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return value instanceof URLSearchParams;
|
|
14
|
-
},
|
|
15
|
-
parse: {
|
|
16
|
-
sync(value, ctx) {
|
|
17
|
-
return {
|
|
18
|
-
value: ctx.parse(value.toString()),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
async async(value, ctx) {
|
|
22
|
-
return {
|
|
23
|
-
value: await ctx.parse(value.toString()),
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
stream(value, ctx) {
|
|
27
|
-
return {
|
|
28
|
-
value: ctx.parse(value.toString()),
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
serialize(node, ctx) {
|
|
33
|
-
return 'new URLSearchParams(' + ctx.serialize(node.value) + ')';
|
|
34
|
-
},
|
|
35
|
-
deserialize(node, ctx) {
|
|
36
|
-
return new URLSearchParams(ctx.deserialize(node.value) as string);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export default URLSearchParamsPlugin;
|
package/web/url.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { SerovalNode } from 'seroval';
|
|
2
|
-
import { createPlugin } from 'seroval';
|
|
3
|
-
|
|
4
|
-
const URLPlugin = /* @__PURE__ */ createPlugin<URL, { value: SerovalNode }>({
|
|
5
|
-
tag: 'seroval-plugins/web/URL',
|
|
6
|
-
test(value) {
|
|
7
|
-
if (typeof URL === 'undefined') {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
return value instanceof URL;
|
|
11
|
-
},
|
|
12
|
-
parse: {
|
|
13
|
-
sync(value, ctx) {
|
|
14
|
-
return {
|
|
15
|
-
value: ctx.parse(value.href),
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
async async(value, ctx) {
|
|
19
|
-
return {
|
|
20
|
-
value: await ctx.parse(value.href),
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
stream(value, ctx) {
|
|
24
|
-
return {
|
|
25
|
-
value: ctx.parse(value.href),
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
serialize(node, ctx) {
|
|
30
|
-
return 'new URL(' + ctx.serialize(node.value) + ')';
|
|
31
|
-
},
|
|
32
|
-
deserialize(node, ctx) {
|
|
33
|
-
return new URL(ctx.deserialize(node.value) as string);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export default URLPlugin;
|